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

ADD: display global disciplines in bill with links for each student #547

parent 2e1b25e8
Branches
No related merge requests found
DROP FUNCTION IF EXISTS public.getdisciplinesforgroup(pgroupid integer, psemesterid integer, pshowhidden boolean);
DROP FUNCTION IF EXISTS public.getdisciplinesforgroup(pgroupid integer, psemesterid integer, pshowglobal boolean, pshowhidden boolean);
CREATE OR REPLACE FUNCTION public.getdisciplinesforgroup(pgroupid integer, psemesterid integer, pshowglobal boolean DEFAULT false, pshowhidden boolean DEFAULT false)
RETURNS TABLE("ID" integer, "SubjectID" integer, "SubjectName" character varying, "Subtype" scientific_disciplinary_coursework, "Type" exam_credit_grading_credit, "CompoundDiscID" integer, "CompoundDiscName" character varying, "CurRate" integer, "MaxRate" integer, "IsGlobal" boolean)
RETURNS TABLE("ID" integer, "SubjectID" integer, "SubjectName" character varying, "Subtype" scientific_disciplinary_coursework, "Type" exam_credit_grading_credit, "CompoundDiscID" integer, "CompoundDiscName" character varying, "CurRate" integer, "MaxRate" integer, "IsGlobal" boolean, "GlobalName" character varying)
LANGUAGE plpgsql
AS $function$
BEGIN
......@@ -15,10 +15,12 @@ BEGIN
view_disciplines.CompoundDiscName as "CompoundDiscName",
view_disciplines.CurRate as "CurRate",
view_disciplines.MaxRate as "MaxRate",
view_disciplines.isGlobal as "IsGlobal"
view_disciplines.isGlobal as "IsGlobal",
global_disciplines.name as "GlobalName"
FROM students_groups
LEFT JOIN view_disciplines_recordbooks ON students_groups.RecordBookID = view_disciplines_recordbooks.RecordBookID
INNER JOIN view_disciplines ON view_disciplines_recordbooks.DisciplineID = view_disciplines.DisciplineID
LEFT JOIN global_disciplines ON view_disciplines.DisciplineID = global_disciplines.disciplineid
WHERE students_groups.GroupID = pGroupID AND
students_groups.SemesterID = pSemesterID AND
view_disciplines.SemesterID = pSemesterID AND
......
......@@ -63,28 +63,28 @@ class Controller_Office_Bill extends Controller_Environment_Office
protected static function processGlobal($disciplines, $students, $rates) {
$res = [];
$subjects = [];
$globals = [];
$num = 1;
$subjectsToGlobals = [];
$disciplinesToGlobals = [];
$nextGlobalNum = 1;
foreach ($disciplines as $disc) {
if ($disc['IsGlobal']) {
$subj = $disc['SubjectID'];
if (array_key_exists($subj, $subjects)) {
$globals[$disc['ID']] = $num - 1;
if (array_key_exists($subj, $subjectsToGlobals)) {
$disciplinesToGlobals[$disc['ID']] = $nextGlobalNum - 1;
} else {
$subjects[$subj] = $num;
$globals[$disc['ID']] = $num;
$newD = [
'ID' => $num,
$subjectsToGlobals[$subj] = $nextGlobalNum;
$disciplinesToGlobals[$disc['ID']] = $nextGlobalNum;
$newGlobalDiscipline = [
'ID' => $nextGlobalNum,
'SubjectName' => $disc["SubjectName"],
];
$res[$num] = $newD;
$num++;
$res[$nextGlobalNum] = $newGlobalDiscipline;
$nextGlobalNum++;
}
foreach($students as $student) {
$rate = $rates[$student['ID']][$disc['ID']];
if ($rate) {
$res[$globals[$disc['ID']]][$student['ID']] = $disc['ID'];
$res[$disciplinesToGlobals[$disc['ID']]][$student['ID']] = $disc['ID'];
}
}
}
......@@ -106,7 +106,7 @@ class Controller_Office_Bill extends Controller_Environment_Office
$rates = Model_Rating::getRatesForGroupAll($groupID, $semesterID);
$ratesMap = self::getRateMap($rates, $disciplines);
$globalDisciplines = self::processGlobal($disciplines, $students, $rates);
$globalDisciplines = self::processGlobal($disciplines, $students, $ratesMap);
$this->twig->set_filename(static::OFFICE . 'bill')
->set([
......
......@@ -8,14 +8,16 @@
</td>
{% endfor %}
{% for dis in Disciplines %}
<td class="title">
{% if dis.CompoundDiscID %}
{{ HTML.anchor('/compound_disciplines/' ~ dis.CompoundDiscID,
dis.CompoundDiscName, {'title': dis.CompoundDiscName })|raw }}
{% else %}
{{ HTML.anchor('/discipline/' ~ dis.ID ~ '/rate', dis.SubjectName, {'title': dis.SubjectName })|raw }}
{% endif %}
</td>
{% if not dis.IsGlobal %}
<td class="title">
{% if dis.CompoundDiscID %}
{{ HTML.anchor('/compound_disciplines/' ~ dis.CompoundDiscID,
dis.CompoundDiscName, {'title': dis.CompoundDiscName })|raw }}
{% else %}
{{ HTML.anchor('/discipline/' ~ dis.ID ~ '/rate', dis.SubjectName, {'title': dis.SubjectName })|raw }}
{% endif %}
</td>
{% endif %}
{% endfor %}
</tr>
......@@ -27,19 +29,30 @@
{% set id = GlobalDisciplines[disc.ID][stud.ID] %}
{% set rate = Rates[stud.ID][id] %}
{% if rate %}
<td class="{{ typeClasses[rate.Type] }}">{{ rate.rating }}</td>
<td>
{{ HTML.anchor('/discipline/' ~ id ~ '/rate',
'<div class = ' ~ typeClasses[rate.Type] ~ '>' ~ rate.rating ~ '</div>',
{
'title': Disciplines[id].GlobalName,
'target': '_blank'
})|raw }}
</td>
{% else %}
<td class="absent_rate"> -</td>
<td class="absent_rate">
-
</td>
{% endif %}
{% endfor %}
{% for disc in Disciplines %}
{% set id = -disc.CompoundDiscID ?: disc.ID %}
{% set rate = Rates[stud.ID][id] %}
{% if not disc.IsGlobal %}
{% set id = -disc.CompoundDiscID ?: disc.ID %}
{% set rate = Rates[stud.ID][id] %}
{% if rate %}
<td class="{{ typeClasses[rate.Type] }}">{{ rate.rating }}</td>
{% else %}
<td class="absent_rate"> -</td>
{% if rate %}
<td class="{{ typeClasses[rate.Type] }}">{{ rate.rating }}</td>
{% else %}
<td class="absent_rate"> -</td>
{% endif %}
{% endif %}
{% endfor %}
</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