File size: 505 Bytes
9129e20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from docx import Document
import os


def read_docx_rubric(path):
    """Read a .docx rubric and return a list of paragraphs (stripped).

    If the file contains clearly labeled criteria (e.g., numbered or bold lines),
    this will return a list of non-empty lines to be used as criteria.
    """
    if not os.path.exists(path):
        return []
    doc = Document(path)
    texts = []
    for p in doc.paragraphs:
        t = p.text.strip()
        if t:
            texts.append(t)
    return texts