diff --git a/backend/apps/quizzes/serializers.py b/backend/apps/quizzes/serializers.py index 1ce477a..8228589 100644 --- a/backend/apps/quizzes/serializers.py +++ b/backend/apps/quizzes/serializers.py @@ -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 @@ -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): diff --git a/backend/apps/users/views.py b/backend/apps/users/views.py index f72e170..d0f8055 100644 --- a/backend/apps/users/views.py +++ b/backend/apps/users/views.py @@ -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 @@ -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"] diff --git a/frontend/trigger.txt b/frontend/trigger.txt index 5c33b15..b7dab10 100644 --- a/frontend/trigger.txt +++ b/frontend/trigger.txt @@ -1 +1 @@ -trigger +trigger 1