Exam Table/Model/Controller

This commit is contained in:
Your Name 2021-08-04 14:01:21 +02:00
parent 38efe1af1b
commit 42e06d1005
18 changed files with 278 additions and 0 deletions

View File

@ -26,3 +26,15 @@
## ExamTyperatingAnswer
- BelongsTo ExamTyperatingQuestion
## ExamMemberRank
- BelongsTo MemberRank
- **TODO** BelongsTo Member (External DB)
- **TODO** HasMany ExamMemberRankQuestion
## ExamTyperating
- BelongsTo Typerating
- **TODO** BelongsTo Member (External DB)
- **TODO** HasMany ExamTyperatingQuestion

View File

@ -0,0 +1,21 @@
<?php namespace GermanAirlinesVa\Schooling\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class ExamMemberRank extends Controller
{
public $implement = ['Backend\Behaviors\ListController'];
public $listConfig = 'config_list.yaml';
public function __construct()
{
parent::__construct();
}
public function listExtendQuery($query)
{
$query->where('member_rank_id', '<>', null);
}
}

View File

@ -0,0 +1,21 @@
<?php namespace GermanAirlinesVa\Schooling\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class ExamTyperating extends Controller
{
public $implement = ['Backend\Behaviors\ListController'];
public $listConfig = 'config_list.yaml';
public function __construct()
{
parent::__construct();
}
public function listExtendQuery($query)
{
$query->where('typerating_id', '<>', null);
}
}

View File

@ -0,0 +1,17 @@
<div data-control="toolbar">
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', true)"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
</div>

View File

@ -0,0 +1,11 @@
list: $/germanairlinesva/schooling/models/exammemberrank/columns.yaml
modelClass: GermanAirlinesVa\Schooling\Models\ExamMemberRank
title: Exams Member Rank
noRecordsMessage: 'backend::lang.list.no_records'
showSetup: true
showCheckboxes: true
recordsPerPage: 20
toolbar:
buttons: list_toolbar
search:
prompt: 'backend::lang.list.search_prompt'

View File

@ -0,0 +1 @@
<?= $this->listRender() ?>

View File

@ -0,0 +1,17 @@
<div data-control="toolbar">
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', true)"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
</div>

View File

@ -0,0 +1,11 @@
list: $/germanairlinesva/schooling/models/examtyperating/columns.yaml
modelClass: GermanAirlinesVa\Schooling\Models\ExamTyperating
title: Exams Typerating
noRecordsMessage: 'backend::lang.list.no_records'
showSetup: true
showCheckboxes: true
recordsPerPage: 20
toolbar:
buttons: list_toolbar
search:
prompt: 'backend::lang.list.search_prompt'

View File

@ -0,0 +1 @@
<?= $this->listRender() ?>

View File

@ -15,6 +15,8 @@
'exam_question_typerating' => 'Exam Typerating Questions',
'exam_answer_rank' => 'Exam Member Rank Answers',
'exam_answer_typerating' => 'Exam Typerating Answers',
'exam_member_rank' => 'Exams Member Rank',
'exam_typerating' => 'Exams Typerating',
],
'permissions' => [
'tab' => 'German Airlines VA - Schooling',

37
models/ExamMemberRank.php Normal file
View File

@ -0,0 +1,37 @@
<?php namespace GermanAirlinesVa\Schooling\Models;
use Model;
/**
* Model
*/
class ExamMemberRank extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
public $table = 'exams';
protected $connection = 'germanairlinesva_schooling';
/**
* @var array Validation rules
*/
public $rules = [
'member_id' => 'required',
'member_rank_id' => 'required',
'start' => 'required',
'status' => 'required',
];
public $belongsTo = [
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
];
}

37
models/ExamTyperating.php Normal file
View File

@ -0,0 +1,37 @@
<?php namespace GermanAirlinesVa\Schooling\Models;
use Model;
/**
* Model
*/
class ExamTyperating extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
public $table = 'exams';
protected $connection = 'germanairlinesva_schooling';
/**
* @var array Validation rules
*/
public $rules = [
'member_id' => 'required',
'typerating_id' => 'required',
'start' => 'required',
'status' => 'required',
];
public $belongsTo = [
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
];
}

View File

@ -31,6 +31,10 @@ class ExamTyperatingQuestion extends Model
'text' => 'required',
];
public $hasMany = [
'exam_answers' => 'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
];
public $belongsTo = [
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
];

View File

@ -0,0 +1,18 @@
columns:
id:
label: id
type: number
member_id:
label: member_id
type: number
member_rank:
label: member_rank
type: text
relation: member_rank
valueFrom: name
start:
label: start
type: datetime
status:
label: status
type: text

View File

@ -0,0 +1,18 @@
columns:
id:
label: id
type: number
member_id:
label: member_id
type: number
typerating:
label: typerating
type: text
relation: typerating
valueFrom: name
start:
label: start
type: datetime
status:
label: status
type: text

View File

@ -36,6 +36,14 @@ navigation:
label: 'germanairlinesva.schooling::lang.menu.exam_answer_typerating'
url: germanairlinesva/schooling/examtyperatinganswer
icon: icon-check
side-menu-item7:
label: 'germanairlinesva.schooling::lang.menu.exam_member_rank'
url: germanairlinesva/schooling/exammemberrank
icon: icon-file-text
side-menu-item8:
label: 'germanairlinesva.schooling::lang.menu.exam_typerating'
url: germanairlinesva/schooling/examtyperating
icon: icon-file-text
permissions:
schooling:
tab: 'germanairlinesva.schooling::lang.permissions.tab'

View File

@ -0,0 +1,40 @@
<?php namespace GermanAirlinesVa\Schooling\Updates;
use DB;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateExams extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_schooling')->create('exams', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('member_id')->unsigned();
$table
->bigInteger('member_rank_id')
->unsigned()
->nullable();
$table
->foreign('member_rank_id')
->references('id')
->on('member_ranks');
$table
->bigInteger('typerating_id')
->unsigned()
->nullable();
$table
->foreign('typerating_id')
->references('id')
->on('typeratings');
$table->datetime('start')->default(DB::raw('NOW()'));
$table->enum('status', ['pending', 'validated', 'closed', 'open']);
});
}
public function down()
{
Schema::connection('germanairlinesva_schooling')->dropIfExists('exams');
}
}

View File

@ -11,3 +11,5 @@
- builder_table_create_exam_questions.php
- 'Created table exam_answers'
- builder_table_create_exam_answers.php
- 'Created table exams'
- builder_table_create_exams.php