Skip to content

Commit

Permalink
Merge pull request #147 from HE-Arc/mbu-144-backend-corrige-community…
Browse files Browse the repository at this point in the history
…-question

fix error when saving new community question
  • Loading branch information
maelys-buhler authored Apr 19, 2024
2 parents e8de9fa + 77baa19 commit 7dcf976
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/masteriqapp/views/QuestionView.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class QuestionView(viewsets.ViewSet):
def new(self, request, pk):
category = get_object_or_404(self.queryset, pk=pk)
if 'question' in request.session:
actual_question = self.question_model.objects.get(pk=request.session['question'])
actual_question = get_object_or_404(self.question_model.objects.all(), pk=request.session['question'])
if actual_question.category == category:
serializer = QuestionSerializer(actual_question)
return Response(serializer.data, status=status.HTTP_200_OK)
Expand Down Expand Up @@ -84,7 +84,7 @@ def new_community(self, request):
status=status.HTTP_400_BAD_REQUEST)

for option in datas['options']:
option_serializer = OptionSerializer(data={"text": option, "is_correct": False, "question": 3})
option_serializer = OptionSerializer(data={"text": option, "is_correct": False, "question": question.id})

if option_serializer.is_valid():
option_serializer.save()
Expand Down

0 comments on commit 7dcf976

Please sign in to comment.