From 7d75a279112bce3969d2d4a2b70d74dd67570e29 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Mon, 30 Mar 2020 20:39:55 +0530 Subject: Show question test_cases, exclude unncessary fields from API --- api/serializers.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'api') diff --git a/api/serializers.py b/api/serializers.py index df66730..1c1e6a4 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -6,15 +6,21 @@ from yaksh.models import ( class QuestionSerializer(serializers.ModelSerializer): + test_cases = serializers.SerializerMethodField() + + def get_test_cases(self, obj): + test_cases = obj.get_test_cases_as_dict() + return test_cases + class Meta: model = Question - fields = '__all__' + exclude = ('partial_grading', ) class QuizSerializer(serializers.ModelSerializer): class Meta: model = Quiz - fields = '__all__' + exclude = ('view_answerpaper', ) class QuestionPaperSerializer(serializers.ModelSerializer): @@ -63,4 +69,11 @@ class CourseSerializer(serializers.ModelSerializer): class Meta: model = Course - fields = '__all__' + exclude = ( + 'teachers', + 'rejected', + 'requests', + 'students', + 'grading_system', + 'view_grade', + ) -- cgit