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
8024bae2
Commit
8024bae2
authored
Jun 06, 2016
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enforce display name in CAPA problems
FEDX-198
parent
849e3b79
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
3 deletions
+48
-3
common/lib/xmodule/xmodule/capa_base.py
+1
-1
common/lib/xmodule/xmodule/capa_module.py
+13
-0
common/lib/xmodule/xmodule/tests/test_capa_module.py
+28
-0
lms/templates/problem.html
+6
-2
No files found.
common/lib/xmodule/xmodule/capa_base.py
View file @
8024bae2
...
...
@@ -659,7 +659,7 @@ class CapaMixin(CapaFields):
check_button_checking
=
False
content
=
{
'name'
:
self
.
display_name_with_default
_escaped
,
'name'
:
self
.
display_name_with_default
,
'html'
:
html
,
'weight'
:
self
.
weight
,
}
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
8024bae2
...
...
@@ -128,6 +128,19 @@ class CapaModule(CapaMixin, XModule):
return
json
.
dumps
(
result
,
cls
=
ComplexEncoder
)
@property
def
display_name_with_default
(
self
):
"""
Constructs the display name for a CAPA problem.
Default to the display_name if it isn't None or not an empty string,
else fall back to problem category.
"""
if
self
.
display_name
is
None
or
not
self
.
display_name
.
strip
():
return
self
.
location
.
block_type
return
self
.
display_name
class
CapaDescriptor
(
CapaFields
,
RawDescriptor
):
"""
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
8024bae2
...
...
@@ -1719,6 +1719,34 @@ class CapaModuleTest(unittest.TestCase):
(
'answerpool'
,
[
'choice_1'
,
'choice_3'
,
'choice_2'
,
'choice_0'
]))
self
.
assertEquals
(
event_info
[
'success'
],
'incorrect'
)
@ddt.unpack
@ddt.data
(
{
'display_name'
:
None
,
'expected_display_name'
:
'problem'
},
{
'display_name'
:
''
,
'expected_display_name'
:
'problem'
},
{
'display_name'
:
' '
,
'expected_display_name'
:
'problem'
},
{
'display_name'
:
'CAPA 101'
,
'expected_display_name'
:
'CAPA 101'
}
)
def
test_problem_display_name_with_default
(
self
,
display_name
,
expected_display_name
):
"""
Verify that display_name_with_default works as expected.
"""
module
=
CapaFactory
.
create
(
display_name
=
display_name
)
self
.
assertEqual
(
module
.
display_name_with_default
,
expected_display_name
)
@ddt.data
(
''
,
' '
,
)
def
test_problem_no_display_name
(
self
,
display_name
):
"""
Verify that if problem display name is not provided then a default name is used.
"""
module
=
CapaFactory
.
create
(
display_name
=
display_name
)
module
.
get_problem_html
()
render_args
,
_
=
module
.
system
.
render_template
.
call_args
context
=
render_args
[
1
]
self
.
assertEqual
(
context
[
'problem'
][
'name'
],
module
.
location
.
block_type
)
@ddt.ddt
class
CapaDescriptorTest
(
unittest
.
TestCase
):
...
...
lms/templates/problem.html
View file @
8024bae2
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%
page
expression_filter=
"h"
/>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
from
openedx
.
core
.
djangolib
.
markup
import
HTML
%
>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<h3
class=
"hd hd-2 problem-header"
>
...
...
@@ -9,7 +13,7 @@
<div
class=
"problem"
>
<div
aria-live=
"polite"
>
${
problem['html']
}
${
HTML(problem['html'])
}
</div>
<div
class=
"action"
>
<input
type=
"hidden"
name=
"problem_id"
value=
"${ problem['name'] }"
/>
...
...
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