From a31d645f77128869deb9cc5513ccc9f9cab5e9cb Mon Sep 17 00:00:00 2001 From: PavelBegunkov <asml.Silence@gmail.com> Date: Tue, 16 Dec 2014 19:21:56 +0300 Subject: [PATCH] exam --- .../classes/Controller/Teacher/Rating.php | 43 ++++++++++++------- .../application/views/teacher/exam.twig | 2 +- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php index b7353d03f..d44a918e9 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -148,17 +148,18 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $structureHandled = array(); - $maxRate = 0; $i = 1; $module = 0; $try_1 = 0; // try = 1 - экзамен, = 2, 3 - пересдачи + $maxRate = 0; $i = 0; $module = 0; $try_1 = 0; // try = 1 - экзамен, = 2, 3 - пересдачи + $examRate = 0; foreach($structure as $row) { - //if($row['ModuleID'] != $module) - //{ - // $i = 1; - // $module = $row['ModuleID']; - //} - //if ($i == 1) - // $twig->SubjectName = $row['SubjectName']; + if($row['ModuleID'] != $module) + { + ++$i; + $module = $row['ModuleID']; + } + if ($i == 1) + $twig->SubjectName = $row['SubjectName']; if(!isset($structureHandled[$i]['SubmodulesCount'])) { $structureHandled[$i]['SubmodulesCount'] = 0; @@ -172,17 +173,18 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $twig->examSubmoduleID = $row['SubmoduleID']; $structureHandled[$i][$j]['SubmoduleID'] = $row['SubmoduleID']; - if ($row['ModuleType'] == 'extra') + if ($row['ModuleType'] == 'extra') { $structureHandled[$i][$j]['Title'] = 'Добор баллов'; + $maxRate += $row['MaxRate']; + } else { $try++; - if ($try > 1) - $structureHandled[$i][$j]['Title'] = 'Пересдача '.($try - 1); - else $structureHandled[$i][$j]['Title'] = 'Ркзамен'; + $examRate = $row['MaxRate']; + $structureHandled[$i][$j]['Title'] = 'Пересдача '.$try; } //$structureHandled[$i][$j]['Description'] = $row['SubmoduleDescription']; // Описание $structureHandled[$i][$j]['MaxRate'] = (int) $row['MaxRate']; - $maxRate += $row['MaxRate']; + } $structureHandled['ModulesCount'] = $i; $structureHandled['MaxRate'] = (int) $maxRate; @@ -198,7 +200,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $i_g = 0; $i_s = 0; $curGroup = 0; foreach($students as $row) { - // Группа + // Группа if ($curGroup !== $row['GroupID']) { $curGroup = $row['GroupID']; $i_g++; @@ -230,12 +232,21 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $rate = $db->getMapForStudentExam($row['ID'], $id); $i_r = 0; $rateHandled[$i_g]['Students'][$i_s]['RateResult'] = 0; + $examRate = 0; + foreach($rate as $r) { $i_r++; + if ($r['ModuleType'] == 'exam') { + if (!is_null($r['Rate'])) + $examRate = $r['Rate']; + } else { + $rateHandled[$i_g]['Students'][$i_s]['RateResult'] += $r['Rate']; + } + $rateHandled[$i_g]['Students'][$i_s]['Rates'][$i_r]['SubmoduleID'] = $r['SubmoduleID']; - $rateHandled[$i_g]['Students'][$i_s]['Rates'][$i_r]['Rate'] = $r['Rate']; - $rateHandled[$i_g]['Students'][$i_s]['RateResult'] += $r['Rate']; + $rateHandled[$i_g]['Students'][$i_s]['Rates'][$i_r]['Rate'] = $r['Rate']; } + $rateHandled[$i_g]['Students'][$i_s]['RateResult'] += $examRate; } diff --git a/~dev_rating/application/views/teacher/exam.twig b/~dev_rating/application/views/teacher/exam.twig index e44e61f05..3937974c1 100644 --- a/~dev_rating/application/views/teacher/exam.twig +++ b/~dev_rating/application/views/teacher/exam.twig @@ -26,7 +26,7 @@ <tr class="RatingTableModulesHead"> <td class="title" width="150px">Модуль</td> {% for i in 1..headerRate.ModulesCount %} - <td class="subject {% if headerRate[i].ModuleType == 'bonus' %} bonus{% endif %}" colspan="{{headerRate[i].SubmodulesCount}}"> + <td class="subject" colspan="{{headerRate[i].SubmodulesCount}}" {% if headerRate[i].ModuleType != 'exam' %} rowspan="2" {% endif %}> {{ headerRate[i].ModuleTitle }} </td> {% endfor %} -- GitLab