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:
@@ -8,21 +8,32 @@ const Vocab = sequelize.define('Vocab', {
|
||||
primaryKey: true,
|
||||
comment: 'Unique identifier for vocabulary entry'
|
||||
},
|
||||
vocab_code: {
|
||||
type: DataTypes.STRING(50),
|
||||
unique: true,
|
||||
allowNull: false,
|
||||
comment: 'Unique code for vocabulary (e.g., vocab-001-eat)'
|
||||
// Từ thực tế (wash, washes, washing, ate, eaten...)
|
||||
text: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
index: true
|
||||
},
|
||||
base_word: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
comment: 'Base form of the word'
|
||||
// Từ gốc để nhóm lại (wash, eat...)
|
||||
base_word: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
index: true
|
||||
},
|
||||
// Đã xuất hiện trong khối nào, bài học nào, lesson nào
|
||||
// Ví dụ 111 là grade 1, unit 1, lesson 1
|
||||
location: {
|
||||
type: DataTypes.INTEGER,
|
||||
comment: 'Location or source of the vocabulary'
|
||||
},
|
||||
// Loại biến thể (V1, V2, V3, V_ing, Noun_Form...)
|
||||
form_key: {
|
||||
type: DataTypes.STRING(20),
|
||||
defaultValue: 'base'
|
||||
},
|
||||
// Nội dung dùng chung (có thể lưu JSON để dễ quản lý hoặc dùng chung cho cả group)
|
||||
translation: {
|
||||
type: DataTypes.STRING(200),
|
||||
allowNull: false,
|
||||
comment: 'Vietnamese translation'
|
||||
type: DataTypes.STRING(200)
|
||||
},
|
||||
difficulty_score: {
|
||||
type: DataTypes.INTEGER,
|
||||
@@ -33,6 +44,10 @@ const Vocab = sequelize.define('Vocab', {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Category of the word (e.g., Action Verbs, Nouns)'
|
||||
},
|
||||
topic: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Topic of the word (e.g., Food, Travel, Education)'
|
||||
},
|
||||
images: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
@@ -73,8 +88,8 @@ const Vocab = sequelize.define('Vocab', {
|
||||
updatedAt: 'updated_at',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_vocab_code',
|
||||
fields: ['vocab_code']
|
||||
name: 'idx_vocab_text',
|
||||
fields: ['text']
|
||||
},
|
||||
{
|
||||
name: 'idx_base_word',
|
||||
@@ -83,6 +98,10 @@ const Vocab = sequelize.define('Vocab', {
|
||||
{
|
||||
name: 'idx_category',
|
||||
fields: ['category']
|
||||
},
|
||||
{
|
||||
name: 'idx_location',
|
||||
fields: ['location']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user