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
7 changes: 7 additions & 0 deletions common/lib/xmodule/xmodule/js/spec/problem/edit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ If first and last symbols are not brackets, or they are not closed, stringrespon
= (7), 7
= (1+2

Just input 100 test. Stringresponse will appear:
= 100 test

[Explanation]
Pi, or the the ratio between a circle's circumference to its diameter, is an irrational number known to extreme precision. It is value is approximately equal to 3.14.

Expand Down Expand Up @@ -195,6 +198,10 @@ If you look at your hand, you can count that you have five fingers.
<stringresponse answer="(1+2" type="ci" >
<textline size="20"/>
</stringresponse>
<p>Just input 100 test. Stringresponse will appear:</p>
<stringresponse answer="100 test" type="ci" >
<textline size="20"/>
</stringresponse>
<solution>
<div class="detailed-solution">
<p>Explanation</p>
Expand Down
13 changes: 12 additions & 1 deletion common/lib/xmodule/xmodule/js/src/problem/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,17 @@
);
},

checkIsNumeric = function(stringValue) {
// remove OLX feedback
if ((stringValue.indexOf('{{') !== -1) && (stringValue.indexOf('}}') !== -1)) {
stringValue = stringValue.replace(/{{[\s\S]*?}}/g, '').trim();

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.

Can you add some comment on what this replace is meant to do? Is it trying to remove all white space from this string?

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.

= 3.14159 +- .02   {{ Pie for everyone!   }}

->

= 3.14159 +- .02

}
if (stringValue.match(/[a-z]/i)) {
return false;
}
return !isNaN(parseFloat(stringValue));
},

getAnswerData = function(answerValue) {
var answerData = {},
answerParams = /(.*?)\+\-\s*(.*?$)/.exec(answerValue);
Expand All @@ -593,7 +604,7 @@
firstAnswer = answerValues[0].replace(/^\=\s*/, '');

// If answer is not numerical
if (isNaN(parseFloat(firstAnswer)) && !isRangeToleranceCase(firstAnswer)) {
if (!checkIsNumeric(firstAnswer) && !isRangeToleranceCase(firstAnswer)) {
return false;
}

Expand Down