From d7e1364426e440f584feeab35e0b6f9f31586683 Mon Sep 17 00:00:00 2001 From: Dmitry Belan Date: Mon, 28 Sep 2026 23:41:58 +0300 Subject: [PATCH] Change threshold to raw points and add custom points per question --- lmsege/lms/models.py | 11 +++++------ lmsege/lms/views.py | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lmsege/lms/models.py b/lmsege/lms/models.py index 27e813e..bfab799 100644 --- a/lmsege/lms/models.py +++ b/lmsege/lms/models.py @@ -26,7 +26,7 @@ class Assignment(models.Model): deadline = models.DateTimeField('Дедлайн', blank=True, null=True, help_text='После этого времени ответы не принимаются.') time_limit = models.PositiveIntegerField('Лимит времени (минуты)', blank=True, null=True, help_text='Например, 235 для 3ч 55м. Оставьте пустым, если без таймера.') allow_late_submissions = models.BooleanField('Разрешить дорешивание', default=True, help_text='Если включено, ученики смогут сдавать задание после дедлайна с пометкой "После дедлайна".') - passing_threshold = models.PositiveIntegerField('Порог прохождения (%)', default=1, help_text='Процент выполнения, необходимый для прохождения. Например, 1.') + passing_threshold = models.PositiveIntegerField('Порог прохождения (в баллах)', default=10, help_text='Количество баллов, необходимое для прохождения. Например, 10.') class Meta: verbose_name = 'Задание' @@ -47,6 +47,7 @@ class Question(models.Model): question_type = models.CharField('Тип ответа', max_length=20, choices=TYPE_CHOICES, default='TEXT_AUTO') table_rows = models.PositiveIntegerField('Количество строк в таблице', default=2, blank=True, null=True, help_text='Укажите количество строк. Столбцов всегда 2.') correct_answer = models.CharField('Правильный ответ (для автопроверки)', max_length=255, blank=True, null=True, help_text='Оставьте пустым для ручной проверки. Для таблицы вводите ответы в формате "Ответ1|Ответ2;Ответ3|Ответ4" (строки через точку с запятой, столбцы через прямую черту).') + points = models.PositiveIntegerField('Баллы за правильный ответ', default=1, help_text='Количество баллов, которое дается за эту задачу (для автопроверки).') order = models.PositiveIntegerField('Порядок', default=0) class Meta: @@ -90,12 +91,11 @@ class Submission(models.Model): total = float(parts[1].strip()) percentage = (earned / total) * 100 if total > 0 else 0 - threshold_percent = self.assignment.passing_threshold - is_passed = percentage >= threshold_percent + threshold_points = self.assignment.passing_threshold + is_passed = earned >= threshold_points total_int = int(total) if total.is_integer() else total earned_int = int(earned) if earned.is_integer() else earned - threshold_points = int(total * (threshold_percent / 100.0)) return { 'earned': earned_int, @@ -103,9 +103,8 @@ class Submission(models.Model): 'percentage': percentage, 'percentage_str': f"{percentage:.1f}", 'is_passed': is_passed, - 'threshold_percent': threshold_percent, 'threshold_points': threshold_points, - 'threshold_text': 'Выше порога' if is_passed else f'Ниже порога (Мин: {threshold_percent}%)', + 'threshold_text': 'Выше порога' if is_passed else f'Ниже порога (Мин: {threshold_points} б)', 'color': '#2ea043' if is_passed else '#f85149' } except Exception: diff --git a/lmsege/lms/views.py b/lmsege/lms/views.py index 44c531f..538ddd0 100644 --- a/lmsege/lms/views.py +++ b/lmsege/lms/views.py @@ -142,11 +142,11 @@ def assignment_detail(request, pk): if q.correct_answer: correct = strip_tags(q.correct_answer).strip().lower() answer_obj.is_correct = (val.strip().lower() == correct) - answer_obj.points = 1 if answer_obj.is_correct else 0 + answer_obj.points = q.points if answer_obj.is_correct else 0 total_points += answer_obj.points else: all_auto = False - max_points += 1 + max_points += q.points elif q.question_type == 'TABLE_AUTO': rows = getattr(q, 'table_rows', 2) or 2 table_data = [] @@ -171,11 +171,11 @@ def assignment_detail(request, pk): is_correct = False break answer_obj.is_correct = is_correct - answer_obj.points = 1 if is_correct else 0 + answer_obj.points = q.points if is_correct else 0 total_points += answer_obj.points else: all_auto = False - max_points += 1 + max_points += q.points else: all_auto = False val = form.cleaned_data.get(f'file_{q.id}')