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;
     }
 }
 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;
     }
 }
 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;
     }
 }
 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]);
 }
 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;
 }
 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]);
 }
 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;
 }
 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;
     }
 }
Exemple #9
0
 public static function newExamList($id_student, $id_semester)
 {
     $currentStudent = StudentEducation::findOne($id_student);
     $studentResults = StudentResult::find()->innerJoinWith(['idStudentEducation' => function ($query) use($currentStudent) {
         $query->where(['year' => $currentStudent->year, 'group' => $currentStudent->group]);
     }])->where(['id_discipline_semester' => $id_semester])->select('id_student');
     $students = StudentEducation::find()->joinWith(['idStudent' => function ($query) {
         $query->orderBy('name');
     }])->where(['year' => $currentStudent->year, 'id_program' => $currentStudent->id_program, 'course' => $currentStudent->course, 'group' => $currentStudent->group])->andWhere(['not in', 'id_student', $studentResults])->all();
     $results = [];
     foreach ($students as $student) {
         $result = new StudentResult();
         $result->id_student_education = $student->id;
         $result->id_discipline_semester = $id_semester;
         $results[] = $result;
     }
     return $results;
 }
Exemple #10
0
 /**
  * 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;
 }
Exemple #11
0
 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;
             }
         }
     }
 }
Exemple #12
0
<?php

use common\models\Program;
use common\models\StudentEducation;
use common\models\StudentResult;
/* @var $this yii\web\View */
/* @var $provider yii\data\ActiveDataProvider */
/* @var $program Program */
/* @var $idParent integer */
/* @var $student StudentEducation */
/* @var $result StudentResult */
$result = StudentResult::findOne($idParent);
$student = StudentEducation::findOne($result->id_student_education);
$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'][] = ['label' => 'Результаты', 'url' => ['/student/result/index', 'id' => $student->id_student]];
$this->params['breadcrumbs'][] = $this->title;
?>
<h2>Файлы</h2>
<h3>
    Студент: <?php 
echo $student->studentName;
?>
    Дисциплина: <?php 
echo $result->idDisciplineSemester->idDiscipline->fullName;
?>
</h3>

<?php 
Exemple #13
0
<?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']);
Exemple #14
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdStudentEducation()
 {
     return $this->hasOne(StudentEducation::className(), ['id' => 'id_student_education']);
 }
Exemple #15
0
 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;
     }
 }
Exemple #16
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStudentEducations()
 {
     return $this->hasMany(StudentEducation::className(), ['id_program' => 'id']);
 }
Exemple #17
0
<?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 
Exemple #18
0
 protected function getIdFaculty($id, $parent = false)
 {
     if ($parent) {
         $model = Program::findOne($id);
         return $model->id_faculty;
     } else {
         $model = StudentEducation::findOne($id);
         return $model->idProgram->id_faculty;
     }
 }