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
261b5c45
Commit
261b5c45
authored
Aug 05, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change and simplify template; move if statement on `status` into python
parent
c65f0cac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
37 deletions
+69
-37
common/lib/capa/capa/inputtypes.py
+12
-2
common/lib/capa/capa/templates/formulaequationinput.html
+11
-32
common/lib/capa/capa/tests/test_input_templates.py
+26
-1
common/lib/capa/capa/tests/test_inputtypes.py
+18
-0
common/lib/xmodule/xmodule/css/capa/display.scss
+2
-2
No files found.
common/lib/capa/capa/inputtypes.py
View file @
261b5c45
...
@@ -1086,9 +1086,19 @@ class FormulaEquationInput(InputTypeBase):
...
@@ -1086,9 +1086,19 @@ class FormulaEquationInput(InputTypeBase):
def
_extra_context
(
self
):
def
_extra_context
(
self
):
"""
"""
TODO (vshnayder): Get rid of
this
once we have a standard way of requiring js to be loaded.
TODO (vshnayder): Get rid of
'previewer'
once we have a standard way of requiring js to be loaded.
"""
"""
return
{
'previewer'
:
'/static/js/capa/formula_equation_preview.js'
,
}
# `reported_status` is basically `status`, except we say 'unanswered'
reported_status
=
''
if
self
.
status
==
'unsubmitted'
:
reported_status
=
'unanswered'
elif
self
.
status
in
(
'correct'
,
'incorrect'
,
'incomplete'
):
reported_status
=
self
.
status
return
{
'previewer'
:
'/static/js/capa/formula_equation_preview.js'
,
'reported_status'
:
reported_status
}
def
handle_ajax
(
self
,
dispatch
,
get
):
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
'''
...
...
common/lib/capa/capa/templates/formulaequationinput.html
View file @
261b5c45
<section
id=
"formulaequationinput_${id}"
class=
"formulaequationinput"
>
<section
id=
"formulaequationinput_${id}"
class=
"formulaequationinput"
>
<div
class=
"script_placeholder"
data-src=
"${previewer}"
/>
<div
class=
"${reported_status}"
id=
"status_${id}"
>
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
data-input-id=
"${id}"
value=
"${value|h}"
%
if
size:
size=
"${size}"
%
endif
/>
% if status == 'unsubmitted':
<p
class=
"status"
>
${reported_status}
</p>
<div
class=
"unanswered"
id=
"status_${id}"
>
% elif status == 'correct':
<div
class=
"correct"
id=
"status_${id}"
>
% elif status == 'incorrect':
<div
class=
"incorrect"
id=
"status_${id}"
>
% elif status == 'incomplete':
<div
class=
"incorrect"
id=
"status_${id}"
>
% endif
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
data-input-id=
"${id}"
value=
"${value|h}"
%
if
size:
size=
"${size}"
%
endif
/>
<p
class=
"status"
>
% if status == 'unsubmitted':
unanswered
% elif status == 'correct':
correct
% elif status == 'incorrect':
incorrect
% elif status == 'incomplete':
incomplete
% endif
</p>
<div
id=
"input_${id}_preview"
class=
"equation"
>
<div
id=
"input_${id}_preview"
class=
"equation"
>
\[\]
\[\]
<img
src=
"/static/images/spinner.gif"
class=
"loading"
/>
<img
src=
"/static/images/spinner.gif"
class=
"loading"
/>
</div>
</div>
<p
id=
"answer_${id}"
class=
"answer"
></p>
<p
id=
"answer_${id}"
class=
"answer"
></p>
</div>
% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
<div
class=
"script_placeholder"
data-src=
"${previewer}"
/>
</div>
% endif
</section>
</section>
common/lib/capa/capa/tests/test_input_templates.py
View file @
261b5c45
...
@@ -447,7 +447,32 @@ class TextlineTemplateTest(TemplateTestCase):
...
@@ -447,7 +447,32 @@ class TextlineTemplateTest(TemplateTestCase):
xpath
=
"//span[@class='message']"
xpath
=
"//span[@class='message']"
self
.
assert_has_text
(
xml
,
xpath
,
self
.
context
[
'msg'
])
self
.
assert_has_text
(
xml
,
xpath
,
self
.
context
[
'msg'
])
# TODO formulaequationinput tests
class
FormulaEquationInputTemplateTest
(
TemplateTestCase
):
"""
Test make template for `<formulaequationinput>`s.
"""
TEMPLATE_NAME
=
'formulaequationinput.html'
def
setUp
(
self
):
self
.
context
=
{
'id'
:
2
,
'value'
:
'PREFILLED_VALUE'
,
'status'
:
'unsubmitted'
,
'previewer'
:
'file.js'
,
'reported_status'
:
'REPORTED_STATUS'
,
}
super
(
FormulaEquationInputTemplateTest
,
self
)
.
setUp
()
def
test_no_size
(
self
):
xml
=
self
.
render_to_xml
(
self
.
context
)
self
.
assert_no_xpath
(
xml
,
"//input[@size]"
,
self
.
context
)
def
test_size
(
self
):
self
.
context
[
'size'
]
=
'40'
xml
=
self
.
render_to_xml
(
self
.
context
)
self
.
assert_has_xpath
(
xml
,
"//input[@size='40']"
,
self
.
context
)
class
AnnotationInputTemplateTest
(
TemplateTestCase
):
class
AnnotationInputTemplateTest
(
TemplateTestCase
):
"""
"""
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
261b5c45
...
@@ -809,6 +809,24 @@ class FormulaEquationTest(unittest.TestCase):
...
@@ -809,6 +809,24 @@ class FormulaEquationTest(unittest.TestCase):
}
}
self
.
assertEqual
(
context
,
expected
)
self
.
assertEqual
(
context
,
expected
)
def
test_rendering_reported_status
(
self
):
"""
Verify that the 'reported status' matches expectations.
"""
test_values
=
{
''
:
''
,
# Default
'unsubmitted'
:
'unanswered'
,
'correct'
:
'correct'
,
'incorrect'
:
'incorrect'
,
'incomplete'
:
'incomplete'
,
'not a status'
:
''
}
for
self_status
,
reported_status
in
test_values
.
iteritems
():
self
.
the_input
.
status
=
self_status
context
=
self
.
the_input
.
_get_render_context
()
# pylint: disable=W0212
self
.
assertEqual
(
context
[
'reported_status'
],
reported_status
)
def
test_formcalc_ajax_sucess
(
self
):
def
test_formcalc_ajax_sucess
(
self
):
"""
"""
Verify that using the correct dispatch and valid data produces a valid response
Verify that using the correct dispatch and valid data produces a valid response
...
...
common/lib/xmodule/xmodule/css/capa/display.scss
View file @
261b5c45
...
@@ -173,7 +173,7 @@ section.problem {
...
@@ -173,7 +173,7 @@ section.problem {
}
}
}
}
&
.incorrect
,
&
.ui-icon-close
{
&
.incorrect
,
&
.
incomplete
,
&
.
ui-icon-close
{
p
.status
{
p
.status
{
@include
inline-block
();
@include
inline-block
();
background
:
url('../images/incorrect-icon.png')
center
center
no-repeat
;
background
:
url('../images/incorrect-icon.png')
center
center
no-repeat
;
...
@@ -275,7 +275,7 @@ section.problem {
...
@@ -275,7 +275,7 @@ section.problem {
width
:
25px
;
width
:
25px
;
}
}
&
.incorrect
,
&
.ui-icon-close
{
&
.incorrect
,
&
.
incomplete
,
&
.
ui-icon-close
{
@include
inline-block
();
@include
inline-block
();
background
:
url('../images/incorrect-icon.png')
center
center
no-repeat
;
background
:
url('../images/incorrect-icon.png')
center
center
no-repeat
;
height
:
20px
;
height
:
20px
;
...
...
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