Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
088b5c66
Commit
088b5c66
authored
Oct 11, 2016
by
Albert St. Aubin
Committed by
cahrens
Oct 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected issue with the Show Hint button enabled state with single hint.
TNL-5737
parent
f8589e4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
7 deletions
+40
-7
common/lib/xmodule/xmodule/capa_base.py
+9
-6
common/lib/xmodule/xmodule/tests/test_capa_module.py
+31
-1
No files found.
common/lib/xmodule/xmodule/capa_base.py
View file @
088b5c66
...
...
@@ -565,12 +565,12 @@ class CapaMixin(CapaFields):
return
html
def
_should_enable_demand_hint
(
self
,
hint_index
,
demand_hints
):
def
_should_enable_demand_hint
(
self
,
demand_hints
,
hint_index
=
None
):
"""
Should the demand hint option be enabled?
Arguments:
hint_index (int): The current hint index.
hint_index (int): The current hint index
, or None (default value) if no hint is currently being shown
.
demand_hints (list): List of hints.
Returns:
bool: True is the demand hint is possible.
...
...
@@ -578,7 +578,11 @@ class CapaMixin(CapaFields):
"""
# hint_index is the index of the last hint that will be displayed in this rendering,
# so add 1 to check if others exist.
return
len
(
demand_hints
)
>
0
,
len
(
demand_hints
)
>
0
and
hint_index
+
1
<
len
(
demand_hints
)
if
hint_index
is
None
:
should_enable
=
len
(
demand_hints
)
>
0
else
:
should_enable
=
len
(
demand_hints
)
>
0
and
hint_index
+
1
<
len
(
demand_hints
)
return
len
(
demand_hints
)
>
0
,
should_enable
def
get_demand_hint
(
self
,
hint_index
):
"""
...
...
@@ -621,7 +625,7 @@ class CapaMixin(CapaFields):
event_info
[
'hint_text'
]
=
get_inner_html_from_xpath
(
demand_hints
[
hint_index
])
self
.
runtime
.
publish
(
self
,
'edx.problem.hint.demandhint_displayed'
,
event_info
)
_
,
should_enable_next_hint
=
self
.
_should_enable_demand_hint
(
hint_index
,
demand_hints
)
_
,
should_enable_next_hint
=
self
.
_should_enable_demand_hint
(
demand_hints
=
demand_hints
,
hint_index
=
hint_index
)
# We report the index of this hint, the client works out what index to use to get the next hint
return
{
...
...
@@ -663,9 +667,8 @@ class CapaMixin(CapaFields):
}
# If demand hints are available, emit hint button and div.
hint_index
=
0
demand_hints
=
self
.
lcp
.
tree
.
xpath
(
"//problem/demandhint/hint"
)
demand_hint_possible
,
should_enable_next_hint
=
self
.
_should_enable_demand_hint
(
hint_index
,
demand_hints
)
demand_hint_possible
,
should_enable_next_hint
=
self
.
_should_enable_demand_hint
(
demand_hints
=
demand_hints
)
answer_notification_type
,
answer_notification_message
=
self
.
_get_answer_notification
(
render_notifications
=
submit_notification
)
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
088b5c66
...
...
@@ -1238,7 +1238,8 @@ class CapaModuleTest(unittest.TestCase):
module
=
CapaFactory
.
create
(
xml
=
self
.
demand_xml
)
module
.
get_problem_html
()
# ignoring html result
context
=
module
.
system
.
render_template
.
call_args
[
0
][
1
]
self
.
assertEqual
(
context
[
'demand_hint_possible'
],
True
)
self
.
assertTrue
(
context
[
'demand_hint_possible'
])
self
.
assertTrue
(
context
[
'should_enable_next_hint'
])
# Check the AJAX call that gets the hint by index
result
=
module
.
get_demand_hint
(
0
)
...
...
@@ -1253,6 +1254,35 @@ class CapaModuleTest(unittest.TestCase):
self
.
assertEqual
(
result
[
'hint_index'
],
0
)
self
.
assertTrue
(
result
[
'should_enable_next_hint'
])
def
test_single_demand_hint
(
self
):
"""
Test the hint button enabled state when there is just a single hint.
"""
test_xml
=
"""
<problem>
<p>That is the question</p>
<multiplechoiceresponse>
<choicegroup type="MultipleChoice">
<choice correct="false">Alpha <choicehint>A hint</choicehint>
</choice>
<choice correct="true">Beta</choice>
</choicegroup>
</multiplechoiceresponse>
<demandhint>
<hint>Only demand hint</hint>
</demandhint>
</problem>"""
module
=
CapaFactory
.
create
(
xml
=
test_xml
)
module
.
get_problem_html
()
# ignoring html result
context
=
module
.
system
.
render_template
.
call_args
[
0
][
1
]
self
.
assertTrue
(
context
[
'demand_hint_possible'
])
self
.
assertTrue
(
context
[
'should_enable_next_hint'
])
# Check the AJAX call that gets the hint by index
result
=
module
.
get_demand_hint
(
0
)
self
.
assertEqual
(
result
[
'hint_index'
],
0
)
self
.
assertFalse
(
result
[
'should_enable_next_hint'
])
def
test_demand_hint_logging
(
self
):
module
=
CapaFactory
.
create
(
xml
=
self
.
demand_xml
)
# Re-mock the module_id to a fixed string, so we can check the logging
...
...
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