strat tidying up anatomy question form
This commit is contained in:
+15
-4
@@ -33,6 +33,9 @@ from dal import autocomplete
|
||||
|
||||
from tinymce.widgets import TinyMCE
|
||||
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Submit
|
||||
|
||||
class AnatomyAnswerForm(ModelForm):
|
||||
class Meta:
|
||||
model = UserAnswer
|
||||
@@ -76,6 +79,14 @@ class AnatomyQuestionForm(ModelForm):
|
||||
ModelForm.__init__(self, *args, **kwargs)
|
||||
|
||||
super(AnatomyQuestionForm, self).__init__(*args, **kwargs)
|
||||
|
||||
self.helper = FormHelper()
|
||||
self.helper.form_id = 'id-anatomy-question-form'
|
||||
#self.helper.form_class = 'blueForms'
|
||||
#self.helper.form_method = 'post'
|
||||
#self.helper.form_action = ''
|
||||
|
||||
#self.helper.add_input(Submit('submit', 'Submit'))
|
||||
# self.fields['question'].widget.attrs = {'class': 'question-form', 'rows': 10, 'cols': 100}
|
||||
# self.fields['feedback'].widget.attrs = {'class': 'feedback-form', 'rows': 10, 'cols': 100}
|
||||
self.fields["question_type"] = ModelChoiceField(
|
||||
@@ -145,15 +156,15 @@ class AnatomyQuestionForm(ModelForm):
|
||||
fields = [
|
||||
"question_type",
|
||||
"image",
|
||||
"answer_help",
|
||||
"answer_suggest_incorrect",
|
||||
"region",
|
||||
"description",
|
||||
"modality",
|
||||
"region",
|
||||
"structure",
|
||||
"feedback",
|
||||
"examination",
|
||||
"body_part",
|
||||
"description",
|
||||
"answer_help",
|
||||
"answer_suggest_incorrect",
|
||||
"open_access",
|
||||
]
|
||||
|
||||
|
||||
+4
-4
@@ -72,12 +72,12 @@ class QuestionType(models.Model):
|
||||
@reversion.register
|
||||
class AnatomyQuestion(QuestionBase):
|
||||
question_type = models.ForeignKey(
|
||||
QuestionType, on_delete=models.SET_NULL, null=True, default=1
|
||||
QuestionType, on_delete=models.SET_NULL, null=True, default=1, help_text="Type of question, this is the question text that will be displayed to the user."
|
||||
)
|
||||
|
||||
image = models.ImageField(
|
||||
upload_to=image_directory_path,
|
||||
help_text="The image to use for the question. Ideally use use unmarked images and annotate (arrow) them on the test system. If you wish to reuse an image that is already uploaded 'clone' the question that contains it.",
|
||||
help_text="The image to use for the question. Ideally use unmarked images and annotate (arrow) them on the test system. If you wish to reuse an image that is already uploaded 'clone' the question that contains it.",
|
||||
)
|
||||
|
||||
image_annotations = models.TextField(
|
||||
@@ -90,9 +90,9 @@ class AnatomyQuestion(QuestionBase):
|
||||
help_text="Short description of the image e.g. 'Sagittal CT Chest, Abdomen & Pelvis', will be displayed as the title.",
|
||||
)
|
||||
|
||||
answer_help = models.TextField(default="", blank=True, null=True, help_text="Helpful information for marking")
|
||||
answer_help = models.TextField(default="", blank=True, null=True, help_text="Helpful information for marking, this will not be displayed to the user taking the exam.")
|
||||
|
||||
answer_suggest_incorrect = ArrayField(models.CharField(max_length=255, null=True), default=list, blank=True)
|
||||
answer_suggest_incorrect = ArrayField(models.CharField(max_length=255, null=True), default=list, blank=True, help_text="An array that defines text that if found in the answer is likely incorrect. This is used to aid marking")
|
||||
|
||||
examination = models.ForeignKey(
|
||||
Examination, on_delete=models.SET_NULL, null=True, blank=True
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
{% extends "anatomy/base.html" %}
|
||||
|
||||
{% load static %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block title %}
|
||||
Anatomy
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block js %}
|
||||
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
|
||||
@@ -220,6 +226,12 @@
|
||||
{% endif %}
|
||||
|
||||
<h2>{{object|yesno:"Update,Create"}} Question</h2>
|
||||
<details class="help-text">
|
||||
<summary><i class="bi bi-info-circle"></i> Help</summary>
|
||||
<p>This form can be used to create an Anatomy question.</p>
|
||||
|
||||
<p>Question type can be selected from a predefined list. If you require a more please contact ross.kruger@nhs.net.</p>
|
||||
</details>
|
||||
<form action="" method="post" enctype="multipart/form-data" id="anatomyquestion-form">
|
||||
{% csrf_token %}
|
||||
<a href="/anatomy/examination/create" id="add_examination" class="add-popup"
|
||||
@@ -227,9 +239,7 @@
|
||||
<a href="/anatomy/body_part/create" id="add_body_part" class="add-popup"
|
||||
onclick="return showAddPopup(this);"><img src="{% static '/img/icon-addlink.svg' %}"></a>
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{{ form|crispy }}
|
||||
<div id="drop-container" class="drop-target">Drop image here
|
||||
<div id="drop-filenames"></div>
|
||||
</div>
|
||||
|
||||
+4
-1
@@ -494,6 +494,7 @@ class AnatomyQuestionCreateBase(RevisionMixin, LoginRequiredMixin, CreateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AnatomyQuestionCreateBase, self).get_context_data(**kwargs)
|
||||
context["question"] = context["object"]
|
||||
if self.request.POST:
|
||||
context["answer_formset"] = AnswerFormSet(
|
||||
self.request.POST, self.request.FILES
|
||||
@@ -526,6 +527,9 @@ class AnatomyQuestionCreateBase(RevisionMixin, LoginRequiredMixin, CreateView):
|
||||
else:
|
||||
return super().form_invalid(form)
|
||||
|
||||
def get_success_url(self) -> str:
|
||||
return redirect("anatomy:question_detail", pk=self.object.pk)
|
||||
|
||||
|
||||
class AnatomyQuestionCreate(AnatomyQuestionCreateBase):
|
||||
|
||||
@@ -540,7 +544,6 @@ class AnatomyQuestionCreate(AnatomyQuestionCreateBase):
|
||||
|
||||
return initial
|
||||
|
||||
|
||||
# # There has to be a better way...
|
||||
# try:
|
||||
# s = (i.pk for i in self.request.user.AnatomyQuestion_default.site.all())
|
||||
|
||||
@@ -78,9 +78,6 @@ class FirstImageColumn(tables.Column):
|
||||
|
||||
|
||||
class CidUserTable(tables.Table):
|
||||
# edit = tables.LinkColumn(
|
||||
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||
# )
|
||||
cid = tables.LinkColumn(
|
||||
"cid_scores", args=[A("cid"), A("passcode")], orderable=True
|
||||
)
|
||||
@@ -129,9 +126,6 @@ class CidUserTable(tables.Table):
|
||||
|
||||
|
||||
class CidUserExamTable(tables.Table):
|
||||
# edit = tables.LinkColumn(
|
||||
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||
# )
|
||||
cid = tables.LinkColumn(
|
||||
"cid_scores", args=[A("cid"), A("passcode")], orderable=True
|
||||
)
|
||||
@@ -189,9 +183,6 @@ class CidUserExamTable(tables.Table):
|
||||
|
||||
|
||||
class UserUserTable(tables.Table):
|
||||
# edit = tables.LinkColumn(
|
||||
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||
# )
|
||||
|
||||
user = tables.Column(
|
||||
linkify={"viewname": "account_profile", "args": [A("username")]},
|
||||
|
||||
@@ -1287,4 +1287,20 @@ tr:has(> td > a) {
|
||||
/* For crispy... */
|
||||
.select2-selection {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
.help-text, .help-text summary {
|
||||
cursor: help !important;
|
||||
}
|
||||
|
||||
details.help-text > summary {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* .selector, .selector-available, .selector-chosen {
|
||||
display: inline-block;
|
||||
} */
|
||||
|
||||
#div_id_exams {
|
||||
display: inline-block;
|
||||
}
|
||||
@@ -24,9 +24,6 @@ urlpatterns = [
|
||||
views.QuestionDelete.as_view(),
|
||||
name="question_delete",
|
||||
),
|
||||
# path("question/<int:pk>/update", views.QuestionUpdate.as_view(), name="anatomy_question_update"),
|
||||
# path("exam/<int:pk>/<int:sk>/mark", views.mark, name="mark"),
|
||||
# path("exam/<int:pk>/mark", views.mark_overview, name="mark_overview"),
|
||||
path(
|
||||
"exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/take",
|
||||
views.exam_take,
|
||||
|
||||
Reference in New Issue
Block a user