diff --git a/src/addons/mod/data/fields/checkbox/component/addon-mod-data-field-checkbox.html b/src/addons/mod/data/fields/checkbox/component/addon-mod-data-field-checkbox.html
index 76533f6a0..6b0110b6f 100644
--- a/src/addons/mod/data/fields/checkbox/component/addon-mod-data-field-checkbox.html
+++ b/src/addons/mod/data/fields/checkbox/component/addon-mod-data-field-checkbox.html
@@ -17,4 +17,4 @@
-
+
diff --git a/src/addons/mod/data/fields/checkbox/component/checkbox.ts b/src/addons/mod/data/fields/checkbox/component/checkbox.ts
index 3a1268c10..7b9ef0a64 100644
--- a/src/addons/mod/data/fields/checkbox/component/checkbox.ts
+++ b/src/addons/mod/data/fields/checkbox/component/checkbox.ts
@@ -25,6 +25,7 @@ import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-fiel
})
export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginBaseComponent {
+ content?: string;
options: {
key: string;
value: string;
@@ -40,31 +41,32 @@ export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginB
return;
}
- this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
-
- const values: string[] = [];
- if (this.editMode && this.value && this.value.content) {
- this.value.content.split('##').forEach((value) => {
- const x = this.options.findIndex((option) => value == option.key);
- if (x >= 0) {
- values.push(value);
- }
- });
- }
-
if (this.searchMode) {
this.addControl('f_' + this.field.id + '_allreq');
}
- this.addControl('f_' + this.field.id, values);
+ this.addControl('f_' + this.field.id, this.getValidValues(this.value));
}
/**
* @inheritdoc
*/
protected updateValue(value?: Partial): void {
- this.value = value || {};
- this.value.content = value?.content?.split('##').join('
');
+ super.updateValue(value);
+
+ this.content = this.getValidValues(value).join('
');
+ }
+
+ /**
+ * Get the list of valid values from current field value.
+ *
+ * @param value Field value.
+ * @returns List of valid values.
+ */
+ protected getValidValues(value?: Partial): string[] {
+ this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
+
+ return value?.content?.split('##').filter((value) => this.options.some(option => value === option.key)) ?? [];
}
}
diff --git a/src/addons/mod/data/fields/multimenu/component/addon-mod-data-field-multimenu.html b/src/addons/mod/data/fields/multimenu/component/addon-mod-data-field-multimenu.html
index d7b459a7c..b5c82796c 100644
--- a/src/addons/mod/data/fields/multimenu/component/addon-mod-data-field-multimenu.html
+++ b/src/addons/mod/data/fields/multimenu/component/addon-mod-data-field-multimenu.html
@@ -18,4 +18,4 @@
-
+
diff --git a/src/addons/mod/data/fields/multimenu/component/multimenu.ts b/src/addons/mod/data/fields/multimenu/component/multimenu.ts
index a331fd8bf..46cb8696f 100644
--- a/src/addons/mod/data/fields/multimenu/component/multimenu.ts
+++ b/src/addons/mod/data/fields/multimenu/component/multimenu.ts
@@ -25,6 +25,7 @@ import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-fiel
})
export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPluginBaseComponent {
+ content?: string;
options: {
key: string;
value: string;
@@ -40,31 +41,32 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin
return;
}
- this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
-
- const values: string[] = [];
- if (this.editMode && this.value?.content) {
- this.value.content.split('##').forEach((value) => {
- const x = this.options.findIndex((option) => value == option.key);
- if (x >= 0) {
- values.push(value);
- }
- });
- }
-
if (this.searchMode) {
this.addControl('f_' + this.field.id + '_allreq');
}
- this.addControl('f_' + this.field.id, values);
+ this.addControl('f_' + this.field.id, this.getValidValues(this.value));
}
/**
* @inheritdoc
*/
protected updateValue(value?: Partial): void {
- this.value = value || {};
- this.value.content = value?.content && value.content.split('##').join('
');
+ super.updateValue(value);
+
+ this.content = this.getValidValues(value).join('
');
+ }
+
+ /**
+ * Get the list of valid values from current field value.
+ *
+ * @param value Field value.
+ * @returns List of valid values.
+ */
+ protected getValidValues(value?: Partial): string[] {
+ this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
+
+ return value?.content?.split('##').filter((value) => this.options.some(option => value === option.key)) ?? [];
}
}
diff --git a/src/addons/mod/lesson/services/lesson-helper.ts b/src/addons/mod/lesson/services/lesson-helper.ts
index 2fd998089..7c7666792 100644
--- a/src/addons/mod/lesson/services/lesson-helper.ts
+++ b/src/addons/mod/lesson/services/lesson-helper.ts
@@ -269,9 +269,14 @@ export class AddonModLessonHelperProvider {
if (option.checked || multiChoiceQuestion.multi) {
// Add the control.
- const value = multiChoiceQuestion.multi ?
- { value: option.checked, disabled: option.disabled } : option.checked;
- questionForm.addControl(option.name, this.formBuilder.control(value));
+ if (multiChoiceQuestion.multi) {
+ questionForm.addControl(
+ option.name,
+ this.formBuilder.control({ value: option.checked, disabled: option.disabled }),
+ );
+ } else {
+ questionForm.addControl(option.name, this.formBuilder.control(option.value));
+ }
controlAdded = true;
}
@@ -464,7 +469,7 @@ export class AddonModLessonHelperProvider {
let input = element.querySelector('input[type="checkbox"][name*="answer"]');
if (input) {
// Truefalse or multichoice.
- const successBadge = element.querySelector('.badge.badge-success');
+ const successBadge = element.querySelector('.badge.bg-success, .badge.badge-success');
const data: AddonModLessonCheckboxAnswerData = {
isCheckbox: true,
checked: !!input.checked,
diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss
index 93ce2a0bc..a0f0d9694 100644
--- a/src/theme/theme.base.scss
+++ b/src/theme/theme.base.scss
@@ -83,7 +83,8 @@ html[dir=rtl] {
@each $color-name, $unused in $colors {
.text-#{$color-name},
- p.text-#{$color-name} {
+ p.text-#{$color-name},
+ .text-#{$color-name} p {
color: var(--ion-color-#{$color-name}) !important;
}
}