Exam Question/Answer 3-way m:n
This commit is contained in:
parent
aa073a5029
commit
837d86ae21
10
README.md
10
README.md
@ -13,28 +13,34 @@
|
|||||||
|
|
||||||
- BelongsTo MemberRank
|
- BelongsTo MemberRank
|
||||||
- HasMany ExamMemberRankAnswer
|
- HasMany ExamMemberRankAnswer
|
||||||
|
- BelongsToMany ExamMemberRank
|
||||||
|
|
||||||
## ExamTyperatingQuestion
|
## ExamTyperatingQuestion
|
||||||
|
|
||||||
- BelongsTo Typerating
|
- BelongsTo Typerating
|
||||||
- HasMany ExamTyperatingAnswer
|
- HasMany ExamTyperatingAnswer
|
||||||
|
- BelongsToMany ExamTyperating
|
||||||
|
|
||||||
## ExamMemberRankAnswer
|
## ExamMemberRankAnswer
|
||||||
|
|
||||||
- BelongsTo ExamMemberRankQuestion
|
- BelongsTo ExamMemberRankQuestion
|
||||||
|
- BelongsToMany ExamMemberRank
|
||||||
|
|
||||||
## ExamTyperatingAnswer
|
## ExamTyperatingAnswer
|
||||||
|
|
||||||
- BelongsTo ExamTyperatingQuestion
|
- BelongsTo ExamTyperatingQuestion
|
||||||
|
- BelongsToMany ExamTyperating
|
||||||
|
|
||||||
## ExamMemberRank
|
## ExamMemberRank
|
||||||
|
|
||||||
- BelongsTo MemberRank
|
- BelongsTo MemberRank
|
||||||
- **TODO** BelongsTo Member (External DB)
|
- **TODO** BelongsTo Member (External DB)
|
||||||
- **TODO** HasMany ExamMemberRankQuestion
|
- BelongsToMany ExamMemberRankQuestion
|
||||||
|
- BelongsToMany ExamMemberRankAnswers
|
||||||
|
|
||||||
## ExamTyperating
|
## ExamTyperating
|
||||||
|
|
||||||
- BelongsTo Typerating
|
- BelongsTo Typerating
|
||||||
- **TODO** BelongsTo Member (External DB)
|
- **TODO** BelongsTo Member (External DB)
|
||||||
- **TODO** HasMany ExamTyperatingQuestion
|
- BelongsToMany ExamTyperatingQuestion
|
||||||
|
- BelongsToMany ExamTyperatingAnswers
|
||||||
|
|||||||
@ -12,9 +12,4 @@ class ExamMemberRank extends Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('member_rank_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,4 @@ class ExamMemberRankAnswer extends Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->leftJoin('exam_questions', 'exam_questions.id', 'exam_answers.exam_question_id');
|
|
||||||
$query->where('exam_questions.member_rank_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,4 @@ class ExamMemberRankQuestion extends Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('member_rank_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,9 +12,4 @@ class ExamTyperating extends Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('typerating_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,4 @@ class ExamTyperatingAnswer extends Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->leftJoin('exam_questions', 'exam_questions.id', 'exam_answers.exam_question_id');
|
|
||||||
$query->where('exam_questions.typerating_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,4 @@ class ExamTyperatingQuestion extends Controller
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('typerating_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
name: Exam Typerating Answer
|
name: Exam Typerating Answer
|
||||||
form: $/germanairlinesva/schooling/models/examtyperatinganswer/fields.yaml
|
form: $/germanairlinesva/schooling/models/examtyperatinganswer/fields.yaml
|
||||||
modelClass: GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer
|
modelClass: GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer
|
||||||
defaultRedirect: germanairlinesva/schooling/examtyperatinganswer
|
defaultRedirect: germanairlinesva/schooling/examtyperatinganswer
|
||||||
create:
|
create:
|
||||||
redirect: 'germanairlinesva/schooling/examtyperatinganswer/update/:id'
|
redirect: 'germanairlinesva/schooling/examtyperatinganswer/update/:id'
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
list: $/germanairlinesva/schooling/models/examtyperatinganswer/columns.yaml
|
list: $/germanairlinesva/schooling/models/examtyperatinganswer/columns.yaml
|
||||||
modelClass: GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer
|
modelClass: GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer
|
||||||
title: Exam Typerating Answers
|
title: Exam Typerating Answers
|
||||||
noRecordsMessage: 'backend::lang.list.no_records'
|
noRecordsMessage: 'backend::lang.list.no_records'
|
||||||
showSetup: true
|
showSetup: true
|
||||||
|
|||||||
@ -34,4 +34,33 @@ class ExamMemberRank extends Model
|
|||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $belongsToMany = [
|
||||||
|
'exam_questions' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamMemberRankQuestion',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_id',
|
||||||
|
'otherKey' => 'exam_question_id',
|
||||||
|
],
|
||||||
|
'exam_answers' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_id',
|
||||||
|
'otherKey' => 'exam_answer_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::addGlobalScope('exam_member_rank_member_rank_id', function ($builder) {
|
||||||
|
$builder->where('member_rank_id', '<>', null);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,4 +33,29 @@ class ExamMemberRankAnswer extends Model
|
|||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'exam_question' => ['GermanAirlinesVa\Schooling\Models\ExamMemberRankQuestion', 'key' => 'exam_question_id'],
|
'exam_question' => ['GermanAirlinesVa\Schooling\Models\ExamMemberRankQuestion', 'key' => 'exam_question_id'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $belongsToMany = [
|
||||||
|
'exam_member_ranks' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamMemberRank',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_answer_id',
|
||||||
|
'otherKey' => 'exam_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::addGlobalScope('exam_member_rank_answer_member_rank_id', function ($builder) {
|
||||||
|
$builder->whereHas('exam_question', function ($query) {
|
||||||
|
$query->where('member_rank_id', '<>', null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,10 +32,36 @@ class ExamMemberRankQuestion extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public $hasMany = [
|
public $hasMany = [
|
||||||
'exam_answers' => 'GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer',
|
'exam_answers' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer',
|
||||||
|
'key' => 'exam_question_id',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $belongsToMany = [
|
||||||
|
'exam_member_ranks' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamMemberRank',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_question_id',
|
||||||
|
'otherKey' => 'exam_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::addGlobalScope('exam_member_rank_question_member_rank_id', function ($builder) {
|
||||||
|
$builder->where('member_rank_id', '<>', null);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,4 +34,33 @@ class ExamTyperating extends Model
|
|||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $belongsToMany = [
|
||||||
|
'exam_questions' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamTyperatingQuestion',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_id',
|
||||||
|
'otherKey' => 'exam_question_id',
|
||||||
|
],
|
||||||
|
'exam_answers' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_id',
|
||||||
|
'otherKey' => 'exam_answer_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::addGlobalScope('exam_typerating_typerating_id', function ($builder) {
|
||||||
|
$builder->where('typerating_id', '<>', null);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Models;
|
<?php namespace GermanAirlinesVa\Schooling\Models;
|
||||||
|
|
||||||
use Model;
|
use Model;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model
|
* Model
|
||||||
@ -33,4 +34,29 @@ class ExamTyperatingAnswer extends Model
|
|||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'exam_question' => ['GermanAirlinesVa\Schooling\Models\ExamTyperatingQuestion', 'key' => 'exam_question_id'],
|
'exam_question' => ['GermanAirlinesVa\Schooling\Models\ExamTyperatingQuestion', 'key' => 'exam_question_id'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $belongsToMany = [
|
||||||
|
'exam_typeratings' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamTyperating',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_answer_id',
|
||||||
|
'otherKey' => 'exam_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::addGlobalScope('exam_typerating_answer_typerating_id', function (Builder $builder) {
|
||||||
|
$builder->whereHas('exam_question', function ($query) {
|
||||||
|
$query->where('typerating_id', '<>', null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,10 +32,36 @@ class ExamTyperatingQuestion extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public $hasMany = [
|
public $hasMany = [
|
||||||
'exam_answers' => 'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
|
'exam_answers' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
|
||||||
|
'key' => 'exam_question_id',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $belongsToMany = [
|
||||||
|
'exam_typeratings' => [
|
||||||
|
'GermanAirlinesVa\Schooling\Models\ExamTyperating',
|
||||||
|
'table' => 'exam_exam_answer_exam_question',
|
||||||
|
'key' => 'exam_question_id',
|
||||||
|
'otherKey' => 'exam_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::addGlobalScope('exam_typerating_question_typerating_id', function ($builder) {
|
||||||
|
$builder->where('typerating_id', '<>', null);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
<?php namespace GermanAirlinesVa\Schooling\Updates;
|
||||||
|
|
||||||
|
use Schema;
|
||||||
|
use October\Rain\Database\Updates\Migration;
|
||||||
|
|
||||||
|
class BuilderTableCreateExamExamAnswerExamQuestion extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('germanairlinesva_schooling')->create('exam_exam_answer_exam_question', function($table)
|
||||||
|
{
|
||||||
|
$table->engine = 'InnoDB';
|
||||||
|
$table->bigIncrements('id')->unsigned();
|
||||||
|
$table->bigInteger('exam_id')->unsigned();
|
||||||
|
$table
|
||||||
|
->foreign('exam_id')
|
||||||
|
->references('id')
|
||||||
|
->on('exams');
|
||||||
|
$table->bigInteger('exam_answer_id')->unsigned();
|
||||||
|
$table
|
||||||
|
->foreign('exam_answer_id')
|
||||||
|
->references('id')
|
||||||
|
->on('exam_answers');
|
||||||
|
$table->bigInteger('exam_question_id')->unsigned();
|
||||||
|
$table
|
||||||
|
->foreign('exam_question_id')
|
||||||
|
->references('id')
|
||||||
|
->on('exam_questions');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('germanairlinesva_schooling')->disableForeignKeyConstraints();
|
||||||
|
Schema::dropIfExists('germanairlinesva_schooling_exam_exam_answer_exam_question');
|
||||||
|
Schema::connection('germanairlinesva_schooling')->disableForeignKeyConstraints();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,17 @@
|
|||||||
1.0.1:
|
1.0.1:
|
||||||
- 'Initialize plugin.'
|
- 'Initialize plugin.'
|
||||||
- 'Create table deferred_bindings'
|
- 'Create table deferred_bindings'
|
||||||
- builder_table_create_deferred_bindings.php
|
- builder_table_create_deferred_bindings.php
|
||||||
1.0.2:
|
1.0.2:
|
||||||
- 'Created table typeratings'
|
- 'Created table typeratings'
|
||||||
- builder_table_create_typeratings.php
|
- builder_table_create_typeratings.php
|
||||||
- 'Created table member_ranks'
|
- 'Created table member_ranks'
|
||||||
- builder_table_create_member_ranks.php
|
- builder_table_create_member_ranks.php
|
||||||
- 'Created table exam_questions'
|
- 'Created table exam_questions'
|
||||||
- builder_table_create_exam_questions.php
|
- builder_table_create_exam_questions.php
|
||||||
- 'Created table exam_answers'
|
- 'Created table exam_answers'
|
||||||
- builder_table_create_exam_answers.php
|
- builder_table_create_exam_answers.php
|
||||||
- 'Created table exams'
|
- 'Created table exams'
|
||||||
- builder_table_create_exams.php
|
- builder_table_create_exams.php
|
||||||
|
- 'Created table exam_exam_answer_exam_question'
|
||||||
|
- builder_table_create_exam_exam_answer_exam_question.php
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user