Compare commits
16 Commits
7024bd0a77
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f0a2ac15fb | |||
| 0bdba12a0e | |||
| 3302d89057 | |||
| fb1f54d8b9 | |||
| 5f232a645c | |||
| ad6e4b2943 | |||
| 85ff347090 | |||
| ac87652534 | |||
| 77799b26cc | |||
| 837d86ae21 | |||
| aa073a5029 | |||
| d3b30100a9 | |||
| ed2b39fe26 | |||
| 42e06d1005 | |||
| 38efe1af1b | |||
| 5bf71f2ea4 |
@@ -4,25 +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
|
||||||
|
|
||||||
|
- BelongsTo MemberRank
|
||||||
|
- BelongsTo Member (External DB, creation in Social Plugin)
|
||||||
|
- BelongsToMany ExamMemberRankQuestion
|
||||||
|
- BelongsToMany ExamMemberRankAnswers
|
||||||
|
|
||||||
|
## ExamTyperating
|
||||||
|
|
||||||
|
- BelongsTo Typerating
|
||||||
|
- BelongsTo Member (External DB, creation in Social Plugin)
|
||||||
|
- BelongsToMany ExamTyperatingQuestion
|
||||||
|
- BelongsToMany ExamTyperatingAnswers
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
|
use Backend\Classes\Controller;
|
||||||
|
|
||||||
|
class ExamMemberRank extends Controller
|
||||||
|
{
|
||||||
|
public $implement = ['Backend\Behaviors\ListController'];
|
||||||
|
|
||||||
|
public $listConfig = 'config_list.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use BackendMenu;
|
|
||||||
|
|
||||||
class ExamMemberRankAnswer extends Controller
|
class ExamMemberRankAnswer extends Controller
|
||||||
{
|
{
|
||||||
@@ -10,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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use BackendMenu;
|
|
||||||
|
|
||||||
class ExamMemberRankQuestion extends Controller
|
class ExamMemberRankQuestion extends Controller
|
||||||
{
|
{
|
||||||
@@ -10,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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
|
use Backend\Classes\Controller;
|
||||||
|
|
||||||
|
class ExamTyperating extends Controller
|
||||||
|
{
|
||||||
|
public $implement = ['Backend\Behaviors\ListController'];
|
||||||
|
|
||||||
|
public $listConfig = 'config_list.yaml';
|
||||||
|
|
||||||
|
public $requiredPermissions = ['germanairlinesva.schooling.master'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use BackendMenu;
|
|
||||||
|
|
||||||
class ExamTyperatingAnswer extends Controller
|
class ExamTyperatingAnswer extends Controller
|
||||||
{
|
{
|
||||||
@@ -10,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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use BackendMenu;
|
|
||||||
|
|
||||||
class ExamTyperatingQuestion extends Controller
|
class ExamTyperatingQuestion extends Controller
|
||||||
{
|
{
|
||||||
@@ -10,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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use BackendMenu;
|
|
||||||
|
|
||||||
class MemberRank extends Controller
|
class MemberRank extends Controller
|
||||||
{
|
{
|
||||||
@@ -10,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();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
<?php namespace GermanAirlinesVa\Schooling\Controllers;
|
||||||
|
|
||||||
use Backend\Classes\Controller;
|
use Backend\Classes\Controller;
|
||||||
use BackendMenu;
|
|
||||||
|
|
||||||
class Typerating extends Controller
|
class Typerating extends Controller
|
||||||
{
|
{
|
||||||
@@ -10,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();
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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'
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<?= $this->listRender() ?>
|
||||||
@@ -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>
|
||||||
@@ -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'
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<?= $this->listRender() ?>
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
'exam_question_typerating' => 'Exam Typerating Questions',
|
'exam_question_typerating' => 'Exam Typerating Questions',
|
||||||
'exam_answer_rank' => 'Exam Member Rank Answers',
|
'exam_answer_rank' => 'Exam Member Rank Answers',
|
||||||
'exam_answer_typerating' => 'Exam Typerating Answers',
|
'exam_answer_typerating' => 'Exam Typerating Answers',
|
||||||
|
'exam_member_rank' => 'Exams Member Rank',
|
||||||
|
'exam_typerating' => 'Exams Typerating',
|
||||||
],
|
],
|
||||||
'permissions' => [
|
'permissions' => [
|
||||||
'tab' => 'German Airlines VA - Schooling',
|
'tab' => 'German Airlines VA - Schooling',
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<?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',
|
||||||
|
'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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?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',
|
||||||
|
];
|
||||||
|
|
||||||
|
public $belongsTo = [
|
||||||
|
'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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,34 @@ class ExamTyperatingQuestion extends Model
|
|||||||
'text' => 'required',
|
'text' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $hasMany = [
|
||||||
|
'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',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
columns:
|
||||||
|
id:
|
||||||
|
label: id
|
||||||
|
type: number
|
||||||
|
member:
|
||||||
|
label: member
|
||||||
|
type: text
|
||||||
|
relation: member
|
||||||
|
valueFrom: name
|
||||||
|
member_rank:
|
||||||
|
label: member_rank
|
||||||
|
type: text
|
||||||
|
relation: member_rank
|
||||||
|
valueFrom: name
|
||||||
|
start:
|
||||||
|
label: start
|
||||||
|
type: datetime
|
||||||
|
status:
|
||||||
|
label: status
|
||||||
|
type: text
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
columns:
|
||||||
|
id:
|
||||||
|
label: id
|
||||||
|
type: number
|
||||||
|
member:
|
||||||
|
label: member
|
||||||
|
type: text
|
||||||
|
relation: member
|
||||||
|
valueFrom: name
|
||||||
|
typerating:
|
||||||
|
label: typerating
|
||||||
|
type: text
|
||||||
|
relation: typerating
|
||||||
|
valueFrom: name
|
||||||
|
start:
|
||||||
|
label: start
|
||||||
|
type: datetime
|
||||||
|
status:
|
||||||
|
label: status
|
||||||
|
type: text
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "graphql",
|
"name": "schooling",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "Plugin.php",
|
"main": "Plugin.php",
|
||||||
"repository": "https://git.hofmannnet.myhome-server.de/GermanAirlines/GermanAirlinesVA-GraphQL.git",
|
"repository": "https://git.hofmannnet.myhome-server.de/GermanAirlines/GermanAirlinesVA-Schooling.git",
|
||||||
"author": "German Airlines VA",
|
"author": "German Airlines VA",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -11,6 +11,6 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "git config core.hooksPath .hooks",
|
"preinstall": "git config core.hooksPath .hooks",
|
||||||
"format": "prettier --write './**/*.{php,html,htm,yaml}'"
|
"format": "prettier --write './**/*.{php,html,yaml}'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-3
@@ -1,7 +1,7 @@
|
|||||||
plugin:
|
plugin:
|
||||||
name: 'germanairlinesva.schooling::lang.plugin.name'
|
name: 'germanairlinesva.schooling::lang.plugin.name'
|
||||||
description: 'germanairlinesva.schooling::lang.plugin.description'
|
description: 'germanairlinesva.schooling::lang.plugin.description'
|
||||||
author: 'German Airlines Va'
|
author: 'German Airlines VA'
|
||||||
icon: oc-icon-university
|
icon: oc-icon-university
|
||||||
homepage: ''
|
homepage: ''
|
||||||
navigation:
|
navigation:
|
||||||
@@ -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'
|
||||||
@@ -36,7 +36,15 @@ navigation:
|
|||||||
label: 'germanairlinesva.schooling::lang.menu.exam_answer_typerating'
|
label: 'germanairlinesva.schooling::lang.menu.exam_answer_typerating'
|
||||||
url: germanairlinesva/schooling/examtyperatinganswer
|
url: germanairlinesva/schooling/examtyperatinganswer
|
||||||
icon: icon-check
|
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:
|
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,6 +1,5 @@
|
|||||||
<?php namespace GermanAirlinesVa\Fleet\Updates;
|
<?php namespace GermanAirlinesVa\Schooling\Updates;
|
||||||
|
|
||||||
use Config;
|
|
||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?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')->disableForeignKeyConstraints();
|
||||||
|
Schema::connection('germanairlinesva_schooling')->dropIfExists('exams');
|
||||||
|
Schema::connection('germanairlinesva_schooling')->enableForeignKeyConstraints();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,3 +11,7 @@
|
|||||||
- 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'
|
||||||
|
- 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