コード例 #1
0
 public function execute($user, $item, $params)
 {
     if (Yii::$app->user->isGuest) {
         return false;
     }
     $role = Yii::$app->user->identity->role;
     if ($role == User::ROLE_ADMIN) {
         return true;
     } elseif (!isset($params['id_program'])) {
         return false;
     } elseif ($role == User::ROLE_STUDENT) {
         $model = StudentEducation::find()->where(['id_student' => Yii::$app->user->identity->id_student, 'year' => YearHelper::getYear()])->one();
         if (!$model) {
             return false;
         } else {
             return $params['id_program'] == $model->id_program;
         }
     } elseif ($role == User::ROLE_LOCAL_ADMIN || $role == User::ROLE_INSPECTOR) {
         $model = Program::findOne($params['id_program']);
         if (!$model) {
             return false;
         } else {
             return Yii::$app->user->identity->id_faculty == $model->id_faculty;
         }
     } else {
         return false;
     }
 }
コード例 #2
0
 protected function getIdFaculty($id, $parent = false)
 {
     if ($parent) {
         $model = StudentEducation::find()->where(['id_student' => $id, 'year' => YearHelper::getYear()])->one();
         return $model->idProgram->id_faculty;
     } else {
         $model = StudentEducation::findOne($id);
         return $model->idProgram->id_faculty;
     }
 }
コード例 #3
0
 public function actionIndex($id)
 {
     // $id - in Student
     /* @var $student StudentEducation */
     $student = StudentEducation::find()->where(['id_student' => $id, 'year' => YearHelper::getYear()])->one();
     if (!$student) {
         $this->redirect($this->goHome());
     }
     $provider = new ActiveDataProvider(['query' => ResultHelper::StudentResults($student->id), 'pagination' => false]);
     return $this->render('index', ['provider' => $provider, 'student' => $student]);
 }
コード例 #4
0
 public function checkFaculty($rule, $action)
 {
     /* @var $model StudentEducation */
     $id_student = Yii::$app->request->get('id');
     $model = StudentEducation::find()->where(['id_student' => $id_student, 'year' => YearHelper::getYear()])->one();
     if ($model) {
         return Yii::$app->user->can('viewFaculty', ['id_faculty' => $model->idProgram->id_faculty]);
     } else {
         return false;
     }
 }
コード例 #5
0
 public function actionIndex($id)
 {
     // $id - Student
     /* @var $student StudentEducation */
     $student = StudentEducation::find()->where(['id_student' => $id, 'year' => YearHelper::getYear()])->one();
     if (!$student) {
         $this->redirect($this->goHome());
     }
     $provider = new ActiveDataProvider(['query' => ResultHelper::StudentResults($student->id), 'pagination' => ['pageSize' => 10, 'pageSizeParam' => false]]);
     Yii::$app->session->set('studentResultPage', Yii::$app->request->get('page'));
     return $this->render('student', ['provider' => $provider, 'student' => $student]);
 }
コード例 #6
0
ファイル: UserController.php プロジェクト: vastander/yii2-eer
 protected function getIdFaculty($id, $parent = false)
 {
     $year = YearHelper::getYear();
     if ($parent) {
         $id_student = $id;
     } else {
         $model = User::findOne($id);
         $id_student = $model->id_student;
     }
     $student = StudentEducation::find()->where(['year' => $year, 'id_student' => $id_student])->one();
     return $student->idProgram->id_faculty;
 }
コード例 #7
0
 private function checkAccess($id_student)
 {
     if (Yii::$app->user->can('updateStudent', ['id_student' => $id_student])) {
         return true;
     } else {
         /* @var $student StudentEducation */
         $student = StudentEducation::find()->where(['id_student' => $id_student, 'year' => YearHelper::getYear()])->one();
         if (Yii::$app->user->can('updateFaculty', ['id_faculty' => $student->idProgram->id_faculty])) {
             return true;
         }
     }
     return false;
 }
