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

Fix Clear UI with correct answers #35

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 4 additions & 6 deletions courses/templates/homework/homework.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ <h3 class="mb-3">Questions</h3>
<p class="question-text">
Question {{ forloop.counter }}.
{{ question.text }}
{% if question.scores_for_correct_answer > 1 %}
<span class="text-muted">({{ question.scores_for_correct_answer }} points)</span>
{% else %}
<span class="text-muted">({{ question.scores_for_correct_answer }} point)</span>
{% endif %}
<span class="text-muted">({{ question.scores_for_correct_answer|pluralize }} point)</span>
</p>

{% if is_authenticated and disabled and question.question_type == 'MC' and not answer.is_answered%}
<p style="background-color: #FFF3CD;">Question not answered</p>
{% endif %}
{% if question.question_type == 'MC' %}
{% for option in answer.options %}
<div class="form-check {{ option.correctly_selected_class }}">
Expand Down
5 changes: 3 additions & 2 deletions courses/views/homework.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def process_question_options_multiple_choice_or_checkboxes(
if homework.is_scored:
correct_indices = question.get_correct_answer_indices()

is_answered = True if len(selected_options) > 0 else False
for zero_based_index, option in enumerate(possible_answers):
index = zero_based_index + 1
is_selected = index in selected_options
Expand All @@ -93,7 +94,7 @@ def process_question_options_multiple_choice_or_checkboxes(

options.append(processed_answer)

return {"options": options}
return {"options": options, "is_answered": is_answered}


def extract_selected_options(answer):
Expand Down Expand Up @@ -125,7 +126,7 @@ def extract_selected_options(answer):
def determine_answer_class(is_selected: bool, is_correct: bool) -> str:
if is_selected and is_correct:
return "option-answer-correct"
if not is_selected and is_correct:
if not is_selected and is_correct:
return "option-answer-correct"
if is_selected and not is_correct:
return "option-answer-incorrect"
Expand Down