generic score pages
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</ul>
|
||||
<br /> Total mark: {{ total_score }} / {{max_score}}
|
||||
<div>
|
||||
<a href="{% url 'anatomy:cid_scores' cid %}">Other exams</a>
|
||||
<a href="{% url 'cid_scores' cid %}">Other exams</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
+2
-2
@@ -29,8 +29,8 @@ urlpatterns = [
|
||||
path("exam/json/", 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"),
|
||||
#path("cid/<int:pk>", views.cid_scores, name="cid_scores"),
|
||||
#path("cid/", views.cid_selector, name="cid_selector"),
|
||||
path("ajax/exam/flag/", views.flag_question, name="flag_question"),
|
||||
path("body_part/create/", views.create_body_part, name="create_body_part"),
|
||||
path("body_part/ajax/get_body_part_id",
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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 %}
|
||||
@@ -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 %}
|
||||
@@ -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"),
|
||||
]
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ urlpatterns = [
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path("accounts/profile", views.profile, name="profile"),
|
||||
path("", TemplateView.as_view(template_name="index.html"), name="home"),
|
||||
path("cid/<int:pk>", views.cid_scores, name="cid_scores"),
|
||||
path("cid/", views.cid_selector, name="cid_selector"),
|
||||
|
||||
]
|
||||
|
||||
|
||||
@@ -21,9 +21,56 @@ from django.http import Http404, JsonResponse
|
||||
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
|
||||
from physics.models import CidUserAnswer as PhysicsCidUserAnswer
|
||||
from physics.models import Exam as PhysicsExam
|
||||
|
||||
from anatomy.models import CidUserAnswer as AnatomyCidUserAnswer
|
||||
from anatomy.models import Exam as AnatomyExam
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
def profile(request):
|
||||
user = request.user
|
||||
return render(request, "profile.html", {"user": user})
|
||||
|
||||
|
||||
def cid_selector(request):
|
||||
return render(
|
||||
request,
|
||||
"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()
|
||||
physics_answers = PhysicsCidUserAnswer.objects.filter(
|
||||
cid=cid)
|
||||
anatomy_answers = AnatomyCidUserAnswer.objects.filter(
|
||||
cid=cid)
|
||||
|
||||
|
||||
if not physics_answers and not anatomy_answers:
|
||||
raise Http404("cid not found")
|
||||
|
||||
physics_exam_ids = physics_answers.values_list("exam").distinct()
|
||||
physics_exams = PhysicsExam.objects.filter(id__in=physics_exam_ids)
|
||||
|
||||
anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
|
||||
anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids)
|
||||
|
||||
|
||||
return render(
|
||||
request,
|
||||
"cid_scores.html",
|
||||
{
|
||||
"physics_exams": physics_exams,
|
||||
"anatomy_exams": anatomy_exams,
|
||||
"cid": cid,
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,20 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="">
|
||||
<h2>CID: {{ cid }}</h2>
|
||||
The following exams have been found (click to view answers and scores):
|
||||
<h3>Physics</h3>
|
||||
<ul>
|
||||
{% for exam in physics_exams %}
|
||||
<li><a href="{% url 'physics:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h3>Anatomy</h3>
|
||||
<ul>
|
||||
{% for exam in anatomy_exams %}
|
||||
<li><a href="{% url 'anatomy:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends 'physics/base.html' %}
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="physics">
|
||||
<div class="">
|
||||
<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>
|
||||
Reference in New Issue
Block a user