Reihenfolge_Fragetyp(und Lizenzenz_Dateien)
This commit is contained in:
@@ -339,13 +339,28 @@ def waiting_room(request, join_code):
|
||||
|
||||
def selected_mode(request, join_code):
|
||||
|
||||
|
||||
|
||||
|
||||
mode = request.GET.get('mode','default')
|
||||
request.session['mode'] = mode
|
||||
quiz_game = get_object_or_404(QuizGame, join_code=join_code)
|
||||
quiz = get_object_or_404(QivipQuiz, pk=quiz_game.quiz_id.id)
|
||||
QuizGameParticipant.objects.filter(quiz_game=quiz_game).delete()
|
||||
|
||||
QuizGameParticipant.objects.filter(quiz_game=quiz_game).delete()
|
||||
|
||||
# Hier werden die Fragen gemischt!
|
||||
import random
|
||||
questions = quiz_game.quiz_id.questions.all()
|
||||
for question in questions:
|
||||
try:
|
||||
data = json.loads(question.data)
|
||||
if (data.get('type') == 'order' or data.get('type') == 'multiple_choice') and 'options' in data:
|
||||
|
||||
random.shuffle(data['options'])
|
||||
question.data = json.dumps(data)
|
||||
question.save(update_fields=['data'])
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
context = {
|
||||
'quiz': quiz,
|
||||
'quiz_game': quiz_game,
|
||||
|
||||
Reference in New Issue
Block a user