Lots of improvemnets
This commit is contained in:
+16
-1
@@ -181,6 +181,11 @@ class QuestionBase(models.Model):
|
||||
"""If this makes sense in the question/answer context override"""
|
||||
return None
|
||||
|
||||
def get_author_objects(self):
|
||||
"""Returns a comma seperated text list of authors"""
|
||||
authors = [i for i in self.author.all()]
|
||||
return authors
|
||||
|
||||
|
||||
class SeriesImageBase(models.Model):
|
||||
"""
|
||||
@@ -320,7 +325,7 @@ class SeriesBase(models.Model):
|
||||
return False
|
||||
|
||||
def get_author_objects(self):
|
||||
"""Returns a comma seperated text list of authors"""
|
||||
"""Returns a list of authors"""
|
||||
if self.author:
|
||||
return self.author.all()
|
||||
else:
|
||||
@@ -703,6 +708,12 @@ class ExamCollectionGenericBase(models.Model):
|
||||
new.save()
|
||||
return new
|
||||
|
||||
def get_question_cid_user_answer(self, question_index, cid):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_question_user_user_answer(self, question_index, user):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_cid_user_exams(
|
||||
self, cid_user: "CidUser" = None, user_user: User = None
|
||||
) -> "CidUserExam":
|
||||
@@ -833,6 +844,10 @@ class ExamBase(ExamCollectionGenericBase):
|
||||
def get_question_index(self, question):
|
||||
return list(self.exam_questions.all()).index(question)
|
||||
|
||||
def get_question_by_index(self, index:int):
|
||||
# There must be a better way to do this
|
||||
return list(self.exam_questions.all())[index]
|
||||
|
||||
def get_cid_user_score(self, cid_user):
|
||||
c = "c/" + str(cid_user)
|
||||
if c in self.user_scores:
|
||||
|
||||
+41
-13
@@ -11,9 +11,19 @@ urlpatterns = [
|
||||
# path('', views.question_list, name='question_list'),
|
||||
path("examination/", views.ExaminationView.as_view(), name="examination_view"),
|
||||
path("examination/<int:pk>", views.examination_detail, name="examination_detail"),
|
||||
path("examination/<int:pk>/delete", views.ExaminationDelete.as_view(), name="examination_delete"),
|
||||
path("examination/<int:pk>/update", views.ExaminationUpdate.as_view(), name="examination_update"),
|
||||
path("examination/<int:pk>/merge", views.examination_merge, name="examination_merge"),
|
||||
path(
|
||||
"examination/<int:pk>/delete",
|
||||
views.ExaminationDelete.as_view(),
|
||||
name="examination_delete",
|
||||
),
|
||||
path(
|
||||
"examination/<int:pk>/update",
|
||||
views.ExaminationUpdate.as_view(),
|
||||
name="examination_update",
|
||||
),
|
||||
path(
|
||||
"examination/<int:pk>/merge", views.examination_merge, name="examination_merge"
|
||||
),
|
||||
path("examination/create/", views.create_examination, name="create_examination"),
|
||||
path(
|
||||
"examination/ajax/get_examination_id",
|
||||
@@ -60,7 +70,11 @@ urlpatterns = [
|
||||
name="cid_group_detail",
|
||||
),
|
||||
path("cids/group/<int:pk>/email", views.group_email, name="group_email"),
|
||||
path("cids/group/<int:pk>/exams", views.CidGroupExamUpdate.as_view(), name="cid_group_exams"),
|
||||
path(
|
||||
"cids/group/<int:pk>/exams",
|
||||
views.CidGroupExamUpdate.as_view(),
|
||||
name="cid_group_exams",
|
||||
),
|
||||
path(
|
||||
"cids/group/<int:pk>/email_results",
|
||||
views.group_email_results,
|
||||
@@ -106,7 +120,11 @@ urlpatterns = [
|
||||
views.user_group_view_detail,
|
||||
name="user_group_detail",
|
||||
),
|
||||
path("user/group/<int:pk>/exams", views.UserGroupExamUpdate.as_view(), name="user_group_exams"),
|
||||
path(
|
||||
"user/group/<int:pk>/exams",
|
||||
views.UserGroupExamUpdate.as_view(),
|
||||
name="user_group_exams",
|
||||
),
|
||||
path(
|
||||
"user/group/<int:pk>/update",
|
||||
views.UserUserGroupUpdate.as_view(),
|
||||
@@ -191,6 +209,16 @@ def generic_exam_urls(generic_exam_view: GenericExamViews):
|
||||
generic_exam_view.exam_question_detail,
|
||||
name="exam_question_detail",
|
||||
),
|
||||
#path(
|
||||
# "exam/<int:pk>/question/<int:sk>/answer/<str:user_or_cid>",
|
||||
# generic_exam_view.exam_question_user_answer,
|
||||
# name="exam_question_user_answer",
|
||||
#),
|
||||
path(
|
||||
"exam/<int:pk>/question/<int:sk>/answer/<str:c_or_u>/<str:user_or_cid>",
|
||||
generic_exam_view.exam_question_user_answer,
|
||||
name="exam_question_user_answer",
|
||||
),
|
||||
path(
|
||||
"exam/<int:exam_id>/user/<int:user_id>",
|
||||
generic_exam_view.exam_user,
|
||||
@@ -333,26 +361,26 @@ def generic_exam_urls(generic_exam_view: GenericExamViews):
|
||||
generic_exam_view.exam_question_json_unbased_cid,
|
||||
name="exam_question_json_unbased_cid",
|
||||
),
|
||||
#path(
|
||||
# path(
|
||||
# "exam/json/<int:pk>/<int:sk>",
|
||||
# generic_exam_view.exam_question_json,
|
||||
# name="exam_question_json",
|
||||
#),
|
||||
#path(
|
||||
# ),
|
||||
# path(
|
||||
# "exam/json/<int:pk>/<int:sk>/unbased",
|
||||
# generic_exam_view.exam_question_json_unbased,
|
||||
# name="exam_question_json_unbased",
|
||||
#),
|
||||
#path(
|
||||
# ),
|
||||
# path(
|
||||
# "exam/json/<int:pk>/<int:cid>/<str:passcode>/<int:sk>",
|
||||
# generic_exam_view.exam_question_json_cid,
|
||||
# name="exam_question_json_cid",
|
||||
#),
|
||||
#path(
|
||||
# ),
|
||||
# path(
|
||||
# "exam/json/<int:pk>/<int:cid>/<str:passcode>/<int:sk>/unbased",
|
||||
# generic_exam_view.exam_question_json_unbased_cid,
|
||||
# name="exam_question_json_unbased_cid",
|
||||
#),
|
||||
# ),
|
||||
path(
|
||||
"exam/json/<int:pk>/recreate",
|
||||
generic_exam_view.exam_json_recreate,
|
||||
|
||||
@@ -1353,6 +1353,35 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
{"filter": filter, "app_name": self.app_name},
|
||||
)
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_question_user_answer(self, request, pk: int, sk: int, c_or_u: str, user_or_cid: str):
|
||||
exam: ExamBase = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
#question = exam.exam_questions.all()[sk]
|
||||
|
||||
if c_or_u == "u":
|
||||
user = get_object_or_404(User,pk=user_or_cid)
|
||||
answer = exam.get_question_user_user_answer(sk, user)
|
||||
elif c_or_u == "c":
|
||||
#cid_user = CidUser.objects.filter(cid=user_or_cid)
|
||||
answer =exam.get_question_cid_user_answer(sk, user_or_cid)
|
||||
else:
|
||||
raise Http404
|
||||
|
||||
print(answer)
|
||||
return HttpResponse(answer)
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_question_cid_user_answer(self, request, pk: int, sk: int, cid: str):
|
||||
exam: ExamBase = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
#question = exam.exam_questions.all()[sk]
|
||||
|
||||
cid_user = CidUser.objects.filter(cid=cid)
|
||||
answer =exam.get_question_cid_user_answer(sk, cid_user)
|
||||
|
||||
print(answer)
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_question_detail(self, request, pk, sk):
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
Reference in New Issue
Block a user