|
| 1 | +# Course XML Quick Reference |
| 2 | + |
| 3 | +**Quick guide for validating and working with Themis course XML** |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Basic Usage |
| 8 | + |
| 9 | +### Validate Course XML |
| 10 | + |
| 11 | +```typescript |
| 12 | +import { validateCourseXML } from '$lib/schemas/courseValidator'; |
| 13 | + |
| 14 | +const result = validateCourseXML(xmlString); |
| 15 | +// Returns: { valid: boolean, errors: string[], warnings: string[] } |
| 16 | +``` |
| 17 | + |
| 18 | +### Get Summary |
| 19 | + |
| 20 | +```typescript |
| 21 | +import { validateAndSummarize } from '$lib/schemas/courseValidator'; |
| 22 | + |
| 23 | +const summary = validateAndSummarize(xmlString); |
| 24 | +console.log(summary.summary); |
| 25 | +// "✓ Course XML is valid (2 warnings)" or |
| 26 | +// "✗ Course XML validation failed (5 errors, 2 warnings)" |
| 27 | +``` |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Minimum Requirements |
| 32 | + |
| 33 | +### Course Level |
| 34 | +- ✓ At least 1 arc |
| 35 | +- ✓ Structure: `"facilitated"` or `"peer-led"` |
| 36 | +- ✓ CourseDescription with ≥1 paragraph |
| 37 | +- ✓ CohortProps with prerequisites and experience |
| 38 | + |
| 39 | +### Arc Level |
| 40 | +- ✓ At least 1 module per arc |
| 41 | +- ✓ Sequential ordering (1, 2, 3...) |
| 42 | +- ✓ ArcDescription, ArcProps, ArcContent |
| 43 | + |
| 44 | +### Module Level |
| 45 | +- ✓ Sequential ordering within arc |
| 46 | +- ✓ ModuleDescription, ModuleProps, ModuleSpecification |
| 47 | + |
| 48 | +### Module Specification |
| 49 | +- ✓ Min 3 objectives |
| 50 | +- ✓ Min 5 primary research topics |
| 51 | +- ✓ Min 2 project briefs (each: 3+ skills, 3+ examples) |
| 52 | +- ✓ Min 2 project twists (each: 2+ examples) |
| 53 | +- ✓ Min 1 additional skills category |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## Temporal Consistency |
| 58 | + |
| 59 | +**Rule:** `sum(module weeks) ≤ arc weeks ≤ course weeks` |
| 60 | + |
| 61 | +**Errors when:** |
| 62 | +- Arc weeks exceed course weeks |
| 63 | +- Module weeks exceed arc weeks |
| 64 | + |
| 65 | +**Warnings when:** |
| 66 | +- Sum is less than parent (indicates buffer/flexibility) |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Common Validation Errors |
| 71 | + |
| 72 | +| Error | Fix | |
| 73 | +|-------|-----| |
| 74 | +| `Root element must be <Course>` | Use `<Course>` as root tag | |
| 75 | +| `Course must contain at least one <Arc>` | Add at least one arc | |
| 76 | +| `module must have at least 3 objectives` | Add more objectives | |
| 77 | +| `module must have at least 5 primary research topics` | Add more topics | |
| 78 | +| `sum of arc weeks exceeds course total weeks` | Adjust weeks to be consistent | |
| 79 | +| `Structure must be "facilitated" or "peer-led"` | Use exact string value | |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Error vs Warning |
| 84 | + |
| 85 | +**Errors** (block validation): |
| 86 | +- Missing required elements |
| 87 | +- Invalid attribute values |
| 88 | +- Cardinality violations (too few objectives/topics/etc) |
| 89 | +- Temporal inconsistency (child > parent) |
| 90 | + |
| 91 | +**Warnings** (non-blocking): |
| 92 | +- Missing optional metadata |
| 93 | +- Count attribute mismatch |
| 94 | +- Temporal buffer (child < parent) |
| 95 | +- Empty/self-closing modules |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## XML Structure Cheatsheet |
| 100 | + |
| 101 | +```xml |
| 102 | +<Course name="" doc_date="" doc_time="" version="1.0"> |
| 103 | + <CourseProps arcs="" modules="" weeks="" days=""> |
| 104 | + <CourseMetadata /> |
| 105 | + <CourseLogistics><TotalArcs/><TotalModules/><Structure/></CourseLogistics> |
| 106 | + <CourseTemporal><TotalWeeks/><DaysPerWeek/><TotalDays/></CourseTemporal> |
| 107 | + </CourseProps> |
| 108 | + <CohortProps learners=""> |
| 109 | + <CohortAssumptions><AssumedCohortSize/></CohortAssumptions> |
| 110 | + <LearnerPrerequisites/> |
| 111 | + <LearnerExperience><PrereqLevel/><FocusArea/></LearnerExperience> |
| 112 | + </CohortProps> |
| 113 | + <CourseDescription><DescriptionParagraph/></CourseDescription> |
| 114 | + <CourseContent> |
| 115 | + <CourseProgression /> |
| 116 | + <Arcs> |
| 117 | + <Arc order="" name="" modules="" weeks=""> |
| 118 | + <ArcDescription /> |
| 119 | + <ArcProps><ArcLogistics/><ArcTemporal/></ArcProps> |
| 120 | + <ArcContent> |
| 121 | + <Themes><ArcTheme/></Themes> |
| 122 | + <ArcProgression /> |
| 123 | + <Modules> |
| 124 | + <Module order="" in_arc="" name="" weeks=""> |
| 125 | + <ModuleDescription /> |
| 126 | + <ModuleProps><ModuleTemporal/></ModuleProps> |
| 127 | + <ModuleSpecification> |
| 128 | + <ModuleOverview><ModuleObjectives/></ModuleOverview> |
| 129 | + <ResearchTopics><PrimaryTopics/></ResearchTopics> |
| 130 | + <Projects><ProjectBriefs/><ProjectTwists/></Projects> |
| 131 | + <AdditionalSkills><SkillsCategory/></AdditionalSkills> |
| 132 | + </ModuleSpecification> |
| 133 | + </Module> |
| 134 | + </Modules> |
| 135 | + </ArcContent> |
| 136 | + </Arc> |
| 137 | + </Arcs> |
| 138 | + </CourseContent> |
| 139 | +</Course> |
| 140 | +``` |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## File Locations |
| 145 | + |
| 146 | +- **Schema Template:** `src/data/templates/themis/courseSchema.xml` |
| 147 | +- **Validator:** `src/lib/schemas/courseValidator.ts` |
| 148 | +- **Tests:** `src/lib/schemas/courseValidator.test.ts` |
| 149 | +- **Full Docs:** `docs/dev/course-xml-specification.md` |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## Quick Debug Pattern |
| 154 | + |
| 155 | +```typescript |
| 156 | +const result = validateCourseXML(xmlString); |
| 157 | + |
| 158 | +if (!result.valid) { |
| 159 | + console.error('Validation Errors:'); |
| 160 | + result.errors.forEach((e, i) => console.error(`${i + 1}. ${e}`)); |
| 161 | + |
| 162 | + console.warn('Validation Warnings:'); |
| 163 | + result.warnings.forEach((w, i) => console.warn(`${i + 1}. ${w}`)); |
| 164 | +} |
| 165 | +``` |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +## Self-Closing vs Full Modules |
| 170 | + |
| 171 | +```xml |
| 172 | +<!-- Planned but not generated --> |
| 173 | +<Module order="1" in_arc="1" name="" weeks="4" /> |
| 174 | + |
| 175 | +<!-- Fully generated --> |
| 176 | +<Module order="1" in_arc="1" name="Module Title" weeks="4"> |
| 177 | + <ModuleDescription>...</ModuleDescription> |
| 178 | + <ModuleProps>...</ModuleProps> |
| 179 | + <ModuleSpecification>...</ModuleSpecification> |
| 180 | +</Module> |
| 181 | +``` |
| 182 | + |
| 183 | +Validator warns on self-closing modules but doesn't error. |
| 184 | + |
| 185 | +--- |
| 186 | + |
| 187 | +## Integration Points |
| 188 | + |
| 189 | +**Themis 2.3 (XML Export):** |
| 190 | +```typescript |
| 191 | +// 1. Serialize course to XML |
| 192 | +const xmlString = serialiseCourseToXml(courseData); |
| 193 | + |
| 194 | +// 2. Validate |
| 195 | +const validation = validateCourseXML(xmlString); |
| 196 | +if (!validation.valid) { |
| 197 | + throw new Error('Invalid XML: ' + validation.errors.join(', ')); |
| 198 | +} |
| 199 | + |
| 200 | +// 3. Download |
| 201 | +downloadCourseXml(courseData); |
| 202 | +``` |
| 203 | + |
| 204 | +**Theia (XML Upload - Future):** |
| 205 | +```typescript |
| 206 | +// 1. Upload XML file |
| 207 | +const xmlString = await file.text(); |
| 208 | + |
| 209 | +// 2. Validate |
| 210 | +const validation = validateCourseXML(xmlString); |
| 211 | +if (!validation.valid) { |
| 212 | + showErrors(validation.errors); |
| 213 | + return; |
| 214 | +} |
| 215 | + |
| 216 | +// 3. Parse and resume workflow |
| 217 | +const courseData = parseXmlToCourseData(xmlString); |
| 218 | +``` |
| 219 | + |
| 220 | +--- |
| 221 | + |
| 222 | +## Related Documentation |
| 223 | + |
| 224 | +- **Full Specification:** `docs/dev/course-xml-specification.md` |
| 225 | +- **Module XML Schema:** `src/data/templates/metis/outputSchema.xml` |
| 226 | +- **Module Validator:** `src/lib/schemas/moduleValidator.ts` |
| 227 | +- **Themis Types:** `src/lib/types/themis.ts` |
0 commit comments