Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default_grade to Course #839

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-04-28 13:26+0000\n"
"POT-Creation-Date: 2024-05-21 12:53+0000\n"
"PO-Revision-Date: 2024-04-11 19:46+0000\n"
"Last-Translator: Дмитрий Чернушевич <dmi4er4@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
7 changes: 6 additions & 1 deletion apps/courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,13 @@ class Course(TimezoneAwareMixin, TimeStampedModel, DerivableFieldsMixin):
verbose_name=_("Duration"),
max_length=10, db_index=True,
help_text=_("Duration of course"),
choices=CourseDurations,
choices=CourseDurations.choices,
default=CourseDurations.FULL)
default_grade = models.CharField(
verbose_name=_("Enrollment|default_grade"),
max_length=100,
choices=GradeTypes.default_grades,
default=GradeTypes.NOT_GRADED)
completed_at = models.DateField(
_("Date of completion"),
blank=True,
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-04-28 13:26+0000\n"
"POT-Creation-Date: 2024-05-21 12:53+0000\n"
"PO-Revision-Date: 2015-03-18 08:34+0000\n"
"Last-Translator: Jannis Leidel <jannis@leidel.info>\n"
"Language-Team: Russian (http://www.transifex.com/projects/p/django/language/"
Expand Down
9 changes: 9 additions & 0 deletions apps/learning/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,25 @@ class EnrollmentAdmin(BaseModelAdmin):
]
search_fields = ['course__meta_course__name', 'student__last_name']
exclude = ['grade_changed']
exclude_create = ['grade']
raw_id_fields = ("student", "course", "invitation", "student_profile",
"student_group")
inlines = [EnrollmentGradeLogAdminInline]


def get_readonly_fields(self, request, obj=None):
if obj:
return ['course', 'student', 'grade_changed_local', 'modified']
else:
return ['grade_changed_local', 'modified']

def get_fields(self, request, obj=None):
fields = super().get_fields(request, obj)
if obj is None:
return [field for field in fields if field not in self.exclude_create]
else:
return fields

def grade_changed_local(self, obj):
return admin_datetime(obj.grade_changed_local())
grade_changed_local.admin_order_field = 'grade_changed'
Expand Down
3 changes: 3 additions & 0 deletions apps/learning/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ def __str__(self):

def save(self, *args, **kwargs):
created = self.pk is None
if created and self.course is not None:
self.grade = self.course.default_grade

super().save(*args, **kwargs)

def clean(self):
Expand Down
6 changes: 5 additions & 1 deletion apps/learning/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class GradingSystems(DjangoChoices):

class GradeTypes(DjangoChoices):
"""
Used as grade choices for the Enrollment model.
Used as grade choices for the Enrollment model and as default_grade choices for Course model.
"""
NOT_GRADED = C('not_graded', _("Not graded"), system='__all__',
russian_label="Без оценки", order=0)
Expand Down Expand Up @@ -109,6 +109,10 @@ class GradeTypes(DjangoChoices):
FOUR.value, FIVE.value, SIX.value, SEVEN.value, EIGHT.value, NINE.value, TEN.value}
unsatisfactory_grades = {NOT_GRADED.value, UNSATISFACTORY.value, WITHOUT_GRADE.value,
ONE.value, TWO.value, THREE.value}
default_grades = {
(NOT_GRADED.value, NOT_GRADED.label),
(WITHOUT_GRADE.value, WITHOUT_GRADE.label),
}

@classmethod
def is_suitable_for_grading_system(cls, choice, grading_system):
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-04-28 13:26+0000\n"
"POT-Creation-Date: 2024-05-21 12:53+0000\n"
"PO-Revision-Date: 2022-02-21 15:24+0000\n"
"Last-Translator: Сергей Жеревчук <pacabest@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\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-04-28 13:26+0000\n"
"POT-Creation-Date: 2024-05-21 12:53+0000\n"
"PO-Revision-Date: 2019-10-31 16:30+0000\n"
"Last-Translator: b' <pacabest@gmail.com>'\n"
"Language-Team: LANGUAGE <LL@li.org>\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-04-28 13:26+0000\n"
"POT-Creation-Date: 2024-05-21 12:53+0000\n"
"PO-Revision-Date: 2020-02-03 16:52+0000\n"
"Last-Translator: b' <pacabest@gmail.com>'\n"
"Language-Team: LANGUAGE <LL@li.org>\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-04-28 13:26+0000\n"
"POT-Creation-Date: 2024-05-21 12:53+0000\n"
"PO-Revision-Date: 2020-09-09 04:43+0000\n"
"Last-Translator: b' <pacabest@gmail.com>'\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
Loading