Compare commits
3 Commits
55c47d4842
...
0b6df835fc
Author | SHA1 | Date |
---|---|---|
|
0b6df835fc | 3 weeks ago |
|
a00793bcdb | 3 weeks ago |
|
70eb021c6b | 3 weeks ago |
22 changed files with 617 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Category extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_categories'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'content', |
||||||
|
'content_vi', |
||||||
|
'description', |
||||||
|
'status', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercises() |
||||||
|
{ |
||||||
|
return $this->hasMany(Exercise::class, 'category_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Exercise extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_exercises'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'subject_id', |
||||||
|
'lesson_name', |
||||||
|
'description', |
||||||
|
'level', |
||||||
|
'avatar', |
||||||
|
'status', |
||||||
|
'category_id', |
||||||
|
'skill_id', |
||||||
|
'year', |
||||||
|
'media_object_id', |
||||||
|
]; |
||||||
|
|
||||||
|
public function subject() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Subject::class, 'subject_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function category() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Category::class, 'category_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function skill() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Skill::class, 'skill_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function questionGroups() |
||||||
|
{ |
||||||
|
return $this->hasMany(QuestionGroup::class, 'exercise_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function questions() |
||||||
|
{ |
||||||
|
return $this->hasMany(Question::class, 'exercise_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class ExerciseQuestion extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_exercise_questions'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'exercise_id', |
||||||
|
'question_id', |
||||||
|
'position', |
||||||
|
]; |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Media extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_media'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'object_id', |
||||||
|
'file_name', |
||||||
|
'file_url', |
||||||
|
'mime_type', |
||||||
|
'size_bytes', |
||||||
|
'position', |
||||||
|
]; |
||||||
|
|
||||||
|
// Gợi ý: nếu cần polymorphic, bạn sẽ thay bằng morphTo() |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Question extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_questions'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'exercise_id', |
||||||
|
'content', |
||||||
|
'description', |
||||||
|
'group_id', |
||||||
|
'question_type_id', |
||||||
|
'level', |
||||||
|
'score', |
||||||
|
'answer', |
||||||
|
'explanation', |
||||||
|
'hint', |
||||||
|
'media_object_id', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercise() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Exercise::class, 'exercise_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function group() |
||||||
|
{ |
||||||
|
return $this->belongsTo(QuestionGroup::class, 'group_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function type() |
||||||
|
{ |
||||||
|
return $this->belongsTo(QuestionType::class, 'question_type_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function choices() |
||||||
|
{ |
||||||
|
return $this->hasMany(QuestionChoice::class, 'question_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function blanks() |
||||||
|
{ |
||||||
|
return $this->hasMany(QuestionBlank::class, 'question_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionBlank extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_blanks'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'question_id', |
||||||
|
'position', |
||||||
|
'correct_answer', |
||||||
|
'other_answers', |
||||||
|
]; |
||||||
|
|
||||||
|
public function question() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Question::class, 'question_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionChoice extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_choices'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'question_id', |
||||||
|
'label', |
||||||
|
'content', |
||||||
|
'is_correct', |
||||||
|
'media', |
||||||
|
'media_object_id', |
||||||
|
'position', |
||||||
|
]; |
||||||
|
|
||||||
|
public function question() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Question::class, 'question_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionGroup extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_groups'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'content', |
||||||
|
'content_vi', |
||||||
|
'exercise_id', |
||||||
|
'is_question_order_fixed', |
||||||
|
'is_option_order_fixed', |
||||||
|
'position', |
||||||
|
'paragraph', |
||||||
|
'media_object_id', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercise() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Exercise::class, 'exercise_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function questions() |
||||||
|
{ |
||||||
|
return $this->hasMany(Question::class, 'group_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionType extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_types'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'name', |
||||||
|
'code', |
||||||
|
'description', |
||||||
|
'status', |
||||||
|
]; |
||||||
|
|
||||||
|
public function questions() |
||||||
|
{ |
||||||
|
return $this->hasMany(Question::class, 'question_type_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Skill extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_skills'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'name', |
||||||
|
'code', |
||||||
|
'description', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercises() |
||||||
|
{ |
||||||
|
return $this->hasMany(Exercise::class, 'skill_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class Subject extends Model |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_subjects', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->string('name'); |
||||||
|
$table->string('code')->unique(); |
||||||
|
$table->text('description')->nullable(); |
||||||
|
$table->integer('status')->default(1); // true = active, false = inactive |
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); // deleted_at |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_subjects'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_categories', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->string('content'); |
||||||
|
$table->string('content_vi')->nullable(); |
||||||
|
$table->text('description')->nullable(); |
||||||
|
$table->integer('status')->default(1); |
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_categories'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_skills', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->string('name'); |
||||||
|
$table->string('code')->unique(); |
||||||
|
$table->text('description')->nullable(); |
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_skills'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_question_types', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->string('name'); |
||||||
|
$table->text('description')->nullable(); |
||||||
|
$table->string('code')->unique(); |
||||||
|
$table->integer('status')->default(1); |
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_question_types'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_media', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->unsignedBigInteger('object_id'); |
||||||
|
$table->string('file_name'); |
||||||
|
$table->string('file_url'); |
||||||
|
$table->string('mime_type'); |
||||||
|
$table->unsignedBigInteger('size_bytes'); |
||||||
|
$table->integer('position')->nullable(); |
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_media'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_exercises', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
|
||||||
|
$table->unsignedBigInteger('subject_id'); |
||||||
|
$table->string('lesson_name'); |
||||||
|
$table->text('description')->nullable(); |
||||||
|
$table->integer('level')->default(0); |
||||||
|
$table->string('avatar')->nullable(); |
||||||
|
$table->integer('status')->default(1); // |
||||||
|
$table->unsignedBigInteger('category_id'); |
||||||
|
$table->unsignedBigInteger('skill_id'); |
||||||
|
$table->string('year')->nullable(); |
||||||
|
$table->unsignedBigInteger('media_object_id')->nullable(); |
||||||
|
|
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_exercises'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,32 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_question_groups', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->text('content'); |
||||||
|
$table->text('content_vi')->nullable(); |
||||||
|
$table->unsignedBigInteger('exercise_id'); |
||||||
|
|
||||||
|
$table->integer('is_question_order_fixed')->default(0); |
||||||
|
$table->integer('is_option_order_fixed')->default(0); |
||||||
|
$table->integer('position')->default(0); |
||||||
|
$table->text('paragraph')->nullable(); |
||||||
|
$table->unsignedBigInteger('media_object_id')->nullable(); |
||||||
|
|
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
|
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_question_groups'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,34 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_questions', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->unsignedBigInteger('exercise_id'); |
||||||
|
$table->text('content'); |
||||||
|
$table->text('description')->nullable(); |
||||||
|
$table->unsignedBigInteger('group_id')->nullable(); |
||||||
|
$table->unsignedBigInteger('question_type_id'); |
||||||
|
$table->integer('level')->default(0); |
||||||
|
$table->integer('score')->default(1); |
||||||
|
$table->text('answer')->nullable(); |
||||||
|
$table->text('explanation')->nullable(); |
||||||
|
$table->text('hint')->nullable(); |
||||||
|
$table->unsignedBigInteger('media_object_id')->nullable(); |
||||||
|
|
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
|
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_questions'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_exercise_questions', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
|
||||||
|
$table->unsignedBigInteger('exercise_id'); |
||||||
|
$table->unsignedBigInteger('question_id'); |
||||||
|
$table->integer('position')->default(0); |
||||||
|
|
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
|
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_exercise_questions'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,32 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_question_choices', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
|
||||||
|
// Chỉ giữ cột, không còn ràng buộc FK |
||||||
|
$table->unsignedBigInteger('question_id'); |
||||||
|
$table->string('label')->nullable(); |
||||||
|
$table->text('content')->nullable(); |
||||||
|
$table->integer('is_correct')->default(0); // 0 = false, 1 = true |
||||||
|
// $table->json('media')->nullable(); |
||||||
|
$table->unsignedBigInteger('media_object_id')->nullable(); |
||||||
|
$table->integer('position')->default(0); |
||||||
|
|
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
|
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_question_choices'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
|
||||||
|
return new class extends Migration { |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('se_question_blanks', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->unsignedBigInteger('question_id'); |
||||||
|
$table->integer('position')->default(0); |
||||||
|
$table->text('correct_answer'); |
||||||
|
$table->json('other_answers')->nullable(); |
||||||
|
$table->timestamps(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('se_question_blanks'); |
||||||
|
} |
||||||
|
}; |
Loading…
Reference in new issue