Bugfix: Text Input problem type expects numeric answer when correct answer starts with a number

This commit is contained in:
Dmitry
2018-12-26 18:30:15 +03:00
parent 8593d4dc71
commit a30a53a09d
2 changed files with 19 additions and 1 deletions

View File

@@ -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.
@@ -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>

View File

@@ -573,6 +573,17 @@
);
},
checkIsNumeric = function(stringValue) {
// remove OLX feedback
if ((stringValue.indexOf('{{') !== -1) && (stringValue.indexOf('}}') !== -1)) {
stringValue = stringValue.replace(/{{[\s\S]*?}}/g, '').trim();
}
if (stringValue.match(/[a-z]/i)) {
return false;
}
return !isNaN(parseFloat(stringValue));
},
getAnswerData = function(answerValue) {
var answerData = {},
answerParams = /(.*?)\+\-\s*(.*?$)/.exec(answerValue);
@@ -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;
}