Skip to content
Snippets Groups Projects
Commit 4284e4e1 authored by Anton Bagliy's avatar Anton Bagliy
Browse files

Merge branch 'issue405_specialty_groups' into develop

parents 357d8808 dee64daa
Branches
No related merge requests found
ALTER TABLE public.study_groups ADD COLUMN specid integer DEFAULT null;
ALTER TABLE public.study_groups
DROP CONSTRAINT study_groups_facultyid_gradeid_groupnum_formid_key;
ALTER TABLE ONLY public.study_groups
ADD CONSTRAINT study_groups_facultyid_gradeid_groupnum_formid_spec_key UNIQUE (facultyid, gradeid, groupnum, formid, specid);
ALTER TABLE ONLY public.study_groups
ADD CONSTRAINT study_groups_ibfk_5 FOREIGN KEY (specid) REFERENCES specializations(id);
-- script to fill study_groups.specid from latest record in groups_years
-- after creating empty specid column
update study_groups set specid=(
select groups_years.specializationid from groups_years
where groups_years.groupid=study_groups.id
order by groups_years.year desc
limit 1
) where specid is null;
DROP FUNCTION IF EXISTS public.creategroup(pgradeid integer, pgroupnum integer, pspecname character varying, pfacultyid integer, pyear integer, pformid 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 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
and study_groups.specid=vSpecId;
if ( vGroupID is null) then
INSERT INTO study_groups (GradeID, GroupNum, FacultyID, FormID, SpecID)
VALUES (pGradeID, pGroupNum, pFacultyID, pFormID, vSpecId)
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$;
......@@ -50,10 +50,17 @@ class Controller_Teacher_Discipline_Edit extends Controller_Environment_Teacher
public function action_edit_students() {
$this->manageGroups($this->discipline, $students, $attached);
$allGroups = $this->discipline->getAllGroups()->as_array();
$groupInfo = array();
foreach($allGroups as $group) {
$groupInfo[$group["ID"]] = array('SpecName' => $group["SpecName"]);
}
$this->twig->set([
'Groups' => $students,
'GroupsAttached' => $attached,
'GroupsForDiscipline' => $groupInfo,
'GradesList' => Model_Grades::loadAll(),
'GroupsList' => $this->discipline->Faculty->getGroups($this->discipline->GradeID),
'SemesterID' => $this->discipline->SemesterID,
......
......@@ -39,7 +39,7 @@
<h2 class="BlueTitle">Основные студенты</h2>
{% for groupID, group in Groups %}
<div class="GradeAndGroupTitle ActionShowHideGroupContainer" id="{{ groupID }}">
<span class="info">{{ Rus[group[0].Degree] }}, курс {{ group[0].GradeNum }} группа {{ group[0].GroupNum }}</span>
<span class="info">{{ Rus[group[0].Degree] }}, курс {{ group[0].GradeNum }} группа {{ group[0].GroupNum }} | {{ GroupsForDiscipline[group[0].GroupID]["SpecName"] }}</span>
<span class="Action">Открыть список ▼</span>
</div>
......
......@@ -212,6 +212,7 @@
{% endif %}
{{ Group.GroupNum }} группа
| {{ Group["SpecName"] }}
</span>
</div>
</td>
......
......@@ -167,6 +167,7 @@
{% endif %}
{{ Group.GroupNum }} группа
| {{ Group["SpecName"] }}
</td>
</tr>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment