An error occurred while loading the file. Please try again.
-
xamgore authored
+ new API methods + some code refactoring
792e1bbb
Forked from
it-lab / grade
Source project has a limited visibility.
Index.php 1.81 KiB
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Student_Index extends Controller_UserEnvironment {
public function action_index() {
$student_id = $this->user['StudentID'];
$disciplines = Model_Student::with($student_id)->getDisciplines();
foreach ($disciplines as $dis) {
switch ($dis->subtype) {
case 'disciplinary_coursework':
$dis['teachers'] = ['Курсовая']; break;
case 'scientific_coursework':
$dis['teachers'] = ['Науч. рук.']; break;
default:
$dis['teachers'] = self::getTeachersForDiscipline($dis->ID);
}
$dis['control'] = DataHelper::LocalizeExamType($dis->type);
# fixme: ExamRate is not defined in the `GetDisciplinesForStudent` function!
$dis['colorScheme'] = Model_Subjects::getECTSMark($dis['rate'], $dis['maxCurrentRate'], NULL /*$dis['examRate']*/);
}
$twig = Twig::factory('student/index');
$twig->disciplines = $disciplines;
$twig->User = $this->user;
$twig->Semester = $this->SemesterInfo;
$twig->SemesterList = Model_Semesters::toArray();
$this->response->body($twig);
}
/**
* @param $id int discipline id
* @return array list of short-form names
*/
private static function getTeachersForDiscipline($id) {
$teachers = Model_Discipline::load($id)->getTeachers();
$list = array();
foreach ($teachers as $teacher)
$list[] = DataHelper::AbbreviateName($teacher);
return $list;
}
public function action_settings() {
$twig = Twig::factory('settings');
$twig->User = $this->user;
$this->response->body($twig);
}
}