Problem
Two bugs in Moodle category provisioning plus a missing safety feature:
-
Wrong semester tag generation: ProvisionCategories extracted year values via .slice(2, 4) on startDate/endDate without accounting for the academic year. When a single semester is selected (dates fall in the same calendar year), this produces wrong tags — e.g., S22626 instead of S22526 for semester 2 of school year 2025-2026.
-
Unhelpful error on webservice_access_exception: The Moodle client threw a generic error with no guidance on how to fix the permission issue.
-
No category preview: Unlike courses, category provisioning went straight to execution with no preview step.
Solution
- Add
ComputeSchoolYears() to MoodleCourseTransformService for school-year-aware startYY/endYY computation
- Replace static year extraction in
ProvisionCategories with per-semester ComputeSchoolYears calls
- Improve
webservice_access_exception error with actionable hint
- Add
POST /moodle/provision/categories/preview endpoint (read-only, no concurrency guard)
- Add error wrapping to existing
ProvisionCategories endpoint (consistency with tree endpoints)
Files Changed
src/modules/moodle/services/moodle-course-transform.service.ts
src/modules/moodle/services/moodle-course-transform.service.spec.ts
src/modules/moodle/services/moodle-provisioning.service.ts
src/modules/moodle/services/moodle-provisioning.service.spec.ts
src/modules/moodle/lib/moodle.client.ts
src/modules/moodle/lib/moodle.client.spec.ts (new)
src/modules/moodle/controllers/moodle-provisioning.controller.ts
src/modules/moodle/controllers/moodle-provisioning.controller.spec.ts
Testing
- 59 tests passing across 4 suites (27 new)
- Frontend admin console changes in separate
admin.faculytics repo
Problem
Two bugs in Moodle category provisioning plus a missing safety feature:
Wrong semester tag generation:
ProvisionCategoriesextracted year values via.slice(2, 4)onstartDate/endDatewithout accounting for the academic year. When a single semester is selected (dates fall in the same calendar year), this produces wrong tags — e.g.,S22626instead ofS22526for semester 2 of school year 2025-2026.Unhelpful error on
webservice_access_exception: The Moodle client threw a generic error with no guidance on how to fix the permission issue.No category preview: Unlike courses, category provisioning went straight to execution with no preview step.
Solution
ComputeSchoolYears()toMoodleCourseTransformServicefor school-year-awarestartYY/endYYcomputationProvisionCategorieswith per-semesterComputeSchoolYearscallswebservice_access_exceptionerror with actionable hintPOST /moodle/provision/categories/previewendpoint (read-only, no concurrency guard)ProvisionCategoriesendpoint (consistency with tree endpoints)Files Changed
src/modules/moodle/services/moodle-course-transform.service.tssrc/modules/moodle/services/moodle-course-transform.service.spec.tssrc/modules/moodle/services/moodle-provisioning.service.tssrc/modules/moodle/services/moodle-provisioning.service.spec.tssrc/modules/moodle/lib/moodle.client.tssrc/modules/moodle/lib/moodle.client.spec.ts(new)src/modules/moodle/controllers/moodle-provisioning.controller.tssrc/modules/moodle/controllers/moodle-provisioning.controller.spec.tsTesting
admin.faculyticsrepo