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
d5ea6f63
Commit
d5ea6f63
authored
Mar 26, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address Cale's review comments
parent
cda7fd0d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
30 deletions
+59
-30
mentoring/answer.py
+16
-2
mentoring/choice.py
+6
-1
mentoring/mcq.py
+1
-1
mentoring/mentoring.py
+2
-3
mentoring/message.py
+6
-1
mentoring/questionnaire.py
+0
-9
mentoring/step.py
+11
-8
mentoring/table.py
+8
-3
mentoring/tip.py
+9
-2
No files found.
mentoring/answer.py
View file @
d5ea6f63
...
@@ -168,7 +168,8 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
...
@@ -168,7 +168,8 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
return
student_input
return
student_input
def
fallback_view
(
self
,
view_name
,
context
=
None
):
def
mentoring_view
(
self
,
context
=
None
):
""" Render this XBlock within a mentoring block. """
context
=
context
or
{}
context
=
context
or
{}
context
[
'self'
]
=
self
context
[
'self'
]
=
self
html
=
loader
.
render_template
(
'templates/html/answer_editable.html'
,
context
)
html
=
loader
.
render_template
(
'templates/html/answer_editable.html'
,
context
)
...
@@ -179,7 +180,15 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
...
@@ -179,7 +180,15 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
fragment
.
initialize_js
(
'AnswerBlock'
)
fragment
.
initialize_js
(
'AnswerBlock'
)
return
fragment
return
fragment
def
student_view
(
self
,
context
=
None
):
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
def
submit
(
self
,
submission
):
def
submit
(
self
,
submission
):
"""
The parent block is handling a student submission, including a new answer for this
block. Update accordingly.
"""
self
.
student_input
=
submission
[
0
][
'value'
]
.
strip
()
self
.
student_input
=
submission
[
0
][
'value'
]
.
strip
()
self
.
save
()
self
.
save
()
log
.
info
(
u'Answer submitted for`{}`: "{}"'
.
format
(
self
.
name
,
self
.
student_input
))
log
.
info
(
u'Answer submitted for`{}`: "{}"'
.
format
(
self
.
name
,
self
.
student_input
))
...
@@ -260,7 +269,8 @@ class AnswerRecapBlock(AnswerMixin, StudioEditableXBlockMixin, XBlock):
...
@@ -260,7 +269,8 @@ class AnswerRecapBlock(AnswerMixin, StudioEditableXBlockMixin, XBlock):
return
self
.
get_model_object
()
.
student_input
return
self
.
get_model_object
()
.
student_input
return
''
return
''
def
fallback_view
(
self
,
view_name
,
context
=
None
):
def
mentoring_view
(
self
,
context
=
None
):
""" Render this XBlock within a mentoring block. """
context
=
context
or
{}
context
=
context
or
{}
context
[
'title'
]
=
self
.
display_name
context
[
'title'
]
=
self
.
display_name
context
[
'description'
]
=
self
.
description
context
[
'description'
]
=
self
.
description
...
@@ -270,3 +280,7 @@ class AnswerRecapBlock(AnswerMixin, StudioEditableXBlockMixin, XBlock):
...
@@ -270,3 +280,7 @@ class AnswerRecapBlock(AnswerMixin, StudioEditableXBlockMixin, XBlock):
fragment
=
Fragment
(
html
)
fragment
=
Fragment
(
html
)
fragment
.
add_css_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/css/answer.css'
))
fragment
.
add_css_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/css/answer.css'
))
return
fragment
return
fragment
def
student_view
(
self
,
context
=
None
):
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
mentoring/choice.py
View file @
d5ea6f63
...
@@ -68,9 +68,14 @@ class ChoiceBlock(StudioEditableXBlockMixin, XBlock):
...
@@ -68,9 +68,14 @@ class ChoiceBlock(StudioEditableXBlockMixin, XBlock):
status
=
self
.
_
(
u"Out of Context"
)
# Parent block should implement describe_choice_correctness()
status
=
self
.
_
(
u"Out of Context"
)
# Parent block should implement describe_choice_correctness()
return
self
.
_
(
u"Choice ({status})"
)
.
format
(
status
=
status
)
return
self
.
_
(
u"Choice ({status})"
)
.
format
(
status
=
status
)
def
fallback_view
(
self
,
view_name
,
context
):
def
mentoring_view
(
self
,
context
=
None
):
""" Render this choice string within a mentoring block question. """
return
Fragment
(
u'<span class="choice-text">{}</span>'
.
format
(
self
.
content
))
return
Fragment
(
u'<span class="choice-text">{}</span>'
.
format
(
self
.
content
))
def
student_view
(
self
,
context
=
None
):
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
def
validate_field_data
(
self
,
validation
,
data
):
def
validate_field_data
(
self
,
validation
,
data
):
"""
"""
Validate this block's field data.
Validate this block's field data.
...
...
mentoring/mcq.py
View file @
d5ea6f63
...
@@ -83,7 +83,7 @@ class MCQBlock(QuestionnaireAbstractBlock):
...
@@ -83,7 +83,7 @@ class MCQBlock(QuestionnaireAbstractBlock):
tips_html
.
append
(
tip
.
render
(
'mentoring_view'
)
.
content
)
tips_html
.
append
(
tip
.
render
(
'mentoring_view'
)
.
content
)
if
tips_html
:
if
tips_html
:
formatted_tips
=
ResourceLoader
(
__name__
)
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
formatted_tips
=
loader
.
render_template
(
'templates/html/tip_choice_group.html'
,
{
'tips_html'
:
tips_html
,
'tips_html'
:
tips_html
,
})
})
...
...
mentoring/mentoring.py
View file @
d5ea6f63
...
@@ -341,7 +341,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -341,7 +341,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
self
.
attempted
=
True
self
.
attempted
=
True
if
self
.
is_assessment
:
if
self
.
is_assessment
:
return
self
.
handle
AssessmentS
ubmit
(
submissions
,
suffix
)
return
self
.
handle
_assessment_s
ubmit
(
submissions
,
suffix
)
submit_results
=
[]
submit_results
=
[]
completed
=
True
completed
=
True
...
@@ -410,8 +410,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
...
@@ -410,8 +410,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
'num_attempts'
:
self
.
num_attempts
'num_attempts'
:
self
.
num_attempts
}
}
def
handleAssessmentSubmit
(
self
,
submissions
,
suffix
):
def
handle_assessment_submit
(
self
,
submissions
,
suffix
):
completed
=
False
completed
=
False
current_child
=
None
current_child
=
None
children
=
[
self
.
runtime
.
get_block
(
child_id
)
for
child_id
in
self
.
children
]
children
=
[
self
.
runtime
.
get_block
(
child_id
)
for
child_id
in
self
.
children
]
...
...
mentoring/message.py
View file @
d5ea6f63
...
@@ -64,10 +64,15 @@ class MentoringMessageBlock(XBlock, StudioEditableXBlockMixin):
...
@@ -64,10 +64,15 @@ class MentoringMessageBlock(XBlock, StudioEditableXBlockMixin):
""" translate text """
""" translate text """
return
self
.
runtime
.
service
(
self
,
"i18n"
)
.
ugettext
(
text
)
return
self
.
runtime
.
service
(
self
,
"i18n"
)
.
ugettext
(
text
)
def
fallback_view
(
self
,
view_name
,
context
):
def
mentoring_view
(
self
,
context
=
None
):
""" Render this message for use by a mentoring block. """
html
=
u'<div class="message {msg_type}">{content}</div>'
.
format
(
msg_type
=
self
.
type
,
content
=
self
.
content
)
html
=
u'<div class="message {msg_type}">{content}</div>'
.
format
(
msg_type
=
self
.
type
,
content
=
self
.
content
)
return
Fragment
(
html
)
return
Fragment
(
html
)
def
student_view
(
self
,
context
=
None
):
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
@property
@property
def
display_name_with_default
(
self
):
def
display_name_with_default
(
self
):
if
self
.
type
==
'max_attempts_reached'
:
if
self
.
type
==
'max_attempts_reached'
:
...
...
mentoring/questionnaire.py
View file @
d5ea6f63
...
@@ -142,15 +142,6 @@ class QuestionnaireAbstractBlock(StudioEditableXBlockMixin, StudioContainerXBloc
...
@@ -142,15 +142,6 @@ class QuestionnaireAbstractBlock(StudioEditableXBlockMixin, StudioContainerXBloc
def
mentoring_view
(
self
,
context
=
None
):
def
mentoring_view
(
self
,
context
=
None
):
return
self
.
student_view
(
context
)
return
self
.
student_view
(
context
)
def
assessment_step_view
(
self
,
context
=
None
):
"""
assessment_step_view is the same as mentoring_view, except its DIV will have a different
class (.xblock-v1-assessment_step_view) that we use for assessments to hide all the
steps with CSS and to detect which children of mentoring are "Steps" and which are just
decorative elements/instructions.
"""
return
self
.
mentoring_view
(
context
)
@property
@property
def
custom_choices
(
self
):
def
custom_choices
(
self
):
custom_choices
=
[]
custom_choices
=
[]
...
...
mentoring/step.py
View file @
d5ea6f63
...
@@ -66,15 +66,18 @@ class StepMixin(object):
...
@@ -66,15 +66,18 @@ class StepMixin(object):
def
author_view
(
self
,
context
):
def
author_view
(
self
,
context
):
context
=
context
or
{}
context
=
context
or
{}
context
[
'hide_header'
]
=
True
context
[
'hide_header'
]
=
True
try
:
return
self
.
mentoring_view
(
context
)
return
self
.
mentoring_view
(
context
)
except
AttributeError
:
return
self
.
fallback_view
(
'mentoring_view'
,
context
)
def
author_preview_view
(
self
,
context
):
def
author_preview_view
(
self
,
context
):
context
=
context
or
{}
context
=
context
or
{}
context
[
'hide_header'
]
=
True
context
[
'hide_header'
]
=
True
try
:
return
self
.
student_view
(
context
)
return
self
.
student_view
(
context
)
except
AttributeError
:
def
assessment_step_view
(
self
,
context
=
None
):
return
self
.
fallback_view
(
'student_view'
,
context
)
"""
assessment_step_view is the same as mentoring_view, except its DIV will have a different
class (.xblock-v1-assessment_step_view) that we use for assessments to hide all the
steps with CSS and to detect which children of mentoring are "Steps" and which are just
decorative elements/instructions.
"""
return
self
.
mentoring_view
(
context
)
mentoring/table.py
View file @
d5ea6f63
...
@@ -134,7 +134,8 @@ class MentoringTableColumn(StudioEditableXBlockMixin, StudioContainerXBlockMixin
...
@@ -134,7 +134,8 @@ class MentoringTableColumn(StudioEditableXBlockMixin, StudioContainerXBlockMixin
editable_fields
=
(
"header"
,
)
editable_fields
=
(
"header"
,
)
has_children
=
True
has_children
=
True
def
fallback_view
(
self
,
view_name
,
context
):
def
mentoring_view
(
self
,
context
=
None
):
""" Render this XBlock within a mentoring block. """
context
=
context
or
{}
context
=
context
or
{}
fragment
=
Fragment
()
fragment
=
Fragment
()
for
child_id
in
self
.
children
:
for
child_id
in
self
.
children
:
...
@@ -144,13 +145,17 @@ class MentoringTableColumn(StudioEditableXBlockMixin, StudioContainerXBlockMixin
...
@@ -144,13 +145,17 @@ class MentoringTableColumn(StudioEditableXBlockMixin, StudioContainerXBlockMixin
# with HTML we don't want. So just grab its HTML directly.
# with HTML we don't want. So just grab its HTML directly.
child_frag
=
Fragment
(
child
.
data
)
child_frag
=
Fragment
(
child
.
data
)
else
:
else
:
child_frag
=
child
.
render
(
view_name
,
context
)
child_frag
=
child
.
render
(
'mentoring_view'
,
context
)
fragment
.
add_content
(
child_frag
.
content
)
fragment
.
add_content
(
child_frag
.
content
)
fragment
.
add_frag_resources
(
child_frag
)
fragment
.
add_frag_resources
(
child_frag
)
return
fragment
return
fragment
def
author_preview_view
(
self
,
context
):
def
author_preview_view
(
self
,
context
):
return
self
.
fallback_view
(
'mentoring_view'
,
context
)
return
self
.
mentoring_view
(
context
)
def
student_view
(
self
,
context
=
None
):
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
def
author_edit_view
(
self
,
context
):
def
author_edit_view
(
self
,
context
):
"""
"""
...
...
mentoring/tip.py
View file @
d5ea6f63
...
@@ -30,6 +30,8 @@ from xblock.validation import ValidationMessage
...
@@ -30,6 +30,8 @@ from xblock.validation import ValidationMessage
from
xblockutils.resources
import
ResourceLoader
from
xblockutils.resources
import
ResourceLoader
from
xblockutils.studio_editable
import
StudioEditableXBlockMixin
from
xblockutils.studio_editable
import
StudioEditableXBlockMixin
loader
=
ResourceLoader
(
__name__
)
# Make '_' a no-op so we can scrape strings
# Make '_' a no-op so we can scrape strings
def
_
(
text
):
def
_
(
text
):
...
@@ -86,14 +88,19 @@ class TipBlock(StudioEditableXBlockMixin, XBlock):
...
@@ -86,14 +88,19 @@ class TipBlock(StudioEditableXBlockMixin, XBlock):
values_list
.
append
(
display_name
)
values_list
.
append
(
display_name
)
return
self
.
_
(
u"Tip for {list_of_choices}"
)
.
format
(
list_of_choices
=
u", "
.
join
(
values_list
))
return
self
.
_
(
u"Tip for {list_of_choices}"
)
.
format
(
list_of_choices
=
u", "
.
join
(
values_list
))
def
fallback_view
(
self
,
view_name
,
context
):
def
mentoring_view
(
self
,
context
=
None
):
html
=
ResourceLoader
(
__name__
)
.
render_template
(
"templates/html/tip.html"
,
{
""" Render this XBlock within a mentoring block. """
html
=
loader
.
render_template
(
"templates/html/tip.html"
,
{
'content'
:
self
.
content
,
'content'
:
self
.
content
,
'width'
:
self
.
width
,
'width'
:
self
.
width
,
'height'
:
self
.
height
,
'height'
:
self
.
height
,
})
})
return
Fragment
(
html
)
return
Fragment
(
html
)
def
student_view
(
self
,
context
=
None
):
""" Normal view of this XBlock, identical to mentoring_view """
return
self
.
mentoring_view
(
context
)
def
clean_studio_edits
(
self
,
data
):
def
clean_studio_edits
(
self
,
data
):
"""
"""
Clean up the edits during studio_view save
Clean up the edits during studio_view save
...
...
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