fix: add empty answer to problem without answers (#235)

This commit is contained in:
Kristin Aoki
2023-02-07 20:04:16 -05:00
committed by GitHub
parent 613b8d16ae
commit 87aaa7f3ff
3 changed files with 35 additions and 1 deletions

View File

@@ -59,7 +59,15 @@ export class OLXParser {
let data = {};
const widget = _.get(this.problem, `${problemType}.${widgetName}`);
const choice = _.get(widget, option);
if (_.isArray(choice)) {
if (_.isEmpty(choice)) {
answers.push(
{
id: indexToLetterMap[answers.length],
title: '',
correct: true,
},
);
} else if (_.isArray(choice)) {
choice.forEach((element, index) => {
const title = element['#text'];
const correct = eval(element['@_correct'].toLowerCase());