feat: add answer range (#291)

* feat: add answer range

* feat: add margin for doropdown

* fix: improve test converage
This commit is contained in:
connorhaugh
2023-03-30 10:34:45 -04:00
committed by GitHub
parent 98ec415e2b
commit c2b67429d3
16 changed files with 606 additions and 42 deletions

View File

@@ -263,7 +263,6 @@ export class OLXParser {
let answerFeedback = '';
const answers = [];
let responseParam = {};
// TODO: UI needs to be added to support adding tolerence in numeric response.
const feedback = this.getFeedback(numericalresponse);
if (_.has(numericalresponse, 'responseparam')) {
const type = _.get(numericalresponse, 'responseparam.@_type');
@@ -272,11 +271,13 @@ export class OLXParser {
[type]: defaultValue,
};
}
const isAnswerRange = /[([]\d*,\d*[)\]]/gm.test(numericalresponse['@_answer']);
answers.push({
id: indexToLetterMap[answers.length],
title: numericalresponse['@_answer'],
correct: true,
selectedFeedback: feedback,
isAnswerRange,
...responseParam,
});
@@ -299,6 +300,7 @@ export class OLXParser {
title: additionalAnswer['@_answer'],
correct: true,
selectedFeedback: answerFeedback,
isAnswerRange: false,
});
}
return { answers };

View File

@@ -351,12 +351,14 @@ export const numericInputWithFeedbackAndHintsOLX = {
title: '100',
correct: true,
selectedFeedback: '<p>You can specify optional feedback like this, which appears after this answer is submitted.</p>',
isAnswerRange: false,
tolerance: '5',
},
{
id: 'B',
title: '200',
correct: true,
isAnswerRange: false,
selectedFeedback: '<p>You can specify optional feedback like this, which appears after this answer is submitted.</p>',
},
],