Newer
Older
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Teacher_Discipline_Rating extends Controller_Environment_Teacher
// make it possible to download files
Cookie::set('fD', 'true');
Антон Шалимов
committed
// Получить из кука SGID выбранную ранее группу для данной дисциплины
private function getFilterGroupID($disciplineID) {
$groups = json_decode(Cookie::get('SGID', null), true);
if ($groups && isset($groups[$disciplineID])) {
return $groups[$disciplineID];
private static function getTitle($pageType, $try, &$module) {
if ($pageType == 'rate') {
$title = $module['SubmoduleName'];
} else if ($module['ModuleType'] == 'extra') {
$title = 'Добор баллов';
} else if ($try === 0) {
$title = 'Основная сдача';
} else {
$title = 'Пересдача ' . $try;
}
return $title;
}
// Шапка таблицы: структура УКД (модули и мероприятия)
private function getStructure($id, $pageType) {
$structure = Model_Map::getRoadmap($id, $pageType);
if ($structure->count() == 0) {
throw HTTP_Exception::factory(404, "Страница не найдена");
$maxRate = $i = $try = 0; // try = 1 - экзамен, = 2, 3 - пересдачи
$lastModuleID = -1;
if ($row['ModuleID'] != $lastModuleID) {
$lastModuleID = $row['ModuleID'];
$structureHandled[++$i] = [
'SubmodulesCount' => 0,
'MaxRate' => 0,
'ModuleTitle' => $row['ModuleName'],
'ModuleType' => $row['ModuleType'],
$j = $structureHandled[$i]['SubmodulesCount'] += 1;
$structureHandled[$i]['MaxRate'] += (int) $row['MaxRate'];
$curSubmodule['MaxRate'] = (int) $curSubmodule['MaxRate'];
$curSubmodule['Title'] = self::getTitle($pageType, $try, $row);
if ($pageType == 'rate' || $row['ModuleType'] == 'extra') {
$structureHandled['MaxRate'] = (int) $maxRate;
return $structureHandled;
}
private function processGroupInfo(&$groupInfo) {
//GroupID, GroupNum, GradeNum, isAttached etc.
$out = $groupInfo;
//Формирование заголовка курса
$gradeNum = $groupInfo['GradeNum'];
$out['GradeTitle'] = ($groupInfo['Degree'] == 'master')
? 'Магистратура, ' . $gradeNum . ' год'
: $gradeNum . ' курс';
$out['GroupTitle'] = $out['GradeTitle'] . " " . $groupInfo['GroupNum'] . " группа";
private function getRatesForRatingPage($info, &$rateResult) {
$submoduleID =
($moduleType == 'exam') ? -1 :
(($moduleType == 'extra') ? -2
: $row['SubmoduleID']);
Антон Шалимов
committed
$rates[] = [
'Type' => $moduleType,
'SubmoduleID' => $submoduleID,
private function correctExtra(&$curStudent, $examType, $lastExtraIndex, $firstEmptyExtraIndex, $totalExtraRate) {
if ($curStudent['RateSemesterResult'] >= $bottomLimit &&
$curStudent['RateSemesterResult'] < $topLimit
) // студент задолженик
$maxExtraRate = $topLimit - $curStudent['RateSemesterResult'];
if ($lastExtraIndex >= 0) {
$curStudent['Rates'][$lastExtraIndex]['MaxRate'] = $maxExtraRate - $totalExtraRate
+ $curStudent['Rates'][$lastExtraIndex]['Rate'];
if ($firstEmptyExtraIndex >= 0) {
$curStudent['Rates'][$firstEmptyExtraIndex]['MaxRate'] = $maxExtraRate - $totalExtraRate;
}
private function getRatesForExamPage(&$curStudent, $rateList, $examType, $disciplineID) {
$rowIndex = 0;
$lastExam = $lastExtraIndex = $lastNilExam = $firstEmptyExtra = -1;
$rateExtra = 0;
Антон Шалимов
committed
if ($moduleType == 'exam' || $moduleType == 'extra') {
$curStudent['Rates'][$rowIndex] = [
'SubmoduleID' => $curRate['SubmoduleID'],
'Rate' => $curRate['Rate'],
'ExamPeriodOption' => $curRate['ExamPeriodOption'],
];
Антон Шалимов
committed
}
$lastExam = $rowIndex;
if ($lastNilExam < 0) {
$lastNilExam = $rowIndex;
} else {
$curStudent['Rates'][$lastExtraIndex]['Blocked'] = true;
}
$lastExtraIndex = $rowIndex;
$curStudent['Rate'] += $curRate['Rate'];
$rateExtra += $curRate['Rate'];
if ($firstEmptyExtra < 0) {
$firstEmptyExtra = $rowIndex;
} else {
break;
default:
throw HTTP_Exception::factory(500, "Некорректный тип модуля!");
}
// $total = Model_Rating->GetStudentRate($curStudent['ID'], $disciplineID);
// $total = ($total[0])?$total[0]['Num']:0;
// if ($total)
// $total = 0;
$curStudent['RateResult'] = $curStudent['RateSemesterResult'] + $rateExtra;
if ($lastExam >= 0) {
$curStudent['RateResult'] += $curStudent['Rates'][$lastExam]['Rate'];
}
$this->correctExtra($curStudent, $examType, $lastExtraIndex, $firstEmptyExtra, $rateExtra);
public function action_history() {
$id = $this->request->param('id');
])->set_filename('teacher/history');
}
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
public function action_exam() {
$id = $this->request->param('id');
$discipline = Model_Discipline::load($id);
$discipline['GroupID_Filter'] = $this->getFilterGroupID($id);
$discipline['LocalizedExamType'] = RusLang::tr($discipline->Type);
// Студенты и их баллы
$students = Model_Rating::GetStudentsForRating($id);
$rateHandled = [];
$groupsHandled = [];
$groupInd = $studentInd = $curGroupID = 0;
foreach ($students as $row) {
if ($curGroupID !== $row['GroupID']) {
$curGroupID = $row['GroupID'];
$studentInd = 0;
$group = &$rateHandled[++$groupInd];
$group = $this->processGroupInfo($row);
$groupsHandled[$curGroupID] = $group['GroupTitle'];
}
// Студенты
$group['Students'][$studentInd] = $row;
$curStudent = &$group['Students'][$studentInd++]; //ID, Name, isAttached
// Баллы студента
$rate = Model_Rating::getExamRates($id, $row['ID']);
$this->getRatesForExamPage($curStudent, $rate, $discipline->Type, $id);
}
// Шапка таблицы: структура УКД (модули и мероприятия)
$this->twig->set([
'groups' => $groupsHandled,
'rateTable' => $rateHandled,
'headerRate' => $this->getStructure($id, 'exam'),
'Discipline' => $discipline,
'Discipline_JSON' => json_encode($discipline),
])->set_filename('teacher/discipline/rating/exam');
$discipline['GroupID_Filter'] = $this->getFilterGroupID($id);
$discipline['LocalizedExamType'] = RusLang::tr($discipline->Type);
$rateHandled = [];
$groupsHandled = [];
$groupInd = $studentInd = $curGroupID = 0;
foreach ($students as $row) {
if ($curGroupID !== $row['GroupID']) {
$curGroupID = $row['GroupID'];
$studentInd = 0;
$group = &$rateHandled[++$groupInd];
$group = $this->processGroupInfo($row);
$groupsHandled[$curGroupID] = $group['GroupTitle'];
$group['Students'][$studentInd] = $row;
$curStudent = &$group['Students'][$studentInd++]; //ID, Name, isAttached
$ratesRaw = Model_Rating::getRates($id, $row['ID']);
$curStudent['Rates'] = $this->getRatesForRatingPage($ratesRaw, $curStudent['RateResult']);
'groups' => $groupsHandled,
'rateTable' => $rateHandled,
'headerRate' => $this->getStructure($id, 'rate'),
'Discipline' => $discipline,
'Discipline_JSON' => json_encode($discipline),
])->set_filename('teacher/discipline/rating/rate');