fix: more correct parsing of settings, for scoring; use empty string instead of null for empty attempts. TNL-10433.

This commit is contained in:
Ken Clary
2023-02-09 18:46:29 -05:00
parent 7c0309189f
commit 38e262eee0
6 changed files with 58 additions and 15 deletions

View File

@@ -15,11 +15,15 @@ export const parseScoringSettings = (metadata) => {
let scoring = {};
let attempts = popuplateItem({}, 'max_attempts', 'number', metadata);
if (!_.isEmpty(attempts)) {
const unlimited = _.isNaN(attempts.number);
attempts = { ...attempts, unlimited };
scoring = { ...scoring, attempts };
if (_.isEmpty(attempts) || _.isNaN(attempts.number)) {
attempts = { unlimited: true, number: '' };
} else {
attempts.unlimited = false;
if (attempts.number < 0) {
attempts.number = 0;
}
}
scoring = { ...scoring, attempts };
scoring = popuplateItem(scoring, 'weight', 'weight', metadata);