コード例 #1
0
 /**
  * Finds the ExerciseSubject model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ExerciseSubject the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ExerciseSubject::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
ファイル: Exercise.php プロジェクト: mrhat24/site-for-pm
 /**
  * @get subject
  */
 public function getSubject()
 {
     return $this->hasOne(ExerciseSubject::className(), ['id' => 'subject_id']);
 }
コード例 #3
0
ファイル: control.php プロジェクト: mrhat24/site-for-pm
        <div class="btn-group">
        <?php 
echo Html::a('Создать', Url::to(['exercise/create']), ['class' => 'btn btn-primary']);
?>
     
        <?php 
echo Html::button('Управление категориями', ['value' => Url::to(['exercise-subject/index']), 'class' => 'btn btn-primary modalButton']);
?>
     
        </div>
    </p>
    <?php 
Pjax::begin(['enablePushState' => false]);
?>
    <?php 
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' => 'subject_id', 'value' => 'subject.name', 'filter' => yii\helpers\ArrayHelper::map(\common\models\ExerciseSubject::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->distinct()->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', 'data-pjax' => 0]);
}, 'delete' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['class' => 'btn btn-default', 'data-method' => 'post', 'data-confirm' => 'Вы уверены что хотите это удалить?']);
}]]]]);
?>
    <?php 
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();
コード例 #4
0
ファイル: _form_give.php プロジェクト: mrhat24/site-for-pm
    
    <?php 
echo Html::tag('br');
?>
    
    <div class="panel panel-default">
        <div class='panel-heading'>Текст задания</div>
             <div class='panel-body'  id="givepreview" ></div>
    </div>
    
    <?php 
echo Html::label('Тип упражнений');
?>
    
    <?php 
echo Select2::widget(['name' => 'exersice_type', 'id' => 'exersice_type', 'data' => ArrayHelper::map(ExerciseSubject::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выберите типы упражений ...', 'multiple' => true, 'onchange' => '
                var arr = []; 
                $("#exersice_type :selected").each(function(i, selected){ 
                  arr[i] = $(selected).val(); 
                });
                $.post( "' . Url::to(['//exercise/exersicelistbytype', 'id' => '']) . '"+arr, function( data ) {
                  $( "#exersices" ).html( data );
                });
            '], 'pluginOptions' => ['tags' => true]]);
?>
    
    <?php 
echo Html::tag('br');
?>
    
    <?php 
コード例 #5
0
ファイル: _update_form.php プロジェクト: mrhat24/site-for-pm
                $.post( "' . Url::to(['//exercise/exersicelistbytype', 'id' => '']) . '"+arr, function( data ) {
                  $( "#exersices" ).html( data );
                });
            '], 'pluginOptions' => ['tags' => true]]);
?>
    
    <?php 
echo Html::tag('br');
?>
    
    <?php 
echo Html::label('Упражнения');
?>
    
    <?php 
echo Select2::widget(['name' => 'exersices', 'id' => 'exersices', 'value' => ArrayHelper::getColumn($model->exercises, 'exercise.id'), 'data' => ArrayHelper::map(Exercise::find()->where(['subject_id' => ArrayHelper::getColumn(ExerciseSubject::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->all(), 'id')])->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select a color ...', 'multiple' => true, 'onchange' => '
                var arr = []; 
                $("#exersices :selected").each(function(i, selected){ 
                  arr[i] = $(selected).val(); 
                });               
                $.post( "' . Url::to(['//task/exersicespreview', 'list' => '']) . '"+arr, function( data ) {
                  $( "#exersicespreview" ).html( data );
                });
            '], 'pluginOptions' => ['tags' => true]]);
?>
    
    
    <?php 
echo Html::tag('br');
?>
    
コード例 #6
0
ファイル: _form.php プロジェクト: mrhat24/site-for-pm
/* @var $model common\models\Exercise */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="exercise-form">

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

    <?php 
//= $form->field($model, 'teacher_id')->textInput()
?>
    
    <?php 
echo $form->field($model, 'subject_id')->dropDownList(ArrayHelper::map(ExerciseSubject::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->all(), 'id', 'name'));
?>
    
    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        
    
    <?php 
echo $form->field($model, 'text')->widget(MarkdownEditor::className(), MdEditorHelp::getMdParamsWithMath());
?>
  
    
    <?php 
echo $form->field($model, 'test')->checkbox();
?>