feat: tolerance Setting Widget (#286)

* feat: tolerance Setting Widget

* fix: tolerance position and percent summary
This commit is contained in:
connorhaugh
2023-03-22 14:31:02 -04:00
committed by GitHub
parent 16003a7f4a
commit df5af3efd9
8 changed files with 335 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import _ from 'lodash-es';
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
import { ProblemTypeKeys } from '../../../data/constants/problem';
import { ToleranceTypes } from '../components/EditProblemView/SettingsWidget/settingsComponents/Tolerance/constants';
class ReactStateOLXParser {
constructor(problemState) {
@@ -306,6 +307,7 @@ class ReactStateOLXParser {
buildNumericalResponse() {
const { answers } = this.problemState;
const { tolerance } = this.problemState.settings;
const { selectedFeedback } = this.editorObject;
let answerObject = {};
const additionalAnswers = [];
@@ -316,11 +318,11 @@ class ReactStateOLXParser {
if (answer.correct && !firstCorrectAnswerParsed) {
firstCorrectAnswerParsed = true;
let responseParam = {};
if (_.has(answer, 'tolerance')) {
if (tolerance?.value) {
responseParam = {
responseparam: {
'@_type': 'tolerance',
'@_default': _.get(answer, 'tolerance', 0),
'@_default': `${tolerance.value}${tolerance.type === ToleranceTypes.number.type ? '' : '%'}`,
},
};
}