|
11 | 11 | # files. |
12 | 12 | import pmss |
13 | 13 |
|
| 14 | +import learning_observer.communication_protocol.integration |
14 | 15 | import learning_observer.communication_protocol.query as q |
| 16 | +import learning_observer.constants as constants |
15 | 17 | import learning_observer.settings |
| 18 | +import learning_observer.rosters |
16 | 19 |
|
17 | 20 | from learning_observer import downloads as d |
18 | 21 |
|
|
26 | 29 |
|
27 | 30 | NAME = "The Writing Observer" |
28 | 31 |
|
| 32 | +@learning_observer.communication_protocol.integration.publish_function('writing_observer.roster_with_provenance') |
| 33 | +async def roster_with_provenance(roster, course_id): |
| 34 | + """Fetch roster entries and add STUDENT provenance for protocol consumers.""" |
| 35 | + for student in roster: |
| 36 | + if constants.USER_ID not in student: |
| 37 | + continue |
| 38 | + student['provenance'] = {'STUDENT': {constants.USER_ID: student[constants.USER_ID]}} |
| 39 | + return roster |
| 40 | + |
| 41 | + |
29 | 42 | # things that process data versus things that interact with the environment |
30 | 43 | # side-effects or not |
31 | 44 | # course_id or rosters.course_id to distinguish or provide a default - how to specify selector |
|
96 | 109 | EXECUTION_DAG = { |
97 | 110 | "execution_dag": { |
98 | 111 | "roster": course_roster(runtime=q.parameter("runtime"), course_id=q.parameter("course_id", required=True)), |
| 112 | + "roster_with_provenance": q.call('writing_observer.roster_with_provenance')(roster=q.variable('roster'), course_id=q.parameter("course_id", required=True)), |
99 | 113 | # all documents for a student |
100 | 114 | 'student_with_docs': q.select( |
101 | 115 | q.keys( |
|
118 | 132 | fields={'text': 'text'} |
119 | 133 | ), |
120 | 134 | 'single_student_profile': single_student_from_roster( |
121 | | - roster=q.variable('roster'), |
| 135 | + roster=q.variable('roster_with_provenance'), |
122 | 136 | student_id=q.parameter('student_id', required=True) |
123 | 137 | ), |
124 | 138 | "docs": q.select( |
125 | 139 | q.keys( |
126 | | - 'writing_observer.reconstruct', |
127 | | - STUDENTS=q.variable("roster"), |
128 | | - STUDENTS_path='user_id', |
129 | | - RESOURCES=q.variable("update_docs"), |
130 | | - RESOURCES_path='doc_id' |
| 140 | + 'writing_observer.reconstruct', |
| 141 | + scope_fields={ |
| 142 | + "student": {"values": q.variable("roster"), "path": "user_id"}, |
| 143 | + "doc_id": {"values": q.variable("update_docs"), "path": "doc_id"} |
| 144 | + } |
131 | 145 | ), |
132 | 146 | fields={'text': 'text'} |
133 | 147 | ), |
|
147 | 161 | ), |
148 | 162 | "doc_ids": q.select(q.keys('writing_observer.last_document', STUDENTS=q.variable("roster"), STUDENTS_path='user_id'), fields={'document_id': 'doc_id'}), |
149 | 163 | 'update_docs': update_via_google(runtime=q.parameter("runtime"), doc_ids=q.variable('doc_sources')), |
150 | | - "docs": q.select(q.keys('writing_observer.reconstruct', STUDENTS=q.variable("roster"), STUDENTS_path='user_id', RESOURCES=q.variable("update_docs"), RESOURCES_path='doc_id'), fields={'text': 'text'}), |
| 164 | + |
151 | 165 | "docs_combined": q.join(LEFT=q.variable("docs"), RIGHT=q.variable("roster"), LEFT_ON='provenance.provenance.STUDENT.value.user_id', RIGHT_ON='user_id'), |
152 | 166 | 'nlp': process_texts(writing_data=q.variable('docs'), options=q.parameter('nlp_options', required=False, default=[])), |
153 | 167 | 'nlp_sep_proc': q.select(q.keys('writing_observer.nlp_components', STUDENTS=q.variable('roster'), STUDENTS_path='user_id', RESOURCES=q.variable("doc_ids"), RESOURCES_path='doc_id'), fields='All'), |
|
219 | 233 | "output": "" |
220 | 234 | }, |
221 | 235 | "roster": { |
222 | | - "returns": "roster", |
| 236 | + "returns": "roster_with_provenance", |
223 | 237 | "parameters": ["course_id"], |
224 | 238 | "output": "" |
225 | 239 | }, |
|
0 commit comments