Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
349b58bb
Commit
349b58bb
authored
Feb 26, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors caused by abuse of display_name
parent
323d03b8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
22 deletions
+39
-22
mentoring/components/answer.py
+7
-1
mentoring/components/choice.py
+10
-8
mentoring/components/message.py
+7
-1
mentoring/components/questionnaire.py
+8
-11
mentoring/components/tip.py
+7
-1
No files found.
mentoring/components/answer.py
View file @
349b58bb
...
...
@@ -137,9 +137,15 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
editable_fields
=
(
'question'
,
'name'
,
'min_characters'
,
'weight'
,
'default_from'
)
@property
def
display_name
(
self
):
def
studio_
display_name
(
self
):
return
u"Question {}"
.
format
(
self
.
step_number
)
if
not
self
.
lonely_step
else
u"Question"
def
__getattribute__
(
self
,
name
):
""" Provide a read-only display name without adding a display_name field to the class. """
if
name
==
"display_name"
:
return
self
.
studio_display_name
return
super
(
AnswerBlock
,
self
)
.
__getattribute__
(
name
)
@lazy
def
student_input
(
self
):
"""
...
...
mentoring/components/choice.py
View file @
349b58bb
...
...
@@ -53,16 +53,18 @@ class ChoiceBlock(StudioEditableXBlockMixin, XBlock):
)
editable_fields
=
(
'content'
,
)
@property
def
studio_display_name
(
self
):
try
:
status
=
self
.
get_parent
()
.
describe_choice_correctness
(
self
.
value
)
except
Exception
:
status
=
u"Out of Context"
# Parent block should implement describe_choice_correctness()
return
u"Choice ({})"
.
format
(
status
)
def
__getattribute__
(
self
,
name
):
"""
Provide a read-only display name without adding a display_name field to the class.
"""
""" Provide a read-only display name without adding a display_name field to the class. """
if
name
==
"display_name"
:
try
:
status
=
self
.
get_parent
()
.
describe_choice_correctness
(
self
.
value
)
except
Exception
:
status
=
u"Out of Context"
# Parent block should implement describe_choice_correctness()
return
u"Choice ({})"
.
format
(
status
)
return
self
.
studio_display_name
return
super
(
ChoiceBlock
,
self
)
.
__getattribute__
(
name
)
def
fallback_view
(
self
,
view_name
,
context
):
...
...
mentoring/components/message.py
View file @
349b58bb
...
...
@@ -62,7 +62,7 @@ class MentoringMessageBlock(XBlock, StudioEditableXBlockMixin):
return
Fragment
(
html
)
@property
def
display_name
(
self
):
def
studio_
display_name
(
self
):
if
self
.
type
==
'max_attempts_reached'
:
max_attempts
=
self
.
get_parent
()
.
max_attempts
return
u"Message when student reaches max. # of attempts ({current_limit})"
.
format
(
...
...
@@ -74,6 +74,12 @@ class MentoringMessageBlock(XBlock, StudioEditableXBlockMixin):
return
u"Message shown when incomplete"
return
u"INVALID MESSAGE"
def
__getattribute__
(
self
,
name
):
""" Provide a read-only display name without adding a display_name field to the class. """
if
name
==
"display_name"
:
return
self
.
studio_display_name
return
super
(
MentoringMessageBlock
,
self
)
.
__getattribute__
(
name
)
@classmethod
def
get_template
(
cls
,
template_id
):
"""
...
...
mentoring/components/questionnaire.py
View file @
349b58bb
...
...
@@ -43,15 +43,6 @@ loader = ResourceLoader(__name__)
# Classes ###########################################################
class
property_with_default
(
property
):
"""
Decorator for creating a dynamic display_name property that looks like an XBlock field. This
is needed for Studio container page blocks as studio will try to read
BlockClass.display_name.default
"""
default
=
u"Question"
class
QuestionnaireAbstractBlock
(
StudioEditableXBlockMixin
,
StudioContainerXBlockMixin
,
StepMixin
,
XBlock
):
"""
An abstract class used for MCQ/MRQ blocks
...
...
@@ -114,10 +105,16 @@ class QuestionnaireAbstractBlock(StudioEditableXBlockMixin, StudioContainerXBloc
return
block
@property
_with_default
def
display_name
(
self
):
@property
def
studio_
display_name
(
self
):
return
u"Question {}"
.
format
(
self
.
step_number
)
if
not
self
.
lonely_step
else
u"Question"
def
__getattribute__
(
self
,
name
):
""" Provide a read-only display name without adding a display_name field to the class. """
if
name
==
"display_name"
:
return
self
.
studio_display_name
return
super
(
QuestionnaireAbstractBlock
,
self
)
.
__getattribute__
(
name
)
def
student_view
(
self
,
context
=
None
):
name
=
getattr
(
self
,
"unmixed_class"
,
self
.
__class__
)
.
__name__
...
...
mentoring/components/tip.py
View file @
349b58bb
...
...
@@ -54,7 +54,7 @@ class TipBlock(StudioEditableXBlockMixin, XBlock):
editable_fields
=
(
'values'
,
'content'
,
'width'
,
'height'
)
@property
def
display_name
(
self
):
def
studio_
display_name
(
self
):
values_list
=
[]
for
entry
in
self
.
get_parent
()
.
human_readable_choices
:
if
entry
[
"value"
]
in
self
.
values
:
...
...
@@ -64,6 +64,12 @@ class TipBlock(StudioEditableXBlockMixin, XBlock):
values_list
.
append
(
display_name
)
return
u"Tip for {}"
.
format
(
u", "
.
join
(
values_list
))
def
__getattribute__
(
self
,
name
):
""" Provide a read-only display name without adding a display_name field to the class. """
if
name
==
"display_name"
:
return
self
.
studio_display_name
return
super
(
TipBlock
,
self
)
.
__getattribute__
(
name
)
def
fallback_view
(
self
,
view_name
,
context
):
html
=
ResourceLoader
(
__name__
)
.
render_template
(
"templates/html/tip.html"
,
{
'content'
:
self
.
content
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment