Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
62423ffb
Commit
62423ffb
authored
8 years ago
by
Albert (AJ) St. Aubin
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #13719 from edx/christina/tnl-5737
Corrected issue with the Show Hint button enabled state with single hint.
parents
f8589e4d
088b5c66
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/capa_base.py
+9
-6
9 additions, 6 deletions
common/lib/xmodule/xmodule/capa_base.py
common/lib/xmodule/xmodule/tests/test_capa_module.py
+31
-1
31 additions, 1 deletion
common/lib/xmodule/xmodule/tests/test_capa_module.py
with
40 additions
and
7 deletions
common/lib/xmodule/xmodule/capa_base.py
+
9
−
6
View file @
62423ffb
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/tests/test_capa_module.py
+
31
−
1
View file @
62423ffb
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment