.
This commit is contained in:
+20
-15
@@ -69,7 +69,7 @@ from rapids.models import RapidCreationDefault
|
||||
|
||||
from rest_framework import viewsets
|
||||
|
||||
from .serializers import ExamSerializer
|
||||
from .serializers import ExamSerializer, QuestionAnswerSerializer
|
||||
|
||||
from generic.mixins import SuperuserRequiredMixin
|
||||
|
||||
@@ -926,19 +926,6 @@ class QuestionDelete(AuthorOrCheckerRequiredMixin, DeleteView):
|
||||
|
||||
RapidExamViews = ExamViews(Exam, Rapid, "rapids", "rapid", loadJsonAnswer)
|
||||
|
||||
class ExamViewSet(viewsets.ModelViewSet):
|
||||
#queryset = Exam.objects.all().order_by('name')
|
||||
serializer_class = ExamSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
This view should return a list exams available to a user.
|
||||
"""
|
||||
user = self.request.user
|
||||
if user.groups.filter(name="rapid_checker").exists():
|
||||
return Exam.objects.all()
|
||||
|
||||
return Exam.objects.filter(author__id=user.id)
|
||||
|
||||
class ExamCreate(LoginRequiredMixin, CreateView):
|
||||
model = Exam
|
||||
@@ -957,4 +944,22 @@ class RapidUserAnswerView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||
|
||||
class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
|
||||
model = CidUserAnswer
|
||||
success_url = reverse_lazy("rapids:rapid_user_answer_view")
|
||||
success_url = reverse_lazy("rapids:rapid_user_answer_view")
|
||||
|
||||
class ExamViewSet(viewsets.ModelViewSet):
|
||||
#queryset = Exam.objects.all().order_by('name')
|
||||
serializer_class = ExamSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
This view should return a list exams available to a user.
|
||||
"""
|
||||
user = self.request.user
|
||||
if user.groups.filter(name="rapid_checker").exists():
|
||||
return Exam.objects.all()
|
||||
|
||||
return Exam.objects.filter(author__id=user.id)
|
||||
|
||||
class QuestionAnswerViewSet(viewsets.ModelViewSet):
|
||||
#queryset = Exam.objects.all().order_by('name')
|
||||
serializer_class = QuestionAnswerSerializer
|
||||
Reference in New Issue
Block a user