コード例 #8
0
ファイル: ResultHelper.php プロジェクト: vastander/yii2-eer
 public static function DisciplineResults($id, $id_discipline_name)
 {
     // $id - DisciplineSemester
     $discipline_studied = new Query();
     $discipline_studied->select(['discipline.*', 'discipline_semester.course', 'discipline_semester.semester', 'discipline_semester.id as id_semester'])->from('discipline')->innerJoin('discipline_semester', 'discipline_semester.id_discipline = discipline.id')->where(['discipline_semester.id' => $id]);
     $studentCurrent = new Query();
     $studentCurrent->select(['student_education.*', 'student.name', 'discipline.id_semester'])->from('student_education')->innerJoin('student', 'student_education.id_student = student.id')->innerJoin(['discipline' => $discipline_studied], 'discipline.id_program = student_education.id_program and
             student_education.course = discipline.course')->where(['student_education.year' => YearHelper::getYear()]);
     $result = new Query();
     $result->select(['student_result.*', 'discipline_semester.max_rating'])->from('student_result')->innerJoin('student_education', 'student_education.id = student_result.id_student_education')->innerJoin('discipline_semester', 'discipline_semester.id = student_result.id_discipline_semester')->where(['discipline_semester.id' => $id, 'student_result.id_discipline_name' => $id_discipline_name]);
     $query = new Query();
     $query->select(['student.name', 'student.id as id_student', 'student.id_semester', 'result.assesment', 'result.rating', 'result.max_rating', 'result.id as id_result'])->from(['student' => $studentCurrent])->leftJoin(['result' => $result], 'student.id = result.id_student_education')->orderBy('student.name');
     return $query;
 }
コード例 #9
0
 private function allowed()
 {
     if (Yii::$app->user->can('viewFaculty', ['id_faculty' => $this->model->id_faculty])) {
         return true;
     } elseif (Yii::$app->user->can('updateStudent')) {
         $student = StudentEducation::find()->where(['id_student' => Yii::$app->user->identity->id_student, 'year' => YearHelper::getYear()])->one();
         if (!$student) {
             return false;
         } else {
             return $student->id_program == $this->model->id;
         }
     } else {
         return false;
     }
 }
コード例 #10
0
ファイル: StudentSearch.php プロジェクト: vastander/yii2-eer
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($id_program, $id_student, $params)
 {
     $query = StudentEducation::find()->where(['id_program' => $id_program, 'year' => YearHelper::getYear()]);
     $query->andFilterWhere(['id_student' => $id_student]);
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10, 'pageSizeParam' => false]]);
     $provider->setSort(['attributes' => ['studentName' => ['asc' => ['student.name' => SORT_ASC], 'desc' => ['student.name' => SORT_DESC], 'label' => 'StudentName'], 'course', 'group'], 'defaultOrder' => ['course' => SORT_DESC, 'studentName' => SORT_ASC]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['idStudent']);
         return $provider;
     }
     $query->andFilterWhere(['course' => $this->course]);
     $query->andFilterWhere(['like', 'group', $this->group]);
     $query->joinWith(['idStudent' => function ($q) {
         /* @var $q \yii\db\ActiveQuery */
         $q->andWhere('student.name LIKE "%' . $this->studentName . '%" ');
     }]);
     return $provider;
 }
コード例 #11
0
ファイル: MainController.php プロジェクト: vastander/yii2-eer
 public function checkProgram($rule, $action)
 {
     $id_program = Yii::$app->request->get('id_program');
     $id_faculty = Program::findOne($id_program)->id_faculty;
     if (Yii::$app->user->can('viewFaculty', ['id_faculty' => $id_faculty])) {
         return true;
     } else {
         $id_student = Yii::$app->user->identity->id_student;
         if (!$id_student) {
             return false;
         } else {
             $student = StudentEducation::find()->where(['id_student' => $id_student, 'year' => YearHelper::getYear()])->one();
             if (!$student) {
                 return false;
             } else {
                 return $student->id_program == $id_program;
             }
         }
     }
 }
コード例 #12
0
ファイル: delete.php プロジェクト: vastander/yii2-eer
<?php

use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\StudentEducation */
?>
<p>
    Удалить запись о студенте <?php 
echo $model->studentName;
?>
 в <?php 
echo \common\helpers\YearHelper::getEducationYear();
?>
 учебном году?
</p>

<?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-primary', 'id' => 'deleteButton']);
?>

