Files
learning-platform/pb_migrations/1781000000_created_theme_sessions.js
RaymondVerhoef d38c75beb1
All checks were successful
On Push to Main / test (push) Successful in 46s
On Push to Main / publish (push) Successful in 1m28s
On Push to Main / deploy-dev (push) Successful in 2m9s
feat: theme-level weekly sessions and theme-grouped knowledge library
- New theme_sessions + theme_session_completions PocketBase collections
- Generate a detailed per-week theme summary covering every topic in the
  week's curriculum slot via EMIT_THEME_SESSION_TOOL; cache per
  (curriculum_version, week_number)
- Replace Leren.jsx "This Week's Topic" card with "This Week's Theme
  Session" that opens the new ThemeSessionView; per-topic micro-learnings
  remain reachable as optional practice from inside the session
- Group the Knowledge Library by topic.theme, pin the current week's
  theme on top, and badge topics already covered by the active session
- Mark week complete when the user finishes reading the theme session

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 10:44:10 +02:00

204 lines
5.0 KiB
JavaScript

/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const curriculumVersionsCollectionId = "pbc_curriculum_v2";
const teamMembersCollectionId = "pbc_3980519374";
const themeSessions = new Collection({
"id": "pbc_theme_sessions_0",
"name": "theme_sessions",
"type": "base",
"system": false,
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text_id_ts",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"system": false,
"id": "rel_curriculum_version",
"name": "curriculum_version",
"type": "relation",
"required": true,
"presentable": false,
"collectionId": curriculumVersionsCollectionId,
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
},
{
"hidden": false,
"id": "num_week_number_ts",
"max": 26,
"min": 1,
"name": "week_number",
"onlyInt": true,
"presentable": false,
"required": true,
"system": false,
"type": "number"
},
{
"system": false,
"id": "text_theme_ts",
"name": "theme",
"type": "text",
"required": true,
"presentable": false,
"max": 0,
"min": 0,
"pattern": ""
},
{
"system": false,
"id": "json_content_ts",
"name": "content",
"type": "json",
"required": true,
"presentable": false
},
{
"hidden": false,
"id": "autodate_created_ts",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": true,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate_updated_ts",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": true,
"type": "autodate"
}
],
"indexes": [
"CREATE UNIQUE INDEX `idx_theme_sessions_version_week` ON `theme_sessions` (`curriculum_version`, `week_number`)"
],
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": ""
});
app.save(themeSessions);
const themeSessionCompletions = new Collection({
"id": "pbc_theme_session_completions_0",
"name": "theme_session_completions",
"type": "base",
"system": false,
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text_id_tsc",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"system": false,
"id": "rel_tsc_team_member",
"name": "team_member_id",
"type": "relation",
"required": true,
"presentable": false,
"collectionId": teamMembersCollectionId,
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
},
{
"system": false,
"id": "rel_tsc_theme_session",
"name": "theme_session_id",
"type": "relation",
"required": true,
"presentable": false,
"collectionId": themeSessions.id,
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
},
{
"hidden": false,
"id": "num_tsc_session_week",
"max": null,
"min": 1,
"name": "session_week",
"onlyInt": true,
"presentable": false,
"required": true,
"system": false,
"type": "number"
},
{
"hidden": false,
"id": "autodate_created_tsc",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": true,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate_updated_tsc",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": true,
"type": "autodate"
}
],
"indexes": [
"CREATE UNIQUE INDEX `idx_theme_session_completions_user_week` ON `theme_session_completions` (`team_member_id`, `session_week`)"
],
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": ""
});
app.save(themeSessionCompletions);
}, (app) => {
const themeSessionCompletions = app.findCollectionByNameOrId("theme_session_completions");
if (themeSessionCompletions) {
app.delete(themeSessionCompletions);
}
const themeSessions = app.findCollectionByNameOrId("theme_sessions");
if (themeSessions) {
app.delete(themeSessions);
}
})