diff options
author | prathamesh | 2019-06-21 03:23:45 +0530 |
---|---|---|
committer | prathamesh | 2019-06-21 03:23:45 +0530 |
commit | a7b4b9e0c6699987d1dee4007e9c62da15559432 (patch) | |
tree | 7cb2bfe3dcb36f073ad9db1f1b1d3a2f465cd2d0 /api/serializers.py | |
parent | 81d1e4e4ff4406f7f3823c40a82cf21096f2ccec (diff) | |
download | online_test-a7b4b9e0c6699987d1dee4007e9c62da15559432.tar.gz online_test-a7b4b9e0c6699987d1dee4007e9c62da15559432.tar.bz2 online_test-a7b4b9e0c6699987d1dee4007e9c62da15559432.zip |
Add API to get complete course details and AnswerPaper for the quiz
Courses are retrieved in which the user is a student.
Complete course info is made available.
Answerpaper is created if does not exists on start quiz.
AnswerPaper detail info is made available.
If attempts are not allowed then the message is retrieved.
Diffstat (limited to 'api/serializers.py')
-rw-r--r-- | api/serializers.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/api/serializers.py b/api/serializers.py index d34f269..df66730 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -1,5 +1,8 @@ from rest_framework import serializers -from yaksh.models import Question, Quiz, QuestionPaper, AnswerPaper +from yaksh.models import ( + Question, Quiz, QuestionPaper, AnswerPaper, Course, + LearningModule, LearningUnit, Lesson +) class QuestionSerializer(serializers.ModelSerializer): @@ -21,6 +24,43 @@ class QuestionPaperSerializer(serializers.ModelSerializer): 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 + fields = '__all__' |