generic score pages

This commit is contained in:
Ross
2020-12-16 22:50:11 +00:00
parent a6d87d1e89
commit b557305730
13 changed files with 135 additions and 60 deletions
+4
View File
@@ -17,6 +17,10 @@ class QuestionAdmin(VersionAdmin):
#IncorrectAnatomyAnswersInline,
ExamInline,
]
#fields = ("stem",
#("a", "a_answer"),
#("b", "b_answer"),
#)
admin.site.register(Category)
@@ -0,0 +1,43 @@
# Generated by Django 3.1.3 on 2020-12-16 22:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('physics', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='exam',
name='time_limit',
field=models.IntegerField(blank=True, help_text='Exam time limit (in seconds)', null=True),
),
migrations.AlterField(
model_name='question',
name='a_answer',
field=models.BooleanField(default=True, help_text='Answer (check for true, uncheck for false)'),
),
migrations.AlterField(
model_name='question',
name='b_answer',
field=models.BooleanField(default=True, help_text='Answer (check for true, uncheck for false)'),
),
migrations.AlterField(
model_name='question',
name='c_answer',
field=models.BooleanField(default=True, help_text='Answer (check for true, uncheck for false)'),
),
migrations.AlterField(
model_name='question',
name='d_answer',
field=models.BooleanField(default=True, help_text='Answer (check for true, uncheck for false)'),
),
migrations.AlterField(
model_name='question',
name='e_answer',
field=models.BooleanField(default=True, help_text='Answer (check for true, uncheck for false)'),
),
]
+13 -5
View File
@@ -24,12 +24,14 @@ class Question(models.Model):
help_text="Stem of the question",
)
answer_help_text = "Answer (check for true, uncheck for false)"
a = models.TextField(
blank=False,
help_text="The question text",
)
a_answer = models.BooleanField(
help_text="Answer (check for true)", default=True
help_text=answer_help_text, default=True
)
b = models.TextField(
@@ -37,7 +39,7 @@ class Question(models.Model):
help_text="The question text",
)
b_answer = models.BooleanField(
help_text="Answer", default=True
help_text=answer_help_text, default=True
)
c = models.TextField(
@@ -45,7 +47,7 @@ class Question(models.Model):
help_text="The question text",
)
c_answer = models.BooleanField(
help_text="Answer", default=True
help_text=answer_help_text, default=True
)
d = models.TextField(
@@ -53,7 +55,7 @@ class Question(models.Model):
help_text="The question text",
)
d_answer = models.BooleanField(
help_text="Answer", default=True
help_text=answer_help_text, default=True
)
e = models.TextField(
@@ -61,7 +63,7 @@ class Question(models.Model):
help_text="The question text",
)
e_answer = models.BooleanField(
help_text="Answer", default=True
help_text=answer_help_text, default=True
)
created_date = models.DateTimeField(default=timezone.now)
@@ -113,6 +115,12 @@ class Exam(models.Model):
help_text="If an exams results should be available", default=True
)
time_limit = models.IntegerField(
help_text="Exam time limit (in seconds)",
blank=True,
null=True,
)
def __str__(self):
return self.name
-13
View File
@@ -1,13 +0,0 @@
{% extends 'physics/base.html' %}
{% block content %}
<div class="physics">
<h2>CID: {{ cid }}</h2>
The following exams have been found (click to view answers and scores):
<ul>
{% for exam in exams %}
<li><a href="{% url 'physics:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
{% endfor %}
</ul>
</div>
{% endblock %}
@@ -1,18 +0,0 @@
{% extends 'physics/base.html' %}
{% block content %}
<div class="physics">
<h2>Please enter your CID</h2>
<p>CID: <input type="text" name="cid" id="cid-input"></p>
<button id="cid-selector-go-button">Go...</button>
</div>
<script>
$(document).ready(function () {
$("#cid-selector-go-button").click(() => {
cid = document.getElementById("cid-input").value;
window.location = window.location + cid;
})
})
</script>
{% endblock %}
@@ -17,7 +17,7 @@
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<div>
<a href="{% url 'physics:cid_scores' cid %}">Other exams</a>
<a href="{% url 'cid_scores' cid %}">Other exams</a>
</div>
</div>
{% endblock %}
-2
View File
@@ -25,6 +25,4 @@ urlpatterns = [
path("exam/available", views.active_exams, name="active_exams"),
#path("exam/json/<int:pk>", views.exam_json, name="exam_json"),
#path("exam/json/<int:pk>/recreate", views.exam_json_recreate, name="exam_json_recreate"),
path("cid/<int:pk>", views.cid_scores, name="cid_scores"),
path("cid/", views.cid_selector, name="cid_selector"),
]
-34
View File
@@ -251,40 +251,6 @@ def exam_scores_cid_user(request, pk, sk):
},
)
def cid_selector(request):
return render(
request,
"physics/cid_selector.html",
)
def cid_scores(request, pk):
#exam = get_object_or_404(Exam, pk=pk)
# TODO:Need some kind of test for cid
cid = pk
#questions = exam.exam_questions.all()
answers = CidUserAnswer.objects.filter(
cid=cid)
if not answers:
raise Http404("cid not found")
exam_ids = answers.values_list("exam").distinct()
exams = Exam.objects.filter(id__in=exam_ids)
return render(
request,
"physics/cid_scores.html",
{
"exams": exams,
"cid": cid,
},
)
def exam_take(request, pk):