Enhance shorts exam functionality by adding history tracking and updating feedback display in exam scores template
This commit is contained in:
+2
-2
@@ -2296,7 +2296,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
ans = user_answer.get_answer()
|
||||
answer_score = user_answer.get_answer_score()
|
||||
|
||||
if self.app_name == "longs":
|
||||
if self.app_name in ("longs", "shorts"):
|
||||
feedback = user_answer.candidate_feedback
|
||||
|
||||
match self.app_name:
|
||||
@@ -2336,7 +2336,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
answers.append(ans)
|
||||
answers_marks.append(answer_score)
|
||||
|
||||
if self.app_name == "longs":
|
||||
if self.app_name in ("longs", "shorts"):
|
||||
answers_and_marks.append(
|
||||
(ans, answer_score, correct_answer, feedback)
|
||||
)
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ class Question(QuestionBase):
|
||||
based: bool = True,
|
||||
feedback: bool = False,
|
||||
answers: bool = True,
|
||||
history: bool = False,
|
||||
history: bool = True,
|
||||
annotations: bool = False,
|
||||
) -> QuestionData:
|
||||
"""Returns a json representation of the question"""
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
Question <span class="question-number">1</span>
|
||||
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
|
||||
</div>
|
||||
<div class="feedback"></div>
|
||||
<div class="history"></div>
|
||||
<div>
|
||||
<details>
|
||||
<summary>Sample Answers:</summary>
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="shorts">
|
||||
{% include 'user_score_header.html' %}
|
||||
<ul class="score-answer-list">
|
||||
{% for ans, score, correct_answer in answers_and_marks %}
|
||||
{% for ans, score, correct_answer, feedback in answers_and_marks %}
|
||||
<li class="user-answer-li" data-question-number="{{forloop.counter}}">Question {{forloop.counter}} - Correct answer: {% if exam.publish_results %}<span class="correct-answer">{{correct_answer}}</span>{% endif %}
|
||||
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
|
||||
<br/>
|
||||
@@ -28,8 +28,11 @@
|
||||
<span class="submitted-user-answer">
|
||||
<pre>{{ans}}</pre>
|
||||
</span>
|
||||
{% if exam.publish_results or view_all_results%}
|
||||
{% if exam.publish_results or view_all_results %}
|
||||
<span class="answer-score">Score: {{score}}</span>
|
||||
{% if feedback %}
|
||||
<span class="answer-feedback badge badge-secondary" style="margin-left:10px;">Feedback: {{ feedback }}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
</li>
|
||||
@@ -73,7 +76,15 @@
|
||||
"detail": { "images": images, "annotations": data.annotations }
|
||||
});
|
||||
|
||||
window.dispatchEvent(event);
|
||||
if (!images || images.length === 0) {
|
||||
$("#single-dicom-viewer").html("<p>No images for this question</p>");
|
||||
} else{
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
|
||||
if (data.history) {
|
||||
$(".question-display-block .history").empty().append(`History:<pre>${data.history}</pre>`);
|
||||
}
|
||||
console.log(data)
|
||||
if (data.answers && data.answers.length > 0) {
|
||||
// Format: [[answer, score], ...]
|
||||
@@ -86,7 +97,6 @@
|
||||
}
|
||||
n = parseInt(question_number) + 1
|
||||
$(".question-display-block .question-number").empty().append(n);
|
||||
$(".question-display-block .feedback").empty().append(`Feedback: ${data.feedback}<br />`);
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
$(".inner-display-block").show();
|
||||
|
||||
Reference in New Issue
Block a user