fix(client): allow numbers as answers (#38992)

Handles yaml floats.
This commit is contained in:
Oliver Eyton-Williams
2020-06-02 18:52:44 +02:00
committed by GitHub
parent 6d879e3439
commit 1244e9775f

View File

@ -27,8 +27,10 @@ function plugin() {
if (lang === 'yml') { if (lang === 'yml') {
const tests = YAML.load(value); const tests = YAML.load(value);
if (tests.question) { if (tests.question) {
// mdToHTML can not parse numbers. If an answer is a number
// (i.e. 5, not '5') it has to be converted.
tests.question.answers = tests.question.answers.map(answer => tests.question.answers = tests.question.answers.map(answer =>
mdToHTML(answer) mdToHTML(answer.toString())
); );
tests.question.text = mdToHTML(tests.question.text); tests.question.text = mdToHTML(tests.question.text);
} }