Add Context APIs and refactor vocab models
All checks were successful
Deploy to Production / deploy (push) Successful in 25s

Introduce Context and ContextGuide features: add Sequelize models (models/Context.js, models/ContextGuide.js), controllers (controllers/contextController.js, controllers/contextGuideController.js) and authenticated route handlers (routes/contextRoutes.js, routes/contextGuideRoutes.js). Wire the new routes into app.js and export the models from models/index.js. Refactor vocabulary: remove VocabForm, VocabMapping and VocabRelation models and relationships, update models/Vocab.js schema and indexes, and add migrate-vocab.js to drop/recreate the vocab table for the new schema. Also add a lesson editor UI (public/lesson-editor.html) and a small cleanup in models/Lesson.js.
This commit is contained in:
silverpro89
2026-02-02 10:05:46 +07:00
parent 81a7ab5b6c
commit 97dbbd4d12
15 changed files with 1018 additions and 248 deletions

View File

@@ -35,9 +35,6 @@ const LessonLeaderboard = require('./LessonLeaderboard');
// Group 3.2: Vocabulary System (NEW)
const Vocab = require('./Vocab');
const VocabMapping = require('./VocabMapping');
const VocabForm = require('./VocabForm');
const VocabRelation = require('./VocabRelation');
// Group 3.3: Grammar System (NEW)
const Grammar = require('./Grammar');
@@ -47,6 +44,10 @@ const GrammarMediaStory = require('./GrammarMediaStory');
// Group 3.4: Story System (NEW)
const Story = require('./Story');
// Group 3.5: Context (NEW)
const Context = require('./Context');
const ContextGuide = require('./ContextGuide');
// Group 4: Attendance
const AttendanceLog = require('./AttendanceLog');
const AttendanceDaily = require('./AttendanceDaily');
@@ -164,18 +165,7 @@ const setupRelationships = () => {
Lesson.hasMany(LessonLeaderboard, { foreignKey: 'lesson_id', as: 'leaderboard' });
// Vocabulary relationships (NEW)
// Vocab -> VocabMapping (1:N)
Vocab.hasMany(VocabMapping, { foreignKey: 'vocab_id', as: 'mappings' });
VocabMapping.belongsTo(Vocab, { foreignKey: 'vocab_id', as: 'vocab' });
// Vocab -> VocabForm (1:N)
Vocab.hasMany(VocabForm, { foreignKey: 'vocab_id', as: 'forms' });
VocabForm.belongsTo(Vocab, { foreignKey: 'vocab_id', as: 'vocab' });
// Vocab -> VocabRelation (1:N)
Vocab.hasMany(VocabRelation, { foreignKey: 'vocab_id', as: 'relations' });
VocabRelation.belongsTo(Vocab, { foreignKey: 'vocab_id', as: 'vocab' });
VocabRelation.belongsTo(Vocab, { foreignKey: 'related_vocab_id', as: 'relatedVocab' });
// No additional relationships needed
// Grammar relationships (NEW)
// Grammar -> GrammarMapping (1:N)
@@ -299,9 +289,6 @@ module.exports = {
// Group 3.2: Vocabulary System (NEW)
Vocab,
VocabMapping,
VocabForm,
VocabRelation,
// Group 3.3: Grammar System (NEW)
Grammar,
@@ -310,6 +297,10 @@ module.exports = {
// Group 3.4: Story System (NEW)
Story,
// Group 3.5: Context (NEW)
Context,
ContextGuide,
// Group 4: Attendance
AttendanceLog,