diff options
author | Palaparthy Adityachandra | 2020-05-13 16:24:52 +0530 |
---|---|---|
committer | GitHub | 2020-05-13 16:24:52 +0530 |
commit | f7825eade425cb51ba053763db9d9fd051b0f4ce (patch) | |
tree | bc15b6cf7b5bbab4d4c8cfac5dd43abaaf778777 /api/serializers.py | |
parent | b8636965de8a86e68fd542754678e6826c7e5eac (diff) | |
parent | 833b96ac49499810934ada8ba02750623455d0cd (diff) | |
download | online_test-f7825eade425cb51ba053763db9d9fd051b0f4ce.tar.gz online_test-f7825eade425cb51ba053763db9d9fd051b0f4ce.tar.bz2 online_test-f7825eade425cb51ba053763db9d9fd051b0f4ce.zip |
Merge branch 'master' into merge_monitor_regrade
Diffstat (limited to 'api/serializers.py')
-rw-r--r-- | api/serializers.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/api/serializers.py b/api/serializers.py new file mode 100644 index 0000000..1c1e6a4 --- /dev/null +++ b/api/serializers.py @@ -0,0 +1,79 @@ +from rest_framework import serializers +from yaksh.models import ( + Question, Quiz, QuestionPaper, AnswerPaper, Course, + LearningModule, LearningUnit, Lesson +) + + +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 + exclude = ('partial_grading', ) + + +class QuizSerializer(serializers.ModelSerializer): + class Meta: + model = Quiz + exclude = ('view_answerpaper', ) + + +class QuestionPaperSerializer(serializers.ModelSerializer): + class Meta: + model = QuestionPaper + fields = '__all__' + + +class AnswerPaperSerializer(serializers.ModelSerializer): + + questions = QuestionSerializer(many=True) + + class Meta: + model = AnswerPaper + fields = '__all__' + + +class LessonSerializer(serializers.ModelSerializer): + class Meta: + model = Lesson + fields = '__all__' + + +class LearningUnitSerializer(serializers.ModelSerializer): + + quiz = QuizSerializer() + lesson = LessonSerializer() + + class Meta: + model = LearningUnit + fields = '__all__' + + +class LearningModuleSerializer(serializers.ModelSerializer): + + learning_unit = LearningUnitSerializer(many=True) + + class Meta: + model = LearningModule + fields = '__all__' + + +class CourseSerializer(serializers.ModelSerializer): + + learning_module = LearningModuleSerializer(many=True) + + class Meta: + model = Course + exclude = ( + 'teachers', + 'rejected', + 'requests', + 'students', + 'grading_system', + 'view_grade', + ) |