diff --git a/~dev_rating/application/classes/Controller/Teacher/Rating.php b/~dev_rating/application/classes/Controller/Teacher/Rating.php index 514d80cbf01dd89c10472c22b1c0c023172cbc46..dea08e8edd8902165e030c2abafe429efa5245f7 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Rating.php +++ b/~dev_rating/application/classes/Controller/Teacher/Rating.php @@ -3,48 +3,65 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { public function before() { - Cookie::set('fD', 'true'); // Без РєСѓРєРё файл качаться РЅРµ будет, типа защита + Cookie::set('fD', 'true'); // Ставим РєСѓРє fD, чтоб иметь возможность скачать отчет TODO + + $this->model_rating = new Model_Teacher_Rating; + $this->model_discipline = new Model_Teacher_Map; + parent::before(); } - - // Получить РёР· РєСѓРєР° SGID выбранную ранее РіСЂСѓРїРїСѓ - private function GetSGID($id) + + // Получить РёР· РєСѓРєР° SGID выбранную ранее РіСЂСѓРїРїСѓ для данной дисциплины + private function getStudyGroupID_ForFilter($id) { # $id = disciplineID - $SG_ar = json_decode(Cookie::get('SGID', null), true); - if ($SG_ar !== null) + $SG_array = json_decode(Cookie::get('SGID', null), true); + if ($SG_array !== null) { - if (array_key_exists($id, $SG_ar)) - return $SG_ar[$id]; + if (array_key_exists($id, $SG_array)) + return $SG_array[$id]; } return 0; } + // Настройки дисциплины Рё выбранная РіСЂСѓРїРїР°(для фильтра) + private function getDisciplineInformation($id) { + + $temp = $this->model_discipline->getDisciplineInfoByID($id); + $disciplineInfo['ExamType'] = $temp[0]['ExamType']; + $disciplineInfo['ID'] = $id; + $disciplineInfo['StudyGroupID_Filter'] = $this->getStudyGroupID_ForFilter($id); + + return $disciplineInfo; + } + + + // Страница оценивания РІ течение семестра public function action_edit() { $twig = Twig::factory('teacher/rating'); $twig->User = $this->UserInfo; $id = $this->request->param('id'); - $db = new Model_Teacher_Rating; - + // Шапка таблицы: структура РЈРљР” (модули Рё мероприятия) - $structure = $db->GetMapForDiscipline($this->UserInfo['TeacherID'], $id); + $structure = $this->model_rating->GetMapForDiscipline($this->UserInfo['TeacherID'], $id); if($structure->count() == 0) throw HTTP_Exception::factory (404, "Для дисциплины СЃ ID $id РЅРµ создана РЈРљР” или такой дисциплины РЅРµ существует!"); $structureHandled = array(); - $maxRate = 0; $i = 0; $module = 0; + $maxRate = 0; $i = 0; $temp_moduleID = 0; foreach($structure as $row) { - if($row['ModuleID'] != $module) + if($row['ModuleID'] != $temp_moduleID) { - $i++; - $module = $row['ModuleID']; + $i++; // todo + $temp_moduleID = $row['ModuleID']; } if ($i == 1) - $twig->SubjectName = $row['SubjectName']; + $twig->SubjectName = $row['SubjectName']; + if(!isset($structureHandled[$i]['SubmodulesCount'])) { $structureHandled[$i]['SubmodulesCount'] = 0; @@ -70,14 +87,11 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { } $structureHandled['ModulesCount'] = $i; $structureHandled['MaxRate'] = (int) $maxRate; - - $twig->headerRate = $structureHandled; - //echo debug::vars($structureHandled); // end Шапка таблицы // Студенты Рё РёС… баллы - $students = $db->GetStudentsForRating($this->UserInfo['TeacherID'], $id); + $students = $this->model_rating->GetStudentsForRating($this->UserInfo['TeacherID'], $id); $rateHandled = array(); $groupsHandled = array(); @@ -85,7 +99,8 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { foreach($students as $row) { // Группа - if ($curGroup !== $row['GroupID']) { + if ($curGroup !== $row['GroupID']) + { $curGroup = $row['GroupID']; $i_g++; $rateHandled[$i_g]['GroupID'] = $row['GroupID']; @@ -104,7 +119,37 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $groupsHandled[$curGroup] = $rateHandled[$i_g]['GradeTitle']." ".$row['GroupNum']." РіСЂСѓРїРїР°"; } + // Студенты + $curStudent = array(); + $i_s++; + $curStudent['ID'] = $row['ID']; + $curStudent['Last'] = $row['Last']; + $curStudent['First'] = $row['First']; + $curStudent['Second'] = $row['Second']; + $curStudent['isAttached'] = $row['isAttached']; // #1 + + // Баллы студента + $rates = $this->model_rating->getMapForStudent($row['ID'], $id); + $i_r = 0; + $curStudent['RateResult'] = 0; + foreach($rates as $r) { + $i_r++; + $curStudent['Rates'][$i_r]['Rate'] = $r['Rate']; + $curStudent['RateResult'] += $r['Rate']; + + if ($r['ModuleType'] == 'exam') + $curStudent['Rates'][$i_r]['SubmoduleID'] = -1; + else if ($r['ModuleType'] == 'extra') + $curStudent['Rates'][$i_r]['SubmoduleID'] = -2; + else + $curStudent['Rates'][$i_r]['SubmoduleID'] = $r['SubmoduleID']; + + $curStudent['Rates'][$i_r]['Type'] = $r['ModuleType']; + } + $rateHandled[$i_g]['Students'][$i_s] = $curStudent; + + /* $i_s++; $rateHandled[$i_g]['Students'][$i_s]['ID'] = $row['ID']; $rateHandled[$i_g]['Students'][$i_s]['Last'] = $row['Last']; @@ -113,7 +158,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $rateHandled[$i_g]['Students'][$i_s]['isAttached'] = $row['isAttached']; // #1 // Баллы студента - $rate = $db->getMapForStudent($row['ID'], $id); + $rate = $this->model_rating->getMapForStudent($row['ID'], $id); $i_r = 0; $rateHandled[$i_g]['Students'][$i_s]['RateResult'] = 0; foreach($rate as $r) { @@ -128,53 +173,49 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { else $rateHandled[$i_g]['Students'][$i_s]['Rates'][$i_r]['SubmoduleID'] = $r['SubmoduleID']; } + */ } + // РќР° вывод + $twig->headerRate = $structureHandled; $twig->rateTable = $rateHandled; $twig->groups = $groupsHandled; - $twig->studyGroupID = $this->GetSGID($id); - - $twig->DisciplineID = $id; + $twig->disciplineInfo = $this->getDisciplineInformation($id); + $twig->disciplineInfo_JSON = json_encode($twig->disciplineInfo); $this->response->body($twig); } + // Страница оценивания РІ сессию public function action_exam() { $twig = Twig::factory('teacher/exam'); $twig->User = $this->UserInfo; $id = $this->request->param('id'); - $db = new Model_Teacher_Rating; - - // Узнаем ExamType TODO - $dbMap = new Model_Teacher_Map; - $disc_temp = $dbMap->getDisciplineInfoByID($id); - $disciplineInfo['ExamType'] = $disc_temp[0]['ExamType']; - $disciplineInfo['ID'] = $id; - // END TODO // Шапка таблицы: структура РЈРљР” (модули Рё мероприятия) - $structure = $db->GetMapForDisciplineExam($this->UserInfo['TeacherID'], $id); + $structure = $this->model_rating->GetMapForDisciplineExam($this->UserInfo['TeacherID'], $id); if($structure->count() == 0) throw HTTP_Exception::factory (404, "Страница РЅРµ найдена"); $structureHandled = array(); - $maxRate = 0; $i = 0; $module = 0; $try_1 = 0; // try = 1 - экзамен, = 2, 3 - пересдачи + $maxRate = 0; $i = 0; $temp_moduleID = 0; $try_1 = 0; // try = 1 - экзамен, = 2, 3 - пересдачи $examRate = 0; $try = 0; foreach($structure as $row) { - if($row['ModuleID'] != $module) + if($row['ModuleID'] != $temp_moduleID) { - ++$i; - $module = $row['ModuleID']; + ++$i; // todo + $temp_moduleID = $row['ModuleID']; } if ($i == 1) - $twig->SubjectName = $row['SubjectName']; + $twig->SubjectName = $row['SubjectName']; + if(!isset($structureHandled[$i]['SubmodulesCount'])) { $structureHandled[$i]['SubmodulesCount'] = 0; @@ -206,12 +247,10 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { } $structureHandled['ModulesCount'] = $i; $structureHandled['MaxRate'] = (int) $maxRate; - - $twig->headerRate = $structureHandled; // end Шапка таблицы // Студенты Рё РёС… баллы РїРѕ экзамену - $students = $db->GetStudentsForRating($this->UserInfo['TeacherID'], $id); + $students = $this->model_rating->GetStudentsForRating($this->UserInfo['TeacherID'], $id); $rateHandled = array(); $groupsHandled = array(); @@ -241,9 +280,8 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $groupsHandled[$curGroupID] = $rateHandled[$i_g]['GradeTitle']." ".$row['GroupNum']." РіСЂСѓРїРїР°"; $i_s = 0; } - // Студенты - - + + // Студенты $curStudent = array(); $curStudent['ID'] = $row['ID']; $curStudent['Last'] = $row['Last']; @@ -256,7 +294,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $i_r = 0; $examRate = 0; $extraNum = 0; - $rate = $db->getMapForStudentExam($row['ID'], $id); + $rate = $this->model_rating->getMapForStudentExam($row['ID'], $id); $lastExam = -1; $lastExtra = -1; @@ -304,7 +342,7 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $curStudent['RateResult'] += $examRate; - $total = $db->GetStudentRate($row['ID'], $id); + $total = $this->model_rating->GetStudentRate($row['ID'], $id); $total = $total[0]['Num']; if (is_null($total)) $total = 0; @@ -334,14 +372,13 @@ class Controller_Teacher_Rating extends Controller_UserEnvi { $i_s++; } - //echo Debug::vars($structureHandled); - //echo Debug::vars($rateHandled); + // РќР° вывод + $twig->headerRate = $structureHandled; $twig->rateTable = $rateHandled; $twig->groups = $groupsHandled; - $twig->studyGroupID = $this->GetSGID($id); - - $twig->disciplineInfo = $disciplineInfo; + $twig->disciplineInfo = $this->getDisciplineInformation($id); + $twig->disciplineInfo_JSON = json_encode($twig->disciplineInfo); $this->response->body($twig); } diff --git a/~dev_rating/application/views/teacher/exam.twig b/~dev_rating/application/views/teacher/exam.twig index c8b6c50780ae427d74530cc6af9b0933112d2133..096ffba4714dcd19ad69fb5f62fe117d6eb663fb 100644 --- a/~dev_rating/application/views/teacher/exam.twig +++ b/~dev_rating/application/views/teacher/exam.twig @@ -126,6 +126,6 @@ </div> </div> <div id="hidden_div"> - { "studyGroupID": "{{ studyGroupID }}" } + {{ disciplineInfo_JSON|raw }} </div> {% endblock %} \ No newline at end of file diff --git a/~dev_rating/application/views/teacher/rating.twig b/~dev_rating/application/views/teacher/rating.twig index 6c63dfc15c823200904ed248c52f6954679f892c..d2298cd4f8a06f3a0c055b1a97e03d76295abb14 100644 --- a/~dev_rating/application/views/teacher/rating.twig +++ b/~dev_rating/application/views/teacher/rating.twig @@ -15,7 +15,8 @@ <h2 class="h2_titleSubject">{{ SubjectName }}</h2> <button class="downloadExcel" style="display: none">Скачать РІ excel формате [dev version]</button> - {{ HTML.anchor('exam/'~DisciplineID, + + {{ HTML.anchor('exam/'~disciplineInfo.ID, "Перейти Рє сессии в†’", {'title': 'Сессия', 'class': 'exam_a'})|raw }} @@ -97,7 +98,7 @@ </td> {% else %} {% set j = j - 1 %} - <td class="staticCell"> + <td class="staticCell{% if student.Rates[i].Type == 'exam' %} examCell{% endif %}"> <p>{{ student.Rates[i].Rate }}</p> </td> {% endif %} @@ -116,6 +117,6 @@ </div> </div> <div id="hidden_div"> - { "studyGroupID": "{{ studyGroupID }}" } + {{ disciplineInfo_JSON|raw }} </div> {% endblock %} \ No newline at end of file diff --git a/~dev_rating/media/js/rating.js b/~dev_rating/media/js/rating.js index 7cfac75c8140ba3f0eaf92359c44feb7309c97d1..c85ab1fdeb94fdf6f558329544ae9ece6d372eaa 100644 --- a/~dev_rating/media/js/rating.js +++ b/~dev_rating/media/js/rating.js @@ -2,7 +2,7 @@ var $ = jQuery; $(function() { var g_col; var g_row; - var g_isFocusCell = false; // Стоит фокус или нет + var g_isFocusCell = false; // Стоит фокус РЅР° ячейки или нет var g_oldRateCell = null; var g_submoduleID = null; var g_studentID = null; @@ -15,11 +15,14 @@ $(function() { var g_URL = (window.location.href).split("/"); var g_disciplineID = g_URL[g_URL.length - 1]; - // studyGroupID для фильтра (Рффект памяти) + // Настройки дисциплины: + // + ID - id дисциплины + // + studyGroupID_Filter - studyGroupID для фильтра (Рффект памяти) var json_settings = $.parseJSON($("#hidden_div").html()); + console.log(json_settings); $("#hidden_div").remove(); - filterGroups(json_settings.studyGroupID); - $(".groupSelector [value='"+ json_settings.studyGroupID +"']").attr("selected", "selected"); + filterGroups(json_settings.StudyGroupID_Filter); + $(".groupSelector [value='"+ json_settings.StudyGroupID_Filter +"']").attr("selected", "selected"); // Скрываем РІСЃРµ остальные РіСЂСѓРїРїС‹ // 0 - показать РІСЃРµ @@ -142,7 +145,7 @@ $(function() { var rateResult = parseInt(jThis.siblings(".rateResultCell").text()) - oldRate + newRate; - // exams + // страница сессии if (jThis.attr("class").indexOf("attemptCell") >= 0) { //if (jThis.siblings(".semesterRateResultCell ").length > 0) { @@ -154,7 +157,7 @@ $(function() { }); //} } - //end exams + //end страница сессии if (rateResult > 100) { jThis.children("input").val(oldRate); @@ -163,6 +166,14 @@ $(function() { } else { + if ((json_settings.ExamType == "exam") && (rateResult - parseInt(jThis.siblings(".examCell").text())) > 60) + { + jThis.children("input").val(oldRate); + EventInspector_ShowMsg("РЎСѓРјРјР° баллов РЅРµ может привышать 60 (С‚.Рє. 40 РЅР° экзамен)", "error"); + jThis.children("input").removeAttr("disabled"); + return -1; + } + if (newRate <= g_submoduleMaxRate) { $.ajax({