import minimist from "minimist"; import { EXAM_GENERATOR, EXAM_PREVIEW } from '../exam-spec'; import { ExamUtils } from "examma-ray/dist/ExamUtils"; import { OriginalExamRenderer, SampleSolutionExamRenderer } from "examma-ray"; import { mkdirSync } from "fs"; function main() { const argv = minimist(process.argv, { alias: { "a": "all-questions", "p": "preview", "s": "sample-solution", "q": "spec-only" }, default: { } }); const all_questions: string = argv["all-questions"]; const preview: string = argv["preview"]; const sample_solution: string = argv["sample-solution"]; const spec_only: string = argv["spec-only"]; const exam = EXAM_GENERATOR.exam; if (spec_only) { // Render exam specification only, not individual exams mkdirSync(`data/${exam.exam_id}`, { recursive: true }); ExamUtils.writeExamSpecificationToFileSync( `data/${exam.exam_id}/exam-spec.json`, exam.spec ); return; } if (all_questions || preview) { EXAM_PREVIEW.writeAll(); } else { const exam_renderer = sample_solution ? new SampleSolutionExamRenderer() : new OriginalExamRenderer(); EXAM_GENERATOR.assignExams(ExamUtils.loadCSVRoster("roster.csv")), EXAM_GENERATOR.writeAll(exam_renderer); } } main();