continue building examcollections
This commit is contained in:
+71
-8
@@ -59,6 +59,8 @@ from .forms import (
|
||||
CidGroupExamForm,
|
||||
CidUserForm,
|
||||
CidUserExamForm,
|
||||
ExamCollectionCloneForm,
|
||||
ExamCollectionForm,
|
||||
ExaminationForm,
|
||||
CidUserGroupForm,
|
||||
ExaminationMergeForm,
|
||||
@@ -85,9 +87,9 @@ from .models import (
|
||||
)
|
||||
|
||||
from rapids.models import Rapid as RapidQuestion, RapidImage
|
||||
from rapids.models import Exam as RapidExam
|
||||
from rapids.models import Exam as RapidsExam
|
||||
from longs.models import Long as LongQuestion, LongSeries
|
||||
from longs.models import Exam as LongExam
|
||||
from longs.models import Exam as LongsExam
|
||||
from anatomy.models import AnatomyQuestion as AnatomyQuestion
|
||||
from anatomy.models import Exam as AnatomyExam
|
||||
from sbas.models import Question as SbasQuestion
|
||||
@@ -260,10 +262,10 @@ def generic_exam_json_edit(request):
|
||||
question_type = request.POST.get("type")
|
||||
|
||||
if question_type == "rapids":
|
||||
Exam = RapidExam
|
||||
Exam = RapidsExam
|
||||
Question = RapidQuestion
|
||||
elif question_type == "longs":
|
||||
Exam = LongExam
|
||||
Exam = LongsExam
|
||||
Question = LongQuestion
|
||||
elif question_type == "anatomy":
|
||||
Exam = AnatomyExam
|
||||
@@ -917,6 +919,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
cid_candidates = exam.valid_cid_users.count()
|
||||
users_candidates = exam.valid_user_users.count()
|
||||
|
||||
|
||||
return render(
|
||||
request,
|
||||
"{}/exam_overview.html".format(self.app_name),
|
||||
@@ -2466,9 +2469,9 @@ class CidUserExamView(CidManagerRequiredMixin, SingleTableMixin, FilterView):
|
||||
filters = {"archive": False, "exam_mode": True}
|
||||
|
||||
physics_exams = [(i.name, i.pk) for i in PhysicsExam.objects.filter(**filters)]
|
||||
rapid_exams = [(i.name, i.pk) for i in RapidExam.objects.filter(**filters)]
|
||||
rapid_exams = [(i.name, i.pk) for i in RapidsExam.objects.filter(**filters)]
|
||||
sba_exams = [(i.name, i.pk) for i in SbasExam.objects.filter(**filters)]
|
||||
longs_exams = [(i.name, i.pk) for i in LongExam.objects.filter(**filters)]
|
||||
longs_exams = [(i.name, i.pk) for i in LongsExam.objects.filter(**filters)]
|
||||
anatomy_exams = [(i.name, i.pk) for i in AnatomyExam.objects.filter(**filters)]
|
||||
casecollection_exams = [
|
||||
(i.name, i.pk)
|
||||
@@ -2504,9 +2507,9 @@ class CidUserView(CidManagerRequiredMixin, SingleTableMixin, FilterView):
|
||||
filters = {"archive": False, "exam_mode": True}
|
||||
|
||||
physics_exams = [(i.name, i.pk) for i in PhysicsExam.objects.filter(**filters)]
|
||||
rapid_exams = [(i.name, i.pk) for i in RapidExam.objects.filter(**filters)]
|
||||
rapid_exams = [(i.name, i.pk) for i in RapidsExam.objects.filter(**filters)]
|
||||
sba_exams = [(i.name, i.pk) for i in SbasExam.objects.filter(**filters)]
|
||||
longs_exams = [(i.name, i.pk) for i in LongExam.objects.filter(**filters)]
|
||||
longs_exams = [(i.name, i.pk) for i in LongsExam.objects.filter(**filters)]
|
||||
anatomy_exams = [(i.name, i.pk) for i in AnatomyExam.objects.filter(**filters)]
|
||||
casecollection_exams = [
|
||||
(i.name, i.pk)
|
||||
@@ -3262,6 +3265,66 @@ class ExamCollectionList(ListView):
|
||||
class ExamCollectionDetail(DetailView, AuthorRequiredMixin):
|
||||
model = ExamCollection
|
||||
|
||||
class ExamCollectionEdit(UpdateView, AuthorRequiredMixin):
|
||||
model = ExamCollection
|
||||
form_class = ExamCollectionForm
|
||||
|
||||
class ExamCollectionCreate(CreateView, AuthorRequiredMixin):
|
||||
model = ExamCollection
|
||||
form_class = ExamCollectionForm
|
||||
|
||||
class ExamCollectionClone(CreateView, AuthorRequiredMixin):
|
||||
model = ExamCollection
|
||||
template_name = "generic/examcollection_clone_form.html"
|
||||
form_class = ExamCollectionCloneForm
|
||||
|
||||
def get_initial(self):
|
||||
old_object = get_object_or_404(self.model, pk=self.kwargs["pk"])
|
||||
self.initial_object = old_object
|
||||
|
||||
|
||||
initial_data = model_to_dict(old_object, exclude=["id", "date"])
|
||||
|
||||
## We manually transfer the forign keys / m2m relationships
|
||||
#questions = old_object.exam_questions.all().values_list("id", flat=True)
|
||||
authors = old_object.author.all().values_list("id", flat=True)
|
||||
|
||||
## clear the associated groups
|
||||
#initial_data["valid_user_users"] = []
|
||||
#initial_data["valid_cid_users"] = []
|
||||
#initial_data["cid_user_groups"] = []
|
||||
#initial_data["user_user_groups"] = []
|
||||
|
||||
#initial_data["active"] = False
|
||||
#initial_data["publish_results"] = False
|
||||
|
||||
#self.exam_questions = list(questions)
|
||||
self.author = list(authors)
|
||||
|
||||
return initial_data
|
||||
|
||||
def form_valid(self, form):
|
||||
object = form.save()
|
||||
# Reapply these otherwise they get lost?
|
||||
#object.exam_questions.set(self.exam_questions)
|
||||
|
||||
GROUP_TYPES = (
|
||||
("Rapid Exams", "rapids_exams", RapidsExam),
|
||||
("Long Exams", "longs_exams", LongsExam),
|
||||
("SBA Exams", "sbas_exams", SbasExam),
|
||||
("Physic Exams", "physics_exams", PhysicsExam),
|
||||
("Anatomy Exams", "anatomy_exams", AnatomyExam),
|
||||
)
|
||||
|
||||
object.author.set(self.author)
|
||||
object.save()
|
||||
return HttpResponseRedirect(object.get_absolute_url())
|
||||
|
||||
class ExamCollectionDelete(DeleteView, AuthorRequiredMixin):
|
||||
model = ExamCollection
|
||||
template_name = "confirm_delete.html"
|
||||
success_url = reverse_lazy("generic:examcollection_list")
|
||||
|
||||
class ExaminationView(SuperuserRequiredMixin, SingleTableMixin, FilterView):
|
||||
model = Examination
|
||||
table_class = ExaminationTable
|
||||
|
||||
Reference in New Issue
Block a user