diff --git a/wax-questions-service/src/NumericalAnswerService/components/ExactAnswerComponent.js b/wax-questions-service/src/NumericalAnswerService/components/ExactAnswerComponent.js index ce36de4d81751fdd94f18114ccfff46fe67aac1f..586fb979a046a3f712021d28cfce424395e0abdb 100644 --- a/wax-questions-service/src/NumericalAnswerService/components/ExactAnswerComponent.js +++ b/wax-questions-service/src/NumericalAnswerService/components/ExactAnswerComponent.js @@ -13,6 +13,7 @@ const ValueContainer = styled.div` display: flex; flex-direction: column; margin-right: 25px; + label { font-size: 12px; } @@ -66,7 +67,8 @@ const ExactAnswerComponent = ({ node, readOnly, testMode, showFeedBack }) => { const onlyNumbers = value => { return value - .replace(/[^0-9.]/g, '') + .replace(/[^-?0-9.]/g, '') + .replace(/(?<!^)-/g, '') .replace(/(\..*?)\..*/g, '$1') .replace(/^0[^.]/, '0'); }; @@ -124,11 +126,14 @@ const ExactAnswerComponent = ({ node, readOnly, testMode, showFeedBack }) => { }; // SUBMIT - const exactMultMargin = parseFloat((exact * marginError) / 100); + const exactMultMargin = Math.abs(parseFloat((exact * marginError) / 100)); + const castExactStudent = ['-', '-.', '.'].includes(exactStudent) + ? 0 + : Number(exactStudent); const computedMaxValue = Number(exactMultMargin) + Number(exact); const computedMinValue = Number(exact) - Number(exactMultMargin); const isCorrect = !!( - exactStudent <= computedMaxValue && exactStudent >= computedMinValue + castExactStudent <= computedMaxValue && castExactStudent >= computedMinValue ); return ( diff --git a/wax-questions-service/src/NumericalAnswerService/components/PreciseAnswerComponent.js b/wax-questions-service/src/NumericalAnswerService/components/PreciseAnswerComponent.js index 84f67178732a943aad8f9478664b321450d0803e..f4a685487192bd4fd378b35576b64276b1a93023 100644 --- a/wax-questions-service/src/NumericalAnswerService/components/PreciseAnswerComponent.js +++ b/wax-questions-service/src/NumericalAnswerService/components/PreciseAnswerComponent.js @@ -13,6 +13,7 @@ const ValueContainer = styled.div` display: flex; flex-direction: column; margin-right: 25px; + label { font-size: 12px; } @@ -66,7 +67,7 @@ const PreciseAnswerComponent = ({ node, readOnly, testMode, showFeedBack }) => { const onlyNumbers = value => { return value - .replace(/[^0-9.;]/g, '') + .replace(/[^-?0-9.;]/g, '') .replace(/(\..*?)\..*/g, '$1') .replace(/^0[^.]/, '0'); }; @@ -158,7 +159,7 @@ const PreciseAnswerComponent = ({ node, readOnly, testMode, showFeedBack }) => { )} {readOnly && showFeedBack && ( <ResultContainer> - <span>{`(Accepted Answers : ${precise.replaceAll(';', ' -')})`}</span> + <span>{`(Accepted Answers : ${precise.replaceAll(';', '; ')})`}</span> <span> Answer:{' '} <FinalResult isCorrect={isCorrect}> diff --git a/wax-questions-service/src/NumericalAnswerService/components/RangeAnswerComponent.js b/wax-questions-service/src/NumericalAnswerService/components/RangeAnswerComponent.js index 3896b668c76c56d4e52034d5b95999409c33edf2..ceced5a0d4f82945cff37a309ae959a5f244fafa 100644 --- a/wax-questions-service/src/NumericalAnswerService/components/RangeAnswerComponent.js +++ b/wax-questions-service/src/NumericalAnswerService/components/RangeAnswerComponent.js @@ -13,6 +13,7 @@ const ValueContainer = styled.div` display: flex; flex-direction: column; margin-right: 25px; + label { font-size: 12px; } @@ -70,7 +71,8 @@ const RangeAnswerComponent = ({ node, readOnly, testMode, showFeedBack }) => { const onlyNumbers = value => { return value - .replace(/[^0-9.]/g, '') + .replace(/[^-?0-9.]/g, '') + .replace(/(?<!^)-/g, '') .replace(/(\..*?)\..*/g, '$1') .replace(/^0[^.]/, '0'); }; @@ -128,10 +130,12 @@ const RangeAnswerComponent = ({ node, readOnly, testMode, showFeedBack }) => { }; // SUBMIT + const castExactStudent = ['-', '-.', '.'].includes(rangeStudentValue) + ? 0 + : Number(rangeStudentValue); const isCorrect = !!( - Number(rangeStudentValue) <= Number(maxValue) && - Number(rangeStudentValue) >= Number(minValue) + castExactStudent <= Number(maxValue) && castExactStudent >= Number(minValue) ); return (