diff --git a/src/addon/mod/workshop/components/components.module.ts b/src/addon/mod/workshop/components/components.module.ts
new file mode 100644
index 000000000..6111f4bb4
--- /dev/null
+++ b/src/addon/mod/workshop/components/components.module.ts
@@ -0,0 +1,45 @@
+// (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 { CommonModule } from '@angular/common';
+import { IonicModule } from 'ionic-angular';
+import { TranslateModule } from '@ngx-translate/core';
+import { CoreComponentsModule } from '@components/components.module';
+import { CoreDirectivesModule } from '@directives/directives.module';
+import { CoreCourseComponentsModule } from '@core/course/components/components.module';
+import { AddonModWorkshopIndexComponent } from './index/index';
+
+@NgModule({
+ declarations: [
+ AddonModWorkshopIndexComponent
+ ],
+ imports: [
+ CommonModule,
+ IonicModule,
+ TranslateModule.forChild(),
+ CoreComponentsModule,
+ CoreDirectivesModule,
+ CoreCourseComponentsModule
+ ],
+ providers: [
+ ],
+ exports: [
+ AddonModWorkshopIndexComponent
+ ],
+ entryComponents: [
+ AddonModWorkshopIndexComponent
+ ]
+})
+export class AddonModWorkshopComponentsModule {}
diff --git a/src/addon/mod/workshop/components/index/index.html b/src/addon/mod/workshop/components/index/index.html
new file mode 100644
index 000000000..15f9ed06c
--- /dev/null
+++ b/src/addon/mod/workshop/components/index/index.html
@@ -0,0 +1,176 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = phase.code || phase.tasks.length || phase.switchUrl)">
+ {{ phase.title }}
+
+
+
+
diff --git a/src/addon/mod/workshop/pages/phase/phase.module.ts b/src/addon/mod/workshop/pages/phase/phase.module.ts
new file mode 100644
index 000000000..2085e6ca9
--- /dev/null
+++ b/src/addon/mod/workshop/pages/phase/phase.module.ts
@@ -0,0 +1,33 @@
+// (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 { IonicPageModule } from 'ionic-angular';
+import { TranslateModule } from '@ngx-translate/core';
+import { CoreDirectivesModule } from '@directives/directives.module';
+import { AddonModWorkshopPhaseSelectorPage } from './phase';
+import { CoreCompileHtmlComponentModule } from '@core/compile/components/compile-html/compile-html.module';
+
+@NgModule({
+ declarations: [
+ AddonModWorkshopPhaseSelectorPage,
+ ],
+ imports: [
+ CoreDirectivesModule,
+ CoreCompileHtmlComponentModule,
+ IonicPageModule.forChild(AddonModWorkshopPhaseSelectorPage),
+ TranslateModule.forChild()
+ ],
+})
+export class AddonModWorkshopPhaseSelectorPageModule {}
diff --git a/src/addon/mod/workshop/pages/phase/phase.ts b/src/addon/mod/workshop/pages/phase/phase.ts
new file mode 100644
index 000000000..f1fe2fdcc
--- /dev/null
+++ b/src/addon/mod/workshop/pages/phase/phase.ts
@@ -0,0 +1,56 @@
+// (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 { Component } from '@angular/core';
+import { IonicPage, NavParams, ViewController } from 'ionic-angular';
+
+/**
+ * Page that displays the phase selector modal.
+ */
+@IonicPage({ segment: 'addon-mod-workshop-phase-selector' })
+@Component({
+ selector: 'page-addon-mod-workshop-phase-selector',
+ templateUrl: 'phase.html',
+})
+export class AddonModWorkshopPhaseSelectorPage {
+ selected: number;
+ phases: any;
+ workshopPhase: number;
+ protected original: number;
+
+ constructor(params: NavParams, private viewCtrl: ViewController) {
+ this.selected = params.get('selected');
+ this.original = this.selected;
+ this.phases = params.get('phases');
+ this.workshopPhase = params.get('workshopPhase');
+ }
+
+ /**
+ * Close modal.
+ */
+ closeModal(): void {
+ this.viewCtrl.dismiss();
+ }
+
+ /**
+ * Select phase.
+ */
+ switchPhase(): void {
+ // This is a quick hack to avoid the first switch phase call done just when opening the modal.
+ if (this.original != this.selected) {
+ this.viewCtrl.dismiss(this.selected);
+ }
+ this.original = null;
+ }
+}
diff --git a/src/addon/mod/workshop/providers/helper.ts b/src/addon/mod/workshop/providers/helper.ts
index 48736cd8b..4007b223a 100644
--- a/src/addon/mod/workshop/providers/helper.ts
+++ b/src/addon/mod/workshop/providers/helper.ts
@@ -268,7 +268,7 @@ export class AddonModWorkshopHelperProvider {
}
/**
- * Get a list of stored attachment files for a submission. See $mmaModWorkshopHelper#storeFiles.
+ * Get a list of stored attachment files for a submission. See AddonModWorkshopHelperProvider#storeFiles.
*
* @param {number} workshopId Workshop ID.
* @param {number} submissionId If not editing, it will refer to timecreated.
@@ -286,7 +286,7 @@ export class AddonModWorkshopHelperProvider {
}
/**
- * Get a list of stored attachment files for a submission and online files also. See $mmaModWorkshopHelper#storeFiles.
+ * Get a list of stored attachment files for a submission and online files also. See AddonModWorkshopHelperProvider#storeFiles.
*
* @param {any} filesObject Files object combining offline and online information.
* @param {number} workshopId Workshop ID.
@@ -355,7 +355,7 @@ export class AddonModWorkshopHelperProvider {
}
/**
- * Get a list of stored attachment files for an assessment. See $mmaModWorkshopHelper#storeFiles.
+ * Get a list of stored attachment files for an assessment. See AddonModWorkshopHelperProvider#storeFiles.
*
* @param {number} workshopId Workshop ID.
* @param {number} assessmentId Assessment ID.
@@ -372,7 +372,7 @@ export class AddonModWorkshopHelperProvider {
}
/**
- * Get a list of stored attachment files for an assessment and online files also. See $mmaModWorkshopHelper#storeFiles.
+ * Get a list of stored attachment files for an assessment and online files also. See AddonModWorkshopHelperProvider#storeFiles.
*
* @param {object} filesObject Files object combining offline and online information.
* @param {number} workshopId Workshop ID.
diff --git a/src/addon/mod/workshop/providers/link-handler.ts b/src/addon/mod/workshop/providers/link-handler.ts
new file mode 100644
index 000000000..6c06a0ca6
--- /dev/null
+++ b/src/addon/mod/workshop/providers/link-handler.ts
@@ -0,0 +1,30 @@
+// (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 } from '@angular/core';
+import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
+import { CoreCourseHelperProvider } from '@core/course/providers/helper';
+import { AddonModWorkshopProvider } from './workshop';
+
+/**
+ * Handler to treat links to workshop.
+ */
+@Injectable()
+export class AddonModWorkshopLinkHandler extends CoreContentLinksModuleIndexHandler {
+ name = 'AddonModWorkshopLinkHandler';
+
+ constructor(courseHelper: CoreCourseHelperProvider) {
+ super(courseHelper, AddonModWorkshopProvider.COMPONENT, 'workshop');
+ }
+}
diff --git a/src/addon/mod/workshop/providers/module-handler.ts b/src/addon/mod/workshop/providers/module-handler.ts
new file mode 100644
index 000000000..bb275e5d9
--- /dev/null
+++ b/src/addon/mod/workshop/providers/module-handler.ts
@@ -0,0 +1,72 @@
+// (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 } from '@angular/core';
+import { NavController, NavOptions } from 'ionic-angular';
+import { AddonModWorkshopIndexComponent } from '../components/index/index';
+import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/course/providers/module-delegate';
+import { CoreCourseProvider } from '@core/course/providers/course';
+import { AddonModWorkshopProvider } from './workshop';
+
+/**
+ * Handler to support workshop modules.
+ */
+@Injectable()
+export class AddonModWorkshopModuleHandler implements CoreCourseModuleHandler {
+ name = 'AddonModWorkshop';
+ modName = 'workshop';
+
+ constructor(private courseProvider: CoreCourseProvider, private workshopProvider: AddonModWorkshopProvider) { }
+
+ /**
+ * Check if the handler is enabled on a site level.
+ *
+ * @return {Promise} Whether or not the handler is enabled on a site level.
+ */
+ isEnabled(): Promise {
+ return this.workshopProvider.isPluginEnabled();
+ }
+
+ /**
+ * Get the data required to display the module in the course contents view.
+ *
+ * @param {any} module The module object.
+ * @param {number} courseId The course ID.
+ * @param {number} sectionId The section ID.
+ * @return {CoreCourseModuleHandlerData} Data to render the module.
+ */
+ getData(module: any, courseId: number, sectionId: number): CoreCourseModuleHandlerData {
+ return {
+ icon: this.courseProvider.getModuleIconSrc('workshop'),
+ title: module.name,
+ class: 'addon-mod_workshop-handler',
+ showDownloadButton: true,
+ action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
+ navCtrl.push('AddonModWorkshopIndexPage', {module: module, courseId: courseId}, options);
+ }
+ };
+ }
+
+ /**
+ * Get the component to render the module. This is needed to support singleactivity course format.
+ * The component returned must implement CoreCourseModuleMainComponent.
+ *
+ * @param {any} course The course object.
+ * @param {any} module The module object.
+ * @return {any} The component to use, undefined if not found.
+ */
+ getMainComponent(course: any, module: any): any {
+ return AddonModWorkshopIndexComponent;
+ }
+}
diff --git a/src/addon/mod/workshop/providers/offline.ts b/src/addon/mod/workshop/providers/offline.ts
index 6ac09becb..c74a1b48e 100644
--- a/src/addon/mod/workshop/providers/offline.ts
+++ b/src/addon/mod/workshop/providers/offline.ts
@@ -418,7 +418,7 @@ export class AddonModWorkshopOfflineProvider {
getAllAssessments(siteId?: string): Promise {
return this.sitesProvider.getSite(siteId).then((site) => {
return site.getDb().getRecords(this.ASSESSMENTS_TABLE).then((records) => {
- records.forEach(this.parseAssessnentRecord.bind(this));
+ records.forEach(this.parseAssessmentRecord.bind(this));
return records;
});
@@ -439,7 +439,7 @@ export class AddonModWorkshopOfflineProvider {
};
return site.getDb().getRecords(this.ASSESSMENTS_TABLE, conditions).then((records) => {
- records.forEach(this.parseAssessnentRecord.bind(this));
+ records.forEach(this.parseAssessmentRecord.bind(this));
return records;
});
@@ -462,7 +462,7 @@ export class AddonModWorkshopOfflineProvider {
};
return site.getDb().getRecord(this.ASSESSMENTS_TABLE, conditions).then((record) => {
- this.parseAssessnentRecord(record);
+ this.parseAssessmentRecord(record);
return record;
});
@@ -498,7 +498,7 @@ export class AddonModWorkshopOfflineProvider {
*
* @param {any} record Assessnent record, modified in place.
*/
- protected parseAssessnentRecord(record: any): void {
+ protected parseAssessmentRecord(record: any): void {
record.inputdata = this.textUtils.parseJSON(record.inputdata);
}
diff --git a/src/addon/mod/workshop/providers/workshop.ts b/src/addon/mod/workshop/providers/workshop.ts
index 5ce7d3a79..9962b836d 100644
--- a/src/addon/mod/workshop/providers/workshop.ts
+++ b/src/addon/mod/workshop/providers/workshop.ts
@@ -24,7 +24,7 @@ import { AddonModWorkshopOfflineProvider } from './offline';
*/
@Injectable()
export class AddonModWorkshopProvider {
- static COMPONENT = 'mmaWorkshopUrl';
+ static COMPONENT = 'mmaModWorkshop';
static PER_PAGE = 10;
static PHASE_SETUP = 10;
static PHASE_SUBMISSION = 20;
@@ -35,6 +35,9 @@ export class AddonModWorkshopProvider {
static EXAMPLES_BEFORE_SUBMISSION: 1;
static EXAMPLES_BEFORE_ASSESSMENT: 2;
+ static SUBMISSION_CHANGED = 'addon_mod_workshop_submission_changed';
+ static ASSESSMENT_SAVED = 'addon_mod_workshop_assessment_saved';
+
protected ROOT_CACHE_KEY = 'mmaModWorkshop:';
constructor(
@@ -346,12 +349,7 @@ export class AddonModWorkshopProvider {
return site.read('mod_workshop_get_user_plan', params, preSets).then((response) => {
if (response && response.userplan && response.userplan.phases) {
- const phases = {};
- response.userplan.phases.forEach((phase) => {
- phases[phase.code] = phase;
- });
-
- return phases;
+ return this.utils.arrayToObject(response.userplan.phases, 'code');
}
return Promise.reject(null);
@@ -1295,7 +1293,7 @@ export class AddonModWorkshopProvider {
/**
* Invalidate the prefetched content except files.
- * To invalidate files, use $mmaModWorkshop#invalidateFiles.
+ * To invalidate files, use AddonModWorkshopProvider#invalidateFiles.
*
* @param {number} moduleId The module ID.
* @param {number} courseId Course ID.
diff --git a/src/addon/mod/workshop/workshop.module.ts b/src/addon/mod/workshop/workshop.module.ts
new file mode 100644
index 000000000..2653be857
--- /dev/null
+++ b/src/addon/mod/workshop/workshop.module.ts
@@ -0,0 +1,49 @@
+// (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 { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate';
+import { CoreCourseModuleDelegate } from '@core/course/providers/module-delegate';
+import { AddonModWorkshopComponentsModule } from './components/components.module';
+import { AddonModWorkshopModuleHandler } from './providers/module-handler';
+import { AddonModWorkshopProvider } from './providers/workshop';
+import { AddonModWorkshopLinkHandler } from './providers/link-handler';
+import { AddonModWorkshopOfflineProvider } from './providers/offline';
+import { AddonModWorkshopSyncProvider } from './providers/sync';
+import { AddonModWorkshopHelperProvider } from './providers/helper';
+import { AddonWorkshopAssessmentStrategyDelegate } from './providers/assessment-strategy-delegate';
+
+@NgModule({
+ declarations: [
+ ],
+ imports: [
+ AddonModWorkshopComponentsModule
+ ],
+ providers: [
+ AddonModWorkshopProvider,
+ AddonModWorkshopModuleHandler,
+ AddonModWorkshopLinkHandler,
+ AddonModWorkshopOfflineProvider,
+ AddonModWorkshopSyncProvider,
+ AddonModWorkshopHelperProvider,
+ AddonWorkshopAssessmentStrategyDelegate
+ ]
+})
+export class AddonModWorkshopModule {
+ constructor(moduleDelegate: CoreCourseModuleDelegate, moduleHandler: AddonModWorkshopModuleHandler,
+ contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModWorkshopLinkHandler) {
+ moduleDelegate.registerHandler(moduleHandler);
+ contentLinksDelegate.registerHandler(linkHandler);
+ }
+}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 8737ec72f..d11018cb9 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -96,6 +96,7 @@ import { AddonModQuizModule } from '@addon/mod/quiz/quiz.module';
import { AddonModScormModule } from '@addon/mod/scorm/scorm.module';
import { AddonModUrlModule } from '@addon/mod/url/url.module';
import { AddonModSurveyModule } from '@addon/mod/survey/survey.module';
+import { AddonModWorkshopModule } from '@addon/mod/workshop/workshop.module';
import { AddonModImscpModule } from '@addon/mod/imscp/imscp.module';
import { AddonModWikiModule } from '@addon/mod/wiki/wiki.module';
import { AddonMessageOutputModule } from '@addon/messageoutput/messageoutput.module';
@@ -202,6 +203,7 @@ export const CORE_PROVIDERS: any[] = [
AddonModScormModule,
AddonModUrlModule,
AddonModSurveyModule,
+ AddonModWorkshopModule,
AddonModImscpModule,
AddonModWikiModule,
AddonMessageOutputModule,