Commit dcf57dd5 by Eugeny Kolpakov Committed by GitHub

Merge pull request #165 from open-craft/ekolpakov/student_view_data_with_display_names

Student view data with display names
parents 21e21468 38407811
......@@ -26,6 +26,7 @@ Problem Builder (`problem-builder`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `max_attempts`: (integer) Max number of allowed attempts.
- `extended_feedback`: (boolean) `true` if extended feedback is enabled for this
block.
......@@ -103,6 +104,7 @@ Step Builder (`step-builder`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `title`: (string) The display name of the component.
- `show_title`: (boolean) `true` if the title should be displayed.
- `weight`: (float) The weight of the problem.
......@@ -164,6 +166,7 @@ Mentoring Step (`sb-step`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"sb-step"` for Mentoring Step components.
- `title`: (string) Step component's display name.
- `show_title`: (boolean) `true` if the title should be displayed.
......@@ -187,6 +190,7 @@ Review Step (`sb-review-step`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"sb-review-step`" for Review Step components.
- `title`: (string) Display name of the component.
- `components`: (array) A list of `student_view_data` output of all immediate
......@@ -201,6 +205,7 @@ Conditional Message component is always child of a Review Step component.
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"sb-conditional-message"` for Conditional
Message components.
- `content`: (string) Content of the message. May contain HTML.
......@@ -214,6 +219,7 @@ Score Summary (`sb-review-score`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"sb-review-score"` for Score Summary
components.
......@@ -223,6 +229,7 @@ Per-Question Feedback (`sb-review-per-question-feedback`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"sb-review-per-question-feedback"` for Score
Summary components.
......@@ -232,6 +239,7 @@ Long Answer (`pb-answer`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"pb-answer"` for Long Answer components.
- `id`: (string) Unique ID (name) of the component.
- `weight`: (float) The weight of this component.
......@@ -269,6 +277,7 @@ Multiple Choice Question (`pb-mcq`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"pb-mcq"` for MCQ components.
- `id`: (string) Unique ID (name) of the component.
- `question`: (string) The content of the question.
......@@ -320,6 +329,7 @@ Rating Question (`pb-rating`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
Identical to [MCQ questions](#multiple-choice-question-pb-mcq) except that the
`type` field always equals `"pb-rating"`.
......@@ -342,6 +352,7 @@ Multiple Response Question (`pb-mrq`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"pb-mrq"` for Multiple Response Question
components.
- `id`: (string) Unique ID (name) of the component.
......@@ -399,6 +410,7 @@ Ranged Value Slider (`pb-slider`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"pb-slider"` for Ranged Value Slider
components.
- `id`: (string) Unique ID (name) of the component.
......@@ -431,6 +443,7 @@ Completion (`pb-completion`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"pb-completion"` for Completion components.
- `id`: (string) Unique ID (name) of the component.
- `title`: (string) Display name of the problem.
......@@ -463,6 +476,7 @@ Plot (`sb-plot`)
### `student_view_data`
- `block_id`: (string) The XBlock's usage ID.
- `display_name`: (string) The XBlock's display name.
- `type`: (string) Always equals `"sb-plot"` for Plot components.
- `title`: (string) Display name of the component.
- `q1_label`: (string) Quadrant I label.
......
......@@ -267,6 +267,7 @@ class AnswerBlock(SubmittingXBlockMixin, AnswerMixin, QuestionMixin, StudioEdita
return {
'id': self.name,
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name,
'type': self.CATEGORY,
'weight': self.weight,
'question': self.question,
......
......@@ -74,8 +74,10 @@ class ChoiceBlock(
Returns a JSON representation of the student_view of this XBlock,
retrievable from the Course Block API.
"""
# display_name_with_default gives out correctness - not adding it here
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self._(u"Choice ({content})").format(content=self.content),
'value': self.value,
'content': self.content,
}
......
......@@ -116,6 +116,7 @@ class CompletionBlock(
return {
'id': self.name,
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
'question': self.question,
'answer': self.answer,
......
......@@ -177,6 +177,7 @@ class MCQBlock(SubmittingXBlockMixin, StudentViewUserStateMixin, QuestionnaireAb
return {
'id': self.name,
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
'question': self.question,
'message': self.message,
......
......@@ -923,6 +923,7 @@ class MentoringBlock(
components.append(block.student_view_data())
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name,
'max_attempts': self.max_attempts,
'extended_feedback': self.extended_feedback,
'feedback_label': self.feedback_label,
......@@ -1272,6 +1273,7 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
return {
'title': self.display_name,
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name,
'show_title': self.show_title,
'weight': self.weight,
'extended_feedback': self.extended_feedback,
......
......@@ -207,6 +207,7 @@ class MRQBlock(SubmittingXBlockMixin, StudentViewUserStateMixin, QuestionnaireAb
return {
'id': self.name,
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name,
'title': self.display_name,
'type': self.CATEGORY,
'weight': self.weight,
......
......@@ -362,6 +362,7 @@ class PlotBlock(
retrievable from the Course XBlock API.
"""
return {
'display_name': self.display_name,
'type': self.CATEGORY,
'title': self.display_name,
'q1_label': self.q1_label,
......
......@@ -128,6 +128,7 @@ class SliderBlock(
return {
'id': self.name,
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
'question': self.question,
'min_label': self.min_label,
......
......@@ -283,6 +283,7 @@ class MentoringStepBlock(
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
'title': self.display_name_with_default,
'show_title': self.show_title,
......
......@@ -112,6 +112,7 @@ class ConditionalMessageBlock(
def student_view_data(self, context=None):
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
'content': self.content,
'score_condition': self.score_condition,
......@@ -163,6 +164,7 @@ class ScoreSummaryBlock(XBlockWithTranslationServiceMixin, XBlockWithPreviewMixi
def student_view_data(self, context=None):
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
}
......@@ -217,6 +219,7 @@ class PerQuestionFeedbackBlock(XBlockWithTranslationServiceMixin, XBlockWithPrev
def student_view_data(self, context=None):
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name_with_default,
'type': self.CATEGORY,
}
......@@ -314,6 +317,7 @@ class ReviewStepBlock(
return {
'block_id': unicode(self.scope_ids.usage_id),
'display_name': self.display_name,
'type': self.CATEGORY,
'title': self.display_name,
'components': components,
......
......@@ -22,9 +22,13 @@ class TestMRQBlock(BlockWithChildrenTestMixin, unittest.TestCase):
"""
block = MRQBlock(Mock(), DictFieldData({}), Mock())
self.assertListEqual(
self.assertItemsEqual(
block.student_view_data().keys(),
['hide_results', 'tips', 'block_id', 'weight', 'title', 'question', 'message', 'type', 'id', 'choices'])
[
'hide_results', 'tips', 'block_id', 'display_name',
'weight', 'title', 'question', 'message', 'type', 'id', 'choices'
]
)
@ddt.ddt
......@@ -139,7 +143,8 @@ class TestMentoringBlock(BlockWithChildrenTestMixin, unittest.TestCase):
}
children = get_mock_components()
children_by_id = {child.block_id: child for child in children}
block_data = {'children': children}
display_name = "I'm problem builder"
block_data = {'display_name': display_name, 'children': children}
block_data.update(shared_data)
block = MentoringBlock(Mock(usage_id=1), DictFieldData(block_data), Mock(usage_id=1))
block.runtime = Mock(
......@@ -149,6 +154,7 @@ class TestMentoringBlock(BlockWithChildrenTestMixin, unittest.TestCase):
)
expected = {
'block_id': '1',
'display_name': display_name,
'components': [
'child_a_json',
],
......
......@@ -14,9 +14,14 @@ class TestMentoringBlock(BlockWithChildrenTestMixin, unittest.TestCase):
def test_student_view_data(self):
blocks_by_id = {}
services_mocks = {
"i18n": Mock(ugettext=lambda string: string)
}
mock_runtime = Mock(
get_block=lambda block_id: blocks_by_id[block_id],
load_block_type=lambda block: block.__class__,
service=lambda _, service_id: services_mocks.get(service_id),
id_reader=Mock(
get_definition_id=lambda block_id: block_id,
get_block_type=lambda block_id: blocks_by_id[block_id],
......@@ -90,6 +95,7 @@ class TestMentoringBlock(BlockWithChildrenTestMixin, unittest.TestCase):
expected = {
'block_id': u'1',
'display_name': step_builder_data['display_name'],
'title': step_builder_data['display_name'],
'show_title': step_builder_data['show_title'],
'weight': step_builder_data['weight'],
......@@ -99,6 +105,7 @@ class TestMentoringBlock(BlockWithChildrenTestMixin, unittest.TestCase):
{
'block_id': '2',
'type': 'sb-step',
'display_name': step_data['display_name'],
'title': step_data['display_name'],
'show_title': step_data['show_title'],
'next_button_label': step_data['next_button_label'],
......@@ -108,14 +115,17 @@ class TestMentoringBlock(BlockWithChildrenTestMixin, unittest.TestCase):
{
'block_id': '3',
'type': 'sb-review-step',
'display_name': review_step_data['display_name'],
'title': review_step_data['display_name'],
'components': [
{
'block_id': '4',
'display_name': "Score Summary",
'type': 'sb-review-score',
},
{
'block_id': '5',
'display_name': "Conditional Message",
'type': 'sb-conditional-message',
'content': conditional_message_data['content'],
'score_condition': conditional_message_data['score_condition'],
......
......@@ -97,6 +97,7 @@ class TipBlock(StudioEditableXBlockMixin, XBlockWithTranslationServiceMixin, XBl
def student_view_data(self, context=None):
return {
'display_name': self.display_name_with_default,
'content': self.content,
'for_choices': self.values,
}
......
......@@ -71,7 +71,7 @@ BLOCKS = [
setup(
name='xblock-problem-builder',
version='2.7.4',
version='2.7.5',
description='XBlock - Problem Builder',
packages=find_packages(),
install_requires=[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment