Compare commits
10 Commits
aa073a5029
...
f0a2ac15fb
| Author | SHA1 | Date | |
|---|---|---|---|
| f0a2ac15fb | |||
| 0bdba12a0e | |||
| 3302d89057 | |||
| fb1f54d8b9 | |||
| 5f232a645c | |||
| ad6e4b2943 | |||
| 85ff347090 | |||
| ac87652534 | |||
| 77799b26cc | |||
| 837d86ae21 |
@@ -4,37 +4,45 @@
|
|||||||
|
|
||||||
- HasMany AircraftTypes (External DB)
|
- HasMany AircraftTypes (External DB)
|
||||||
- HasMany ExamTyperatingQuestion
|
- HasMany ExamTyperatingQuestion
|
||||||
|
- HasMany ExamTyperating
|
||||||
|
|
||||||
## MemberRank
|
## MemberRank
|
||||||
|
|
||||||
- HasMany ExamMemberRankQuestion
|
- HasMany ExamMemberRankQuestion
|
||||||
|
- HasMany ExamMemberRank
|
||||||
|
|
||||||
## ExamMemberRankQuestion
|
## ExamMemberRankQuestion
|
||||||
|
|
||||||
- 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)
|
- BelongsTo Member (External DB, creation in Social Plugin)
|
||||||
- **TODO** HasMany ExamMemberRankQuestion
|
- BelongsToMany ExamMemberRankQuestion
|
||||||
|
- BelongsToMany ExamMemberRankAnswers
|
||||||
|
|
||||||
## ExamTyperating
|
## ExamTyperating
|
||||||
|
|
||||||
- BelongsTo Typerating
|
- BelongsTo Typerating
|
||||||
- **TODO** BelongsTo Member (External DB)
|
- BelongsTo Member (External DB, creation in Social Plugin)
|
||||||
- **TODO** HasMany ExamTyperatingQuestion
|
- BelongsToMany ExamTyperatingQuestion
|
||||||
|
- BelongsToMany ExamTyperatingAnswers
|
||||||
|
|||||||
@@ -8,13 +8,10 @@ class ExamMemberRank extends Controller
|
|||||||
|
|
||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('member_rank_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,10 @@ class ExamMemberRankAnswer extends Controller
|
|||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
public $formConfig = 'config_form.yaml';
|
public $formConfig = 'config_form.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,10 @@ class ExamMemberRankQuestion extends Controller
|
|||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
public $formConfig = 'config_form.yaml';
|
public $formConfig = 'config_form.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('member_rank_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,10 @@ class ExamTyperating extends Controller
|
|||||||
|
|
||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('typerating_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,10 @@ class ExamTyperatingAnswer extends Controller
|
|||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
public $formConfig = 'config_form.yaml';
|
public $formConfig = 'config_form.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,10 @@ class ExamTyperatingQuestion extends Controller
|
|||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
public $formConfig = 'config_form.yaml';
|
public $formConfig = 'config_form.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listExtendQuery($query)
|
|
||||||
{
|
|
||||||
$query->where('typerating_id', '<>', null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class MemberRank extends Controller
|
|||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
public $formConfig = 'config_form.yaml';
|
public $formConfig = 'config_form.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class Typerating extends Controller
|
|||||||
public $listConfig = 'config_list.yaml';
|
public $listConfig = 'config_list.yaml';
|
||||||
public $formConfig = 'config_form.yaml';
|
public $formConfig = 'config_form.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -33,5 +33,86 @@ class ExamMemberRank extends Model
|
|||||||
|
|
||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
||||||
|
'member' => 'GermanAirlinesVa\Social\Models\Member',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function createNew($member_id, $member_rank_id)
|
||||||
|
{
|
||||||
|
$exam = new ExamMemberRank();
|
||||||
|
$exam->member_id = $member_id;
|
||||||
|
$exam->member_rank_id = $member_rank_id;
|
||||||
|
|
||||||
|
$entry = [];
|
||||||
|
$questions = ExamMemberRankQuestion::where('member_rank_id', $member_rank_id)
|
||||||
|
->get()
|
||||||
|
->random(10);
|
||||||
|
foreach ($questions as $question) {
|
||||||
|
array_push($entry, ['exam_question_id' => $question->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$exam->exam_questions = $entry;
|
||||||
|
$exam->save();
|
||||||
|
return $exam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function grade()
|
||||||
|
{
|
||||||
|
$this->load([
|
||||||
|
'exam_questions' => function ($query) {
|
||||||
|
$query->groupBy('id');
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
$returnVal = [];
|
||||||
|
$returnGrade = 0;
|
||||||
|
foreach ($this->exam_questions as $question) {
|
||||||
|
$answers = $question->exam_answers;
|
||||||
|
$returnAnswers = [];
|
||||||
|
$returnAnswerGrade = true;
|
||||||
|
foreach ($answers as $answer) {
|
||||||
|
$given = $this->exam_answers->contains($answer->id);
|
||||||
|
array_push($returnAnswers, [
|
||||||
|
'answer' => $answer,
|
||||||
|
'status' => $given,
|
||||||
|
'grade' => $given == $answer->is_correct,
|
||||||
|
]);
|
||||||
|
$returnAnswerGrade = $returnAnswerGrade && $given == $answer->is_correct;
|
||||||
|
}
|
||||||
|
array_push($returnVal, [
|
||||||
|
'question' => $question,
|
||||||
|
'answers' => $returnAnswers,
|
||||||
|
'grade' => $returnAnswerGrade,
|
||||||
|
]);
|
||||||
|
$returnGrade = $returnAnswerGrade ? $returnGrade + 1 : $returnGrade;
|
||||||
|
}
|
||||||
|
return ['exam' => $returnVal, 'grade' => $returnGrade];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,33 @@ 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,90 @@ class ExamTyperating extends Model
|
|||||||
public $rules = [
|
public $rules = [
|
||||||
'member_id' => 'required',
|
'member_id' => 'required',
|
||||||
'typerating_id' => 'required',
|
'typerating_id' => 'required',
|
||||||
'start' => 'required',
|
|
||||||
'status' => 'required',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public $belongsTo = [
|
public $belongsTo = [
|
||||||
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
||||||
|
'member' => 'GermanAirlinesVa\Social\Models\Member',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function createNew($member_id, $typerating_id)
|
||||||
|
{
|
||||||
|
$exam = new ExamTyperating();
|
||||||
|
$exam->member_id = $member_id;
|
||||||
|
$exam->typerating_id = $typerating_id;
|
||||||
|
|
||||||
|
$entry = [];
|
||||||
|
$questions = ExamTyperatingQuestion::where('typerating_id', $typerating_id)
|
||||||
|
->get()
|
||||||
|
->random(10);
|
||||||
|
foreach ($questions as $question) {
|
||||||
|
array_push($entry, ['exam_question_id' => $question->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$exam->exam_questions = $entry;
|
||||||
|
$exam->save();
|
||||||
|
return $exam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function grade()
|
||||||
|
{
|
||||||
|
$this->load([
|
||||||
|
'exam_questions' => function ($query) {
|
||||||
|
$query->groupBy('id');
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
$returnVal = [];
|
||||||
|
$returnGrade = 0;
|
||||||
|
foreach ($this->exam_questions as $question) {
|
||||||
|
$answers = $question->exam_answers;
|
||||||
|
$returnAnswers = [];
|
||||||
|
$returnAnswerGrade = true;
|
||||||
|
foreach ($answers as $answer) {
|
||||||
|
$given = $this->exam_answers->contains($answer->id);
|
||||||
|
array_push($returnAnswers, [
|
||||||
|
'answer' => $answer,
|
||||||
|
'status' => $given,
|
||||||
|
'grade' => $given == $answer->is_correct,
|
||||||
|
]);
|
||||||
|
$returnAnswerGrade = $returnAnswerGrade && $given == $answer->is_correct;
|
||||||
|
}
|
||||||
|
array_push($returnVal, [
|
||||||
|
'question' => $question,
|
||||||
|
'answers' => $returnAnswers,
|
||||||
|
'grade' => $returnAnswerGrade,
|
||||||
|
]);
|
||||||
|
$returnGrade = $returnAnswerGrade ? $returnGrade + 1 : $returnGrade;
|
||||||
|
}
|
||||||
|
return ['exam' => $returnVal, 'grade' => $returnGrade];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,33 @@ 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,6 @@ class MemberRank extends Model
|
|||||||
|
|
||||||
public $hasMany = [
|
public $hasMany = [
|
||||||
'exam_questions' => 'GermanAirlinesVa\Schooling\Models\ExamMemberRankQuestion',
|
'exam_questions' => 'GermanAirlinesVa\Schooling\Models\ExamMemberRankQuestion',
|
||||||
|
'exams' => 'GermanAirlinesVa\Schooling\Models\ExamMemberRank',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,5 +29,6 @@ class Typerating extends Model
|
|||||||
public $hasMany = [
|
public $hasMany = [
|
||||||
'aircraft_types' => 'GermanAirlinesVa\Fleet\Models\AircraftType',
|
'aircraft_types' => 'GermanAirlinesVa\Fleet\Models\AircraftType',
|
||||||
'exam_questions' => 'GermanAirlinesVa\Schooling\Models\ExamTyperatingQuestion',
|
'exam_questions' => 'GermanAirlinesVa\Schooling\Models\ExamTyperatingQuestion',
|
||||||
|
'exams' => 'GermanAirlinesVa\Schooling\Models\ExamTyperating',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ columns:
|
|||||||
id:
|
id:
|
||||||
label: id
|
label: id
|
||||||
type: number
|
type: number
|
||||||
member_id:
|
member:
|
||||||
label: member_id
|
label: member
|
||||||
type: number
|
type: text
|
||||||
|
relation: member
|
||||||
|
valueFrom: name
|
||||||
member_rank:
|
member_rank:
|
||||||
label: member_rank
|
label: member_rank
|
||||||
type: text
|
type: text
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ columns:
|
|||||||
id:
|
id:
|
||||||
label: id
|
label: id
|
||||||
type: number
|
type: number
|
||||||
member_id:
|
member:
|
||||||
label: member_id
|
label: member
|
||||||
type: number
|
type: text
|
||||||
|
relation: member
|
||||||
|
valueFrom: name
|
||||||
typerating:
|
typerating:
|
||||||
label: typerating
|
label: typerating
|
||||||
type: text
|
type: text
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ navigation:
|
|||||||
url: /
|
url: /
|
||||||
icon: icon-university
|
icon: icon-university
|
||||||
permissions:
|
permissions:
|
||||||
- schooling
|
- germanairlinesva.schooling.master
|
||||||
sideMenu:
|
sideMenu:
|
||||||
side-menu-item:
|
side-menu-item:
|
||||||
label: 'germanairlinesva.schooling::lang.menu.typeratings'
|
label: 'germanairlinesva.schooling::lang.menu.typeratings'
|
||||||
@@ -45,6 +45,6 @@ navigation:
|
|||||||
url: germanairlinesva/schooling/examtyperating
|
url: germanairlinesva/schooling/examtyperating
|
||||||
icon: icon-file-text
|
icon: icon-file-text
|
||||||
permissions:
|
permissions:
|
||||||
schooling:
|
germanairlinesva.schooling.master:
|
||||||
tab: 'germanairlinesva.schooling::lang.permissions.tab'
|
tab: 'germanairlinesva.schooling::lang.permissions.tab'
|
||||||
label: 'germanairlinesva.schooling::lang.permissions.label'
|
label: 'germanairlinesva.schooling::lang.permissions.label'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php namespace GermanAirlinesVa\Fleet\Updates;
|
<?php namespace GermanAirlinesVa\Schooling\Updates;
|
||||||
|
|
||||||
use Schema;
|
use Schema;
|
||||||
use October\Rain\Database\Updates\Migration;
|
use October\Rain\Database\Updates\Migration;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class BuilderTableCreateExamAnswers extends Migration
|
|||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
|
Schema::connection('germanairlinesva_schooling')->disableForeignKeyConstraints();
|
||||||
Schema::connection('germanairlinesva_schooling')->dropIfExists('exam_answers');
|
Schema::connection('germanairlinesva_schooling')->dropIfExists('exam_answers');
|
||||||
|
Schema::connection('germanairlinesva_schooling')->enableForeignKeyConstraints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?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::connection('germanairlinesva_schooling')->dropIfExists('exam_exam_answer_exam_question');
|
||||||
|
Schema::connection('germanairlinesva_schooling')->enableForeignKeyConstraints();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,6 +35,8 @@ class BuilderTableCreateExams extends Migration
|
|||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
|
Schema::connection('germanairlinesva_schooling')->disableForeignKeyConstraints();
|
||||||
Schema::connection('germanairlinesva_schooling')->dropIfExists('exams');
|
Schema::connection('germanairlinesva_schooling')->dropIfExists('exams');
|
||||||
|
Schema::connection('germanairlinesva_schooling')->enableForeignKeyConstraints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,3 +13,5 @@
|
|||||||
- 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
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ p-defer@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
|
resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
|
||||||
integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=
|
integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=
|
||||||
|
|
||||||
"php-parser@git+https://github.com/glayzzle/php-parser.git#e61e26102144f267ecf5e09020865a9baa6ca2f1":
|
"php-parser@https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1":
|
||||||
version "3.0.2"
|
version "3.0.2"
|
||||||
resolved "git+https://github.com/glayzzle/php-parser.git#e61e26102144f267ecf5e09020865a9baa6ca2f1"
|
resolved "https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1"
|
||||||
|
|
||||||
prettier@^2.3.2:
|
prettier@^2.3.2:
|
||||||
version "2.3.2"
|
version "2.3.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user