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
4580ef89
Commit
4580ef89
authored
Jun 26, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue up MathML conversion to be after render
From
https://www.pivotaltracker.com/story/show/31700967
Fixes #137
parent
7475e415
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
lms/static/coffee/spec/modules/problem_spec.coffee
+18
-9
lms/static/coffee/src/modules/problem.coffee
+8
-7
No files found.
lms/static/coffee/spec/modules/problem_spec.coffee
View file @
4580ef89
...
@@ -52,8 +52,11 @@ describe 'Problem', ->
...
@@ -52,8 +52,11 @@ describe 'Problem', ->
it
'bind the math input'
,
->
it
'bind the math input'
,
->
expect
(
$
(
'input.math'
)).
toHandleWith
'keyup'
,
@
problem
.
refreshMath
expect
(
$
(
'input.math'
)).
toHandleWith
'keyup'
,
@
problem
.
refreshMath
it
'display the math input'
,
->
it
'replace math content on the page'
,
->
expect
(
@
stubbedJax
.
root
.
toMathML
).
toHaveBeenCalled
()
expect
(
MathJax
.
Hub
.
Queue
.
mostRecentCall
.
args
).
toEqual
[
[
'Text'
,
@
stubbedJax
,
''
],
[
@
problem
.
updateMathML
,
@
stubbedJax
,
$
(
'#input_example_1'
).
get
(
0
)]
]
describe
'render'
,
->
describe
'render'
,
->
beforeEach
->
beforeEach
->
...
@@ -238,23 +241,29 @@ describe 'Problem', ->
...
@@ -238,23 +241,29 @@ describe 'Problem', ->
describe
'refreshMath'
,
->
describe
'refreshMath'
,
->
beforeEach
->
beforeEach
->
@
problem
=
new
Problem
1
,
'/problem/url/'
@
problem
=
new
Problem
1
,
'/problem/url/'
@
stubbedJax
.
root
.
toMathML
.
andReturn
'<MathML>'
$
(
'#input_example_1'
).
val
'E=mc^2'
$
(
'#input_example_1'
).
val
'E=mc^2'
@
problem
.
refreshMath
target
:
$
(
'#input_example_1'
).
get
(
0
)
it
'should queue the conversion and MathML element update'
,
->
expect
(
MathJax
.
Hub
.
Queue
).
toHaveBeenCalledWith
[
'Text'
,
@
stubbedJax
,
'E=mc^2'
],
[
@
problem
.
updateMathML
,
@
stubbedJax
,
$
(
'#input_example_1'
).
get
(
0
)]
describe
'updateMathML'
,
->
beforeEach
->
@
problem
=
new
Problem
1
,
'/problem/url/'
@
stubbedJax
.
root
.
toMathML
.
andReturn
'<MathML>'
describe
'when there is no exception'
,
->
describe
'when there is no exception'
,
->
beforeEach
->
beforeEach
->
@
problem
.
refreshMath
target
:
$
(
'#input_example_1'
).
get
(
0
)
@
problem
.
updateMathML
@
stubbedJax
,
$
(
'#input_example_1'
).
get
(
0
)
it
'should convert and display the MathML object'
,
->
expect
(
MathJax
.
Hub
.
Queue
).
toHaveBeenCalledWith
[
'Text'
,
@
stubbedJax
,
'E=mc^2'
]
it
'
should display debug output in hidden div
'
,
->
it
'
convert jax to MathML
'
,
->
expect
(
$
(
'#input_example_1_dynamath'
)).
toHaveValue
'<MathML>'
expect
(
$
(
'#input_example_1_dynamath'
)).
toHaveValue
'<MathML>'
describe
'when there is an exception'
,
->
describe
'when there is an exception'
,
->
beforeEach
->
beforeEach
->
@
stubbedJax
.
root
.
toMathML
.
andThrow
{
restart
:
true
}
@
stubbedJax
.
root
.
toMathML
.
andThrow
{
restart
:
true
}
@
problem
.
refreshMath
target
:
$
(
'#input_example_1'
).
get
(
0
)
@
problem
.
updateMathML
@
stubbedJax
,
$
(
'#input_example_1'
).
get
(
0
)
it
'should queue up the exception'
,
->
it
'should queue up the exception'
,
->
expect
(
MathJax
.
Callback
.
After
).
toHaveBeenCalledWith
[
@
problem
.
refreshMath
,
@
stubbedJax
],
true
expect
(
MathJax
.
Callback
.
After
).
toHaveBeenCalledWith
[
@
problem
.
refreshMath
,
@
stubbedJax
],
true
...
...
lms/static/coffee/src/modules/problem.coffee
View file @
4580ef89
...
@@ -79,14 +79,15 @@ class @Problem
...
@@ -79,14 +79,15 @@ class @Problem
target
=
"display_
#{
element
.
id
.
replace
(
/^input_/
,
''
)
}
"
target
=
"display_
#{
element
.
id
.
replace
(
/^input_/
,
''
)
}
"
if
jax
=
MathJax
.
Hub
.
getAllJax
(
target
)[
0
]
if
jax
=
MathJax
.
Hub
.
getAllJax
(
target
)[
0
]
MathJax
.
Hub
.
Queue
[
'Text'
,
jax
,
$
(
element
).
val
()]
MathJax
.
Hub
.
Queue
[
'Text'
,
jax
,
$
(
element
).
val
()],
[
@
updateMathML
,
jax
,
element
]
try
updateMathML
:
(
jax
,
element
)
=>
output
=
jax
.
root
.
toMathML
''
try
$
(
"#
#{
element
.
id
}
_dynamath"
).
val
(
output
)
$
(
"#
#{
element
.
id
}
_dynamath"
).
val
(
jax
.
root
.
toMathML
''
)
catch
exception
catch
exception
throw
exception
unless
exception
.
restart
throw
exception
unless
exception
.
restart
MathJax
.
Callback
.
After
[
@
refreshMath
,
jax
],
exception
.
restart
MathJax
.
Callback
.
After
[
@
refreshMath
,
jax
],
exception
.
restart
refreshAnswers
:
=>
refreshAnswers
:
=>
@
$
(
'input.schematic'
).
each
(
index
,
element
)
->
@
$
(
'input.schematic'
).
each
(
index
,
element
)
->
...
...
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