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
fa81f303
Commit
fa81f303
authored
Oct 12, 2016
by
Brian Beggs
Committed by
GitHub
Oct 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13735 from edx/release
Merge release -> master for release-2016-10-12
parents
a9c548c3
9629e5bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
10 deletions
+43
-10
common/lib/xmodule/xmodule/capa_base.py
+9
-6
common/lib/xmodule/xmodule/tests/test_capa_module.py
+31
-1
common/static/sass/edx-pattern-library-shims/_buttons.scss
+3
-3
No files found.
common/lib/xmodule/xmodule/capa_base.py
View file @
fa81f303
...
...
@@ -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 @
fa81f303
...
...
@@ -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
...
...
common/static/sass/edx-pattern-library-shims/_buttons.scss
View file @
fa81f303
...
...
@@ -8,7 +8,7 @@
// ----------------------------
// #GLOBALS
// ----------------------------
%btn
{
%btn
-shims
{
display
:
inline-block
;
border-style
:
$btn-border-style
;
border-radius
:
$btn-border-radius
;
...
...
@@ -50,7 +50,7 @@
// #DEFAULT
// ----------------------------
.btn-default
{
@extend
%btn
;
@extend
%btn
-shims
;
border-color
:
$btn-default-border-color
;
background
:
$btn-default-background
;
color
:
$btn-default-color
;
...
...
@@ -85,7 +85,7 @@
// #BRAND
// ----------------------------
.btn-brand
{
@extend
%btn
;
@extend
%btn
-shims
;
border-color
:
$btn-brand-border-color
;
background
:
$btn-brand-background
;
color
:
$btn-brand-color
;
...
...
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