<?php 
require Yii::$app->basePath . '/views/grid/delete.php';
コード例 #13
0
ファイル: DownloadAction.php プロジェクト: vastander/yii2-eer
 private function checkPortfolioAccess($model)
 {
     $id_student = $model->id_student;
     if (!Yii::$app->user->can('updateStudent', ['id_student' => $id_student])) {
         $student = StudentEducation::find()->where(['id_student' => $id_student, 'year' => YearHelper::getYear()])->one();
         if ($student) {
             return Yii::$app->user->can('viewFaculty', ['id_faculty' => $student->idProgram->id_faculty]);
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
コード例 #14
0
ファイル: main.php プロジェクト: vastander/yii2-eer
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
    <?php 
$this->beginBody();
?>
    <div class="wrap">
        <?php 
NavBar::begin(['brandLabel' => 'Администрирование', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$menuItems = [YearHelper::getDropDownArray('Учебный год')];
if (!Yii::$app->user->isGuest) {
    $menuItems = array_merge($menuItems, [['label' => ' Управление пользователями', 'url' => ['/user/main/index', 'idParent' => Yii::$app->user->identity->id_faculty]], ['label' => Yii::$app->user->identity->username . ' - Выход', 'url' => ['/site/logout']]]);
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>

        <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo Alert::widget();
?>
        <?php 
コード例 #15
0
ファイル: index.php プロジェクト: vastander/yii2-eer
<?php

use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\Pjax;
use common\models\Program;
use common\models\StudentEducation;
use common\helpers\YearHelper;
/* @var $this yii\web\View */
/* @var $provider yii\data\ActiveDataProvider */
/* @var $program Program */
/* @var $idParent integer */
/* @var $student StudentEducation */
require Yii::$app->basePath . '/views/grid/index.php';
$student = StudentEducation::findOne(['id_student' => $idParent, 'year' => YearHelper::getYear()]);
$program = Program::findOne($student->id_program);
$this->title = 'История';
$this->params['breadcrumbs'][] = ['label' => 'Образовательные программы', 'url' => ['/program', 'idParent' => $program->id_faculty]];
$this->params['breadcrumbs'][] = ['label' => 'Студенты', 'url' => ['/student', 'idParent' => $student->id_program, 'page' => Yii::$app->session->get('studentPage')]];
$this->params['breadcrumbs'][] = $this->title;
?>
<h2>История</h2>
<h3>
    Студент: <?php 
echo "{$student->studentName}";
?>
</h3>

<p>
    <?php 
echo Html::a('Новый учебный год', ['create', 'idParent' => $idParent], ['class' => 'btn btn-success actionCreate']);
コード例 #16
0
ファイル: index.php プロジェクト: vastander/yii2-eer
<?php

/* @var $this yii\web\View */
/* @var $id integer */
/* @var $beginNodeId integer */
use kartik\tree\TreeView;
use common\models\StudentPortfolio;
use kartik\tree\Module;
use common\models\StudentEducation;
use common\helpers\YearHelper;
use common\models\User;
$this->registerCss("#idPortfolio-detail h3 { display: none }");
/* @var $student StudentEducation */
$student = StudentEducation::find()->where(['id_student' => $id, 'year' => YearHelper::getYear()])->one();
$this->title = 'Портфолио';
if (Yii::$app->user->identity->role != User::ROLE_STUDENT) {
    $this->params['breadcrumbs'][] = ['label' => 'Образовательные программы', 'url' => ['/program', 'idParent' => $student->idProgram->id_faculty]];
    $this->params['breadcrumbs'][] = ['label' => 'Студенты', 'url' => ['main/index', 'idParent' => $student->id_program, 'page' => Yii::$app->session->get('studentPage')]];
}
$this->params['breadcrumbs'][] = $this->title;
?>

<h2>Портфолио</h2>
<h3>
    Студент: <?php 
echo $student->studentName;
?>
 Курс: <?php 
echo $student->course;
?>
 Программа: <?php 
コード例 #17
0
ファイル: main.php プロジェクト: vastander/yii2-eer
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
    <?php 
$this->beginBody();
?>
    <div class="wrap">

        <?php 
NavBar::begin(['brandLabel' => '<span class="brand_text">Результаты освоения образовательных программ</span>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['id' => 'mainMenu', 'class' => 'navbar-fixed-top']]);
$menuItems = [YearHelper::getDropDownArray()];
if (Yii::$app->user->isGuest) {
    $msg = ['label' => 'Войти', 'url' => ['/site/login'], 'class' => 'navbar-link'];
} else {
    $msg = ['label' => Yii::$app->user->identity->username . ' Выход', 'url' => ['/site/logout'], 'class' => 'navbar-link'];
}
$menuItems[] = $msg;
echo Nav::widget(['options' => ['id' => 'mainNav', 'class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>
		
		<div class="jumbotron">
			<div class="container">
				<?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
コード例 #18
0
ファイル: MainController.php プロジェクト: vastander/yii2-eer
 /**
  * Рендер формы задать номер группы
  */
 public function actionGroup($idParent)
 {
     // $idParent - id программы
     $year = YearHelper::getYear();
     $courses = StudentEducation::find()->where(['id_program' => $idParent, 'year' => $year])->select(['course'])->groupBy(['course'])->orderBy('course')->all();
     if (count($courses) == 0) {
         $this->redirect(['index', 'idParent' => $idParent]);
     }
     $course = Yii::$app->request->post('course');
     $course = $course == null ? $courses[0]->course : $course;
     $courses = ArrayHelper::map($courses, 'course', 'course');
     $students = StudentEducation::find()->innerJoinWith(['idStudent' => function ($query) {
         $query->orderBy('name');
     }])->where(['id_program' => $idParent, 'year' => $year, 'course' => $course])->all();
     $students = ArrayHelper::map($students, 'id', 'studentName');
     return $this->render('group', ['idParent' => $idParent, 'courses' => $courses, 'course' => $course, 'students' => $students]);
 }
コード例 #19
0
ファイル: delete.php プロジェクト: vastander/yii2-eer
<?php

use yii\helpers\Html;
use common\helpers\YearHelper;
/* @var $this yii\web\View */
/* @var $model common\models\StudentEducation */
if ($model->year == YearHelper::getYear()) {
    ?>

<p>
    Для удаления записи о текущем годе обучения перейдите в список студентов
</p>

<?php 
} else {
    ?>

<p>
    Удалить запись о годе обучения <?php 
    echo $model->year;
    ?>
 студента <?php 
    echo $model->studentName;
    ?>
?
</p>

<?php 
    echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-primary', 'id' => 'deleteButton']);
    ?>
コード例 #20
0
ファイル: YearAction.php プロジェクト: vastander/yii2-eer
 private function newYear($year)
 {
     YearHelper::setYear($year);
     $this->controller->redirect(Yii::$app->request->referrer);
 }