Skip to content

Commit

Permalink
Merge pull request #39 from zamanafzal/MCKIN-7018
Browse files Browse the repository at this point in the history
Add attributes to student_view_data for both Poll and Survey
  • Loading branch information
mtyaka authored Mar 13, 2018
2 parents c7f34db + 04bcf08 commit 1603aab
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ GET https://<lms_server_url>/api/courses/v1/blocks/?course_id=<course_id>&userna
Example poll return value:
```
"student_view_data": {
"feedback": "This is feedback message survey.",
"private_results": false,
"max_submissions": 1,
"question": "Did the explanation above make sense to you?",
"answers": [
[
Expand Down Expand Up @@ -302,6 +305,10 @@ Example poll return value:
Example survey return value:
```
"student_view_data": {
"feedback": "This is feedback message survey.",
"private_results": false,
"max_submissions": 1,
"block_name": "Poll2",
"answers": [
[
"Y",
Expand Down
7 changes: 7 additions & 0 deletions poll/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ def student_view_data(self, context=None):
return {
'question': self.question,
'answers': self.answers,
'max_submissions': self.max_submissions,
'private_results': self.private_results,
'feedback': self.feedback,
}

@XBlock.handler
Expand Down Expand Up @@ -846,6 +849,10 @@ def student_view_data(self, context=None):
return {
'questions': self.questions,
'answers': self.answers,
'max_submissions': self.max_submissions,
'private_results': self.private_results,
'block_name': self.block_name,
'feedback': self.feedback,
}

@XBlock.handler
Expand Down
16 changes: 15 additions & 1 deletion tests/unit/test_xblock_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def setUp(self):
['O', {'label': 'Other'}],
],
'submissions_count': 5,
'max_submissions': 1,
'private_results': False,
'feedback': 'My Feedback',
}
self.poll_block = PollBlock(
self.runtime,
Expand All @@ -41,6 +44,9 @@ def test_student_view_data(self):
expected_poll_data = {
'question': self.poll_data['question'],
'answers': self.poll_data['answers'],
'max_submissions': self.poll_data['max_submissions'],
'private_results': self.poll_data['private_results'],
'feedback': self.poll_data['feedback'],
}

student_view_data = self.poll_block.student_view_data()
Expand Down Expand Up @@ -86,7 +92,11 @@ def setUp(self):
['N', 'No'],
['M', 'Maybe']
],
'submissions_count': 5
'submissions_count': 5,
'max_submissions': 1,
'private_results': False,
'feedback': 'My Feedback',
'block_name': 'My Block Name',
}
self.survey_block = SurveyBlock(
self.runtime,
Expand All @@ -101,6 +111,10 @@ def test_student_view_data(self):
expected_survery_data = {
'questions': self.survery_data['questions'],
'answers': self.survery_data['answers'],
'max_submissions': self.survery_data['max_submissions'],
'private_results': self.survery_data['private_results'],
'feedback': self.survery_data['feedback'],
'block_name': self.survery_data['block_name'],
}

student_view_data = self.survey_block.student_view_data()
Expand Down

0 comments on commit 1603aab

Please sign in to comment.