Class SyncCourseWithPlRepoJob
- All Implemented Interfaces:
edu.ucsb.cs156.jobs.services.JobContextConsumer
Before doing any work, the job verifies that the user has both PATs, that the course is associated with a GitHub repo and a PrairieLearn course instance, and that the PATs can actually reach both — read/write access to the repo, and access to the course instance via the PrairieLearn API. Any failure terminates the job with a log message telling the user where to fix it (the /profile page for PATs, the PrairieLearn tab of the course settings for the associations).
Unlike the old job, the PlInstance table is not repopulated from the repo's courseInstances
directory: the course's instance already exists, and its shortName/longName are just
sanity-checked (and corrected) against what PrairieLearn reports. Assessments are synced only for
the course's own instance. Questions are still traversed for the whole repo, exactly as before:
the questions directory is walked recursively; a directory containing an
info.json is a question whose questionId is its path relative to questions;
__drafts__ directories are skipped; question directories are not traversed further; stale
PlQuestion rows are deleted (cascading to their PlScaffoldAssessments and join rows).
Assessment sets (issue #93): the assessmentSets array of the repo's top-level
infoCourse.json becomes the PlAssessmentSet rows of the repo (assessment sets are global to the
whole course, not per-instance), matched by abbreviation. Stale rows are deleted.
Assessments: each subdirectory of courseInstances/<instance>/assessments containing an
infoAssessment.json becomes a PlAssessment; the zones key is walked recursively
and every "id" entry links the assessment to a PlQuestion of the repo (the
PlAssessmentQuestion join table, in zone order, rewritten on change). Stale rows are deleted.
Finally the job asks the PrairieLearn API for the instance's assessments and copies the fields from issue #71 (numeric id, number, order, title, and the assessment-set abbreviation/number/heading/color) onto the matching PlAssessment rows, matched by name.
If the questions or per-instance assessments directory is missing (HTTP 404),
that step is skipped entirely — including deletions — because a 404 cannot distinguish "directory
removed" from "token cannot see the repo", and mass-deleting rows over a token problem would be
wrong.
-
Constructor Details
-
SyncCourseWithPlRepoJob
public SyncCourseWithPlRepoJob()
-
-
Method Details
-
getScopeType
- Specified by:
getScopeTypein interfaceedu.ucsb.cs156.jobs.services.JobContextConsumer
-
getScopeId
- Specified by:
getScopeIdin interfaceedu.ucsb.cs156.jobs.services.JobContextConsumer
-
accept
- Specified by:
acceptin interfaceedu.ucsb.cs156.jobs.services.JobContextConsumer- Throws:
Exception
-