numerous improvements

This commit is contained in:
Ross
2020-12-05 18:10:51 +00:00
parent 45e038ccd6
commit a3bf73059c
5 changed files with 45 additions and 10 deletions
+4 -4
View File
@@ -99,8 +99,8 @@ class AnatomyQuestion(models.Model):
def __str__(self):
# Get first answer
a = self.answers.all().first()
return "{} [{}, {}]".format(self.GetPrimaryAnswer(), self.modality,
self.structure)
# Get associated exams
e = self.exams.all().values_list("name", flat=True)
exams = ", ".join(e)
@@ -253,7 +253,7 @@ class UserAnswer(models.Model):
exam = self.exam
except (Exam.DoesNotExist, KeyError) as e:
exam = "None"
return "{}/{}/{}: {}".format(exam, self.cid, self.question.id,
return "{}/{}/{}: {}".format(exam, self.cid, self.question.GetPrimaryAnswer(),
self.answer)
def clean(self):
@@ -284,7 +284,7 @@ class CidUserAnswer(models.Model):
exam = self.exam
except (Exam.DoesNotExist, KeyError) as e:
exam = "None"
return "{}/{}/{}: {}".format(exam, self.cid, self.question.id,
return "{}/{}/{}: {}".format(exam, self.cid, self.question.GetPrimaryAnswer(),
self.answer)
def clean(self):
+29 -1
View File
@@ -64,9 +64,31 @@ a, a:link {
.not-flagged {
}
button {
text-decoration: none;
display:inline-block;
padding:0.35em 1.2em;
border:0.1em solid #52057b;
margin:0 0.3em 0.3em 0;
border-radius:0.12em;
box-sizing: border-box;
text-decoration:none;
font-family:'Roboto',sans-serif;
font-weight:300;
color:#a600ff;
text-align:center;
transition: all 0.2s;
background-color: transparent;
}
button:hover{
color:white;
background-color:#52057b;
}
button a {
text-decoration: none;
color: green;
color: inherit;
}
#admin-link {
@@ -123,4 +145,10 @@ button a {
#question-mark-list li {
padding-bottom: 5px;
}
#start-marking-button {
float: right;
position: sticky;
top: 30px;
}
+2 -2
View File
@@ -10,7 +10,7 @@
<div title="Click to enable / disable the exam">
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}>
</div>
<p><button><a href="{% url 'anatomy:mark_overview' pk=exam.pk %}">Mark exam</a></button></p>
<p><a href="{% url 'anatomy:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
<!--<p><button><a href="{% url 'anatomy:exam_take' pk=exam.pk sk=0 %}">Click here to start</a></button></p>-->
<ol>
@@ -18,7 +18,7 @@ Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}
<li>{{ question.description }}: {{ question.GetPrimaryAnswer }}<img src="{{ question.image|thumbnail_url:'exam-list' }}" alt="thumbail" />
<br />
Exams: {{ question.GetExams }} / Modality: {{ question.modality }}
Modality: {{ question.modality }}
</li>
{% endfor %}
</ol>
+1 -1
View File
@@ -8,6 +8,7 @@
<div>
<button class="show-all-button">Show all</button><button class="show-unmarked-button">Show unmarked</button>
</div>
<div id="stark-marking-button"><a href="{% url 'anatomy:mark' pk=exam.pk sk=0 %}"><button>Click here to start marking</button></a></div>
<ul id="question-mark-list">
{% for question in questions.all %}
@@ -15,6 +16,5 @@
{{ question }}</a><br /> {{ question.GetUnmarkedAnswersString }}</li>
{% endfor %}
</ul>
<p><button><a href="{% url 'anatomy:mark' pk=exam.pk sk=0 %}">Click here to start marking</a></button></p>
</div>
{% endblock %}
+9 -2
View File
@@ -261,21 +261,28 @@ def loadJsonAnswer(answer):
ans.answer = answer["ans"]
ans.save()
return True
@csrf_exempt
def postExamAnswers(request):
if request.is_ajax and request.method == "POST":
n = 0
# horrible but it works
for k in request.POST.dict():
print(k)
for answer in json.loads(k):
loadJsonAnswer(answer)
ret = loadJsonAnswer(answer)
if ret is not True:
return ret
n = n + 1
# print(UserAnswer.objects.filter(exam__id=q["eid"]))
# print(request.urlencode())
return JsonResponse({"success": True})
return JsonResponse({"success": True, "question-number": n})
return JsonResponse({"success": False, "error": "Invalid data"})
# return render(request, "anatomy/exam.html", {"exam" : exam, "question" : question})