Create a gist now

Instantly share code, notes, and snippets.

Embed
last_answer = StudentNumericAnswer.objects.filter(numeric_question=question_id,
student=request.user.id).order_by('updated_at').last()
if request.method == 'GET':
if not last_answer:
return Response(status=status.HTTP_404_NOT_FOUND)
data = StudentNumericAnswerSerializer(last_answer, context={'request': request}).data
# CNK cheat and add the correct answer data here for now
if last_answer.is_answer_correct or last_answer.gave_up:
data['correct_answer'] = {'correct_answer': question.correct_answer,
'tolerance': question.tolerance}
return Response(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment