From e7483549aff8d3e74610d900baa336638647d37d Mon Sep 17 00:00:00 2001 From: RomanSteinberg <romanofficial@yandex.ru> Date: Fri, 9 Jan 2015 17:51:29 +0300 Subject: [PATCH] ADD: download exam final form in dean office --- db/StoredProcedures.sql | 17 +++-- .../classes/Controller/Handler/GetData.php | 15 ++++ .../classes/DataArr/Disciplines.php | 17 +++++ .../application/views/dean_office/index.twig | 21 +++--- .../media/js/dean_office/dean_office.js | 70 ++++++++++++++++--- 5 files changed, 111 insertions(+), 29 deletions(-) diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql index a13e4a953..16c39a0c0 100644 --- a/db/StoredProcedures.sql +++ b/db/StoredProcedures.sql @@ -4089,27 +4089,30 @@ END // -- WHERE students.StudyGroupID = StudyGroupID; -- END // - - - DROP PROCEDURE IF EXISTS GetDisciplinesForGroup// CREATE PROCEDURE `GetDisciplinesForGroup` ( IN `GroupID` INT ) NO SQL BEGIN - SELECT disciplines_groups.DisciplineID + SELECT disciplines_groups.DisciplineID As DisciplineID, + subjects.Name As SubjectName, + disciplines.ExamType As ExamType FROM `disciplines_groups` + INNER JOIN `disciplines` ON disciplines.ID = disciplines_groups.DisciplineID + INNER JOIN `subjects` ON subjects.ID = disciplines.SubjectID WHERE disciplines_groups.StudyGroupID = GroupID UNION DISTINCT - SELECT disciplines_students.DisciplineID + SELECT disciplines_students.DisciplineID As DisciplineID, + subjects.Name As SubjectName, + disciplines.ExamType As ExamType FROM `disciplines_students` INNER JOIN `students` ON disciplines_students.StudentID = students.ID + INNER JOIN `disciplines` ON disciplines.ID = disciplines_students.DisciplineID + INNER JOIN `subjects` ON subjects.ID = disciplines.SubjectID WHERE students.StudyGroupID = GroupID; - END // - DROP PROCEDURE IF EXISTS GetRatesForStudentsGroup// CREATE PROCEDURE `GetRatesForStudentsGroup` ( IN `TeacherID` INT, IN `DisciplineID` INT, diff --git a/~dev_rating/application/classes/Controller/Handler/GetData.php b/~dev_rating/application/classes/Controller/Handler/GetData.php index 8894c24d0..443e13e43 100644 --- a/~dev_rating/application/classes/Controller/Handler/GetData.php +++ b/~dev_rating/application/classes/Controller/Handler/GetData.php @@ -24,4 +24,19 @@ class Controller_Handler_GetData extends Controller_Handler $this->response->body(json_encode($data)); } + // Получить СЃРїРёСЃРѕРє РіСЂСѓРїРї РїРѕ ID РєСѓСЂСЃР° + public function action_GetDisciplinesForGroup() + { + $data['success'] = false; + $this->post -> rule('GroupID', 'not_empty') + -> rule('GroupID', 'digit'); + if($this->post->check()) { + $data['data'] = DataArray::factory('Disciplines')->forGroup( + $this->post->offsetGet('GroupID'))->asArray(); + + $data['success'] = true; + } + $this->response->body(json_encode($data)); + } + } \ No newline at end of file diff --git a/~dev_rating/application/classes/DataArr/Disciplines.php b/~dev_rating/application/classes/DataArr/Disciplines.php index d200d4171..61d8fbedd 100644 --- a/~dev_rating/application/classes/DataArr/Disciplines.php +++ b/~dev_rating/application/classes/DataArr/Disciplines.php @@ -6,6 +6,23 @@ class DataArr_Disciplines { public function __construct() { $this->model = new Model_DataArr_Disciplines; } + + public function forGroup($GroupID) { + $teacherModel = new Model_Teacher_Rating; + $Disciplines = $teacherModel->getDisciplinesForGroup($GroupID); + + $DisciplinesHandled = array(); + $i = 0; + + foreach($Disciplines as $row) { + $i++; + $DisciplinesHandled[$i]['DisciplineID'] = $row['DisciplineID']; + $DisciplinesHandled[$i]['SubjectName'] = $row['SubjectName']; + $DisciplinesHandled[$i]['ExamType'] = $row['ExamType']; + } + + return new DataArray_Result($DisciplinesHandled); + } // TODO: Методы для получения СЃРїРёСЃРєР° дисциплин } \ No newline at end of file diff --git a/~dev_rating/application/views/dean_office/index.twig b/~dev_rating/application/views/dean_office/index.twig index 0e640b162..ff6468dc3 100644 --- a/~dev_rating/application/views/dean_office/index.twig +++ b/~dev_rating/application/views/dean_office/index.twig @@ -11,17 +11,17 @@ {% block main_top_title %}Деканат > Ведомости{% endblock %} {% block main_content %} - <div style="text-align: center"> + <div data-role="page" id="dean_office" style="text-align: center"> <p><b>Шаг 1. Выберите форму аттестации</b></p> <div class="LayerSection"> <div class="itemBlock"> <div class="title">Форма контроля:</div> <div class="field"> <div class="ExamTypeDiv"> - <input id="ExamType" name="ExamType" type="radio" value="exam"> Ркзамен + <input id="ExamChoice" name="DisciplineType" type="radio" value="exam"> Ркзамен </div> <div class="ExamTypeDiv"> - <input id="ExamType" name="ExamType" type="radio" value="credit" checked> Зачет + <input id="CreditChoice" name="DisciplineType" type="radio" value="credit" checked> Зачет </div> </div> </div> @@ -55,18 +55,13 @@ <button class="default_BlueButton" id="DownloadStatement" disabled>Скачать</button> </div> - <p><b>Шаг 4. Дисциплина</b></p> - <div class="LayerSection"> + <div class="LayerSection" id="DisciplineSelect" > + <p><b>Шаг 4. Дисциплина</b></p> <div class="itemBlock"> - <div class="title">РљСѓСЂСЃ:</div> + <div class="title">Дисциплина:</div> <div class="field"> - <select class="SelectDiscipline default_select" id="SelectDiscipline"> - <option>-РќРµ выбран-</option> -{# - {% for Discipline in DisciplinesList %} - <option value="{{ Discipline.ID }}" >{{ Discipline.SubjectName }}</option> - {% endfor %} -#} + <select class="SelectDiscipline default_select" id="SelectDiscipline" disabled> + <option>-РќРµ выбрана-</option> </select> </div> </div> diff --git a/~dev_rating/media/js/dean_office/dean_office.js b/~dev_rating/media/js/dean_office/dean_office.js index 945a52aec..e8b08275a 100644 --- a/~dev_rating/media/js/dean_office/dean_office.js +++ b/~dev_rating/media/js/dean_office/dean_office.js @@ -1,14 +1,32 @@ var $ = jQuery; + +function controlVisualization() { + var disciplineType = $("input[name=DisciplineType]:checked").val(); + if (disciplineType === 'exam') { + $("#DisciplineSelect").show(); + $("#DownloadStatement").hide(); + } else if (disciplineType === 'credit') { + $("#DisciplineSelect").hide(); + $("#DownloadStatement").show(); + } +} + $(function() { + // on page loaded + controlVisualization(); + var jDownloadStatement = $("#DownloadStatement"); + var jDownloadExamDocument = $("#DownloadExamDocument"); + + $("#ExamChoice").change(controlVisualization); + $("#CreditChoice").change(controlVisualization); //Получить СЃРїРёСЃРѕРє РіСЂСѓРїРї РїРѕ ID РєСѓСЂСЃР° $("#SelectGrade").change(function() { var gradeID = parseInt($(this).val()) || 0; var jSelectGroup = $("#SelectGroup"); - if (gradeID > 0) - { + if (gradeID > 0) { $.post( g_URLdir + "handler/GetData/GetGroups", { @@ -42,19 +60,52 @@ $(function() { $("#SelectGroup").change(function() { var groupID = parseInt($(this).val()) || 0; - if (groupID > 0) - jDownloadStatement.removeAttr("disabled"); + if (groupID > 0) { + jDownloadStatement.removeAttr("disabled"); + + // Заполнить СЃРїРёСЃРѕРє дисциплин + var jSelectDiscipline = $("#SelectDiscipline"); + $.post( + g_URLdir + "handler/GetData/GetDisciplinesForGroup", + { + "GroupID": groupID + }, + function (d) { + d = $.parseJSON(d); + if (d.success === true) { + console.log(d.data); + var i = 0; + jSelectDiscipline.html("<option>-РќРµ выбрана-</option>"); + for (i in d.data) { + discipline = d.data[i]; + if (discipline.ExamType !== 'exam') + continue; + jSelectDiscipline.append("<option value='" + discipline.DisciplineID + "'>" + discipline.SubjectName + "</option>"); + } + if (i > 0) + jSelectDiscipline.removeAttr("disabled"); + } + } + ); + } else jDownloadStatement.attr("disabled", "disabled"); }); + $("#SelectDiscipline").change(function() { + var disciplineID = parseInt($(this).val()) || 0; + if (disciplineID > 0) + jDownloadExamDocument.removeAttr("disabled"); + else jDownloadExamDocument.attr("disabled", "disabled"); + }); + // Скачать ведомость $('body').on('click', '#DownloadStatement', function(){ $.fileDownload( g_URLdir + 'handler/FileCreator/GenerateFinalFormsForGroup', { httpMethod: "POST", data: { - "GroupID": parseInt($("#SelectGroup").val()), - "ExamType": $("#ExamType:checked").val() + "GroupID": parseInt($("#SelectGroup").val())//, + //"ExamType": $("input[name=DisciplineType]:checked").val() }, successCallback: function () { @@ -71,8 +122,8 @@ $(function() { httpMethod: "POST", data: { - "GroupID": parseInt($("#SelectGroup").val()), - "ExamType": $("#ExamType:checked").val() + "disciplineID": parseInt($("#SelectDiscipline").val()), + "studyGroupID": parseInt($("#SelectGroup").val()) }, successCallback: function () { @@ -87,4 +138,5 @@ $(function() { // Печать ведомости Рё блокирование дисциплины -}); \ No newline at end of file + +}); -- GitLab