From 8910fc7f5ac3ef7f8230a7f563658c0d1852f04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 17 Apr 2020 13:43:42 +0200 Subject: [PATCH] MOBILE-3370 blocks: Add support for block_activity_results --- scripts/langindex.json | 1 + .../activityresults/activityresults.module.ts | 38 ++++++++++++++ .../activityresults/activityresults.scss | 31 +++++++++++ src/addon/block/activityresults/lang/en.json | 3 ++ .../providers/block-handler.ts | 51 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 127 insertions(+) create mode 100644 src/addon/block/activityresults/activityresults.module.ts create mode 100644 src/addon/block/activityresults/activityresults.scss create mode 100644 src/addon/block/activityresults/lang/en.json create mode 100644 src/addon/block/activityresults/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index 212d23e5c..68829253c 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -27,6 +27,7 @@ "addon.badges.version": "badges", "addon.badges.warnexpired": "badges", "addon.block_activitymodules.pluginname": "block_activity_modules", + "addon.block_activityresults.pluginname": "block_activity_results", "addon.block_badges.pluginname": "block_badges", "addon.block_blogmenu.pluginname": "block_blog_menu", "addon.block_blogrecent.pluginname": "block_blog_recent", diff --git a/src/addon/block/activityresults/activityresults.module.ts b/src/addon/block/activityresults/activityresults.module.ts new file mode 100644 index 000000000..3c0ee74d3 --- /dev/null +++ b/src/addon/block/activityresults/activityresults.module.ts @@ -0,0 +1,38 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@core/block/providers/delegate'; +import { AddonBlockActivityResultsHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockActivityResultsHandler + ] +}) +export class AddonBlockActivityResultsModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockActivityResultsHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/activityresults/activityresults.scss b/src/addon/block/activityresults/activityresults.scss new file mode 100644 index 000000000..b76cb85a9 --- /dev/null +++ b/src/addon/block/activityresults/activityresults.scss @@ -0,0 +1,31 @@ +.addon-block-activity-results core-block-pre-rendered { + ion-item.core-block-content { + table.grades { + @include text-align('start'); + width: 100%; + + .number { + @include text-align('start'); + width: 10%; + } + + .name { + @include text-align('start'); + width: 77%; + } + + .grade { + @include text-align('end'); + } + + caption { + @include text-align('start'); + padding-top: .75rem; + padding-bottom: .75rem; + color: $gray-darker; + font-weight: bold; + font-size: 18px; + } + } + } +} \ No newline at end of file diff --git a/src/addon/block/activityresults/lang/en.json b/src/addon/block/activityresults/lang/en.json new file mode 100644 index 000000000..4dd6abbb7 --- /dev/null +++ b/src/addon/block/activityresults/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Activity results" +} \ No newline at end of file diff --git a/src/addon/block/activityresults/providers/block-handler.ts b/src/addon/block/activityresults/providers/block-handler.ts new file mode 100644 index 000000000..8553cb3a4 --- /dev/null +++ b/src/addon/block/activityresults/providers/block-handler.ts @@ -0,0 +1,51 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable, Injector } from '@angular/core'; + +import { CoreBlockHandlerData } from '@core/block/providers/delegate'; +import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; +import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; + +/** + * Block handler. + */ +@Injectable() +export class AddonBlockActivityResultsHandler extends CoreBlockBaseHandler { + name = 'AddonBlockActivityResults'; + blockName = 'activity_results'; + + constructor() { + super(); + } + + /** + * Returns the data needed to render the block. + * + * @param injector Injector. + * @param block The block to render. + * @param contextLevel The context where the block will be used. + * @param instanceId The instance ID associated with the context level. + * @return Data or promise resolved with the data. + */ + getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number) + : CoreBlockHandlerData | Promise { + + return { + title: 'addon.block_activityresults.pluginname', + class: 'addon-block-activity-results', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 81fdb84a7..e38469ce8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -98,6 +98,7 @@ import { AddonCourseCompletionModule } from '@addon/coursecompletion/coursecompl import { AddonUserProfileFieldModule } from '@addon/userprofilefield/userprofilefield.module'; import { AddonFilesModule } from '@addon/files/files.module'; import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module'; +import { AddonBlockActivityResultsModule } from '@addon/block/activityresults/activityresults.module'; import { AddonBlockBadgesModule } from '@addon/block/badges/badges.module'; import { AddonBlockBlogMenuModule } from '@addon/block/blogmenu/blogmenu.module'; import { AddonBlockBlogTagsModule } from '@addon/block/blogtags/blogtags.module'; @@ -245,6 +246,7 @@ export const WP_PROVIDER: any = null; AddonUserProfileFieldModule, AddonFilesModule, AddonBlockActivityModulesModule, + AddonBlockActivityResultsModule, AddonBlockBadgesModule, AddonBlockBlogMenuModule, AddonBlockBlogRecentModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 3561e6111..6a229b1b1 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -27,6 +27,7 @@ "addon.badges.version": "Version", "addon.badges.warnexpired": "(This badge has expired!)", "addon.block_activitymodules.pluginname": "Activities", + "addon.block_activityresults.pluginname": "Activity results", "addon.block_badges.pluginname": "Latest badges", "addon.block_blogmenu.pluginname": "Blog menu", "addon.block_blogrecent.pluginname": "Recent blog entries",