numerous improvements
This commit is contained in:
+4
-4
@@ -99,8 +99,8 @@ class AnatomyQuestion(models.Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# Get first answer
|
# Get first answer
|
||||||
a = self.answers.all().first()
|
return "{} [{}, {}]".format(self.GetPrimaryAnswer(), self.modality,
|
||||||
|
self.structure)
|
||||||
# Get associated exams
|
# Get associated exams
|
||||||
e = self.exams.all().values_list("name", flat=True)
|
e = self.exams.all().values_list("name", flat=True)
|
||||||
exams = ", ".join(e)
|
exams = ", ".join(e)
|
||||||
@@ -253,7 +253,7 @@ class UserAnswer(models.Model):
|
|||||||
exam = self.exam
|
exam = self.exam
|
||||||
except (Exam.DoesNotExist, KeyError) as e:
|
except (Exam.DoesNotExist, KeyError) as e:
|
||||||
exam = "None"
|
exam = "None"
|
||||||
return "{}/{}/{}: {}".format(exam, self.cid, self.question.id,
|
return "{}/{}/{}: {}".format(exam, self.cid, self.question.GetPrimaryAnswer(),
|
||||||
self.answer)
|
self.answer)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@@ -284,7 +284,7 @@ class CidUserAnswer(models.Model):
|
|||||||
exam = self.exam
|
exam = self.exam
|
||||||
except (Exam.DoesNotExist, KeyError) as e:
|
except (Exam.DoesNotExist, KeyError) as e:
|
||||||
exam = "None"
|
exam = "None"
|
||||||
return "{}/{}/{}: {}".format(exam, self.cid, self.question.id,
|
return "{}/{}/{}: {}".format(exam, self.cid, self.question.GetPrimaryAnswer(),
|
||||||
self.answer)
|
self.answer)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|||||||
@@ -64,9 +64,31 @@ a, a:link {
|
|||||||
.not-flagged {
|
.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 {
|
button a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: green;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#admin-link {
|
#admin-link {
|
||||||
@@ -124,3 +146,9 @@ button a {
|
|||||||
#question-mark-list li {
|
#question-mark-list li {
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#start-marking-button {
|
||||||
|
float: right;
|
||||||
|
position: sticky;
|
||||||
|
top: 30px;
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<div title="Click to enable / disable the exam">
|
<div title="Click to enable / disable the exam">
|
||||||
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}>
|
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}>
|
||||||
</div>
|
</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>-->
|
<!--<p><button><a href="{% url 'anatomy:exam_take' pk=exam.pk sk=0 %}">Click here to start</a></button></p>-->
|
||||||
|
|
||||||
<ol>
|
<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" />
|
<li>{{ question.description }}: {{ question.GetPrimaryAnswer }}<img src="{{ question.image|thumbnail_url:'exam-list' }}" alt="thumbail" />
|
||||||
<br />
|
<br />
|
||||||
Exams: {{ question.GetExams }} / Modality: {{ question.modality }}
|
Modality: {{ question.modality }}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<button class="show-all-button">Show all</button><button class="show-unmarked-button">Show unmarked</button>
|
<button class="show-all-button">Show all</button><button class="show-unmarked-button">Show unmarked</button>
|
||||||
</div>
|
</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">
|
<ul id="question-mark-list">
|
||||||
{% for question in questions.all %}
|
{% for question in questions.all %}
|
||||||
@@ -15,6 +16,5 @@
|
|||||||
{{ question }}</a><br /> {{ question.GetUnmarkedAnswersString }}</li>
|
{{ question }}</a><br /> {{ question.GetUnmarkedAnswersString }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<p><button><a href="{% url 'anatomy:mark' pk=exam.pk sk=0 %}">Click here to start marking</a></button></p>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
+9
-2
@@ -261,21 +261,28 @@ def loadJsonAnswer(answer):
|
|||||||
ans.answer = answer["ans"]
|
ans.answer = answer["ans"]
|
||||||
ans.save()
|
ans.save()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def postExamAnswers(request):
|
def postExamAnswers(request):
|
||||||
if request.is_ajax and request.method == "POST":
|
if request.is_ajax and request.method == "POST":
|
||||||
|
|
||||||
|
n = 0
|
||||||
# horrible but it works
|
# horrible but it works
|
||||||
for k in request.POST.dict():
|
for k in request.POST.dict():
|
||||||
print(k)
|
print(k)
|
||||||
for answer in json.loads(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(UserAnswer.objects.filter(exam__id=q["eid"]))
|
||||||
# print(request.urlencode())
|
# print(request.urlencode())
|
||||||
|
|
||||||
return JsonResponse({"success": True})
|
return JsonResponse({"success": True, "question-number": n})
|
||||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||||
|
|
||||||
# return render(request, "anatomy/exam.html", {"exam" : exam, "question" : question})
|
# return render(request, "anatomy/exam.html", {"exam" : exam, "question" : question})
|
||||||
|
|||||||
Reference in New Issue
Block a user