commit
05e6bcb0b0
|
@ -17,4 +17,4 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</span>
|
</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 {
|
export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginBaseComponent {
|
||||||
|
|
||||||
|
content?: string;
|
||||||
options: {
|
options: {
|
||||||
key: string;
|
key: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
@ -40,31 +41,32 @@ export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginB
|
||||||
return;
|
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) {
|
if (this.searchMode) {
|
||||||
this.addControl('f_' + this.field.id + '_allreq');
|
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
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected updateValue(value?: Partial<AddonModDataEntryField>): void {
|
protected updateValue(value?: Partial<AddonModDataEntryField>): void {
|
||||||
this.value = value || {};
|
super.updateValue(value);
|
||||||
this.value.content = value?.content?.split('##').join('<br>');
|
|
||||||
|
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>
|
</ion-item>
|
||||||
</span>
|
</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 {
|
export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPluginBaseComponent {
|
||||||
|
|
||||||
|
content?: string;
|
||||||
options: {
|
options: {
|
||||||
key: string;
|
key: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
@ -40,31 +41,32 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin
|
||||||
return;
|
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) {
|
if (this.searchMode) {
|
||||||
this.addControl('f_' + this.field.id + '_allreq');
|
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
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected updateValue(value?: Partial<AddonModDataEntryField>): void {
|
protected updateValue(value?: Partial<AddonModDataEntryField>): void {
|
||||||
this.value = value || {};
|
super.updateValue(value);
|
||||||
this.value.content = value?.content && value.content.split('##').join('<br>');
|
|
||||||
|
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) {
|
if (option.checked || multiChoiceQuestion.multi) {
|
||||||
// Add the control.
|
// Add the control.
|
||||||
const value = multiChoiceQuestion.multi ?
|
if (multiChoiceQuestion.multi) {
|
||||||
{ value: option.checked, disabled: option.disabled } : option.checked;
|
questionForm.addControl(
|
||||||
questionForm.addControl(option.name, this.formBuilder.control(value));
|
option.name,
|
||||||
|
this.formBuilder.control({ value: option.checked, disabled: option.disabled }),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
questionForm.addControl(option.name, this.formBuilder.control(option.value));
|
||||||
|
}
|
||||||
controlAdded = true;
|
controlAdded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +469,7 @@ export class AddonModLessonHelperProvider {
|
||||||
let input = element.querySelector<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
|
let input = element.querySelector<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
|
||||||
if (input) {
|
if (input) {
|
||||||
// Truefalse or multichoice.
|
// 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 = {
|
const data: AddonModLessonCheckboxAnswerData = {
|
||||||
isCheckbox: true,
|
isCheckbox: true,
|
||||||
checked: !!input.checked,
|
checked: !!input.checked,
|
||||||
|
|
|
@ -83,7 +83,8 @@ html[dir=rtl] {
|
||||||
|
|
||||||
@each $color-name, $unused in $colors {
|
@each $color-name, $unused in $colors {
|
||||||
.text-#{$color-name},
|
.text-#{$color-name},
|
||||||
p.text-#{$color-name} {
|
p.text-#{$color-name},
|
||||||
|
.text-#{$color-name} p {
|
||||||
color: var(--ion-color-#{$color-name}) !important;
|
color: var(--ion-color-#{$color-name}) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue