diff --git a/db/postgresql/alter_study_groups_formid_17.11.18.sql b/db/postgresql/alter_study_groups_formid_17.11.18.sql new file mode 100644 index 0000000000000000000000000000000000000000..4ff272f4e32799daec615f6be00eb86ebe5e322e --- /dev/null +++ b/db/postgresql/alter_study_groups_formid_17.11.18.sql @@ -0,0 +1,222 @@ +update study_groups set formid=1; + +ALTER TABLE public.study_groups ALTER COLUMN formid SET NOT NULL; +ALTER TABLE public.study_groups ALTER COLUMN formid SET DEFAULT 1; + +ALTER TABLE public.study_groups DROP CONSTRAINT study_groups_facultyid_gradeid_groupnum_key; +ALTER TABLE ONLY public.study_groups + ADD CONSTRAINT study_groups_facultyid_gradeid_groupnum_formid_key UNIQUE (facultyid, gradeid, groupnum, formid); + +INSERT INTO public.study_form(id, formname) VALUES + (1, 'очная'), + (2, 'очно-заочная'), + (3, 'заочная'); + +ALTER TABLE ONLY public.study_groups + ADD CONSTRAINT study_groups_ibfk_4 FOREIGN KEY (formid) REFERENCES study_form(id); + +DROP FUNCTION IF EXISTS public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer); +CREATE OR REPLACE FUNCTION public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer, pformid integer) + RETURNS integer +LANGUAGE plpgsql +AS $function$ +DECLARE vGroupID INT DEFAULT null; + vSpecId INT DEFAULT null; + vGroupYear INT DEFAULT null; + vIsSpecMatch BOOL DEFAULT null; + +BEGIN + --select public.creategroup( + -- :pgradeid, -- put the pgradeid parameter value instead of 'pgradeid' (int4) + -- :pgroupnum, -- put the pgroupnum parameter value instead of 'pgroupnum' (int4) + -- :pspecname, -- put the pspecname parameter value instead of 'pspecname' (varchar) + -- :pfacultyid, -- put the pfacultyid parameter value instead of 'pfacultyid' (int4) + -- :pyear -- put the pyear parameter value instead of 'pyear' (int4) + --); + -- create specialization vSpecId - UNIQUE (pSpecName,pFacultyID) + select specializations.id into vSpecId + from specializations + where specializations.facultyid=pFacultyID and specializations."name" like pSpecName; + if (vSpecId is null) then + INSERT INTO specializations (Name, Abbr, FacultyID) + VALUES (pSpecName, NULL, pFacultyID) + returning id into vSpecId; + end if; + + + -- create group vGroupID - UNIQUE (pGradeID, pGroupNum, pFacultyID) + select study_groups.id into vGroupID + from study_groups + where study_groups.gradeid=pgradeID + and study_groups.groupnum= pGroupNum + and study_groups.facultyid=pFacultyID + and study_groups.formid=pFormID; + if ( vGroupID is null) then + INSERT INTO study_groups (GradeID, GroupNum, FacultyID, FormID) + VALUES (pGradeID, pGroupNum, pFacultyID, pFormID) + returning id into vGroupID ; + end if; + + + SELECT groups_years.groupid, groups_years.specializationid = vSpecId + INTO vGroupYear, vIsSpecMatch + FROM groups_years + WHERE groups_years.groupid = vGroupID AND groups_years."year" = pYear + LIMIT 1; + + IF (vGroupYear is null) THEN + INSERT INTO groups_years (GroupID, Year, SpecializationID) + VALUES (vGroupID, pYear, vSpecId); + ELSEIF NOT vIsSpecMatch THEN + RETURN -1; + END IF; + + RETURN vGroupID; + EXCEPTION + when others then + RETURN -1; +END +$function$; + +DROP FUNCTION IF EXISTS public.getgroupsfordisciplineall(pdisciplineid integer); +CREATE OR REPLACE FUNCTION public.getgroupsfordisciplineall(pdisciplineid integer) + RETURNS TABLE("ID" integer, "GroupNum" integer, "GradeID" integer, "GradeNum" integer, "Degree" bachelor_master_specialist, "SpecID" integer, "SpecName" character varying, "SpecAbbr" character varying, "FormID" character varying) +LANGUAGE plpgsql +AS $function$ + +DECLARE vSemesterID INT DEFAULT -1; vYear INT DEFAULT -1; +BEGIN + vSemesterID := GetDisciplineProperty(pDisciplineID, 'semester'); + SELECT "year" into vYear from semesters where semesters.ID = vSemesterID; + + -- general + attached + CREATE TEMPORARY TABLE IF NOT EXISTS tGroup AS ( + SELECT students_groups.GroupID + FROM view_disciplines_recordbooks + INNER JOIN students_groups ON students_groups.RecordBookID = view_disciplines_recordbooks.RecordBookID AND + students_groups.SemesterID = vSemesterID AND + students_groups.State <= 'outlet' + WHERE view_disciplines_recordbooks.DisciplineID = pDisciplineID AND + 'attach' = COALESCE(view_disciplines_recordbooks.Type, 'attach') + GROUP BY students_groups.GroupID + ); + + return query + SELECT view_groups.GroupID AS "ID", + view_groups.GroupNum as "GroupNum", + view_groups.GradeID as "GradeID", + view_groups.GradeNum as "GradeNum", + view_groups."degree" as "Degree", + view_groups.SpecID as "SpecID", + view_groups.SpecName as "SpecName", + view_groups.SpecAbbr as "SpecAbbr", + (SELECT study_form.FormName from study_form WHERE study_form.id = view_groups.FormID) + --view_groups.FormID as "FormID" + FROM tGroup + INNER JOIN view_groups ON tGroup.GroupID = view_groups.GroupID AND view_groups.Year = vYear + ORDER BY view_groups.GradeID ASC, view_groups.GroupID ASC; +END; +$function$; + +DROP VIEW public.view_groups; +CREATE OR REPLACE VIEW public.view_groups + AS SELECT study_groups.id AS groupid, + study_groups.groupnum, + groups_years.name AS groupname, + grades.id AS gradeid, + grades.num AS gradenum, + grades.degree, + specializations.id AS specid, + specializations.name AS specname, + specializations.abbr AS specabbr, + specializations.code AS speccode, + study_groups.formid AS formid, + faculties.id AS facultyid, + faculties.name AS facultyname, + faculties.abbr AS facultyabbr, + groups_years.year + FROM groups_years + JOIN study_groups ON groups_years.groupid = study_groups.id + JOIN specializations ON groups_years.specializationid = specializations.id + JOIN grades ON study_groups.gradeid = grades.id + JOIN faculties ON faculties.id = specializations.facultyid; + +DROP FUNCTION IF EXISTS public.getgroups(pgradeid integer, pfacultyid integer, psemesterid integer); +CREATE OR REPLACE FUNCTION public.getgroups(pgradeid integer, pfacultyid integer, psemesterid integer) + RETURNS TABLE("ID" integer, "GroupNum" integer, "SpecID" integer, "SpecName" character varying, "SpecAbbr" character varying, "FormID" character varying) +LANGUAGE sql +AS $function$ +--select * from public.getgroups( +-- :pgradeid, -- put the pgradeid parameter value instead of 'pgradeid' (int4) +-- :pfacultyid, -- put the pfacultyid parameter value instead of 'pfacultyid' (int4) +-- :psemesterid -- put the psemesterid parameter value instead of 'psemesterid' (int4) +--); +SELECT view_groups.GroupID AS "ID", + view_groups.GroupNum as "GroupNum", + view_groups.SpecID as "SpecID", + view_groups.SpecName as "SpecName", + view_groups.SpecAbbr as "SpecAbbr", + (SELECT study_form.FormName from study_form WHERE study_form.id = view_groups.FormID) +FROM view_groups + INNER JOIN semesters ON semesters.ID = pSemesterID +WHERE view_groups.GradeID = pGradeID AND + view_groups.FacultyID = pFacultyID AND + view_groups.Year = semesters.Year +ORDER BY view_groups.GroupNum ASC; +$function$; + + +drop function if exists public.getfinalforminfo(pdisciplineid integer, pgroupid integer); +CREATE OR REPLACE FUNCTION public.getfinalforminfo(pdisciplineid integer, pgroupid integer) + RETURNS TABLE("GroupNum" integer, "GroupName" character varying, "GradeID" integer, "GradeNum" integer, "Degree" bachelor_master_specialist, "SpecID" integer, "SpecName" character varying, "SpecAbbr" character varying, "SpecCode" character varying, "FacultyID" integer, "FacultyName" character varying, "FacultyAbbr" character varying, "ExamType" exam_credit_grading_credit, "SubjectID" integer, "SubjectName" character varying, "SubjectAbbr" character varying, "AuthorID" integer, "LastName" character varying, "FirstName" character varying, "SecondName" character varying, "JobPosition" character varying, "Year" integer, "SemesterNum" integer, "StudyForm" character varying) +LANGUAGE sql +AS $function$ +--select * from public.getfinalforminfo( +-- :pdisciplineid, -- put the pdisciplineid parameter value instead of 'pdisciplineid' (int4) +-- :pgroupid -- put the pgroupid parameter value instead of 'pgroupid' (int4) +--); +SELECT study_groups.GroupNum AS "GroupNum", + groups_years.Name AS "GroupName", + grades.ID AS "GradeID", + grades.Num AS "GradeNum", + grades.Degree AS "Degree", + specializations.ID AS "SpecID", + specializations.Name AS "SpecName", + specializations.Abbr AS "SpecAbbr", + specializations.Code AS "SpecCode", + faculties.ID AS "FacultyID", + faculties.Name AS "FacultyName", + faculties.Abbr AS "FacultyAbbr", + disciplines.ExamType AS "ExamType", + subjects.ID AS "SubjectID", + subjects.Name AS "SubjectName", + subjects.Abbr AS "SubjectAbbr", + teachers.ID AS "AuthorID", + accounts.LastName AS "LastName", + accounts.FirstName AS "FirstName", + accounts.SecondName AS "SecondName", + job_positions.Name AS "JobPosition", + --departments.ID AS "DepID", + --departments.Name AS "DepName", + semesters."year" AS "Year", + semesters.Num AS "SemesterNum", + (SELECT study_form.FormName from study_form WHERE study_form.id = ( + select study_groups.formid from study_groups + where study_groups.id = pgroupid + ) + ) AS "StudyForm" +FROM study_groups + INNER JOIN grades ON study_groups.GradeID = grades.ID + INNER JOIN disciplines ON disciplines.ID = pDisciplineID + INNER JOIN subjects ON disciplines.SubjectID = subjects.ID + INNER JOIN teachers ON teachers.ID = disciplines.AuthorID + INNER JOIN accounts ON teachers.AccountID = accounts.ID + --INNER JOIN departments ON departments.ID = teachers.DepartmentID + INNER JOIN job_positions ON job_positions.ID = teachers.JobPositionID + INNER JOIN semesters ON disciplines.SemesterID = semesters.ID + INNER JOIN groups_years ON groups_years.GroupID = study_groups.ID AND groups_years.Year = semesters.Year + INNER JOIN specializations ON groups_years.SpecializationID = specializations.ID + INNER JOIN faculties ON faculties.ID = specializations.FacultyID +WHERE study_groups.ID = pGroupID +LIMIT 1; +$function$ diff --git a/media/js/optionLoader.js b/media/js/optionLoader.js index b7bcb5c3a55cff1033caa11a483f8e8b2a9382a0..cb3247f6cb5c117e43dac626ade7a4aae4c1902f 100644 --- a/media/js/optionLoader.js +++ b/media/js/optionLoader.js @@ -85,10 +85,19 @@ class OptionLoader { */ let getGroupOption = (data) => { let str = `группа ${data.GroupNum}`; + if (data.SpecName) { str += " - "; str += data.SpecName; } + + if (data.FormID === 'заочная') { + str = str+' ЗО'; + } + if (data.FormID === 'очно-заочная') { + str = str+' ВО'; + } + return `<option value='${data.ID}'>${str}</option>`; }; diff --git a/~dev_rating/application/classes/Controller/Api/V0/Student.php b/~dev_rating/application/classes/Controller/Api/V0/Student.php index 309452e1c5c4667e20519ced7f68998302dd7a0a..cb3c4cded7ae72451d671b4ea3f9deae1386dd36 100644 --- a/~dev_rating/application/classes/Controller/Api/V0/Student.php +++ b/~dev_rating/application/classes/Controller/Api/V0/Student.php @@ -76,7 +76,15 @@ class Controller_Api_V0_Student extends Controller_Handler_Api { switch ($recordBookData->form) { case 'Очная': - $recordBookData->form = '1'; + $recordBookData->form = 1; + break; + + case 'Очно-заочная': + $recordBookData->form = 2; + break; + + case 'Заочная': + $recordBookData->form = 3; break; default: @@ -97,7 +105,7 @@ class Controller_Api_V0_Student extends Controller_Handler_Api { $year = Model_Plan::load($recordBookData->planID)->year; - $group = Model_Group::findOrCreate($gradeID, $recordBookData->group, $speciality, $recordBookData->facultyID, $year); + $group = Model_Group::findOrCreate($gradeID, $recordBookData->group, $speciality, $recordBookData->facultyID, $year, $recordBookData->form); if (is_null($group)) { throw new InvalidArgumentException('RecordBook: group not found'); } diff --git a/~dev_rating/application/classes/Controller/Handler/FileCreator.php b/~dev_rating/application/classes/Controller/Handler/FileCreator.php index 13526d68a5e0989689d1d128115f8ca7772c5a1c..18c053bcfe89f4faaa183211fbbc5eab4e680d5f 100644 --- a/~dev_rating/application/classes/Controller/Handler/FileCreator.php +++ b/~dev_rating/application/classes/Controller/Handler/FileCreator.php @@ -433,6 +433,9 @@ class Controller_Handler_FileCreator extends Controller_Handler $range = $objPHPExcel->getNamedRange("CreationDate")->getRange(); $sheet->setCellValue($range, date("d.m.y")); + $range = $objPHPExcel->getNamedRange("StudyForm")->getRange(); + $sheet->setCellValue($range, $data['StudyForm'] . ' форма обучения'); + $range = $objPHPExcel->getNamedRange("Date")->getRange(); if ($disciplineType == 'exam') { $controlDate = "Дата экзамена\n__________"; diff --git a/~dev_rating/application/classes/Controller/Teacher/Index.php b/~dev_rating/application/classes/Controller/Teacher/Index.php index e32d08315e0f1956735a85e9baca54f706e41ea9..9e6b36fe47c843fb6a970d097f3ec63e06717439 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Index.php +++ b/~dev_rating/application/classes/Controller/Teacher/Index.php @@ -33,8 +33,30 @@ class Controller_Teacher_Index extends Controller_Environment_Teacher $list = $dis->getTeachers()->groupByUniqueKey('ID'); $teachers[$dis->ID] = $this->getShortListOfTeachers($list, $dis->AuthorID, $this->user->TeacherID); } - if (isset($dis->GroupNum) && $dis->GroupNum) - $groups[$dis->ID][] = $dis->GroupNum . ' гр'; + if (isset($dis->GroupNum) && $dis->GroupNum) { + $groupDesc = $dis->GroupNum . ' гр'; + $groups[$dis->ID][] = $groupDesc; + } else { + $dis_groups = $dis->getAllGroups()->groupByUniqueKey('ID'); + foreach ($dis_groups as $dis_group) { + $groupDesc = ''; + if ($dis_group['Degree'] === 'bachelor') { + $groupDesc = $dis->GroupNum . ' гр. бакалавриат' ; + } + if ($dis_group['Degree'] === 'master') { + $groupDesc = $dis->GroupNum . 'гр. магистратура '; + } + + if ($dis_group['FormID'] === 'очно-заочная') { + $groupDesc = $groupDesc.' ВО'; + } + if ($dis_group['FormID'] === 'заочная') { + $groupDesc = $groupDesc.' ЗО'; + } + $groups[$dis->ID][] = $dis_group['GradeNum'] . ' к. '. $dis_group['GroupNum'] . $groupDesc; + } + } + if (!isset($students[$dis->ID])) { $students[$dis->ID] = array_filter($dis->getStudents(), function ($student) { @@ -51,7 +73,13 @@ class Controller_Teacher_Index extends Controller_Environment_Teacher 'Subjects' => $subjects, 'Teachers' => $teachers, 'Groups' => $groups, - 'Students' => $students, + // http://gitlab.mmcs.sfedu.ru/it-lab/grade/issues/50 + // Передача списка прикрепленных студентов отключена чтобы + // не загромождать пользовательский интерфейс + // и потому что списки студентов определяются только данными из 1С + // теперь в списке дисциплин нельзя быстро увидеть список студентов + // но можно вернуть эту функциональность, раскомментировав строку + // 'Students' => $students, 'DisciplineCreationISAllowed' => Model_System::loadConfig()->Functional->DisciplineCreation, 'EMailChanged' => $EMailChanged, ])->set_filename('teacher/index'); diff --git a/~dev_rating/application/classes/Model/Discipline.php b/~dev_rating/application/classes/Model/Discipline.php index 72c155974f2153b40a7d02d2a0752a667106c95a..0d61cb4fb5db1309fb370e6976b47816c7f18833 100644 --- a/~dev_rating/application/classes/Model/Discipline.php +++ b/~dev_rating/application/classes/Model/Discipline.php @@ -104,6 +104,14 @@ class Model_Discipline extends Model_Container /** Get groups with separately attached students. */ public function getAllGroups() { + // http://gitlab.mmcs.sfedu.ru/it-lab/grade/issues/50 + // для получения списка групп для всех дисциплин на странице преподавателя + // нужно сделать несколько запросов к GetGroupsForDisciplineAll + // за одно подключение к базе данных + // но тогда функция возвращает один и тот же ответ + // поэтому каждый раз подключаемся заново + $db = Kohana_Database::instance(); + $db->disconnect(); $sql = 'SELECT * FROM GetGroupsForDisciplineAll(:id)'; return DB::query(Database::SELECT, $sql)->param(':id', $this->ID)->execute(); } diff --git a/~dev_rating/application/classes/Model/Group.php b/~dev_rating/application/classes/Model/Group.php index 53015addba3231df5177db07827904416b693a11..62bbcf91b87d38ae044086b2debb1a61b89f029b 100644 --- a/~dev_rating/application/classes/Model/Group.php +++ b/~dev_rating/application/classes/Model/Group.php @@ -14,14 +14,15 @@ class Model_Group extends Model return $g; } - public static function findOrCreate($gradeID, $groupNum, $specialization, $facultyID, $year) { - $sql = 'SELECT * FROM CreateGroup(:gradeID, :groupNum, :specialization, :facultyID, :year) AS "ID"'; + public static function findOrCreate($gradeID, $groupNum, $specialization, $facultyID, $year, $form) { + $sql = 'SELECT * FROM CreateGroup(:gradeID, :groupNum, :specialization, :facultyID, :year, :form) AS "ID"'; $id = DB::query(Database::SELECT, $sql) ->param(':gradeID', $gradeID) ->param(':groupNum', (int)$groupNum) ->param(':specialization', $specialization) ->param(':facultyID', $facultyID) ->param(':year', $year) + ->param(':form', $form) ->execute()->get('ID'); if ($id <= 0) { return null; diff --git a/~dev_rating/application/views/teacher/discipline/journal.twig b/~dev_rating/application/views/teacher/discipline/journal.twig index ce536ff4b2b04e33a92144b5c4e32f1da985eeed..aa1c15425ae7831321e6116d4da37dce7791de21 100644 --- a/~dev_rating/application/views/teacher/discipline/journal.twig +++ b/~dev_rating/application/views/teacher/discipline/journal.twig @@ -102,6 +102,14 @@ {% endif %} {{ Group.GroupNum }} группа + + {% if Group.FormID == 'очно-заочная' %} + ВО + {% endif %} + + {% if Group.FormID == 'заочная' %} + ЗО + {% endif %} </option> {% endfor %} </select> diff --git a/~dev_rating/application/views/teacher/discipline/rating/exam.twig b/~dev_rating/application/views/teacher/discipline/rating/exam.twig index ad5808575dc048123c36d4f2636ee6d0935c3b7d..33cb4d87b9d1f60fb3512d622708fe3b084c7267 100644 --- a/~dev_rating/application/views/teacher/discipline/rating/exam.twig +++ b/~dev_rating/application/views/teacher/discipline/rating/exam.twig @@ -67,6 +67,14 @@ {% endif %} {{ Group.GroupNum }} группа + + {% if Group.FormID == 'очно-заочная' %} + ВО + {% endif %} + + {% if Group.FormID == 'заочная' %} + ЗО + {% endif %} </option> {% endfor %} </select> diff --git a/~dev_rating/application/views/teacher/discipline/rating/rate.twig b/~dev_rating/application/views/teacher/discipline/rating/rate.twig index 32fb0017b5574e035e54bb2586d837cb469e48c0..5085c6d9aefdcf6df7158a83e403e5cda3e4038e 100644 --- a/~dev_rating/application/views/teacher/discipline/rating/rate.twig +++ b/~dev_rating/application/views/teacher/discipline/rating/rate.twig @@ -59,6 +59,13 @@ {% endif %} {{ Group.GroupNum }} группа + {% if Group.FormID == 'очно-заочная' %} + ВО + {% endif %} + + {% if Group.FormID == 'заочная' %} + ЗО + {% endif %} </option> {% endfor %} </select> diff --git a/~dev_rating/application/views/teacher/index.twig b/~dev_rating/application/views/teacher/index.twig index b1cc18baebaf6cdd081a4b6742fbf929f6497d1e..8ce52d1c890291fa83f5b4233527fc9f172ad5c8 100644 --- a/~dev_rating/application/views/teacher/index.twig +++ b/~dev_rating/application/views/teacher/index.twig @@ -28,10 +28,10 @@ {% set StudentsList = StudentsList | merge([StudentName]) %} {% endfor %} {% if GroupsList and StudentsList %} - {{ GroupsList | join(', ') }}, + {{ GroupsList | join(' <br> ') | raw }}, <abbr title="{{ StudentsList | join('\n') }}">Отдельные студенты</abbr> {% elseif GroupsList %} - {{ GroupsList | join(', ') }}. + {{ GroupsList | join(' <br> ') | raw }}. {% elseif StudentsList %} <abbr title="{{ StudentsList | join('\n') }}">Отдельные студенты</abbr> {% else %} diff --git a/~dev_rating/docs/old template credit.xls b/~dev_rating/docs/old template credit.xls index 339f988f24170b1bfa96891150f02f14779e4ae3..f87157bbb6246642dd9ba4061887a9387cadc252 100644 Binary files a/~dev_rating/docs/old template credit.xls and b/~dev_rating/docs/old template credit.xls differ diff --git a/~dev_rating/docs/old template exam.xls b/~dev_rating/docs/old template exam.xls index 5237d59f882691d13792ebe63f99b4fcb18a61c9..45d933ecba99d62bacc7fcf6aafaa07f6bb9cdf1 100644 Binary files a/~dev_rating/docs/old template exam.xls and b/~dev_rating/docs/old template exam.xls differ diff --git a/~dev_rating/docs/template credit 0 1.xls b/~dev_rating/docs/template credit 0 1.xls index 995bcaec860753ce6c713f38f816a19aab141fd9..59db6a2c7516efec69ee22c4501fd39385f38278 100644 Binary files a/~dev_rating/docs/template credit 0 1.xls and b/~dev_rating/docs/template credit 0 1.xls differ diff --git a/~dev_rating/docs/template credit 2 3.xls b/~dev_rating/docs/template credit 2 3.xls index 6e54b1db3ede36de742942f40112c012e6edd8ee..30fbc9f18e1b6080b5da50c9bc1f9de4e3c8310b 100644 Binary files a/~dev_rating/docs/template credit 2 3.xls and b/~dev_rating/docs/template credit 2 3.xls differ diff --git a/~dev_rating/docs/template exam 0 1.xls b/~dev_rating/docs/template exam 0 1.xls index 8d0684d1094a86b778b362e9c4deb0422014987b..50fc704eae8fa28f13b3005d36a3d3edb13b6475 100644 Binary files a/~dev_rating/docs/template exam 0 1.xls and b/~dev_rating/docs/template exam 0 1.xls differ diff --git a/~dev_rating/docs/template exam 2 3.xls b/~dev_rating/docs/template exam 2 3.xls index 60373f5f4e24055abd67e0635e01e78e4381bf24..7545a01b38e03b1a7b329f4cbfcabb31099a59cc 100644 Binary files a/~dev_rating/docs/template exam 2 3.xls and b/~dev_rating/docs/template exam 2 3.xls differ