// lib/canvas/manifest.js — the two wrapper files that make a folder of QTI XML into a
// Canvas-importable package: imsmanifest.xml (IMS Content Packaging) and the Canvas
// proprietary assessment_meta.xml (quiz-level settings).
import { xmlEsc } from "./qti";
// Canvas quiz-level settings. `title` is the only thing Canvas truly needs; everything
// else has a sensible Canvas default if omitted. We emit the fields the user can set.
export function renderAssessmentMeta(ir, assessmentIdent) {
const q = ir.quiz;
const lines = [];
const tag = (name, val) => lines.push(`<${name}>${xmlEsc(String(val))}${name}>`);
const bool = (name, val) => tag(name, val ? "true" : "false");
const opt = (name, val) => { if (val !== "" && val != null) tag(name, val); };
tag("title", q.title);
tag("description", q.description || "");
tag("quiz_type", q.quizType);
tag("points_possible", q.pointsPossible);
opt("time_limit", q.timeLimit);
tag("allowed_attempts", q.allowedAttempts);
tag("scoring_policy", q.scoringPolicy);
bool("shuffle_answers", q.shuffleAnswers);
bool("show_correct_answers", q.showCorrectAnswers);
bool("one_question_at_a_time", q.oneQuestionAtATime);
bool("cant_go_back", q.cantGoBack);
opt("access_code", q.accessCode);
opt("due_at", q.dueAt);
opt("unlock_at", q.unlockAt);
opt("lock_at", q.lockAt);
return `
${lines.join("\n")}
`;
}
export function renderManifest(assessmentIdent, manifestIdent) {
const assessmentHref = `${assessmentIdent}/${assessmentIdent}.xml`;
const metaHref = `${assessmentIdent}/assessment_meta.xml`;
const depIdent = `${assessmentIdent}_dependency`;
return `
IMS Content1.1.3
`;
}