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
b7a164dd
Commit
b7a164dd
authored
Sep 10, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow textinputdynamath to specify its Mathjax preprocessor per-problem
parent
04f221e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
common/lib/capa/capa/inputtypes.py
+8
-0
common/lib/capa/capa/templates/textinput_dynamath.html
+4
-2
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+10
-5
No files found.
common/lib/capa/capa/inputtypes.py
View file @
b7a164dd
...
@@ -326,8 +326,16 @@ def textline_dynamath(element, value, status, render_template, msg=''):
...
@@ -326,8 +326,16 @@ def textline_dynamath(element, value, status, render_template, msg=''):
count
=
int
(
eid
.
split
(
'_'
)[
-
2
])
-
1
# HACK
count
=
int
(
eid
.
split
(
'_'
)[
-
2
])
-
1
# HACK
size
=
element
.
get
(
'size'
)
size
=
element
.
get
(
'size'
)
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
# Preprocessor to insert between raw input and Mathjax
preprocessor
=
{
'class_name'
:
element
.
get
(
'preprocessorClassName'
,
''
),
'script_src'
:
element
.
get
(
'preprocessorSrc'
,
''
)}
if
''
in
preprocessor
.
values
():
preprocessor
=
None
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
,
'hidden'
:
hidden
,
'msg'
:
msg
,
'hidden'
:
hidden
,
'preprocessor'
:
preprocessor
,
}
}
html
=
render_template
(
"textinput_dynamath.html"
,
context
)
html
=
render_template
(
"textinput_dynamath.html"
,
context
)
return
etree
.
XML
(
html
)
return
etree
.
XML
(
html
)
...
...
common/lib/capa/capa/templates/textinput_dynamath.html
View file @
b7a164dd
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
###
###
<section
class=
"text-input-dynamath textinputdynamath capa_inputtype"
id=
"inputtype_${id}"
>
<section
class=
"text-input-dynamath textinputdynamath capa_inputtype"
id=
"inputtype_${id}"
>
<div
class=
"textinputdynamath_data"
data-preprocessor=
"MathjaxPreprocessorFor6002x"
/>
% if preprocessor is not None:
<div
class=
"script_placeholder"
data-src=
"/static/js/mathjax_preprocessor_for_6002x.js"
/>
<div
class=
"textinputdynamath_data"
data-preprocessor=
"${preprocessor['class_name']}"
/>
<div
class=
"script_placeholder"
data-src=
"${preprocessor['script_src']}"
/>
% endif
% if state == 'unsubmitted':
% if state == 'unsubmitted':
<div
class=
"unanswered"
id=
"status_${id}"
>
<div
class=
"unanswered"
id=
"status_${id}"
>
...
...
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
b7a164dd
...
@@ -6,7 +6,6 @@ class @Problem
...
@@ -6,7 +6,6 @@ class @Problem
@
element_id
=
@
el
.
attr
(
'id'
)
@
element_id
=
@
el
.
attr
(
'id'
)
@
url
=
@
el
.
data
(
'url'
)
@
url
=
@
el
.
data
(
'url'
)
@
render
()
@
render
()
@
mathjax_preprocessor
=
false
$
:
(
selector
)
->
$
:
(
selector
)
->
$
(
selector
,
@
el
)
$
(
selector
,
@
el
)
...
@@ -301,6 +300,7 @@ class @Problem
...
@@ -301,6 +300,7 @@ class @Problem
target
=
"display_"
+
elid
target
=
"display_"
+
elid
# MathJax preprocessor is loaded by 'setupInputTypes'
preprocessor_tag
=
"inputtype_"
+
elid
preprocessor_tag
=
"inputtype_"
+
elid
mathjax_preprocessor
=
@
inputtypeDisplays
[
preprocessor_tag
]
mathjax_preprocessor
=
@
inputtypeDisplays
[
preprocessor_tag
]
...
@@ -308,7 +308,6 @@ class @Problem
...
@@ -308,7 +308,6 @@ class @Problem
eqn
=
$
(
element
).
val
()
eqn
=
$
(
element
).
val
()
if
mathjax_preprocessor
if
mathjax_preprocessor
eqn
=
mathjax_preprocessor
(
eqn
)
eqn
=
mathjax_preprocessor
(
eqn
)
MathJax
.
Hub
.
Queue
[
'Text'
,
jax
,
eqn
],
MathJax
.
Hub
.
Queue
[
'Text'
,
jax
,
eqn
],
[
@
updateMathML
,
jax
,
element
]
[
@
updateMathML
,
jax
,
element
]
...
@@ -329,13 +328,19 @@ class @Problem
...
@@ -329,13 +328,19 @@ class @Problem
inputtypeSetupMethods
:
inputtypeSetupMethods
:
textinputdynamath
:
(
element
)
=>
textinputdynamath
:
(
element
)
=>
###
Return: function (eqn) -> eqn that preprocesses the user formula input before
it is fed into MathJax. Return 'false' if no preprocessor specified
###
data
=
$
(
element
).
find
(
'.textinputdynamath_data'
)
data
=
$
(
element
).
find
(
'.textinputdynamath_data'
)
preprocessorClassName
=
data
.
data
(
'preprocessor'
)
preprocessorClassName
=
data
.
data
(
'preprocessor'
)
preprocessorClass
=
window
[
preprocessorClassName
]
preprocessorClass
=
window
[
preprocessorClassName
]
if
typeof
(
preprocessorClass
)
==
'undefined'
preprocessor
=
new
preprocessorClass
()
return
false
return
preprocessor
.
fn
else
preprocessor
=
new
preprocessorClass
()
return
preprocessor
.
fn
javascriptinput
:
(
element
)
=>
javascriptinput
:
(
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