MOBILE-3449 assign: Don't block all assign sync when edit grade
parent
b67ea14abb
commit
88ac2e0c5c
|
@ -20,7 +20,7 @@
|
|||
</ion-item>
|
||||
|
||||
<!-- Tabs: see the submission or grade it. -->
|
||||
<core-tabs [selectedIndex]="selectedTab" [hideUntil]="loaded" parentScrollable="true">
|
||||
<core-tabs [selectedIndex]="selectedTab" [hideUntil]="loaded" parentScrollable="true" (ionChange)="tabSelected($event)">
|
||||
<!-- View the submission tab. -->
|
||||
<core-tab [title]="'addon.mod_assign.submission' | translate">
|
||||
<ng-template>
|
||||
|
|
|
@ -35,7 +35,9 @@ import {
|
|||
} from '../../providers/assign';
|
||||
import { AddonModAssignHelperProvider } from '../../providers/helper';
|
||||
import { AddonModAssignOfflineProvider } from '../../providers/assign-offline';
|
||||
import { AddonModAssignSync } from '../../providers/assign-sync';
|
||||
import { CoreTabsComponent } from '@components/tabs/tabs';
|
||||
import { CoreTabComponent } from '@components/tabs/tab';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { AddonModAssignSubmissionPluginComponent } from '../submission-plugin/submission-plugin';
|
||||
|
||||
|
@ -537,11 +539,6 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy {
|
|||
// Make sure outcomes is an array.
|
||||
gradeInfo.outcomes = gradeInfo.outcomes || [];
|
||||
|
||||
if (!this.isDestroyed) {
|
||||
// Block the assignment.
|
||||
this.syncProvider.blockOperation(AddonModAssignProvider.COMPONENT, this.assign.id);
|
||||
}
|
||||
|
||||
// Treat the grade info.
|
||||
return this.treatGradeInfo();
|
||||
}).then(() => {
|
||||
|
@ -952,15 +949,41 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Block or unblock the automatic sync of the user grade.
|
||||
*
|
||||
* @param block Whether to block or unblock.
|
||||
*/
|
||||
protected setGradeSyncBlocked(block?: boolean): void {
|
||||
if (this.isDestroyed || !this.assign || !this.isGrading) {
|
||||
return;
|
||||
}
|
||||
|
||||
const syncId = AddonModAssignSync.instance.getGradeSyncId(this.assign.id, this.submitId);
|
||||
|
||||
if (block) {
|
||||
this.syncProvider.blockOperation(AddonModAssignProvider.COMPONENT, syncId);
|
||||
} else {
|
||||
this.syncProvider.unblockOperation(AddonModAssignProvider.COMPONENT, syncId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A certain tab has been selected, either manually or automatically.
|
||||
*
|
||||
* @param tab The tab that was selected.
|
||||
*/
|
||||
tabSelected(tab: CoreTabComponent): void {
|
||||
// Block sync when selecting grade tab, unblock when leaving it.
|
||||
this.setGradeSyncBlocked(this.tabs.getIndex(tab) === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component being destroyed.
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.setGradeSyncBlocked(false);
|
||||
this.isDestroyed = true;
|
||||
|
||||
if (this.assign && this.isGrading) {
|
||||
this.syncProvider.unblockOperation(AddonModAssignProvider.COMPONENT, this.assign.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
"submitassignment": "Submit assignment",
|
||||
"submittedearly": "Assignment was submitted {{$a}} early",
|
||||
"submittedlate": "Assignment was submitted {{$a}} late",
|
||||
"syncblockedusercomponent": "user grade",
|
||||
"timemodified": "Last modified",
|
||||
"timeremaining": "Time remaining",
|
||||
"ungroupedusers": "The setting 'Require group to make submission' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions.",
|
||||
|
|
|
@ -31,6 +31,8 @@ import { AddonModAssignOfflineProvider } from './assign-offline';
|
|||
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
|
||||
import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
|
||||
|
||||
import { makeSingleton } from '@singletons/core.singletons';
|
||||
|
||||
/**
|
||||
* Data returned by an assign sync.
|
||||
*/
|
||||
|
@ -79,6 +81,17 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
this.componentTranslate = courseProvider.translateModuleName('assign');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sync ID for a certain user grade.
|
||||
*
|
||||
* @param assignId Assign ID.
|
||||
* @param userId User the grade belongs to.
|
||||
* @return Sync ID.
|
||||
*/
|
||||
getGradeSyncId(assignId: number, userId: number): string {
|
||||
return 'assignGrade#' + assignId + '#' + userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to get scale selected option.
|
||||
*
|
||||
|
@ -373,6 +386,15 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
|
||||
const userId = offlineData.userid;
|
||||
let discardError;
|
||||
const syncId = this.getGradeSyncId(assign.id, userId);
|
||||
|
||||
// Check if this grade sync is blocked.
|
||||
if (this.syncProvider.isBlocked(AddonModAssignProvider.COMPONENT, syncId, siteId)) {
|
||||
this.logger.error(`Cannot sync grade for assign ${assign.id} and user ${userId} because it is blocked.`);
|
||||
|
||||
return Promise.reject(new Error(this.translate.instant('core.errorsyncblocked',
|
||||
{$a: this.translate.instant('addon.mod_assign.syncblockedusercomponent')})));
|
||||
}
|
||||
|
||||
return this.assignProvider.getSubmissionStatus(assign.id, userId, undefined, false, true, true, siteId).then((status) => {
|
||||
const timemodified = status.feedback && (status.feedback.gradeddate || status.feedback.grade.timemodified);
|
||||
|
@ -455,3 +477,5 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class AddonModAssignSync extends makeSingleton(AddonModAssignSyncProvider) {}
|
||||
|
|
|
@ -408,6 +408,7 @@
|
|||
"addon.mod_assign.submitassignment_help": "Once this assignment is submitted you will not be able to make any more changes.",
|
||||
"addon.mod_assign.submittedearly": "Assignment was submitted {{$a}} early",
|
||||
"addon.mod_assign.submittedlate": "Assignment was submitted {{$a}} late",
|
||||
"addon.mod_assign.syncblockedusercomponent": "user grade",
|
||||
"addon.mod_assign.timemodified": "Last modified",
|
||||
"addon.mod_assign.timeremaining": "Time remaining",
|
||||
"addon.mod_assign.ungroupedusers": "The setting 'Require group to make submission' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions.",
|
||||
|
|
Loading…
Reference in New Issue