feat: implement curriculum management system including automated generation, enrichment, and versioning workflows
This commit is contained in:
@@ -246,8 +246,55 @@ export function setSetting(key, value) {
|
||||
return pbUpsert('settings', `key="${key}"`, { value: String(value) }, { key, value: String(value) });
|
||||
}
|
||||
|
||||
// ── Curriculum ────────────────────────────────────────────────────────────────
|
||||
// ── Curriculum Versions (v2) ──────────────────────────────────────────────────
|
||||
|
||||
export async function getCurriculumVersions(status) {
|
||||
try {
|
||||
const opts = { sort: '-version_number' };
|
||||
if (status) opts.filter = `status="${status}"`;
|
||||
return await pb.collection('curriculum_versions').getFullList(opts);
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
export async function getCurriculumVersion(id) {
|
||||
try {
|
||||
return await pb.collection('curriculum_versions').getOne(id);
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
export async function getActiveCurriculumVersion() {
|
||||
try {
|
||||
return await pb.collection('curriculum_versions').getFirstListItem('status="active"');
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
export async function getDraftCurriculumVersion() {
|
||||
try {
|
||||
return await pb.collection('curriculum_versions').getFirstListItem('status="draft"');
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
export async function createCurriculumVersion(data) {
|
||||
return pb.collection('curriculum_versions').create(data);
|
||||
}
|
||||
|
||||
export async function updateCurriculumVersion(id, data) {
|
||||
return pb.collection('curriculum_versions').update(id, data);
|
||||
}
|
||||
|
||||
export async function getNextVersionNumber() {
|
||||
try {
|
||||
const latest = await pb.collection('curriculum_versions').getFirstListItem('', {
|
||||
sort: '-version_number',
|
||||
fields: 'version_number',
|
||||
});
|
||||
return (latest?.version_number || 0) + 1;
|
||||
} catch { return 1; }
|
||||
}
|
||||
|
||||
// ── Curriculum (legacy, v1 — deprecated) ──────────────────────────────────────
|
||||
|
||||
/** @deprecated Use curriculum_versions (v2) instead. */
|
||||
export async function getCurriculum(year) {
|
||||
try {
|
||||
return await pb.collection('curriculum').getFullList({
|
||||
@@ -257,6 +304,7 @@ export async function getCurriculum(year) {
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
/** @deprecated Use curriculum_versions (v2) instead. */
|
||||
export async function getCurriculumWeek(year, weekNumber) {
|
||||
try {
|
||||
return await pb.collection('curriculum').getFirstListItem(
|
||||
@@ -265,11 +313,13 @@ export async function getCurriculumWeek(year, weekNumber) {
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
/** @deprecated Use curriculum_versions (v2) instead. */
|
||||
export function setCurriculumWeek(year, weekNumber, data) {
|
||||
return pbUpsert('curriculum', `year=${year} && week_number=${weekNumber}`,
|
||||
data, { year, week_number: weekNumber, ...data });
|
||||
}
|
||||
|
||||
/** @deprecated Use curriculum_versions (v2) instead. */
|
||||
export async function deleteCurriculumWeek(year, weekNumber) {
|
||||
try {
|
||||
const r = await pb.collection('curriculum').getFirstListItem(
|
||||
@@ -279,6 +329,7 @@ export async function deleteCurriculumWeek(year, weekNumber) {
|
||||
} catch { /* nothing to delete */ }
|
||||
}
|
||||
|
||||
/** @deprecated Use curriculum_versions (v2) instead. */
|
||||
export async function bulkSetCurriculum(year, weeks) {
|
||||
// Delete all existing entries for this year first
|
||||
const existing = await getCurriculum(year);
|
||||
|
||||
Reference in New Issue
Block a user