add suggested answers to anatomy
This commit is contained in:
@@ -7,6 +7,8 @@ from django.forms import (
|
||||
CharField,
|
||||
)
|
||||
from django.forms import inlineformset_factory
|
||||
from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField , SplitArrayWidget
|
||||
|
||||
|
||||
from generic.forms import ExamAuthorFormMixin, ExamFormMixin
|
||||
|
||||
@@ -102,6 +104,8 @@ class AnatomyQuestionForm(ModelForm):
|
||||
queryset=BodyPart.objects.all(),
|
||||
)
|
||||
|
||||
self.fields["answer_suggest_incorrect"] = CharField(max_length=255, required=False)
|
||||
|
||||
if self.user.groups.filter(name="anatomy_checker").exists():
|
||||
exam_queryset = Exam.objects.all()
|
||||
else:
|
||||
@@ -142,6 +146,7 @@ class AnatomyQuestionForm(ModelForm):
|
||||
"question_type",
|
||||
"image",
|
||||
"answer_help",
|
||||
"answer_suggest_incorrect",
|
||||
"region",
|
||||
"modality",
|
||||
"structure",
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.1.4 on 2024-01-11 21:41
|
||||
|
||||
import django.contrib.postgres.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('anatomy', '0008_alter_anatomyquestion_answer_help'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='anatomyquestion',
|
||||
name='answer_suggest_incorrect',
|
||||
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=255), default=list, size=None),
|
||||
),
|
||||
]
|
||||
@@ -3,6 +3,7 @@ import json
|
||||
from django.contrib.contenttypes.fields import GenericRelation
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.conf import settings
|
||||
@@ -93,6 +94,8 @@ class AnatomyQuestion(QuestionBase):
|
||||
|
||||
answer_help = models.TextField(default="", blank=True, null=True, help_text="Helpful information for marking")
|
||||
|
||||
answer_suggest_incorrect = ArrayField(models.CharField(max_length=255), default=list)
|
||||
|
||||
examination = models.ForeignKey(
|
||||
Examination, on_delete=models.SET_NULL, null=True, blank=True
|
||||
)
|
||||
|
||||
@@ -23,7 +23,12 @@
|
||||
Unmarked:
|
||||
<ul id="new-answer-list" class="answer-list">
|
||||
{% for answer in user_answers %}
|
||||
<li><pre><span class="answer not-marked" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||
|
||||
{% if answer in answer_suggest_incorrect %}
|
||||
<li><pre><span class="answer incorrect suggest" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||
{% else %}
|
||||
<li><pre><span class="answer not-marked" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
Marked:
|
||||
@@ -112,6 +117,9 @@
|
||||
|
||||
{% block css %}
|
||||
<style>
|
||||
.suggest {
|
||||
border: 1px dashed;
|
||||
}
|
||||
#primary-answer {
|
||||
font-weight: strong;
|
||||
color: white;
|
||||
|
||||
@@ -62,6 +62,9 @@
|
||||
<div>
|
||||
Answer help: {{ question.answer_help|safe }}
|
||||
</div>
|
||||
<div>
|
||||
Answer suggest incorrect: {{ question.answer_suggest_incorrect }}
|
||||
</div>
|
||||
<div>
|
||||
Description: {{ question.description }}
|
||||
</div>
|
||||
|
||||
@@ -337,6 +337,7 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
||||
half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
|
||||
incorrect_answers = question.answers.filter(status=Answer.MarkOptions.INCORRECT)
|
||||
|
||||
answer_suggest_incorrect: list = []
|
||||
if review:
|
||||
for ans in unmarked_user_answers:
|
||||
# duplicated from user answer model....
|
||||
@@ -352,6 +353,11 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
||||
if mark == "unmarked":
|
||||
unmarked_answers_bool = True
|
||||
review_user_answers.append((ans, mark))
|
||||
else:
|
||||
for ans in unmarked_user_answers:
|
||||
for suggest_incorrect in question.answer_suggest_incorrect:
|
||||
if suggest_incorrect in ans:
|
||||
answer_suggest_incorrect.append(ans)
|
||||
|
||||
return render(
|
||||
request,
|
||||
@@ -370,6 +376,7 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
||||
"half_mark_answers": half_mark_answers,
|
||||
"incorrect_answers": incorrect_answers,
|
||||
"unmarked_exam_answers_only": unmarked_exam_answers_only,
|
||||
"answer_suggest_incorrect": answer_suggest_incorrect,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user