| Current Path : /var/www/html/learn/backend/modules/learning/views/learning-chapter/ |
| Current File : /var/www/html/learn/backend/modules/learning/views/learning-chapter/view.php |
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\modules\learning\models\LearningChapter;
use backend\modules\learning\models\LearningQuiz;
use backend\modules\learning\models\LearningQuizAnswer;
$this->title = Yii::t('app', 'View Details Chapter');
$this->params['breadcrumbs'][] = 'Manage Interactive Learning';
$this->params['breadcrumbs'][] = 'Manage Chapter';
$this->params['breadcrumbs'][] = $this->title;
$this->registerCss('.detail-view th{width:20%;text-align:right;white-space: nowrap;}');
\yii\web\YiiAsset::register($this);
?>
<div class="wrapper wrapper-content animated fadeInRight">
<button type="button" class="btn btn-primary" onclick="window.history.go(-1); return false;">
<i class="mdi mdi-arrow-left-bold-outline"></i> Back to list
</button><br><br>
<div class="ibox float-e-margins">
<div class="ibox-content">
<?=
DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'chapter_status',
'value' => function($model) {
return \backend\modules\refdynawebv2\models\Ref::getDesc('LEARNING_STATUS', $model->chapter_status, 'descr_en');
}
],
[
'attribute' => 'chapter_type',
'value' => function($model) {
return \backend\modules\refdynawebv2\models\Ref::getDesc('CHAPTER_TYPE', $model->chapter_type, 'descr_en');
}
],
'chapter_time',
'chapter_title',
[
'attribute' => 'chapter_content',
'format' => 'raw',
'value' => function($model) {
$output = '';
//Text
if ($model->chapter_type == 'teks') {
$output = $model->chapter_content;
}
//Video
if ($model->chapter_type == 'video') {
if ($model->chapter_video_type == 'youtube')
$output = $model->chapter_video_embed;
else
$output = '<a target="_blank" href="../../../uploads/learning/' . $model->chapter_content . '">Click here to view video</a>';
}
//Powerpoint
if ($model->chapter_type == 'powerpoint') {
$output = $model->chapter_content;
}
//Pdf
if ($model->chapter_type == 'pdf') {
$output = '<a target="_blank" href="../../../uploads/learning/' . $model->chapter_content . '">Click here to view PDF</a>';
}
//Graphic
if ($model->chapter_type == 'imej') {
$output = '';
$imej_arr = json_decode($model->chapter_content, true);
if (!empty($imej_arr)) {
foreach ($imej_arr as $imej_data) {
$output .= '<div class="row" style="margin-bottom:1em;">
<div class="col-sm-2"><img src="../../../uploads/learning/' . $imej_data['image_filename'] . '" style="width:150px;border:1px solid #ccc"></div>
<div class="col-sm-10">' . $imej_data['image_description'] . '</div>
</div>';
}
}
}
//Penilaian
if ($model->chapter_type == 'kuiz') {
$output = '';
$total_question = 0;
$modelQuestion = LearningQuiz::find()->where(['chapter_id' => $model->chapter_id])->orderBy(['quiz_sort' => SORT_ASC])->all();
if (!empty($modelQuestion)) {
foreach ($modelQuestion as $rowQuestion) {
$total_question++;
$output .= "Question " . $total_question . " : <b>" . $rowQuestion->quiz_question . "</b>";
$total_answer = 0;
$modelAnswer = LearningQuizAnswer::find()->where(['quiz_id' => $rowQuestion->quiz_id])->orderBy(['answer_id' => SORT_ASC])->all();
if (!empty($modelAnswer)) {
foreach ($modelAnswer as $rowAnswer) {
$total_answer++;
$label_correct_answer = '';
if ($rowAnswer->answer_correct == 1)
$label_correct_answer = " (Correct Answer)";
$output .= "<br>Answer " . $total_answer . " : <b>" . $rowAnswer->answer . "</b>" . $label_correct_answer;
}
}
$output .= '<br><br>';
}
}
}
return $output;
}
],
[
'attribute' => 'chapter_info',
'format' => 'raw',
],
],
]);
?>
</div>
</div>
</div>