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
e1288eba
Commit
e1288eba
authored
Jul 30, 2012
by
Mike Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for tolerance and decimals
parent
3c9ff574
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
cms/static/grammar.jspeg
+22
-5
common/lib/xmodule/xmodule/js/src/capa/edit.coffee
+6
-0
No files found.
cms/static/grammar.jspeg
View file @
e1288eba
...
...
@@ -10,10 +10,21 @@ start
StudentProducedResponseIdentifier
= '='
NumericalToleranceValueType
= decimal / percentage / integer
NumericalTolerance
= '+-' OptionalSpaces value:NumericalToleranceValueType OptionalSpaces
{
return value;
}
NumericalResponse
= StudentProducedResponseIdentifier OptionalSpaces '(' OptionalSpaces value:NumericalValue OptionalSpaces ')' OptionalSpaces Linebreak
= StudentProducedResponseIdentifier OptionalSpaces '(' OptionalSpaces value:NumericalValue OptionalSpaces
tolerance:NumericalTolerance?
')' OptionalSpaces Linebreak
{
return {'type': 'numerical', 'answer': value};
if (tolerance == "")
tolerance = "5%"
return {'type': 'numerical', 'answer': value, 'tolerance': tolerance};
}
StringResponse
...
...
@@ -80,7 +91,6 @@ OptionalSpaces
Linebreak
= ('\n')
NumericalValue
= additive
...
...
@@ -96,10 +106,16 @@ multiplicative
/ primary
primary
= integer
= decimal
/ integer
/ "(" additive:additive ")" { return additive; }
decimal "decimal"
= first:[0-9]+ point:'.' last:[0-9]+
{ return parseFloat(first.join("") + point + last.join("")); }
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
percentage "percentage"
= digits:[0-9]+ '%' { return parseInt(digits.join(""), 10) + '%'; }
\ No newline at end of file
common/lib/xmodule/xmodule/js/src/capa/edit.coffee
View file @
e1288eba
...
...
@@ -81,6 +81,12 @@ class @CapaDescriptor
newel
=
$
(
doc
.
createElement
(
'numericalresponse'
))
newel
.
attr
'answer'
,
section
.
answer
tolerance
=
$
(
doc
.
createElement
(
'responseparam'
))
tolerance
.
attr
'type'
,
'tolerance'
tolerance
.
attr
'default'
,
section
.
tolerance
tolerance
.
attr
'name'
,
'tol'
tolerance
.
attr
'description'
,
'Numerical Tolerance'
newel
.
append
tolerance
newel
.
append
doc
.
createElement
(
'textline'
)
problem
.
append
(
newel
)
...
...
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