From a07ae84f547e77191e64a12d0eef5fb1f7f21a8c Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 25 Jul 2023 15:38:28 +0900 Subject: [PATCH 1/2] MOBILE-4272 rte: Fix contentChanged event types --- .../mod/assign/submission/onlinetext/component/onlinetext.ts | 2 +- src/addons/mod/forum/components/post/post.ts | 4 ++-- src/addons/mod/forum/pages/new-discussion/new-discussion.ts | 4 ++-- src/addons/mod/glossary/pages/edit/edit.ts | 4 ++-- .../components/assessment-strategy/assessment-strategy.ts | 4 ++-- src/core/services/utils/text.ts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/addons/mod/assign/submission/onlinetext/component/onlinetext.ts b/src/addons/mod/assign/submission/onlinetext/component/onlinetext.ts index d9f32b708..ca9afe172 100644 --- a/src/addons/mod/assign/submission/onlinetext/component/onlinetext.ts +++ b/src/addons/mod/assign/submission/onlinetext/component/onlinetext.ts @@ -111,7 +111,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS * * @param text The new text. */ - onChange(text: string): void { + onChange(text?: string | null): void { // Count words if needed. if (this.wordLimitEnabled) { // Cancel previous wait. diff --git a/src/addons/mod/forum/components/post/post.ts b/src/addons/mod/forum/components/post/post.ts index c2f1d5e80..8024b9c25 100644 --- a/src/addons/mod/forum/components/post/post.ts +++ b/src/addons/mod/forum/components/post/post.ts @@ -332,8 +332,8 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges * * @param text The new text. */ - onMessageChange(text: string): void { - this.formData.message = text; + onMessageChange(text?: string | null): void { + this.formData.message = text ?? ''; } /** diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts index 6978faa24..df9003480 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts @@ -511,8 +511,8 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea * * @param text The new text. */ - onMessageChange(text: string): void { - this.newDiscussion.message = text; + onMessageChange(text?: string | null): void { + this.newDiscussion.message = text ?? ''; } /** diff --git a/src/addons/mod/glossary/pages/edit/edit.ts b/src/addons/mod/glossary/pages/edit/edit.ts index 882f51daa..d5d9a3ed8 100644 --- a/src/addons/mod/glossary/pages/edit/edit.ts +++ b/src/addons/mod/glossary/pages/edit/edit.ts @@ -173,8 +173,8 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { * * @param text The new text. */ - onDefinitionChange(text: string): void { - this.data.definition = text; + onDefinitionChange(text?: string | null): void { + this.data.definition = text ?? ''; } /** diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index e2ea393c4..90afcbac2 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -403,8 +403,8 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe * * @param text The new text. */ - onFeedbackChange(text: string): void { - this.feedbackText = text; + onFeedbackChange(text?: string | null): void { + this.feedbackText = text ?? ''; } /** diff --git a/src/core/services/utils/text.ts b/src/core/services/utils/text.ts index 23596a41f..55c2b5fb5 100644 --- a/src/core/services/utils/text.ts +++ b/src/core/services/utils/text.ts @@ -332,7 +332,7 @@ export class CoreTextUtilsProvider { * @param text Text to count. * @returns Number of words. */ - countWords(text: string): number { + countWords(text?: string | null): number { if (!text || typeof text != 'string') { return 0; } From 7b5fd672e7597b3eda6b1da8e87df8e73cd77157 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 25 Jul 2023 15:39:01 +0900 Subject: [PATCH 2/2] MOBILE-4272 workshop: Fix assessment --- src/addons/mod/forum/components/post/post.ts | 2 +- .../pages/new-discussion/new-discussion.ts | 2 +- .../accumulative/services/handler.ts | 4 +- .../assessment/numerrors/services/handler.ts | 4 +- .../index/addon-mod-workshop-index.html | 12 +- .../mod/workshop/services/workshop-helper.ts | 3 +- .../workshop/tests/behat/basic_usage.feature | 115 ++++++++++++++++++ 7 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 src/addons/mod/workshop/tests/behat/basic_usage.feature diff --git a/src/addons/mod/forum/components/post/post.ts b/src/addons/mod/forum/components/post/post.ts index 8024b9c25..63f44e1b1 100644 --- a/src/addons/mod/forum/components/post/post.ts +++ b/src/addons/mod/forum/components/post/post.ts @@ -333,7 +333,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges * @param text The new text. */ onMessageChange(text?: string | null): void { - this.formData.message = text ?? ''; + this.formData.message = text ?? null; } /** diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts index df9003480..3c4921173 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts @@ -512,7 +512,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea * @param text The new text. */ onMessageChange(text?: string | null): void { - this.newDiscussion.message = text ?? ''; + this.newDiscussion.message = text ?? null; } /** diff --git a/src/addons/mod/workshop/assessment/accumulative/services/handler.ts b/src/addons/mod/workshop/assessment/accumulative/services/handler.ts index b6ca10e7c..563be19b8 100644 --- a/src/addons/mod/workshop/assessment/accumulative/services/handler.ts +++ b/src/addons/mod/workshop/assessment/accumulative/services/handler.ts @@ -129,9 +129,7 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandlerService implem hasErrors = true; } - if (currentValues[idx].peercomment) { - data['peercomment__idx_' + idx] = currentValues[idx].peercomment; - } + data['peercomment__idx_' + idx] = currentValues[idx].peercomment ?? ''; data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); diff --git a/src/addons/mod/workshop/assessment/numerrors/services/handler.ts b/src/addons/mod/workshop/assessment/numerrors/services/handler.ts index b48e438c6..ce7e5dc39 100644 --- a/src/addons/mod/workshop/assessment/numerrors/services/handler.ts +++ b/src/addons/mod/workshop/assessment/numerrors/services/handler.ts @@ -112,9 +112,7 @@ export class AddonModWorkshopAssessmentStrategyNumErrorsHandlerService implement hasErrors = true; } - if (currentValues[idx].peercomment) { - data['peercomment__idx_' + idx] = currentValues[idx].peercomment; - } + data['peercomment__idx_' + idx] = currentValues[idx].peercomment ?? ''; data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); diff --git a/src/addons/mod/workshop/components/index/addon-mod-workshop-index.html b/src/addons/mod/workshop/components/index/addon-mod-workshop-index.html index d5c71c7d2..a9ef7ca64 100644 --- a/src/addons/mod/workshop/components/index/addon-mod-workshop-index.html +++ b/src/addons/mod/workshop/components/index/addon-mod-workshop-index.html @@ -23,12 +23,16 @@ phases[workshop!.phase].tasks.length"> - -