reoorganise atlas modules
This commit is contained in:
+38
-1
@@ -1,6 +1,8 @@
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from django.http import Http404
|
||||
from rad.settings import REMOTE_URL
|
||||
from django.db.models.fields.files import ImageField
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
@@ -506,11 +508,46 @@ class CaseCollection(ExamCollectionGenericBase):
|
||||
return reverse("atlas:collection_detail", kwargs={"pk": self.pk})
|
||||
|
||||
def get_take_url(self):
|
||||
return reverse("atlas:collection_take", kwargs={"pk": self.pk})
|
||||
return reverse("atlas:collection_take_start", kwargs={"pk": self.pk})
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
def review_only(self) -> bool:
|
||||
"""Returns True if a users cannot submit responses
|
||||
|
||||
Returns:
|
||||
bool: _description_
|
||||
"""
|
||||
if self.collection_type == self.COLLECTION_TYPE_CHOICES.REVIEW:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def check_user_can_take(self, cid, passcode, request):
|
||||
"""
|
||||
Helper to check if a user is allowed to access a collection
|
||||
|
||||
Args:
|
||||
cid (_type_): _description_
|
||||
passcode (_type_): _description_
|
||||
request (_type_): _description_
|
||||
|
||||
Raises:
|
||||
Http404: If user does not have access
|
||||
"""
|
||||
if not self.active:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
#if self.collection_is_review():
|
||||
# return True
|
||||
|
||||
#if not self.self_review:
|
||||
|
||||
if not self.check_cid_user(cid, passcode, request):
|
||||
raise Http404("Error accessing exam")
|
||||
|
||||
|
||||
class CaseDetail(models.Model):
|
||||
case = models.ForeignKey(Case, on_delete=models.CASCADE)
|
||||
|
||||
Reference in New Issue
Block a user