add output of the percentage of correct answers
This commit is contained in:
@ -19,6 +19,7 @@ class UserQuestionnaireSearch extends UserQuestionnaire
|
||||
return [
|
||||
[['id', 'questionnaire_id', 'user_id', 'score', 'status'], 'integer'],
|
||||
[['uuid', 'created_at', 'updated_at'], 'safe'],
|
||||
[['percent_correct_answers'], 'number'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -65,6 +66,7 @@ class UserQuestionnaireSearch extends UserQuestionnaire
|
||||
'updated_at' => $this->updated_at,
|
||||
'score' => $this->score,
|
||||
'status' => $this->status,
|
||||
'percent_correct_answers' => $this->percent_correct_answers,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'uuid', $this->uuid]);
|
||||
|
@ -31,6 +31,8 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?php // echo $form->field($model, 'status') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'percent_correct_answers') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
|
@ -39,6 +39,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
// 'UUID',
|
||||
'score',
|
||||
[
|
||||
'attribute' => 'percent_correct_answers',
|
||||
'value' => function($model) {
|
||||
$percent = $model->percent_correct_answers * 100;
|
||||
return $percent . '%';
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
|
@ -20,6 +20,8 @@ YiiAsset::register($this);
|
||||
?>
|
||||
<div class="user-questionnaire-view">
|
||||
|
||||
<!-- --><?php //var_dump($model->setPercentCorrectAnswers(4)); die();?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
@ -46,10 +48,17 @@ YiiAsset::register($this);
|
||||
],
|
||||
'uuid',
|
||||
'score',
|
||||
[
|
||||
'attribute' => 'percent_correct_answers',
|
||||
'value' => function($model) {
|
||||
$percent = $model->percent_correct_answers * 100;
|
||||
return $percent . '%';
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
'value' => function($model) {
|
||||
return Html::tag(
|
||||
'span',
|
||||
$model->status ? 'Active' : 'Not Active',
|
||||
|
Reference in New Issue
Block a user