Add Context APIs and refactor vocab models
All checks were successful
Deploy to Production / deploy (push) Successful in 25s
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:
92
models/Context.js
Normal file
92
models/Context.js
Normal file
@@ -0,0 +1,92 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
const Context = sequelize.define('Context', {
|
||||
uuid: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
comment: 'Unique identifier for context'
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: false,
|
||||
comment: 'Title of the context item'
|
||||
},
|
||||
context: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false,
|
||||
comment: 'Context description'
|
||||
},
|
||||
knowledge: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'Additional knowledge or information'
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING(50),
|
||||
allowNull: false,
|
||||
comment: 'Context type (e.g., vocabulary, grammar)'
|
||||
},
|
||||
desc: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'Detailed description or requirement'
|
||||
},
|
||||
prompt: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Prompt configuration object'
|
||||
},
|
||||
image: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
difficulty: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 1,
|
||||
comment: 'Difficulty level (1-10)'
|
||||
},
|
||||
max: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: 'Maximum number of images or items'
|
||||
},
|
||||
isPrompt: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
comment: 'Prompt created (0/1)'
|
||||
},
|
||||
isList: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
comment: 'Waiting for more images (0/1)'
|
||||
},
|
||||
isApprove: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
comment: 'Teacher approval status (0/1)'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
}
|
||||
}, {
|
||||
tableName: 'context',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_context_type',
|
||||
fields: ['type']
|
||||
},
|
||||
{
|
||||
name: 'idx_context_title',
|
||||
fields: ['title']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = Context;
|
||||
Reference in New Issue
Block a user