From 1a87eb309459bf25c5d73f92f331be3e3276a5bd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 25 Nov 2020 15:33:02 +0100 Subject: [PATCH] MOBILE-3523 qtype_calculated: Fallback if unitsleft is null --- src/addon/qtype/calculated/providers/handler.ts | 2 +- src/core/question/classes/base-question-component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/addon/qtype/calculated/providers/handler.ts b/src/addon/qtype/calculated/providers/handler.ts index 22423edb4..0e432658f 100644 --- a/src/addon/qtype/calculated/providers/handler.ts +++ b/src/addon/qtype/calculated/providers/handler.ts @@ -191,7 +191,7 @@ export class AddonQtypeCalculatedHandler implements CoreQuestionHandler { let unitsLeft = false; let match = null; - if (!question.settings) { + if (!question.settings || question.settings.unitsleft === null) { // We don't know if units should be before or after so we check both. match = answer.match(new RegExp('^' + regexString)); if (!match) { diff --git a/src/core/question/classes/base-question-component.ts b/src/core/question/classes/base-question-component.ts index 91a238153..0dbd9df63 100644 --- a/src/core/question/classes/base-question-component.ts +++ b/src/core/question/classes/base-question-component.ts @@ -108,7 +108,7 @@ export class CoreQuestionBaseComponent { this.question.select = selectModel; // Check which one should be displayed first: the select or the input. - if (this.question.settings) { + if (this.question.settings && this.question.settings.unitsleft !== null) { this.question.selectFirst = this.question.settings.unitsleft == '1'; } else { const input = questionEl.querySelector('input[type="text"][name*=answer]'); @@ -166,7 +166,7 @@ export class CoreQuestionBaseComponent { } // Check which one should be displayed first: the options or the input. - if (this.question.settings) { + if (this.question.settings && this.question.settings.unitsleft !== null) { this.question.optionsFirst = this.question.settings.unitsleft == '1'; } else { const input = questionEl.querySelector('input[type="text"][name*=answer]');