Antworten zeigen/verstecken

This commit is contained in:
nik8
2025-04-05 13:40:55 +02:00
parent 8d1489f513
commit 8c3b365e0b
2 changed files with 63 additions and 30 deletions

View File

@@ -130,16 +130,17 @@ def delete_quiz(request, pk):
def detail_quiz(request, pk):
#quiz = get_object_or_404(QivipQuiz, pk=pk, user_id=request.user)
quiz = get_object_or_404(QivipQuiz, pk=pk)
show_answers = request.GET.get('show_answers', 'false').lower() == 'true'
questions = QivipQuestion.objects.filter(quiz_id=quiz)
# Parse JSON data for each question
for question in questions:
if question.data:
question.data = json.loads(question.data)
context = {
'quiz': quiz,
'questions': questions
'questions': questions,
'detail':show_answers,
}
return render(request, 'library/detail_quiz.html', context)
"""