From 95cd22e76ff31e43ac446fe51c9d489c8b2717f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Oct 2023 10:45:48 +0200 Subject: [PATCH 1/6] MOBILE-4362 workshop: Fix phantom offline submissions --- .../mod/workshop/services/workshop-helper.ts | 38 ++++++++++--------- .../workshop/tests/behat/basic_usage.feature | 3 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/addons/mod/workshop/services/workshop-helper.ts b/src/addons/mod/workshop/services/workshop-helper.ts index c868bfd6e..55eaa30b2 100644 --- a/src/addons/mod/workshop/services/workshop-helper.ts +++ b/src/addons/mod/workshop/services/workshop-helper.ts @@ -449,7 +449,14 @@ export class AddonModWorkshopHelperProvider { * @returns Promise resolved with the files. */ async applyOfflineData( - submission: AddonModWorkshopSubmissionDataWithOfflineData = { + submission?: AddonModWorkshopSubmissionDataWithOfflineData, + actions: AddonModWorkshopOfflineSubmission[] = [], + ): Promise { + if (actions.length === 0) { + return submission; + } + + const baseSubmission = submission ?? { id: 0, workshopid: 0, title: '', @@ -462,12 +469,7 @@ export class AddonModWorkshopHelperProvider { attachment: 0, published: false, late: 0, - }, - actions: AddonModWorkshopOfflineSubmission[] = [], - ): Promise { - if (actions.length === 0) { - return submission; - } + }; let attachmentsId: CoreFileUploaderStoreFilesResult | undefined; const workshopId = actions[0].workshopid; @@ -476,17 +478,17 @@ export class AddonModWorkshopHelperProvider { switch (action.action) { case AddonModWorkshopAction.ADD: case AddonModWorkshopAction.UPDATE: - submission.title = action.title; - submission.content = action.content; - submission.title = action.title; - submission.courseid = action.courseid; - submission.submissionmodified = action.timemodified / 1000; - submission.offline = true; + baseSubmission.title = action.title; + baseSubmission.content = action.content; + baseSubmission.title = action.title; + baseSubmission.courseid = action.courseid; + baseSubmission.submissionmodified = action.timemodified / 1000; + baseSubmission.offline = true; attachmentsId = action.attachmentsid as CoreFileUploaderStoreFilesResult; break; case AddonModWorkshopAction.DELETE: - submission.deleted = true; - submission.submissionmodified = action.timemodified / 1000; + baseSubmission.deleted = true; + baseSubmission.submissionmodified = action.timemodified / 1000; break; default: } @@ -494,13 +496,13 @@ export class AddonModWorkshopHelperProvider { // Check offline files for latest attachmentsid. if (attachmentsId) { - submission.attachmentfiles = + baseSubmission.attachmentfiles = await this.getSubmissionFilesFromOfflineFilesObject(attachmentsId, workshopId); } else { - submission.attachmentfiles = []; + baseSubmission.attachmentfiles = []; } - return submission; + return baseSubmission; } /** diff --git a/src/addons/mod/workshop/tests/behat/basic_usage.feature b/src/addons/mod/workshop/tests/behat/basic_usage.feature index 9d6aee8f5..92d780cc8 100644 --- a/src/addons/mod/workshop/tests/behat/basic_usage.feature +++ b/src/addons/mod/workshop/tests/behat/basic_usage.feature @@ -49,13 +49,14 @@ Feature: Test basic usage of workshop activity in app Given I entered the workshop activity "workshop" on course "Course 1" as "student1" in the app Then I should find "Task to do" within "Submit your work" "ion-item" in the app - When I press "Edit submission" in the app + When I press "Add submission" in the app And I set the field "Title" to "The Answer" in the app And I set the field "Submission content" to "42" in the app And I press "Save" in the app Then I should find "Task done" within "Submit your work" "ion-item" in the app And I should find "The Answer" in the app And I should find "42" in the app + And I should find "Edit submission" in the app Given I entered the workshop activity "workshop" on course "Course 1" as "teacher1" in the app When I pull to refresh in the app From 1f7d0277a9f5d80ef44c179e763f6340c9c18d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Oct 2023 10:47:36 +0200 Subject: [PATCH 2/6] MOBILE-4362 chore: Correctly slot toggles inside ion-item --- src/addons/blog/pages/entries/entries.html | 2 +- .../submission/addon-mod-assign-submission.html | 4 ++-- src/addons/mod/chat/pages/sessions/sessions.html | 2 +- src/addons/mod/data/components/search/search.html | 2 +- .../forum/pages/new-discussion/new-discussion.html | 6 +++--- src/addons/mod/glossary/pages/edit/edit.html | 6 +++--- .../mod/workshop/pages/submission/submission.html | 8 +++++--- src/core/features/settings/pages/dev/dev.html | 11 ++++++----- src/core/features/settings/pages/general/general.html | 6 +++--- src/core/features/settings/pages/site/site.html | 2 +- 10 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/addons/blog/pages/entries/entries.html b/src/addons/blog/pages/entries/entries.html index 44d416a2a..fb9ffa77c 100644 --- a/src/addons/blog/pages/entries/entries.html +++ b/src/addons/blog/pages/entries/entries.html @@ -18,7 +18,7 @@ {{ 'addon.blog.showonlyyourentries' | translate }} - + diff --git a/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html b/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html index 539057e04..2bd756e01 100644 --- a/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html +++ b/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html @@ -363,7 +363,7 @@

{{ 'addon.mod_assign.groupsubmissionsettings' | translate }}

{{ 'addon.mod_assign.applytoteam' | translate }}

- + @@ -387,7 +387,7 @@ {{ 'addon.mod_assign.addattempt' | translate }} - + diff --git a/src/addons/mod/chat/pages/sessions/sessions.html b/src/addons/mod/chat/pages/sessions/sessions.html index a4d654c5d..c2e1b3371 100644 --- a/src/addons/mod/chat/pages/sessions/sessions.html +++ b/src/addons/mod/chat/pages/sessions/sessions.html @@ -19,7 +19,7 @@ {{ 'addon.mod_chat.showincompletesessions' | translate }} - + {{ 'addon.mod_data.advancedsearch' | translate }} - +
diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.html b/src/addons/mod/forum/pages/new-discussion/new-discussion.html index ef312563b..69721b8a6 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.html +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.html @@ -43,7 +43,7 @@
{{ 'addon.mod_forum.posttomygroups' | translate }} - + {{ 'addon.mod_forum.group' | translate }} @@ -58,11 +58,11 @@ {{ 'addon.mod_forum.discussionsubscription' | translate }} - + {{ 'addon.mod_forum.discussionpinned' | translate }} - + {{ 'addon.mod_glossary.entryusedynalink' | translate }} - + {{ 'addon.mod_glossary.casesensitive' | translate }} - + {{ 'addon.mod_glossary.fullmatch' | translate }} - + diff --git a/src/addons/mod/workshop/pages/submission/submission.html b/src/addons/mod/workshop/pages/submission/submission.html index c0aece919..742496405 100644 --- a/src/addons/mod/workshop/pages/submission/submission.html +++ b/src/addons/mod/workshop/pages/submission/submission.html @@ -105,9 +105,11 @@ - {{ 'addon.mod_workshop.publishsubmission' | translate }} - -

{{ 'addon.mod_workshop.publishsubmission_help' | translate }}

+ +

{{ 'addon.mod_workshop.publishsubmission' | translate }}

+

{{ 'addon.mod_workshop.publishsubmission_help' | translate }}

+
+
diff --git a/src/core/features/settings/pages/dev/dev.html b/src/core/features/settings/pages/dev/dev.html index d72cbcba4..55aad8845 100644 --- a/src/core/features/settings/pages/dev/dev.html +++ b/src/core/features/settings/pages/dev/dev.html @@ -22,19 +22,20 @@

Text direction

{{ direction }}

- +

Force safe area margins

- +

Enable staging sites ({{stagingSitesCount}})

- +
@@ -42,14 +43,14 @@

Enable remote styles {{remoteStylesCount}}

- +

Enable site plugin styles {{pluginStylesCount}}

- +
diff --git a/src/core/features/settings/pages/general/general.html b/src/core/features/settings/pages/general/general.html index 5644228d4..feb5e33a3 100644 --- a/src/core/features/settings/pages/general/general.html +++ b/src/core/features/settings/pages/general/general.html @@ -57,7 +57,7 @@

{{ 'core.settings.enablerichtexteditor' | translate }}

{{ 'core.settings.enablerichtexteditordescription' | translate }}

- +
@@ -73,14 +73,14 @@

{{ 'core.settings.debugdisplay' | translate }}

{{ 'core.settings.debugdisplaydescription' | translate }}

- +

{{ 'core.settings.enableanalytics' | translate }}

{{ 'core.settings.enableanalyticsdescription' | translate }}

- +
diff --git a/src/core/features/settings/pages/site/site.html b/src/core/features/settings/pages/site/site.html index bffb5af8c..5b940b309 100644 --- a/src/core/features/settings/pages/site/site.html +++ b/src/core/features/settings/pages/site/site.html @@ -26,7 +26,7 @@

{{ handler.title | translate}}

+ (ionChange)="handler.toggle($event.detail.checked)" slot="end"> From aa96fc45ea41c8a4e887f04bc984fc3a1c5498c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Oct 2023 12:12:42 +0200 Subject: [PATCH 3/6] MOBILE-4362 bootstrap: Support basic button colors --- src/theme/components/format-text.scss | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/theme/components/format-text.scss b/src/theme/components/format-text.scss index 55296f0ff..bf2f2d4cd 100644 --- a/src/theme/components/format-text.scss +++ b/src/theme/components/format-text.scss @@ -113,10 +113,6 @@ core-format-text { padding: 10px 0; } - .btn-link { - background: none; - } - } @keyframes loading { @@ -679,6 +675,29 @@ core-rich-text-editor .core-rte-editor { background-color: var(--#{$color-name}); } } + + .btn-link { + background: none; + } + + button, .btn { + margin: 4px 8px; + padding-left: 12px; + padding-right: 12px; + border-radius: var(--core-input-radius); + a { + color: inherit; + } + } + + @each $color-name, $unused in $colors { + .btn.btn-#{$color-name} { + --color-base: var(--#{$color-name}); + color: var(--#{$color-name}-shade); + border-color: var(--color-base); + background-color: var(--#{$color-name}-tint); + } + } } // h1 is too big and ugly, reduce size when loading. From 3f69d2785eb8975b0b2131d7682a5c3ee7234f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Oct 2023 12:49:03 +0200 Subject: [PATCH 4/6] MOBILE-4362 folder: Workaround on folder button while MOBILE-4147 --- src/core/features/course/components/module/module.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/features/course/components/module/module.scss b/src/core/features/course/components/module/module.scss index 98782c81a..8323c727d 100644 --- a/src/core/features/course/components/module/module.scss +++ b/src/core/features/course/components/module/module.scss @@ -185,4 +185,9 @@ &.indented + ::ng-deep core-course-module.indented ion-card { border-top: 1px solid var(--border-color); } + + // Hide download folder icon meanwhile MOBILE-4147 is not solved + core-format-text.core-module-description ::ng-deep .description-inner .navitem { + display: none; + } } From ecd7ced2235d054c033ce9b57a8b785397c5c661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Oct 2023 12:16:31 +0200 Subject: [PATCH 5/6] MOBILE-4362 label: Add round borders on text & media images --- src/core/features/course/components/module/module.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/features/course/components/module/module.scss b/src/core/features/course/components/module/module.scss index 8323c727d..f17b4f606 100644 --- a/src/core/features/course/components/module/module.scss +++ b/src/core/features/course/components/module/module.scss @@ -94,7 +94,8 @@ } } - .core-module-description ::ng-deep img { + .core-module-description ::ng-deep img, + .activity-title .item-heading core-format-text ::ng-deep img { border-radius: var(--radius-lg); } From 6b0cd694c55b337981e36c2d2570906eb39bfa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Oct 2023 14:01:12 +0200 Subject: [PATCH 6/6] MOBILE-4348 label: Support has custom cm list item to match cards border --- src/addons/mod/label/services/handlers/module.ts | 1 + .../features/course/classes/module-base-handler.ts | 1 + .../components/module/core-course-module.html | 4 ++-- .../features/course/components/module/module.scss | 4 ++++ .../features/course/components/module/module.ts | 13 +++++++++++++ src/core/features/course/services/course.ts | 1 + .../features/course/services/module-delegate.ts | 8 ++++++++ .../siteplugins/classes/handlers/module-handler.ts | 1 + .../features/siteplugins/services/siteplugins.ts | 1 + 9 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/addons/mod/label/services/handlers/module.ts b/src/addons/mod/label/services/handlers/module.ts index 9aea9b5a4..3507a8add 100644 --- a/src/addons/mod/label/services/handlers/module.ts +++ b/src/addons/mod/label/services/handlers/module.ts @@ -56,6 +56,7 @@ export class AddonModLabelModuleHandlerService extends CoreModuleHandlerBase imp title, a11yTitle: '', class: 'addon-mod-label-handler', + hasCustomCmListItem: true, }; } diff --git a/src/core/features/course/classes/module-base-handler.ts b/src/core/features/course/classes/module-base-handler.ts index 9f1235964..7bda916d1 100644 --- a/src/core/features/course/classes/module-base-handler.ts +++ b/src/core/features/course/classes/module-base-handler.ts @@ -45,6 +45,7 @@ export class CoreModuleHandlerBase implements Partial { title: module.name, class: 'addon-mod_' + module.modname + '-handler', showDownloadButton: true, + hasCustomCmListItem: false, action: async ( event: Event, module: CoreCourseModuleData, diff --git a/src/core/features/course/components/module/core-course-module.html b/src/core/features/course/components/module/core-course-module.html index ea67ff1c2..9d2dc797b 100644 --- a/src/core/features/course/components/module/core-course-module.html +++ b/src/core/features/course/components/module/core-course-module.html @@ -1,7 +1,7 @@ diff --git a/src/core/features/course/components/module/module.scss b/src/core/features/course/components/module/module.scss index f17b4f606..c19989d51 100644 --- a/src/core/features/course/components/module/module.scss +++ b/src/core/features/course/components/module/module.scss @@ -7,6 +7,10 @@ ion-card { margin: var(--vertical-margin) var(--horizontal-margin); + + &.activityinline { + border: 0px; + } } ion-item { diff --git a/src/core/features/course/components/module/module.ts b/src/core/features/course/components/module/module.ts index 439b3dab6..649f4f1b7 100644 --- a/src/core/features/course/components/module/module.ts +++ b/src/core/features/course/components/module/module.ts @@ -65,6 +65,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { prefetchStatusIcon$ = new BehaviorSubject(''); // Module prefetch status icon. prefetchStatusText$ = new BehaviorSubject(''); // Module prefetch status text. moduleHasView = true; + activityInline = false; protected prefetchHandler?: CoreCourseModulePrefetchHandler; @@ -101,6 +102,18 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { this.module.handlerData.a11yTitle = this.module.handlerData.a11yTitle ?? this.module.handlerData.title; this.moduleHasView = CoreCourse.moduleHasView(this.module); + if ( + this.module.handlerData.hasCustomCmListItem && + (!this.showAvailability || !this.module.availabilityinfo) && + (!this.showCompletion || !this.hasCompletion) && + (!this.showActivityDates || !this.module.dates?.length) && + !this.module.groupmode && + !(this.module.visible === 0) && + !(this.module.visible !== 0 && this.module.isStealth) + ) { + this.activityInline = true; + } + if (this.showDownloadStatus && this.module.handlerData.showDownloadButton) { const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.module.course); this.updateModuleStatus(status); diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index c536c25d7..25586200a 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -1784,6 +1784,7 @@ export type CoreCourseGetContentsWSModule = { completion?: CoreCourseModuleCompletionTracking; // Type of completion tracking: 0 means none, 1 manual, 2 automatic. completiondata?: CoreCourseModuleWSCompletionData; // Module completion data. contents?: CoreCourseModuleContentFile[]; + groupmode?: number; // @since 4.3. Group mode value downloadcontent?: number; // @since 4.0 The download content value. dates?: { label: string; diff --git a/src/core/features/course/services/module-delegate.ts b/src/core/features/course/services/module-delegate.ts index faf5b59fc..920734e01 100644 --- a/src/core/features/course/services/module-delegate.ts +++ b/src/core/features/course/services/module-delegate.ts @@ -168,6 +168,14 @@ export interface CoreCourseModuleHandlerData { */ showDownloadButton?: boolean; + /** + * Wether activity has the custom cmlist item flag enabled. + * + * Activities like label uses this flag to indicate that it should be + * displayed as a custom course item instead of a tipical activity card. + */ + hasCustomCmListItem?: boolean; + /** * The buttons to display in the module item. * diff --git a/src/core/features/siteplugins/classes/handlers/module-handler.ts b/src/core/features/siteplugins/classes/handlers/module-handler.ts index 6f5de77c6..11854ac74 100644 --- a/src/core/features/siteplugins/classes/handlers/module-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/module-handler.ts @@ -90,6 +90,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp icon: CoreCourse.getModuleIconSrc(module.modname, icon), class: this.handlerSchema.displaydata?.class, showDownloadButton: showDowloadButton !== undefined ? showDowloadButton : hasOffline, + hasCustomCmListItem: this.handlerSchema.hascustomcmlistitem ?? false, }; if (this.handlerSchema.method) { diff --git a/src/core/features/siteplugins/services/siteplugins.ts b/src/core/features/siteplugins/services/siteplugins.ts index 76dc1569b..26257cbe1 100644 --- a/src/core/features/siteplugins/services/siteplugins.ts +++ b/src/core/features/siteplugins/services/siteplugins.ts @@ -895,6 +895,7 @@ export type CoreSitePluginsCourseModuleHandlerData = CoreSitePluginsHandlerCommo supportedfeatures?: Record; manualcompletionalwaysshown?: boolean; nolinkhandlers?: boolean; + hascustomcmlistitem?: boolean; }; /**