Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.

Blades: Fix Numerical input to support mathematical operations. BLD-525.

Blades: Improve calculator's tooltip accessibility. Add possibility to navigate
through the hints via arrow keys. BLD-533.

Expand Down
4 changes: 2 additions & 2 deletions common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe 'MarkdownEditingDescriptor', ->
= 3.14159 +- .02

Enter the approximate value of 502*9:
= 4518 +- 15%
= 502*9 +- 15%

Enter the number of fingers on a human hand:
= 5
Expand All @@ -125,7 +125,7 @@ describe 'MarkdownEditingDescriptor', ->
</numericalresponse>

<p>Enter the approximate value of 502*9:</p>
<numericalresponse answer="4518">
<numericalresponse answer="502*9">
<responseparam type="tolerance" default="15%" />
<formulaequationinput />
</numericalresponse>
Expand Down
9 changes: 6 additions & 3 deletions common/lib/xmodule/xmodule/js/src/problem/edit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,15 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
floatValue = parseFloat(answersList[0]);

if(!isNaN(floatValue)) {
var params = /(.*?)\+\-\s*(.*?$)/.exec(answersList[0]);
// Tries to extract parameters from string like 'expr +- tolerance'
var params = /(.*?)\+\-\s*(.*?$)/.exec(answersList[0]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@polesye could you please provide a comment or two on what is happening. I has a hard time deciphering what is going on here = )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please provide a comment or two on what is happening. I has a hard time deciphering what is going on here = )

Done.

answer = answersList[0].replace(/\s+/g, '');
if(params) {
string = '<numericalresponse answer="' + floatValue + '">\n';
answer = params[1].replace(/\s+/g, '');
string = '<numericalresponse answer="' + answer + '">\n';
string += ' <responseparam type="tolerance" default="' + params[2] + '" />\n';
} else {
string = '<numericalresponse answer="' + floatValue + '">\n';
string = '<numericalresponse answer="' + answer + '">\n';
}
string += ' <formulaequationinput />\n';
string += '</numericalresponse>\n\n';
Expand Down