Skip to content

Commit

Permalink
Completed (#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi4er4 authored Sep 18, 2024
1 parent e5f3154 commit 389d4b4
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 77 deletions.
2 changes: 1 addition & 1 deletion apps/admission/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 09:52+0000\n"
"POT-Creation-Date: 2024-09-16 15:19+0000\n"
"PO-Revision-Date: 2024-07-23 17:04+0000\n"
"Last-Translator: Дмитрий Чернушевич <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion apps/htmlpages/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: django\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 09:52+0000\n"
"POT-Creation-Date: 2024-09-16 15:19+0000\n"
"PO-Revision-Date: 2015-03-18 08:34+0000\n"
"Last-Translator: Jannis Leidel <[email protected]>\n"
"Language-Team: Russian (http://www.transifex.com/projects/p/django/language/"
Expand Down
13 changes: 10 additions & 3 deletions apps/learning/gradebook/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def id(self):
def enrollment_id(self):
return self._enrollment.pk

@property
def enrollment_type_display(self):
return self._enrollment.get_type_display()

@property
def final_grade(self):
return self._enrollment.grade
Expand All @@ -61,12 +65,15 @@ def student_group(self) -> Optional[StudentGroup]:
def student_type(self) -> str:
return self.student_profile.type

@property
def year_of_curriculum(self) -> int:
year_of_curriculum = self.student_profile.year_of_curriculum
return year_of_curriculum if year_of_curriculum else None

@property
def invitation(self) -> Optional[str]:
invitation = self.student_profile.invitation
if invitation:
return invitation.name
return None
return invitation.name if invitation else None


@dataclass
Expand Down
10 changes: 6 additions & 4 deletions apps/learning/gradebook/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,14 @@ def test_empty_gradebook_view(client):
field = 'final_grade_{}'.format(enrollment.pk)
assert field in response.context_data['form'].fields
assert len(students) == len(response.context_data['form'].fields)
assert smart_bytes(_("Students") + f":&nbsp;{len(students)}") in response.content
assert smart_bytes(_("Students and listeners") + f":&nbsp;{len(students)}") in response.content
assert smart_bytes(_("Learners") + f":&nbsp;{len(students)}") in response.content
assert smart_bytes(_("Total students") + f":&nbsp;{len(students)}") in response.content
assert smart_bytes(_("Listeners") + ":&nbsp;0") in response.content
EnrollmentFactory.create(course=co1, type=EnrollmentTypes.LECTIONS_ONLY)
response = client.get(co1.get_gradebook_url())
assert smart_bytes(_("Students") + f":&nbsp;{len(students)}") in response.content
assert smart_bytes(_("Students and listeners") + f":&nbsp;{len(students) + 1}") in response.content
assert smart_bytes(_("Learners") + f":&nbsp;{len(students)}") in response.content
assert smart_bytes(_("Total students") + f":&nbsp;{len(students) + 1}") in response.content
assert smart_bytes(_("Listeners") + ":&nbsp;1") in response.content
for co in [co1, co2]:
url = co.get_gradebook_url()
assert smart_bytes(url) in response.content
Expand Down
18 changes: 14 additions & 4 deletions apps/learning/gradebook/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from django.contrib import messages
from django.core.exceptions import PermissionDenied, ValidationError
from django.db.models import Prefetch
from django.db.models import Prefetch, Q, Count
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.utils.datastructures import MultiValueDictKeyError
Expand Down Expand Up @@ -49,7 +49,7 @@
"ImportAssignmentScoresByYandexLoginView"
]

from learning.settings import AssignmentScoreUpdateSource, EnrollmentGradeUpdateSource
from learning.settings import AssignmentScoreUpdateSource, EnrollmentGradeUpdateSource, EnrollmentTypes
from users.models import StudentTypes, User


