.
This commit is contained in:
@@ -615,6 +615,35 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def exam_cids_edit(self, request, exam_id):
|
||||||
|
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():
|
||||||
|
if not self.check_user_access(request.user, exam_id):
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
|
cid_users = exam.valid_users.all()
|
||||||
|
|
||||||
|
exam_groups = exam.cid_user_groups.all()
|
||||||
|
|
||||||
|
available_cid_users = CidUser().objects.filter(group__in=exam_groups)
|
||||||
|
|
||||||
|
cid_user_count = cid_users.count()
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"exam_cids.html",
|
||||||
|
{
|
||||||
|
"exam": exam,
|
||||||
|
"cid_users": available_cid_users,
|
||||||
|
"cid_user_count": cid_user_count,
|
||||||
|
"app_name": self.app_name,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
# @method_decorator(login_required)
|
# @method_decorator(login_required)
|
||||||
def exam_notes(self, request, pk):
|
def exam_notes(self, request, pk):
|
||||||
exam = get_object_or_404(self.Exam, pk=pk)
|
exam = get_object_or_404(self.Exam, pk=pk)
|
||||||
@@ -644,6 +673,12 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
|
|
||||||
exam = get_object_or_404(self.Exam, pk=pk)
|
exam = get_object_or_404(self.Exam, pk=pk)
|
||||||
|
|
||||||
|
if "edit_cid_users" in request.POST:
|
||||||
|
user_ids = json.loads(request.POST.get("cid_user_ids"))
|
||||||
|
|
||||||
|
data = {"status": "success"}
|
||||||
|
return JsonResponse(data, status=200)
|
||||||
|
|
||||||
if "add_exam_questions" in request.POST:
|
if "add_exam_questions" in request.POST:
|
||||||
question_ids = json.loads(request.POST.get("add_exam_questions"))
|
question_ids = json.loads(request.POST.get("add_exam_questions"))
|
||||||
question_objects = self.Question.objects.filter(pk__in=question_ids)
|
question_objects = self.Question.objects.filter(pk__in=question_ids)
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ from helpers.images import image_as_base64
|
|||||||
|
|
||||||
from django.contrib.contenttypes.fields import GenericRelation
|
from django.contrib.contenttypes.fields import GenericRelation
|
||||||
|
|
||||||
from generic.models import CidUser, Site, Condition, Sign, ExamBase, QuestionNote
|
from generic.models import CidUser, CidUserGroup, Site, Condition, Sign, ExamBase, QuestionNote
|
||||||
|
|
||||||
import reversion
|
import reversion
|
||||||
|
|
||||||
@@ -596,7 +596,7 @@ class Exam(ExamBase):
|
|||||||
CidUser, blank=True, related_name="rapid_exams"
|
CidUser, blank=True, related_name="rapid_exams"
|
||||||
)
|
)
|
||||||
|
|
||||||
cid_user_groups = models.ManyToManyField("generic.CidUserGroup")
|
cid_user_groups = models.ManyToManyField(CidUserGroup)
|
||||||
|
|
||||||
def get_normal_abnormal_breakdown(self):
|
def get_normal_abnormal_breakdown(self):
|
||||||
# Inefficient but more extendible
|
# Inefficient but more extendible
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ urlpatterns = [
|
|||||||
path("exam/all", views.GenericExamViews.exam_list_all, name="exam_list_all"),
|
path("exam/all", views.GenericExamViews.exam_list_all, name="exam_list_all"),
|
||||||
path("exam/create", views.ExamCreate.as_view(), name="exam_create"),
|
path("exam/create", views.ExamCreate.as_view(), name="exam_create"),
|
||||||
path("exam/<int:exam_id>/clone", views.ExamClone.as_view(), name="exam_clone"),
|
path("exam/<int:exam_id>/clone", views.ExamClone.as_view(), name="exam_clone"),
|
||||||
path("exam/<int:exam_id>/cids", views.GenericExamViews.exam_cids, name="exam_cids"),
|
path("exam/<int:exam_id>/cids/edit", views.GenericExamViews.exam_cids, name="exam_cids_edit"),
|
||||||
path("exam/<int:pk>/update", views.ExamUpdate.as_view(), name="exam_update"),
|
path("exam/<int:pk>/update", views.ExamUpdate.as_view(), name="exam_update"),
|
||||||
path("exam/<int:pk>/delete", views.ExamDelete.as_view(), name="exam_delete"),
|
path("exam/<int:pk>/delete", views.ExamDelete.as_view(), name="exam_delete"),
|
||||||
path("exam/json/", views.GenericExamViews.active_exams, name="active_exams"),
|
path("exam/json/", views.GenericExamViews.active_exams, name="active_exams"),
|
||||||
|
|||||||
Reference in New Issue
Block a user