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

REF: code style in rate.twig #574

parent fa6d3feb
Branches
No related merge requests found
...@@ -18,9 +18,7 @@ ...@@ -18,9 +18,7 @@
{% endmacro %} {% endmacro %}
{# Вывод данных "прилеплен" для выдачи корректного ответа #} {# Вывод данных "прилеплен" для выдачи корректного ответа #}
{% macro RateCellCheck(Discipline, ModuleType) %}{{ {% macro RateCellCheck(Discipline, ModuleType) %}{{ Discipline.Milestone == 0 and (ModuleType == 'regular' or ModuleType == 'bonus') }}{% endmacro %}
Discipline.Milestone == 0 and (ModuleType == 'regular' or ModuleType == 'bonus')
}}{% endmacro %}
{% macro RateCell(Col, Row, Discipline, ModuleType, Rate) %} {% macro RateCell(Col, Row, Discipline, ModuleType, Rate) %}
{% if _self.RateCellCheck(Discipline, ModuleType) %} {% if _self.RateCellCheck(Discipline, ModuleType) %}
...@@ -82,168 +80,168 @@ ...@@ -82,168 +80,168 @@
<div class="rateContent"> <div class="rateContent">
<table id="studentsRate"> <table id="studentsRate">
<thead> <thead>
{% set ColCount = 3 %} {% set ColCount = 3 %}
{% for Module in Modules %} {% for Module in Modules %}
{% if Module.Type == 'regular' %} {% if Module.Type == 'regular' %}
{% set ColCount = ColCount + Module.Submodules|length %} {% set ColCount = ColCount + Module.Submodules|length %}
{% else %} {% else %}
{% set ColCount = ColCount + 1 %} {% set ColCount = ColCount + 1 %}
{% endif %} {% endif %}
{% endfor %}
<tr id="modulesHead">
<td>Модуль</td>
{% for Module in Modules if Module.Type == 'regular' %}
<td colspan="{{ Module.Submodules|length }}">{{ Module.Name }}</td>
{% endfor %} {% endfor %}
<tr id="modulesHead"> <td rowspan="3">Итог за семестр</td>
<td>Модуль</td>
{% for Module in Modules if Module.Type == 'regular' %}
<td colspan="{{ Module.Submodules|length }}">{{ Module.Name }}</td>
{% endfor %}
<td rowspan="3">Итог за семестр</td>
{% if Discipline.IsBonus %} {% if Discipline.IsBonus %}
<td rowspan="2">Бонус</td> <td rowspan="2">Бонус</td>
{% endif %} {% endif %}
<td rowspan="3">Добор</td> <td rowspan="3">Добор</td>
{% if Discipline.Type == 'exam' %} {% if Discipline.Type == 'exam' %}
<td rowspan="3">Экзамен</td> <td rowspan="3">Экзамен</td>
{% endif %} {% endif %}
<td rowspan="3">Итог</td> <td rowspan="3">Итог</td>
</tr> </tr>
<tr id="submodulesHead"> <tr id="submodulesHead">
{% set Col = 1 %} {% set Col = 1 %}
<td>Мероприятие</td> <td>Мероприятие</td>
{% for Module in Modules %} {% for Module in Modules %}
{% for Submodule in Module.Submodules if Module.Type == 'regular'%} {% for Submodule in Module.Submodules if Module.Type == 'regular' %}
<td class="col_{{ Col }}">{{ Submodule.Name }}</td> <td class="col_{{ Col }}">{{ Submodule.Name }}</td>
{% set Col = Col + 1 %} {% set Col = Col + 1 %}
{% endfor %}
{% endfor %} {% endfor %}
{% endfor %}
{% if Discipline.IsBonus %} {% if Discipline.IsBonus %}
<td class="col_{{ Col }}" style="display: none">Бонусные баллы</td> <td class="col_{{ Col }}" style="display: none">Бонусные баллы</td>
{% set Col = Col + 1 %} {% set Col = Col + 1 %}
{% endif %} {% endif %}
</tr> </tr>
<tr id="submodulesHeadMaxRate"> <tr id="submodulesHeadMaxRate">
{% set Col = 1 %} {% set Col = 1 %}
<td>Макс. балл</td> <td>Макс. балл</td>
{% for Module in Modules if Module.Type == 'regular' %} {% for Module in Modules if Module.Type == 'regular' %}
{% for Submodule in Module.Submodules %} {% for Submodule in Module.Submodules %}
<td class="col_{{ Col }}" id="regular_{{ Submodule.ID }}">{{ Submodule.Rate }}</td> <td class="col_{{ Col }}" id="regular_{{ Submodule.ID }}">{{ Submodule.Rate }}</td>
{% set Col = Col + 1 %} {% set Col = Col + 1 %}
{% endfor %}
{% endfor %} {% endfor %}
{% endfor %}
{% for Module in Modules if Module.Type == 'bonus' %} {% for Module in Modules if Module.Type == 'bonus' %}
{% for Submodule in Module.Submodules %} {% for Submodule in Module.Submodules %}
<td class="col_{{ Col }}" id="bonus_{{ Submodule.ID }}">{{ Submodule.Rate }}</td> <td class="col_{{ Col }}" id="bonus_{{ Submodule.ID }}">{{ Submodule.Rate }}</td>
{% set Col = Col + 1 %} {% set Col = Col + 1 %}
{% endfor %}
{% endfor %} {% endfor %}
</tr> {% endfor %}
</tr>
</thead> </thead>
<tbody> <tbody>
{% set Row = 1 %} {% set Row = 1 %}
{% for GroupID, StudentsList in Students %} {% for GroupID, StudentsList in Students %}
{% set Group = Groups[GroupID] %} {% set Group = Groups[GroupID] %}
<tr id="group_{{ GroupID }}" class="group_{{ GroupID }}"> <tr id="group_{{ GroupID }}" class="group_{{ GroupID }}">
{% if Discipline.IsGlobal %} {% if Discipline.IsGlobal %}
<td class="group" colspan="{{ ColCount }}" style="display:none"> <td class="group" colspan="{{ ColCount }}" style="display:none">
{% else %} {% else %}
<td class="group" colspan="{{ ColCount }}"> <td class="group" colspan="{{ ColCount }}">
{% endif %}
{% if Group.Degree == 'master' %}
Магистратура, {{ Group.GradeNum }} год
{% elseif Group.Degree == 'specialist' %}
Специалитет, {{ Group.GradeNum }} курс
{% elseif Group.Degree == 'postgraduate' %}
Аспирантура, {{ Group.GradeNum }} год
{% else %}
{{ Group.GradeNum }} курс
{% endif %} {% endif %}
{% if Group.Degree == 'master' %}
Магистратура, {{ Group.GradeNum }} год {{ Group.GroupNum }} группа
{% elseif Group.Degree == 'specialist' %} | {{ Group["SpecName"] }}
Специалитет, {{ Group.GradeNum }} курс </td>
{% elseif Group.Degree == 'postgraduate' %} </tr>
Аспирантура, {{ Group.GradeNum }} год
{% else %} {% for Student in StudentsList %}
{{ Group.GradeNum }} курс <tr id="row_{{ Row }}" class="group_{{ GroupID }}">
{% endif %} {% set Col = 1 %}
{% set SemesterRate = 0 %}
{{ Group.GroupNum }} группа {% set BonusRate = 0 %}
| {{ Group["SpecName"] }} {% set ExtraRate = 0 %}
{% set ExamRate = 0 %}
<td id="student_{{ Student.RecordBookID }}" class="name">
{{ Student.LastName }} {{ Student.FirstName }}
</td> </td>
</tr>
{% for Student in StudentsList %} {% for Module in Modules if Module.Type == 'regular' %}
<tr id="row_{{ Row }}" class="group_{{ GroupID }}"> {% for Submodule in Module.Submodules %}
{% set Col = 1 %} {% set Rate = Rates[Student.RecordBookID][Submodule.ID] %}
{% set SemesterRate = 0 %} {{ _self.RateCell(Col, Row, Discipline, 'regular', Rate) }}
{% set BonusRate = 0 %} {% set Col = Col + _self.RateCellCheck(Discipline, 'regular') %}
{% set ExtraRate = 0 %} {% set SemesterRate = SemesterRate + Rate %}
{% set ExamRate = 0 %} {% endfor %}
{% endfor %}
<td id="student_{{ Student.RecordBookID }}" class="name"> {{ _self.RateCell(Col, Row, Discipline, 'semester', SemesterRate) }}
{{ Student.LastName }} {{ Student.FirstName }} {% set Col = Col + _self.RateCellCheck(Discipline, 'semester') %}
</td>
{% for Module in Modules if Module.Type == 'regular'%} {% if Discipline.IsBonus %}
{% for Module in Modules if Module.Type == 'bonus' %}
{% for Submodule in Module.Submodules %} {% for Submodule in Module.Submodules %}
{% set Rate = Rates[Student.RecordBookID][Submodule.ID] %} {% set Rate = Rates[Student.RecordBookID][Submodule.ID] %}
{{ _self.RateCell(Col, Row, Discipline, 'regular', Rate) }} {% set BonusRate = Rate %}
{% set Col = Col + _self.RateCellCheck(Discipline, 'regular') %}
{% set SemesterRate = SemesterRate + Rate %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{{ _self.RateCell(Col, Row, Discipline, 'bonus', BonusRate) }}
{% set Col = Col + _self.RateCellCheck(Discipline, 'bonus') %}
{% endif %}
{{ _self.RateCell(Col, Row, Discipline, 'semester', SemesterRate) }} {% for Module in Modules if Module.Type == 'extra' %}
{% set Col = Col + _self.RateCellCheck(Discipline, 'semester') %} {% for Submodule in Module.Submodules %}
{% set Rate = Rates[Student.RecordBookID][Submodule.ID] %}
{% if Discipline.IsBonus %} {% set ExtraRate = ExtraRate + Rate %}
{% for Module in Modules if Module.Type == 'bonus' %} {% endfor %}
{% for Submodule in Module.Submodules %} {% endfor %}
{% set Rate = Rates[Student.RecordBookID][Submodule.ID] %} {{ _self.RateCell(Col, Row, Discipline, 'extra', ExtraRate ? ExtraRate) }}
{% set BonusRate = Rate %} {% set Col = Col + _self.RateCellCheck(Discipline, 'extra') %}
{% endfor %}
{% endfor %}
{{ _self.RateCell(Col, Row, Discipline, 'bonus', BonusRate) }}
{% set Col = Col + _self.RateCellCheck(Discipline, 'bonus') %}
{% endif %}
{% for Module in Modules if Module.Type == 'extra' %} {% if Discipline.Type == 'exam' %}
{% for Module in Modules if Module.Type == 'exam' %}
{% for Submodule in Module.Submodules %} {% for Submodule in Module.Submodules %}
{% set Rate = Rates[Student.RecordBookID][Submodule.ID] %} {% set Exam = Exams[Student.RecordBookID][Submodule.ID] %}
{% set ExtraRate = ExtraRate + Rate %} {% set Rate = (Exam.Absence or Exam.AutoPass) ? "" : Exam.Rate %}
{% set ExamRate = max(ExamRate, Rate) %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{{ _self.RateCell(Col, Row, Discipline, 'extra', ExtraRate ? ExtraRate) }} {{ _self.RateCell(Col, Row, Discipline, 'exam', ExamRate ? ExamRate) }}
{% set Col = Col + _self.RateCellCheck(Discipline, 'extra') %} {% set Col = Col + _self.RateCellCheck(Discipline, 'exam') %}
{% endif %}
{% if Discipline.Type == 'exam' %}
{% for Module in Modules if Module.Type == 'exam' %}
{% for Submodule in Module.Submodules %}
{% set Exam = Exams[Student.RecordBookID][Submodule.ID] %}
{% set Rate = (Exam.Absence or Exam.AutoPass) ? "" : Exam.Rate %}
{% set ExamRate = max(ExamRate, Rate) %}
{% endfor %}
{% endfor %}
{{ _self.RateCell(Col, Row, Discipline, 'exam', ExamRate ? ExamRate) }}
{% set Col = Col + _self.RateCellCheck(Discipline, 'exam') %}
{% endif %}
{% set ResultRate = SemesterRate + BonusRate + ExtraRate + ExamRate %} {% set ResultRate = SemesterRate + BonusRate + ExtraRate + ExamRate %}
{{ _self.RateCell(Col, Row, Discipline, 'result', ResultRate > 100 ? '100+' : ResultRate) }} {{ _self.RateCell(Col, Row, Discipline, 'result', ResultRate > 100 ? '100+' : ResultRate) }}
{% set Col = Col + _self.RateCellCheck(Discipline, 'result') %} {% set Col = Col + _self.RateCellCheck(Discipline, 'result') %}
</tr> </tr>
{% set Row = Row + 1 %} {% set Row = Row + 1 %}
{% endfor %}
{% endfor %} {% endfor %}
{% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
......
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