Skip to content
Open

Dev #133

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions backend/apps/quizzes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class QuizSerializer(serializers.ModelSerializer):
"""Serializer for representing `Quiz`."""
numberQuestions = serializers.IntegerField()
questions = QuestionSerializer(many=True, read_only=True)
# questions = serializers.SerializerMethodField()
# questions = QuestionSerializer(many=True, read_only=True)
questions = serializers.SerializerMethodField()

class Meta:
model = Quiz
Expand All @@ -23,25 +23,25 @@ class Meta:
"numberQuestions",
)

# def get_questions(self, instance):
# """Get shuffled list of questions."""
# # The followings don't work:
# # https://stackoverflow.com/a/47618345
# # https://stackoverflow.com/a/2118712
# # Only these methods work:
# # https://stackoverflow.com/a/12073893
# # https://stackoverflow.com/a/33512488
# questions = instance.questions.all()
# questions = sorted(questions, key=lambda x: random.random())
# return [
# QuestionSerializer(
# quest,
# # many=True,
# read_only=True,
# context=self.context,
# ).data
# for quest in questions
# ]
def get_questions(self, instance):
"""Get shuffled list of questions."""
# The followings don't work:
# https://stackoverflow.com/a/47618345
# https://stackoverflow.com/a/2118712
# Only these methods work:
# https://stackoverflow.com/a/12073893
# https://stackoverflow.com/a/33512488
questions = instance.questions.all()
questions = sorted(questions, key=lambda x: random.random())
return [
QuestionSerializer(
quest,
# many=True,
read_only=True,
context=self.context,
).data
for quest in questions
]


class ResultSerializer(serializers.ModelSerializer):
Expand Down
4 changes: 3 additions & 1 deletion backend/apps/users/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.utils import timezone
from rest_framework import mixins
Expand Down Expand Up @@ -60,7 +61,8 @@ def post(self, request):

avatar = ""
if user.avatar and user.avatar.url:
avatar = "http://13.229.40.64:8888" + user.avatar.url
avatar = settings.DOMAIN_URL + user.avatar.url

# full_domain = 'http://' + request.META['HTTP_HOST']
# if request.META["SERVER_PORT"] not in full_domain:
# full_domain += ':' + request.META["SERVER_PORT"]
Expand Down
2 changes: 1 addition & 1 deletion frontend/trigger.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
trigger
trigger 1