+
+
+
+
+
+ {{ note }}
+
+
+
+
+
+
+
+
+
+
+ {{ 'core.hasdatatosync' | translate:{$a: moduleName} }}
+
+
+
+
+
+ {{ 'addon.mod_assign.timeremaining' | translate }}
+ {{ timeRemaining }}
+
+
+ {{ 'addon.mod_assign.latesubmissions' | translate }}
+ {{ lateSubmissions }}
+
+
+
+
+ {{ 'addon.mod_assign.numberofteams' | translate }}
+ {{ 'addon.mod_assign.numberofparticipants' | translate }}
+
+ {{ summary.participantcount }}
+
+
+
+
+
+ {{ 'addon.mod_assign.numberofdraftsubmissions' | translate }}
+
+ {{ summary.submissiondraftscount }}
+
+
+
+
+
+ {{ 'addon.mod_assign.numberofsubmittedassignments' | translate }}
+
+ {{ summary.submissionssubmittedcount }}
+
+
+
+
+
+ {{ 'addon.mod_assign.numberofsubmissionsneedgrading' | translate }}
+
+ {{ summary.submissionsneedgradingcount }}
+
+
+
+
+
+
+ {{ 'addon.mod_assign.ungroupedusers' | translate }}
+
+
+
+
+
+
diff --git a/src/addon/mod/assign/components/index/index.ts b/src/addon/mod/assign/components/index/index.ts
new file mode 100644
index 000000000..ea7497ff5
--- /dev/null
+++ b/src/addon/mod/assign/components/index/index.ts
@@ -0,0 +1,312 @@
+// (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, Optional, Injector } from '@angular/core';
+import { Content, NavController } from 'ionic-angular';
+import { CoreGroupsProvider } from '@providers/groups';
+import { CoreTimeUtilsProvider } from '@providers/utils/time';
+import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component';
+import { AddonModAssignProvider } from '../../providers/assign';
+import { AddonModAssignHelperProvider } from '../../providers/helper';
+import { AddonModAssignOfflineProvider } from '../../providers/assign-offline';
+import { AddonModAssignSyncProvider } from '../../providers/assign-sync';
+import * as moment from 'moment';
+
+/**
+ * Component that displays an assignment.
+ */
+@Component({
+ selector: 'addon-mod-assign-index',
+ templateUrl: 'index.html',
+})
+export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityComponent {
+ component = AddonModAssignProvider.COMPONENT;
+ moduleName = 'assign';
+
+ assign: any; // The assign object.
+ canViewSubmissions: boolean; // Whether the user can view all submissions.
+ timeRemaining: string; // Message about time remaining to submit.
+ lateSubmissions: string; // Message about late submissions.
+ showNumbers = true; // Whether to show number of submissions with each status.
+ summary: any; // The summary.
+ needsGradingAvalaible: boolean; // Whether we can see the submissions that need grading.
+
+ // Status.
+ submissionStatusSubmitted = AddonModAssignProvider.SUBMISSION_STATUS_SUBMITTED;
+ submissionStatusDraft = AddonModAssignProvider.SUBMISSION_STATUS_DRAFT;
+ needGrading = AddonModAssignProvider.NEED_GRADING;
+
+ protected userId: number; // Current user ID.
+ protected syncEventName = AddonModAssignSyncProvider.AUTO_SYNCED;
+
+ // Observers.
+ protected savedObserver;
+ protected submittedObserver;
+ protected gradedObserver;
+
+ constructor(injector: Injector, protected assignProvider: AddonModAssignProvider, @Optional() content: Content,
+ protected assignHelper: AddonModAssignHelperProvider, protected assignOffline: AddonModAssignOfflineProvider,
+ protected syncProvider: AddonModAssignSyncProvider, protected timeUtils: CoreTimeUtilsProvider,
+ protected groupsProvider: CoreGroupsProvider, protected navCtrl: NavController) {
+ super(injector, content);
+ }
+
+ /**
+ * Component being initialized.
+ */
+ ngOnInit(): void {
+ super.ngOnInit();
+
+ this.userId = this.sitesProvider.getCurrentSiteUserId();
+
+ this.loadContent(false, true).then(() => {
+ this.assignProvider.logView(this.assign.id).then(() => {
+ this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
+ }).catch(() => {
+ // Ignore errors.
+ });
+
+ if (!this.canViewSubmissions) {
+ // User can only see his submission, log view the user submission.
+ this.assignProvider.logSubmissionView(this.assign.id).catch(() => {
+ // Ignore errors.
+ });
+ } else {
+ // User can see all submissions, log grading view.
+ this.assignProvider.logGradingView(this.assign.id).catch(() => {
+ // Ignore errors.
+ });
+ }
+ });
+
+ // Listen to events.
+ this.savedObserver = this.eventsProvider.on(AddonModAssignProvider.SUBMISSION_SAVED_EVENT, (data) => {
+ if (this.assign && data.assignmentId == this.assign.id && data.userId == this.userId) {
+ // Assignment submission saved, refresh data.
+ this.showLoadingAndRefresh(true, false);
+ }
+ }, this.siteId);
+
+ this.submittedObserver = this.eventsProvider.on(AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT, (data) => {
+ if (this.assign && data.assignmentId == this.assign.id && data.userId == this.userId) {
+ // Assignment submitted, check completion.
+ this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
+ }
+ }, this.siteId);
+
+ this.gradedObserver = this.eventsProvider.on(AddonModAssignProvider.GRADED_EVENT, (data) => {
+ if (this.assign && data.assignmentId == this.assign.id && data.userId == this.userId) {
+ // Assignment graded, refresh data.
+ this.showLoadingAndRefresh(true, false);
+ }
+ }, this.siteId);
+ }
+
+ /**
+ * Expand the description.
+ */
+ expandDescription(ev?: Event): void {
+ ev && ev.preventDefault();
+ ev && ev.stopPropagation();
+
+ if (this.assign && (this.description || this.assign.introattachments)) {
+ this.textUtils.expandText(this.translate.instant('core.description'), this.description, this.component,
+ this.module.id, this.assign.introattachments);
+ }
+ }
+
+ /**
+ * Get assignment data.
+ *
+ * @param {boolean} [refresh=false] If it's refreshing content.
+ * @param {boolean} [sync=false] If the refresh is needs syncing.
+ * @param {boolean} [showErrors=false] If show errors to the user of hide them.
+ * @return {Promise