Expand Down Expand Up @@ -202,6 +202,12 @@ def get_context_data(self, form: BaseGradebookForm,
.select_related('semester', 'meta_course', 'main_branch'))
context['course_offering_list'] = courses
context['user_type'] = self.user_type
enrollments_summary = Enrollment.active.filter(course=self.course).aggregate(
total_listeners=Count('id', filter=Q(type=EnrollmentTypes.LECTIONS_ONLY)),
total_learners=Count('id', filter=Q(type=EnrollmentTypes.REGULAR))
)
context['total_listeners'] = enrollments_summary['total_listeners']
context['total_learners'] = enrollments_summary['total_learners']

return context

Expand All @@ -224,12 +230,14 @@ def get(self, request, *args, **kwargs):

writer = csv.writer(response)
headers = [
"id",
"Профиль на сайте",
_("Last name"),
_("First name"),
_("Patronymic"),
_("Branch"),
_("Role"),
"Тип записи",
_("CSCUser|Curriculum year"),
_("Group"),
_("Yandex Login"),
_("Telegram Username"),
Expand Down Expand Up @@ -261,12 +269,14 @@ def get(self, request, *args, **kwargs):
gitlab_manytask = connected_providers.get('gitlab-manytask')
writer.writerow(
itertools.chain(
[gradebook_student.enrollment_id,
[student.get_absolute_url(),
student.last_name,
student.first_name,
student.patronymic,
student_profile.branch.name,
student_profile.get_type_display(),
gradebook_student.enrollment_type_display,
gradebook_student.year_of_curriculum,
(student_group and student_group.name) or "-",
student.yandex_login,
student.telegram_username,
Expand Down
2 changes: 1 addition & 1 deletion apps/projects/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 09:52+0000\n"
"POT-Creation-Date: 2024-09-16 15:19+0000\n"
"PO-Revision-Date: 2022-02-21 15:24+0000\n"
"Last-Translator: Сергей Жеревчук <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion apps/surveys/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 09:52+0000\n"
"POT-Creation-Date: 2024-09-16 15:19+0000\n"
"PO-Revision-Date: 2019-10-31 16:30+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion compscicenter_ru/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 09:52+0000\n"
"POT-Creation-Date: 2024-09-16 15:19+0000\n"
"PO-Revision-Date: 2020-02-03 16:52+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion compsciclub_ru/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 09:52+0000\n"
"POT-Creation-Date: 2024-09-16 15:19+0000\n"
"PO-Revision-Date: 2020-09-09 04:43+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
13 changes: 6 additions & 7 deletions lms/jinja2/lms/gradebook/gradebook_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ <h2>
{% endfor %}
</ul>
</div>
<br>
<h2>
<div class="small" style="margin-top: 10px;">{% trans %}Students and listeners{% endtrans %}:&nbsp;{{
gradebook.course.learners_count + gradebook.course.listeners_count }}</div>
</h2>
</div>
<hr>
</div>
Expand Down Expand Up @@ -150,7 +145,7 @@ <h2>
</a>
<div class="cell __study_year {{ loop.cycle('', 'even') }}">
{% if gradebook_student.student_profile.year_of_curriculum %}
{{ gradebook_student.student_profile.year_of_curriculum }}
{{ gradebook_student.year_of_curriculum }}
{% endif %}
</div>
<div class="cell __final_grade {{ loop.cycle('', 'even') }}">
Expand Down Expand Up @@ -178,7 +173,11 @@ <h2>
</div>

<div class="meta">
<div class="cell __student gray">{% trans %}Students{% endtrans %}:&nbsp;{{ gradebook.students|length }}</div>
<div class="cell __student gray">
{% trans %}Learners{% endtrans %}:&nbsp;{{ total_learners }}<br>
{% trans %}Listeners{% endtrans %}:&nbsp;{{ total_listeners }}<br>
{% trans %}Total students{% endtrans %}:&nbsp;{{ total_listeners + total_learners }}
</div>
<div class="cell __final_grade"></div>
<div class="cell __study_year"></div>
{% if gradebook.assignments %}
Expand Down
Loading

0 comments on commit 389d4b4

Please sign in to comment.