start testing

This commit is contained in:
Ross
2022-05-21 11:20:21 +01:00
parent 0ca980ccb6
commit 160bb13b64
18 changed files with 203 additions and 61 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ class AnatomyUserAnswerFilter(django_filters.FilterSet):
model= CidUserAnswer
fields = (
"cid",
#"user",
"user",
"question",
"answer",
#"answer_compare",
@@ -0,0 +1,21 @@
# Generated by Django 3.2.13 on 2022-05-20 19:51
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('anatomy', '0062_exam_valid_user_users'),
]
operations = [
migrations.AddField(
model_name='ciduseranswer',
name='user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_anatomy_user_answers', to=settings.AUTH_USER_MODEL),
),
]
@@ -0,0 +1,24 @@
# Generated by Django 3.2.13 on 2022-05-21 09:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('generic', '0032_userprofile_registration_number'),
('anatomy', '0063_ciduseranswer_user'),
]
operations = [
migrations.AddField(
model_name='exam',
name='cid_user_groups',
field=models.ManyToManyField(blank=True, help_text='These groups define which candidates are able to be added to the exams/collection.', related_name='anatomy_cid_user_groups', to='generic.CidUserGroup'),
),
migrations.AddField(
model_name='exam',
name='user_user_groups',
field=models.ManyToManyField(blank=True, help_text='These groups define which candidates are able to be added to the exams/collection.', related_name='anatomy_user_user_groups', to='generic.UserUserGroup'),
),
]
+18 -4
View File
@@ -15,7 +15,7 @@ from sortedm2m.fields import SortedManyToManyField
import string
from generic.models import CidUser, Examination, ExamBase, QuestionNote
from generic.models import CidUser, CidUserGroup, Examination, ExamBase, QuestionNote, UserUserGroup
from collections import defaultdict
from helpers.images import image_as_base64
@@ -391,6 +391,20 @@ class Exam(ExamBase):
settings.AUTH_USER_MODEL, blank=True, related_name="user_anatomy_exams"
)
cid_user_groups = models.ManyToManyField(
CidUserGroup,
blank=True,
help_text="These groups define which candidates are able to be added to the exams/collection.",
related_name="anatomy_cid_user_groups"
)
user_user_groups = models.ManyToManyField(
UserUserGroup,
blank=True,
help_text="These groups define which candidates are able to be added to the exams/collection.",
related_name="anatomy_user_user_groups"
)
def get_exam_json(self, based=True):
questions = self.exam_questions.all()
@@ -452,9 +466,9 @@ class CidUserAnswer(models.Model):
help_text="Candidate ID (limitied by BigIntegerField size)",
)
#user = models.ForeignKey(
# settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True#, related_name="user_anatomy_user_answers"
#)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True, related_name="user_anatomy_user_answers"
)
# Each user answer is associated with a particular exam
exam = models.ForeignKey(
+1 -1
View File
@@ -69,7 +69,7 @@ class AnatomyUserAnswerTable(tables.Table):
template_name = "django_tables2/bootstrap4.html"
fields = (
"cid",
#"user",
"user",
"question",
"answer",
#"answer_compare",
-5
View File
@@ -250,11 +250,6 @@ def loadJsonAnswer(answer):
{"success": False, "error": "invalid cid / passcode"}
)
# if not exam.active:
# return False, JsonResponse(
# {"success": False, "error": "No active exam: {}".format(eid)}
# )
exiting_answers = CidUserAnswer.objects.filter(
question__id=answer["qid"], exam__id=eid, cid=cid
)