protected function getIdFaculty($id, $parent = false)
 {
     if ($parent) {
         $model = Discipline::findOne($id);
         return $model->idProgram->id_faculty;
     } else {
         $model = DisciplineSemester::findOne($id);
         return $model->idDiscipline->idProgram->id_faculty;
     }
 }
Beispiel #2
0
<?php

use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\Pjax;
use common\models\Program;
use common\models\Discipline;
/* @var $this yii\web\View */
/* @var $provider yii\data\ActiveDataProvider */
/* @var $program Program */
/* @var $discipline Discipline */
/* @var $idParent integer */
require Yii::$app->basePath . '/views/grid/index.php';
$discipline = Discipline::findOne($idParent);
$program = Program::findOne($discipline->id_program);
$this->title = 'Семестры';
$this->params['breadcrumbs'][] = ['label' => 'Образовательные программы', 'url' => ['/program', 'idParent' => $program->id_faculty]];
$this->params['breadcrumbs'][] = ['label' => 'Дисциплины', 'url' => ['/discipline', 'idParent' => $discipline->id_program, 'page' => Yii::$app->session->get('disciplinePage')]];
$this->params['breadcrumbs'][] = $this->title;
?>
<h2>Семестры</h2>
<h3>
    Дисциплина: <?php 
echo $discipline->fullName;
?>
</h3>

<p>
    <?php 
echo Html::a('Новый семестр', ['create', 'idParent' => $idParent], ['class' => 'btn btn-success actionCreate']);
?>
 /**
  * Finds the Discipline model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Discipline the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Discipline::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
 /**
  * @inheritdoc
  * Удаляем связанную дисциплину, если не осталось для нее записи с именем
  */
 public function afterDelete()
 {
     if (!static::find()->where(['id_discipline' => $this->id_discipline_cached])->exists()) {
         Discipline::findOne($this->id_discipline_cached)->delete();
     }
 }
Beispiel #5
0
echo $student->studentName;
?>
 Курс: <?php 
echo $student->course;
?>
</h3>

<?php 
Pjax::begin(['options' => ['id' => 'pjaxWrap']]);
?>



<?php 
echo GridView::widget(['dataProvider' => $provider, 'columns' => [['attribute' => 'code', 'format' => 'text', 'header' => 'Дисциплина', 'value' => function ($model, $key, $index, $column) {
    $discipline = Discipline::findOne($model['id_discipline']);
    return $discipline->fullName;
}], ['attribute' => 'semester', 'header' => 'Семестр'], ['attribute' => 'assesment', 'header' => 'Оценка'], ['attribute' => 'rating', 'header' => 'Рейтинг'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{delete}{file}', 'buttons' => ['update' => 'actionUpdate', 'delete' => 'actionDelete', 'file' => 'actionFile']]]]);
?>

<?php 
Pjax::end();
?>

    <!-- functions for grid buttons actions -->
<?php 
function actionUpdate($url, $model, $key)
{
    $url = Url::to(['update', 'id_student' => $model['id_student'], 'id_semester' => $model['id_semester'], 'id_result' => $model['id_result']]);
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['class' => 'actionUpdate', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'title' => 'Редактировать']);
}
Beispiel #6
0
?>

    <h2>Результаты</h2>
    <h3>
        Студент: <?php 
echo $student->studentName;
?>
 Курс: <?php 
echo $student->course;
?>
    </h3>


<?php 
echo GridView::widget(['dataProvider' => $provider, 'columns' => [['attribute' => 'code', 'format' => 'raw', 'header' => 'Дисциплина', 'value' => function ($model, $key, $index, $column) {
    $disciplineName = Discipline::findOne($model['id_discipline'])->fullName;
    if ($model['id_result']) {
        return Html::a($disciplineName, ['result/view-student', 'id' => $model['id_result']]);
    } else {
        return $disciplineName;
    }
}], ['attribute' => 'semester', 'header' => 'Семестр'], ['attribute' => 'assesment', 'header' => 'Оценка'], ['attribute' => 'rating', 'header' => 'Рейтинг', 'value' => function ($model, $key, $index, $column) {
    if ($model['id_result']) {
        $rating = $model['rating'] ?: '';
        $max_rating = $model['max_rating'] ?: '';
        if ($rating || $max_rating) {
            return "{$rating} / {$max_rating}";
        } else {
            return '';
        }
    }