diff --git a/anatomy/templates/anatomy/exam_scores_user.html b/anatomy/templates/anatomy/exam_scores_user.html index 0a5931ca..b626baf3 100644 --- a/anatomy/templates/anatomy/exam_scores_user.html +++ b/anatomy/templates/anatomy/exam_scores_user.html @@ -12,7 +12,7 @@
Total mark: {{ total_score }} / {{max_score}}
- Other exams + Other exams
{% endblock %} \ No newline at end of file diff --git a/anatomy/urls.py b/anatomy/urls.py index 9d590a47..0cee64b3 100644 --- a/anatomy/urls.py +++ b/anatomy/urls.py @@ -29,8 +29,8 @@ urlpatterns = [ path("exam/json/", views.active_exams, name="active_exams"), path("exam/json/", views.exam_json, name="exam_json"), path("exam/json//recreate", views.exam_json_recreate, name="exam_json_recreate"), - path("cid/", views.cid_scores, name="cid_scores"), - path("cid/", views.cid_selector, name="cid_selector"), + #path("cid/", 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", diff --git a/physics/admin.py b/physics/admin.py index d8871b73..58319c91 100644 --- a/physics/admin.py +++ b/physics/admin.py @@ -17,6 +17,10 @@ class QuestionAdmin(VersionAdmin): #IncorrectAnatomyAnswersInline, ExamInline, ] + #fields = ("stem", + #("a", "a_answer"), + #("b", "b_answer"), + #) admin.site.register(Category) diff --git a/physics/migrations/0002_auto_20201216_2207.py b/physics/migrations/0002_auto_20201216_2207.py new file mode 100644 index 00000000..c8b7da37 --- /dev/null +++ b/physics/migrations/0002_auto_20201216_2207.py @@ -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)'), + ), + ] diff --git a/physics/models.py b/physics/models.py index df435020..d18b00ea 100644 --- a/physics/models.py +++ b/physics/models.py @@ -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 diff --git a/physics/templates/physics/cid_scores.html b/physics/templates/physics/cid_scores.html deleted file mode 100644 index c9260c09..00000000 --- a/physics/templates/physics/cid_scores.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'physics/base.html' %} - -{% block content %} -
-

CID: {{ cid }}

- The following exams have been found (click to view answers and scores): - -
-{% endblock %} diff --git a/physics/templates/physics/exam_scores_user.html b/physics/templates/physics/exam_scores_user.html index b3a52512..ba9074e1 100644 --- a/physics/templates/physics/exam_scores_user.html +++ b/physics/templates/physics/exam_scores_user.html @@ -17,7 +17,7 @@
Total mark: {{ total_score }} / {{max_score}}
- Other exams + Other exams
{% endblock %} \ No newline at end of file diff --git a/physics/urls.py b/physics/urls.py index b0f3f841..0a25884d 100644 --- a/physics/urls.py +++ b/physics/urls.py @@ -25,6 +25,4 @@ urlpatterns = [ path("exam/available", views.active_exams, name="active_exams"), #path("exam/json/", views.exam_json, name="exam_json"), #path("exam/json//recreate", views.exam_json_recreate, name="exam_json_recreate"), - path("cid/", views.cid_scores, name="cid_scores"), - path("cid/", views.cid_selector, name="cid_selector"), ] diff --git a/physics/views.py b/physics/views.py index 076d014b..83d6cb6e 100644 --- a/physics/views.py +++ b/physics/views.py @@ -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): diff --git a/rad/urls.py b/rad/urls.py index 6f840751..83b113f2 100644 --- a/rad/urls.py +++ b/rad/urls.py @@ -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/", views.cid_scores, name="cid_scores"), + path("cid/", views.cid_selector, name="cid_selector"), ] diff --git a/rad/views.py b/rad/views.py index 6dc9d6d7..81eaf6da 100644 --- a/rad/views.py +++ b/rad/views.py @@ -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, + }, + ) \ No newline at end of file diff --git a/templates/cid_scores.html b/templates/cid_scores.html new file mode 100644 index 00000000..bd4955d3 --- /dev/null +++ b/templates/cid_scores.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% block content %} +
+

CID: {{ cid }}

+ The following exams have been found (click to view answers and scores): +

Physics

+
    + {% for exam in physics_exams %} +
  • {{exam.name}}
  • + {% endfor %} +
+

Anatomy

+
    + {% for exam in anatomy_exams %} +
  • {{exam.name}}
  • + {% endfor %} +
+
+{% endblock %} diff --git a/physics/templates/physics/cid_selector.html b/templates/cid_selector.html similarity index 88% rename from physics/templates/physics/cid_selector.html rename to templates/cid_selector.html index fa014eac..7066f3fe 100644 --- a/physics/templates/physics/cid_selector.html +++ b/templates/cid_selector.html @@ -1,7 +1,7 @@ -{% extends 'physics/base.html' %} +{% extends 'base.html' %} {% block content %} -
+

Please enter your CID

CID: