Esempio n. 1
0
 /**
  * Finds the Skill model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Skill the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Skill::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
                <p>
                    <?php 
$skill_id = Yii::$app->request->get('skill_id');
if ($skill_id) {
    echo Html::a('Tạo quiz', ['create', 'skill_id' => $skill_id], ['class' => 'btn btn-success']);
} else {
    echo Html::a('Tạo quiz', ['create'], ['class' => 'btn btn-success']);
}
?>
                </p>
            </div>
        </header>
        <div class="body">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', ['attribute' => 'skill_id', 'content' => function ($data) {
    $skillName = Skill::findOne($data->skill_id)->title;
    return $skillName ? $skillName : '<span style="color:red">Không tìm danh mục</span>';
}, 'format' => 'raw'], ['attribute' => 'question', 'content' => function ($data) {
    return Html::a($data->question, ['view', 'id' => $data->id]);
}], 'answer', ['attribute' => 'difficulty', 'content' => function ($data) {
    switch ($data->difficulty) {
        case '0':
            return '<span class="btn-success label">Dễ</span>';
            break;
        case '1':
            return '<span class="btn-warning label">Trung bình</span>';
            break;
        default:
            return '<span class="btn-danger label">Khó</span>';
            break;
    }
Esempio n. 3
0
?>
</h4>
            <div class="toolbar">
                <p>
                    <?php 
echo Html::a('Cập nhật', ['update', 'id' => $model->id, 'skill_id' => $model->skill_id], ['class' => 'btn btn-primary']);
?>
                    <?php 
echo Html::a('Xóa', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Bạn có chắc muốn xóa Quiz này?', 'method' => 'post']]);
?>
                </p>
            </div>
        </header>
        <div class="body">
            <?php 
$skillName = Skill::findOne($model->skill_id)->title;
if ($created_by = AdminUser::findOne($model->created_by)) {
    $created_by = $created_by->fullname != '' ? $created_by->fullname : $created_by->username;
}
if ($updated_by = AdminUser::findOne($model->updated_by)) {
    $updated_by = $updated_by->fullname != '' ? $updated_by->fullname : $updated_by->username;
}
switch ($model->difficulty) {
    case '0':
        $difficulty = '<span class="btn-success label">Dễ</span>';
        break;
    case '1':
        $difficulty = '<span class="btn-warning label">Trung bình</span>';
        break;
    default:
        $difficulty = '<span class="btn-danger label">Khó</span>';
Esempio n. 4
0
{
    return strcmp($a->parents, $b->parents);
}
usort($skills, "cmp");
$data = Recursive::sortArrayDropDown($skills);
?>

<div class="row-fluid">

    <?php 
$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal']]);
?>

    <?php 
$skill_id = Yii::$app->request->get('skill_id');
if ($skill_id && Skill::findOne($skill_id)) {
    echo $form->field($model, 'skill_id')->hiddenInput(['value' => $skill_id])->label(false);
} else {
    echo $form->field($model, 'skill_id', ['template' => '{label}<div class="controls">{input}{error}{hint}</div>'])->dropdownList($data, ['prompt' => '-- Chọn kỹ năng --', 'class' => 'span6']);
}
?>

    <?php 
echo $form->field($model, 'question', ['template' => '{label}<div class="controls">{input}{error}{hint}</div>'])->textarea(['class' => 'span6']);
?>

    <?php 
echo $form->field($model, 'answer', ['template' => '{label}<div class="controls">{input}{error}{hint}</div>'])->dropdownList(['A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D'], ['class' => 'span6', 'prompt' => '-- Chọn đáp án --']);
?>

    <?php 
Esempio n. 5
0
echo Html::encode($this->title);
?>
</h4>
            <div class="toolbar">
                <p>
                    <?php 
echo Html::a('Tạo kỹ năng', ['create'], ['class' => 'btn btn-success']);
?>
                </p>
            </div>
        </header>
        <div class="body">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', ['attribute' => 'title', 'content' => function ($data) {
    return Html::a($data->title, ['view', 'id' => $data->id]);
}], ['attribute' => 'cat_id', 'content' => function ($data) {
    $categoryName = Category::findOne($data->cat_id)->title;
    return $categoryName ? $categoryName : '<span style="color:red">Không tìm danh mục</span>';
}], ['attribute' => 'Số câu quiz', 'content' => function ($data) {
    $quizs = Quiz::findAll(['skill_id' => $data->id]);
    return '<a href="' . Url::toRoute(['quiz/index', 'skill_id' => $data->id]) . '">' . count($quizs) . '</a>';
}, 'format' => 'raw'], ['attribute' => 'state', 'content' => function ($data) {
    return Skill::findOne($data['id'])->state == 1 ? '<span class="label-success label label-default">Kích hoạt</span>' : '<span class="label-default label">Không kích hoạt</span>';
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete}', 'header' => 'Thao tác', 'buttons' => ['delete' => function ($url, $model) {
    return '<a class="btn btn-danger" aria-label="Delete" data-confirm="Bạn có chắc muốn xóa danh mục này?" data-method="post" data-pjax="0" href="' . $url . '"><i class="icon icon-trash icon-white"></i></a>';
}]]]]);
?>
        </div>
    </div>
</div>