From cfb83dfd6ce7a669067b642a5e89a783c2e4fade Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Thu, 1 Aug 2024 16:40:50 +0530 Subject: [PATCH] feat: add cut-off score to test score slide --- multi_problem_xblock/multi_problem_xblock.py | 7 +++++++ .../public/css/multi_problem_xblock.css | 4 ++++ .../html/multi_problem_xblock_test_scores.html | 10 +++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/multi_problem_xblock/multi_problem_xblock.py b/multi_problem_xblock/multi_problem_xblock.py index fba8f7d..4c495d3 100644 --- a/multi_problem_xblock/multi_problem_xblock.py +++ b/multi_problem_xblock/multi_problem_xblock.py @@ -4,6 +4,7 @@ import json import logging +import math from copy import copy from lxml import etree @@ -273,20 +274,26 @@ def get_test_scores(self, _data, _suffix): if completed_problems != total_problems and total_problems > 0: return Response(_('All problems need to be completed before checking test results!'), status=400) question_answers, student_score, total_possible_score = self._prepare_user_score(include_question_answers=True) + passed = False if self.score_display_format == SCORE_DISPLAY_FORMAT.X_OUT_OF_Y: score_display = f'{student_score}/{total_possible_score}' + cut_off_score = f'{math.ceil(self.cut_off_score * total_possible_score)}/{total_possible_score}' else: score_display = f'{(student_score / total_possible_score):.0%}' + cut_off_score = f'{self.cut_off_score:.0%}' if (student_score / total_possible_score) >= self.cut_off_score: self.publish_completion(1) + passed = True template = loader.render_django_template( '/templates/html/multi_problem_xblock_test_scores.html', { + 'cut_off_score': cut_off_score if self.cut_off_score else '', 'question_answers': question_answers, 'score': score_display, + 'passed': passed, }, ) return Response(template, content_type='text/html') diff --git a/multi_problem_xblock/public/css/multi_problem_xblock.css b/multi_problem_xblock/public/css/multi_problem_xblock.css index 6621911..2480126 100644 --- a/multi_problem_xblock/public/css/multi_problem_xblock.css +++ b/multi_problem_xblock/public/css/multi_problem_xblock.css @@ -132,6 +132,10 @@ margin-right: 10px; } +.multi-problem-test-results .text-red { + color: #b4131b; +} + .multi-problem-test-results .accordion.correct:after { content: var(--correct-svg); margin-left: auto; diff --git a/multi_problem_xblock/templates/html/multi_problem_xblock_test_scores.html b/multi_problem_xblock/templates/html/multi_problem_xblock_test_scores.html index d61c98f..49cdef7 100644 --- a/multi_problem_xblock/templates/html/multi_problem_xblock_test_scores.html +++ b/multi_problem_xblock/templates/html/multi_problem_xblock_test_scores.html @@ -51,7 +51,15 @@

{% trans 'Test score' %}

{% endfor %}
{% trans 'Test Score' %} - {{ score }} + {% if cut_off_score != '' %}1{% endif %} + {{ score }}
+ {% if cut_off_score != '' %} + + 1 + {% trans 'Minimum score required for this to be marked as complete: ' %} + {{ cut_off_score }} + + {% endif %}