allow rodering questions
This commit is contained in:
@@ -107,6 +107,14 @@ Author(s): {% for author in exam.author.all %}
|
|||||||
{{ author }}{% if not forloop.last %}, {% endif %}
|
{{ author }}{% if not forloop.last %}, {% endif %}
|
||||||
{% endfor %}<br/>
|
{% endfor %}<br/>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Extra</summary>
|
||||||
|
<button title="This will clear all user answers and attempts"
|
||||||
|
hx-post="{% url exam.get_app_name|add:':order_questions' exam.pk %}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
>Order questions</button>
|
||||||
|
</details>
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<style>
|
<style>
|
||||||
.answer-management[open] {
|
.answer-management[open] {
|
||||||
|
|||||||
+4
-3
@@ -239,11 +239,11 @@ def generic_exam_urls(generic_exam_view: GenericExamViews):
|
|||||||
generic_exam_view.exam_question_detail,
|
generic_exam_view.exam_question_detail,
|
||||||
name="exam_question_detail",
|
name="exam_question_detail",
|
||||||
),
|
),
|
||||||
#path(
|
# path(
|
||||||
# "exam/<int:pk>/question/<int:sk>/answer/<str:user_or_cid>",
|
# "exam/<int:pk>/question/<int:sk>/answer/<str:user_or_cid>",
|
||||||
# generic_exam_view.exam_question_user_answer,
|
# generic_exam_view.exam_question_user_answer,
|
||||||
# name="exam_question_user_answer",
|
# name="exam_question_user_answer",
|
||||||
#),
|
# ),
|
||||||
path(
|
path(
|
||||||
"exam/<int:pk>/question/<int:sk>/answer/<str:c_or_u>/<str:user_or_cid>",
|
"exam/<int:pk>/question/<int:sk>/answer/<str:c_or_u>/<str:user_or_cid>",
|
||||||
generic_exam_view.exam_question_user_answer,
|
generic_exam_view.exam_question_user_answer,
|
||||||
@@ -342,8 +342,9 @@ def generic_exam_urls(generic_exam_view: GenericExamViews):
|
|||||||
),
|
),
|
||||||
path("exam/", generic_exam_view.exam_list, name="exam_list"),
|
path("exam/", generic_exam_view.exam_list, name="exam_list"),
|
||||||
path("exam/all", generic_exam_view.exam_list_all, name="exam_list_all"),
|
path("exam/all", generic_exam_view.exam_list_all, name="exam_list_all"),
|
||||||
|
path("exam/<int:exam_id>/order_questions", generic_exam_view.order_questions, name="order_questions"),
|
||||||
path("exam/<int:exam_id>/cids", generic_exam_view.exam_cids, name="exam_cids"),
|
path("exam/<int:exam_id>/cids", generic_exam_view.exam_cids, name="exam_cids"),
|
||||||
#path("exam/<int:exam_id>/groups", generic_exam_view.exam_groups_edit, name="exam_groups_edit"),
|
# path("exam/<int:exam_id>/groups", generic_exam_view.exam_groups_edit, name="exam_groups_edit"),
|
||||||
path(
|
path(
|
||||||
"exam/<int:exam_id>/reset_answers",
|
"exam/<int:exam_id>/reset_answers",
|
||||||
generic_exam_view.exam_reset_answers,
|
generic_exam_view.exam_reset_answers,
|
||||||
|
|||||||
@@ -654,6 +654,16 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
def exam_list_all(self, request):
|
def exam_list_all(self, request):
|
||||||
return self.exam_list(request, all=True)
|
return self.exam_list(request, all=True)
|
||||||
|
|
||||||
|
def order_questions(self, request, exam_id):
|
||||||
|
if not self.check_user_edit_access(request.user):
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
|
exam = get_object_or_404(self.Exam, pk=exam_id)
|
||||||
|
|
||||||
|
exam.order_questions()
|
||||||
|
|
||||||
|
return HttpResponse("Done")
|
||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def exam_list(self, request, all=False):
|
def exam_list(self, request, all=False):
|
||||||
if not self.check_user_access(request.user):
|
if not self.check_user_access(request.user):
|
||||||
@@ -2566,6 +2576,7 @@ class ExamCloneMixin():
|
|||||||
object.exam_questions.set(self.exam_questions)
|
object.exam_questions.set(self.exam_questions)
|
||||||
object.author.set(self.author)
|
object.author.set(self.author)
|
||||||
object.save()
|
object.save()
|
||||||
|
object.order_questions()
|
||||||
return HttpResponseRedirect(object.get_absolute_url())
|
return HttpResponseRedirect(object.get_absolute_url())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user