This commit is contained in:
Ross
2021-05-05 22:49:43 +01:00
parent de5ccd5e3d
commit 0da6edf5be
2 changed files with 33 additions and 2 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ urlpatterns = [
path("exam/json/unbased", views.active_exams_unbased, name="active_exams_unbased"),
path("exam/submit", views.exam_submit, name="global_exam_answers_submit"),
#path('', include('generic.urls')),
path("feedback/<str:question_type>/<int:pk>/?", views.AddQuestionNote.as_view(), name="feedback_create"),
path("feedback/<str:question_type>/<int:pk>", views.AddQuestionNote.as_view(), name="feedback_create"),
#path("feedback/", views.AddQuestionNote.as_view(), name="feedback"),
+32 -1
View File
@@ -1005,4 +1005,35 @@ class RapidViewSet(RevisionMixin, viewsets.ModelViewSet):
class ExamDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
model = Exam
success_url = reverse_lazy("rapids:index")
success_url = reverse_lazy("rapids:index")
class AddSuggestedAnswer(LoginRequiredMixin, CreateView):
model = QuestionNote
form_class = QuestionNoteForm
#fields = ("author", "note_type", "note")
def get_form_kwargs(self):
kwargs = super(AddQuestionNote, self).get_form_kwargs()
# update the kwargs for the form init method with yours
kwargs.update(self.kwargs) # self.kwargs contains all url conf params
return kwargs
def get_initial(self):
pk = self.kwargs["pk"]
question_type = self.kwargs["question_type"]
if question_type == "rapid":
question = Rapid
content_type = ContentType.objects.get(model="rapid")
elif question_type == "anatomy":
question = AnatomyQuestion
content_type = ContentType.objects.get(model="anatomyquestion")
elif question_type == "long":
question = Long
content_type = ContentType.objects.get(model="long")
else:
raise PermissionError()
get_object_or_404(question, pk=pk)
return { "content_type" : content_type,
"object_id" : pk }