Beispiel #1
0
 public static function typeList()
 {
     $taskTypes = TaskType::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->all();
     $taskTypeList = array();
     foreach ($taskTypes as $type) {
         $taskTypeList[$type->id] = $type->name;
     }
     return $taskTypeList;
 }
Beispiel #2
0
 /**
  * @get task type
  */
 public function getTaskType()
 {
     return $this->hasOne(TaskType::className(), ['id' => 'type_id']);
 }
Beispiel #3
0
/* @var $model common\models\Task */
/* @var $form yii\widgets\ActiveForm */
$this->registerJs("var mathFieldSpan = document.getElementById('math-field');\n    var latexSpan = document.getElementById('latex');\n    var MQ = MathQuill.getInterface(2); // for backcompat\n    var mathField = MQ.MathField(mathFieldSpan, {\n      spaceBehavesLikeTab: true, // configurable\n      handlers: {\n        edit: function() { // useful event handlers\n          latexSpan.textContent = mathField.latex(); // simple API\n        }\n      }\n    });");
?>

<div class="task-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput();
?>
    <?php 
echo $form->field($model, 'type_id')->dropDownList(TaskType::typeList());
?>
    <?php 
echo $form->field($model, 'text')->widget(MarkdownEditor::className(), ['smarty' => true, 'showExport' => 0, 'footerMessage' => '<p>Введите формулу в формате latex: <span id="math-field"></span></p>
    <p>Результат: <span id="formula"><span id="latex"></span></span></p><p>При копировании в текст заключайте формулу в двойные знаки доллара $$<span>формула</span>$$</p>
    <p><a href="https://ru.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F:%D0%A4%D0%BE%D1%80%D0%BC%D1%83%D0%BB%D1%8B" target="_blank">Примеры формул на Wikipedia</a></p>']);
?>
  
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
 /**
  * Finds the TaskType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TaskType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TaskType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #5
0
          'tags' => true,
          'maximumInputLength' => 10
      ],
  ]); */
?>
    
    <?php 
echo Html::tag('br');
?>
    
    <?php 
echo Html::label('Тип задания');
?>
    
    <?php 
echo Select2::widget(['name' => 'task_type', 'id' => 'task_type', 'data' => ArrayHelper::map(TaskType::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выберите тип заданий ...', 'onchange' => '                  
                $.post( "' . Url::to(['//task/listbytype', 'id' => '']) . '"+$(this).val(), function( data ) {
                  $( "select#task" ).html( data );
                }); '], 'pluginOptions' => ['tags' => true]]);
?>

    
    <?php 
echo Html::tag('br');
?>
    
    <?php 
echo Html::label('Задание');
?>
    
    <?php 
Beispiel #6
0
    
    <?php 
$form = ActiveForm::begin(['options' => ['data-pjax' => true]]);
?>
  

    <?php 
echo Html::tag('br');
?>
    
    <?php 
echo Html::label('Тип задания');
?>
    
    <?php 
echo Select2::widget(['name' => 'task_type', 'id' => 'task_type', 'value' => $model->task->taskType->id, 'data' => ArrayHelper::map(TaskType::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выберите тип заданий ...', 'onchange' => '                  
                $.post( "' . Url::to(['//task/listbytype', 'id' => '']) . '"+$(this).val(), function( data ) {
                  $( "select#task" ).html( data );
                }); '], 'pluginOptions' => ['tags' => true]]);
?>
    
    <?php 
echo Html::tag('br');
?>
    
    <?php 
echo Html::label('Задание');
?>
    
    <?php 
echo Select2::widget(['name' => 'task', 'id' => 'task', 'value' => $model->task->id, 'data' => ArrayHelper::map(Task::find()->where(['type_id' => $model->task->taskType->id])->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выберите задание ...', 'onchange' => '
Beispiel #7
0
    <p>
        <div class="btn-group">
         <?php 
echo Html::a('Создать', Url::to(['task/create']), ['class' => 'btn btn-primary']);
?>
     
        <?php 
echo Html::button('Управление типами', ['value' => Url::to(['task-type/index']), 'class' => 'btn btn-primary modalButton']);
?>
    
        </div>
    </p>    
        
        <?php 
Pjax::begin(['enablePushState' => false]);
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "\n{items}\n{pager}\n{summary}", 'options' => ['class' => 'table table-responsive'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'type_id', 'value' => 'taskType.name', 'label' => 'Тип', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\TaskType::find()->all(), 'name', 'name')], ['class' => 'yii\\grid\\ActionColumn', 'template' => '<div class="btn-group">{view} {update} {delete}</div>', 'buttons' => ['view' => function ($url, $model) {
    return Html::button('<span class="glyphicon glyphicon-eye-open"></span>', ['value' => $url, 'class' => 'btn btn-default modalButton']);
}, 'update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon glyphicon-pencil"></span>', $url, ['class' => 'btn btn-default']);
}, 'delete' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['class' => 'btn btn-default', 'data-method' => 'post', 'data-confirm' => 'Вы уверены что хотите это удалить?']);
}]]]]);
Pjax::end();
?>
  
 <?php 
Modal::begin(['id' => 'modal', 'size' => 'modal-lg', 'clientOptions' => ['modal' => true, 'autoOpen' => false]]);
echo "<div id='modalContent' style='overflow:hidden;'></div>";
Modal::end();
?>
</div>