MOBILE-3014 block: Add Course completion status block feature

main
Pau Ferrer Ocaña 2019-05-08 12:22:37 +02:00
parent 29537504d0
commit c20a158525
6 changed files with 97 additions and 0 deletions

View File

@ -29,6 +29,7 @@
"addon.block_activitymodules.pluginname": "block_activity_modules", "addon.block_activitymodules.pluginname": "block_activity_modules",
"addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarmonth.pluginname": "block_calendar_month",
"addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming",
"addon.block_completionstatus.pluginname": "block_completionstatus",
"addon.block_learningplans.pluginname": "block_lp", "addon.block_learningplans.pluginname": "block_lp",
"addon.block_myoverview.all": "block_myoverview", "addon.block_myoverview.all": "block_myoverview",
"addon.block_myoverview.favourites": "block_myoverview", "addon.block_myoverview.favourites": "block_myoverview",

View File

@ -0,0 +1,38 @@
// (C) Copyright 2015 Martin Dougiamas
//
// 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 { AddonBlockCompletionStatusHandler } from './providers/block-handler';
@NgModule({
declarations: [
],
imports: [
IonicModule,
TranslateModule.forChild()
],
exports: [
],
providers: [
AddonBlockCompletionStatusHandler
]
})
export class AddonBlockCompletionStatusModule {
constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockCompletionStatusHandler) {
blockDelegate.registerHandler(blockHandler);
}
}

View File

@ -0,0 +1,3 @@
{
"pluginname": "Course completion status"
}

View File

@ -0,0 +1,52 @@
// (C) Copyright 2015 Martin Dougiamas
//
// 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 { CoreBlockOnlyTitleComponent } from '@core/block/components/only-title-block/only-title-block';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
/**
* Block handler.
*/
@Injectable()
export class AddonBlockCompletionStatusHandler extends CoreBlockBaseHandler {
name = 'AddonBlockCompletionStatus';
blockName = 'completionstatus';
constructor() {
super();
}
/**
* Returns the data needed to render the block.
*
* @param {Injector} injector Injector.
* @param {any} block The block to render.
* @param {string} contextLevel The context where the block will be used.
* @param {number} instanceId The instance ID associated with the context level.
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
*/
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return {
title: 'addon.block_completionstatus.pluginname',
class: 'addon-block-completion-status',
component: CoreBlockOnlyTitleComponent,
link: 'AddonCourseCompletionReportPage',
linkParams: { courseId: instanceId }
};
}
}

View File

@ -93,6 +93,7 @@ import { AddonFilesModule } from '@addon/files/files.module';
import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module'; import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module';
import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module';
import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module';
import { AddonBlockCompletionStatusModule } from '@addon/block/completionstatus/completionstatus.module';
import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module'; import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module';
import { AddonBlockLearningPlansModule } from '@addon/block/learningplans/learningplans.module'; import { AddonBlockLearningPlansModule } from '@addon/block/learningplans/learningplans.module';
import { AddonBlockPrivateFilesModule } from '@addon/block/privatefiles/privatefiles.module'; import { AddonBlockPrivateFilesModule } from '@addon/block/privatefiles/privatefiles.module';
@ -219,6 +220,7 @@ export const CORE_PROVIDERS: any[] = [
AddonBlockActivityModulesModule, AddonBlockActivityModulesModule,
AddonBlockCalendarMonthModule, AddonBlockCalendarMonthModule,
AddonBlockCalendarUpcomingModule, AddonBlockCalendarUpcomingModule,
AddonBlockCompletionStatusModule,
AddonBlockLearningPlansModule, AddonBlockLearningPlansModule,
AddonBlockMyOverviewModule, AddonBlockMyOverviewModule,
AddonBlockPrivateFilesModule, AddonBlockPrivateFilesModule,

View File

@ -29,6 +29,7 @@
"addon.block_activitymodules.pluginname": "Activities", "addon.block_activitymodules.pluginname": "Activities",
"addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarmonth.pluginname": "Calendar",
"addon.block_calendarupcoming.pluginname": " Upcoming events", "addon.block_calendarupcoming.pluginname": " Upcoming events",
"addon.block_completionstatus.pluginname": "Course completion status",
"addon.block_learningplans.pluginname": "Learning plans", "addon.block_learningplans.pluginname": "Learning plans",
"addon.block_myoverview.all": "All", "addon.block_myoverview.all": "All",
"addon.block_myoverview.favourites": "Starred", "addon.block_myoverview.favourites": "Starred",