some reset ansnwer improvements

This commit is contained in:
Ross
2024-07-29 13:05:09 +01:00
parent 88584f4c37
commit a304c0b4dc
3 changed files with 9 additions and 5 deletions
@@ -56,6 +56,8 @@
<button title="This will clear all user answers and attempts"
hx-post="{% url 'atlas:collection_reset_answers' collection.pk %}"
hx-swap="outerHTML"
hx-confirm="Are you sure you want to reset all answers? This action cannot be undone."
>Reset all answers</button>
</details>
@@ -49,6 +49,7 @@ Exam mode: {{ exam.exam_mode }}<br />
<button title="This will clear all user answers and attempts"
hx-post="{% url exam.get_app_name|add:':exam_reset_answers' exam.pk %}"
hx-swap="outerHTML"
hx-confirm="Are you sure you want to reset all answers? This action cannot be undone."
>Reset all answers</button>
</details>
+6 -5
View File
@@ -502,7 +502,10 @@ class ExamViews(View, LoginRequiredMixin):
# If a user is an exam author they should have acccess
if exam_id is not None:
exam = get_object_or_404(self.Exam, pk=exam_id)
if exam.open_access or user in exam.get_author_objects():
# Remove open_access check for the momement
#if exam.open_access or user in exam.get_author_objects():
# return True
if user in exam.get_author_objects():
return True
if exam.authors_only:
@@ -1046,10 +1049,8 @@ class ExamViews(View, LoginRequiredMixin):
if request.htmx:
exam = get_object_or_404(self.Exam, pk=exam_id)
if not request.user.groups.filter(name="cid_user_manager").exists():
# raise PermissionDenied
if request.user not in exam.author.all():
raise PermissionDenied
if not self.check_user_edit_access(request.user, exam_id):
raise PermissionDenied
## Delete all answers
exam.cid_user_answers.all().delete()