Skip to content
Snippets Groups Projects
Commit 3618a2d5 authored by Роман Штейнберг's avatar Роман Штейнберг
Browse files

FIX: recordbooks switcher on discipline details page

parent aeffdee5
Branches
No related merge requests found
var getSemester;
let getSemester;
$(function () {
let $semesters = $('.semesterSwitcher').first(),
......
......@@ -208,10 +208,10 @@ Route::set('student:index', 'student(/index)')
]);
# discipline view
Route::set('student:subject', 'subject/<id>', ['id' => '[0-9]+'])
Route::set('student:discipline', 'student/discipline/<id>', ['id' => '[0-9]+'])
->defaults([
'directory' => 'Student',
'controller' => 'Subject',
'controller' => 'Discipline',
'action' => 'show'
]);
......
......@@ -9,11 +9,20 @@ class Controller_Environment_Student extends Controller_Environment_User
* @var string
* Path to students twig folder
*/
const STUDENT = 'student/';
const TWIG_FOLDER = 'student/';
/** @var Model_Student */
protected $studentInfo;
public function before() {
parent::before();
$this->user->checkAccess(User::RIGHTS_STUDENT);
$this->studentInfo = Model_Student::load($this->user->StudentID);
$recordBooks = $this->studentInfo->RecordBooks;
if ( ! $this->user->RecordBookID) {
$this->user->RecordBookID = array_values($recordBooks)[0]['ID'];
}
$this->twig->set_global(['RecordBookList' => $recordBooks]);
}
}
\ No newline at end of file
......@@ -90,7 +90,8 @@ class Controller_Handler_Settings extends Controller_Handler
public function action_setRecordBookID() {
$this->post->rule('id', 'not_empty')->rule('id', 'digit');
if ($this->post->check())
if ($this->post->check()) {
$this->user->RecordBookID = (int) $_POST['id'];
}
}
}
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Student_Subject extends Controller_Environment_Student
class Controller_Student_Discipline extends Controller_Environment_Student
{
public function action_show() {
$id = $this->request->param('id');
......@@ -16,7 +16,7 @@ class Controller_Student_Subject extends Controller_Environment_Student
'Submodules' => $map['Submodules'],
'ExtraRate' => $map['ExtraRate'],
'Semester' => Model_Semesters::load($discipline->SemesterID),
])->set_filename(static::STUDENT . 'subject');
])->set_filename(static::TWIG_FOLDER . 'subject');
}
private static function &getTeachersListOf(Model_Discipline $discipline) {
......
......@@ -3,8 +3,7 @@
class Controller_Student_Index extends Controller_Environment_Student
{
public function action_index() {
$student = Model_Student::load($this->user->StudentID);
$disciplines = $student->getDisciplines();
$disciplines = $this->studentInfo->getDisciplines();
$marks = [];
foreach ($disciplines as $dis) {
......@@ -16,24 +15,17 @@ class Controller_Student_Index extends Controller_Environment_Student
}
}
$teachers = $student->getTeachers();
$teachers = $this->studentInfo->getTeachers();
foreach ($teachers as $disID => &$list) {
$list = Controller_Teacher_Index::getShortListOfTeachers($list);
}
//TODO: move
$recordBooks = $student->RecordBooks;
if ( ! $this->user->RecordBookID) {
$this->user->RecordBookID = array_values($recordBooks)[0]['ID'];
}
$recordBooks = $this->studentInfo->RecordBooks;
$this->twig->set([
'Marks' => $marks,
'Disciplines' => $disciplines,
'Teachers' => $teachers,
'SemesterList' => Model_Semesters::loadAll(),
'RecordBookList' => $recordBooks,
])->set_filename(static::STUDENT . 'index');
])->set_filename(static::TWIG_FOLDER . 'index');
}
public function action_settings() {
......
<?php
/**
* @property $StudentID int
* @property $GradeID int
* @property $GradeNum int
* @property $GroupID int
* @property $GroupNum int
* @property $GroupName string
* @property $Degree int
* @property $SpecID int
* @property $SpecName string
* @property $SpecAbbr string
* @property $StudentID int
* @property $GradeID int
* @property $GradeNum int
* @property $GroupID int
* @property $GroupNum int
* @property $GroupName string
* @property $Degree int
* @property $SpecID int
* @property $SpecName string
* @property $SpecAbbr string
* @property $RecordBookID int
*/
class Model_User_Student extends User
{
......
......@@ -27,7 +27,6 @@
* @property-read $UserHash string
* @property-read $PasswordHash string
* @property-read $start_time int
* @property $RecordBookID int
*/
class User implements ArrayAccess
{
......
......@@ -125,7 +125,7 @@
{{ HTML.image('static/img/messageIcon.png', {'height': '11px'})|raw }} (1)
</div>
include 'messages/messages' #}
{% if User.RecordBookID %}
{% if User.Type == 'student' %}
<div class="recordBookLayer">
{{ base.RecordBookSwitcher(RecordBookList) }}
</div>
......
......@@ -17,7 +17,7 @@
</td>
<td class="discTitle">
{{ HTML.anchor('subject/' ~ Discipline.ID, Discipline.SubjectName)|raw }}
{{ HTML.anchor('student/discipline/' ~ Discipline.ID, Discipline.SubjectName)|raw }}
</td>
<td class="discTeachers">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment