Change threshold to raw points and add custom points per question
This commit is contained in:
@@ -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:
|
||||
|
||||
+4
-4
@@ -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}')
|
||||
|
||||
Reference in New Issue
Block a user