Skip to content

Commit 7df87db

Browse files
fixbug don't allow student to see answer
1 parent 42609ab commit 7df87db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

classroom/serializers/question.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class Meta:
2222
'number': {'min_value': 1},
2323
}
2424

25+
def to_representation(self, question):
26+
repr_ = super().to_representation(question)
27+
user = self.context['request'].user
28+
if user.is_student():
29+
repr_['answers'] = [] # Of course don't allow student to see answers
30+
return repr_
31+
2532
def validate(self, attrs):
2633
attrs = super().validate(attrs)
2734
self._validate_question_not_exist(attrs)

0 commit comments

Comments
 (0)