fix a little question ordering bug
This commit is contained in:
@@ -12,8 +12,6 @@ class CheckCanEditMixin():
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
print(self.object)
|
||||
print("1234", self.object.check_user_can_edit(self.request.user))
|
||||
context["can_edit"] = self.object.check_user_can_edit(self.request.user)
|
||||
|
||||
return context
|
||||
|
||||
+5
-1
@@ -835,6 +835,10 @@ class ExamBase(ExamOrCollectionGenericBase):
|
||||
default=False,
|
||||
)
|
||||
|
||||
#randomise_question_order = models.BooleanField(
|
||||
# help_text="If an exam should randomise the order of questions in RTS.",
|
||||
#)
|
||||
|
||||
include_history = models.BooleanField(
|
||||
help_text="If an exam should include history when taking",
|
||||
default=False,
|
||||
@@ -960,7 +964,7 @@ class ExamBase(ExamOrCollectionGenericBase):
|
||||
|
||||
def get_question_by_index(self, index: int):
|
||||
# There must be a better way to do this
|
||||
return list(self.get_questions)[index]
|
||||
return list(self.get_questions())[index]
|
||||
|
||||
def get_cid_user_score(self, cid_user):
|
||||
c = "c/" + str(cid_user)
|
||||
|
||||
+13
-2
@@ -661,6 +661,8 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
exam_list = self.Exam.objects.filter(author__id=request.user.id, exam_mode=True).order_by(
|
||||
"name"
|
||||
)
|
||||
|
||||
exam_list = exam_list | self.Exam.objects.filter(markers__id=request.user.id, exam_mode=True).order_by("name")
|
||||
else:
|
||||
exam_list = self.Exam.objects.prefetch_related("valid_user_users", "valid_cid_users").filter(exam_mode=True).order_by("name")
|
||||
|
||||
@@ -946,6 +948,12 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
cid_candidates = exam.valid_cid_users.count()
|
||||
users_candidates = exam.valid_user_users.count()
|
||||
|
||||
#question_orders = [q.examquestiondetail.sort_order for q in questions]
|
||||
|
||||
# Exam order can be missing when, this can be checked with
|
||||
# exam.exam_questions.select_related().all().order_by("examquestiondetail__sort_order").values_list("examquestiondetail__sort_order")
|
||||
# TODO decide if / how this should be flagged to a user (updating teh exam order will fix)
|
||||
|
||||
|
||||
return render(
|
||||
request,
|
||||
@@ -1467,11 +1475,13 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
if not self.check_user_access(request.user, pk, marker=True):
|
||||
raise PermissionDenied
|
||||
|
||||
question = exam.get_questions()[sk]
|
||||
#question = exam.get_questions()[sk]
|
||||
question = exam.get_question_by_index(sk)
|
||||
|
||||
exam_length = len(exam.exam_questions.all())
|
||||
|
||||
pos = exam.get_question_index(question) + 1
|
||||
#pos = exam.get_question_index(question) + 1
|
||||
pos = sk + 1
|
||||
|
||||
previous = -1
|
||||
if sk > 0:
|
||||
@@ -2510,6 +2520,7 @@ class ExamCloneMixin():
|
||||
initial_data["user_user_groups"] = []
|
||||
|
||||
initial_data["active"] = False
|
||||
initial_data["archive"] = False
|
||||
initial_data["publish_results"] = False
|
||||
|
||||
self.exam_questions = list(questions)
|
||||
|
||||
+4
-4
@@ -129,9 +129,9 @@ class AuthorOrCheckerRequiredMixin(object):
|
||||
or self.request.user.is_superuser
|
||||
):
|
||||
return obj
|
||||
if self.request.user not in obj.get_author_objects():
|
||||
raise PermissionDenied() # or Http404
|
||||
return obj
|
||||
if self.request.user in obj.get_author_objects():
|
||||
return obj
|
||||
raise PermissionDenied() # or Http404
|
||||
|
||||
|
||||
# def index(request):
|
||||
@@ -959,7 +959,7 @@ class ExamCreate(ExamCreateBase):
|
||||
form_class = ExamForm
|
||||
|
||||
|
||||
class ExamUpdate(ExamUpdateBase, AuthorOrCheckerRequiredMixin):
|
||||
class ExamUpdate(AuthorOrCheckerRequiredMixin, ExamUpdateBase):
|
||||
model = Exam
|
||||
form_class = ExamForm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user