commit
05e6bcb0b0
|
@ -17,4 +17,4 @@
|
|||
</ion-item>
|
||||
</span>
|
||||
|
||||
<core-format-text *ngIf="displayMode && value && value.content" [text]="value.content" [filter]="false" />
|
||||
<core-format-text *ngIf="displayMode && content" [text]="content" [filter]="false" />
|
||||
|
|
|
@ -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<AddonModDataEntryField>): void {
|
||||
this.value = value || {};
|
||||
this.value.content = value?.content?.split('##').join('<br>');
|
||||
super.updateValue(value);
|
||||
|
||||
this.content = this.getValidValues(value).join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of valid values from current field value.
|
||||
*
|
||||
* @param value Field value.
|
||||
* @returns List of valid values.
|
||||
*/
|
||||
protected getValidValues(value?: Partial<AddonModDataEntryField>): 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)) ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@
|
|||
</ion-item>
|
||||
</span>
|
||||
|
||||
<core-format-text *ngIf="displayMode && value && value.content" [text]="value.content" [filter]="false" />
|
||||
<core-format-text *ngIf="displayMode && content" [text]="content" [filter]="false" />
|
||||
|
|
|
@ -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<AddonModDataEntryField>): void {
|
||||
this.value = value || {};
|
||||
this.value.content = value?.content && value.content.split('##').join('<br>');
|
||||
super.updateValue(value);
|
||||
|
||||
this.content = this.getValidValues(value).join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of valid values from current field value.
|
||||
*
|
||||
* @param value Field value.
|
||||
* @returns List of valid values.
|
||||
*/
|
||||
protected getValidValues(value?: Partial<AddonModDataEntryField>): 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)) ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
|
||||
if (input) {
|
||||
// Truefalse or multichoice.
|
||||
const successBadge = element.querySelector<HTMLElement>('.badge.badge-success');
|
||||
const successBadge = element.querySelector<HTMLElement>('.badge.bg-success, .badge.badge-success');
|
||||
const data: AddonModLessonCheckboxAnswerData = {
|
||||
isCheckbox: true,
|
||||
checked: !!input.checked,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue