commit
74c59f3254
|
@ -1517,6 +1517,7 @@
|
||||||
"core.nograde": "moodle",
|
"core.nograde": "moodle",
|
||||||
"core.none": "moodle",
|
"core.none": "moodle",
|
||||||
"core.nopasswordchangeforced": "local_moodlemobileapp",
|
"core.nopasswordchangeforced": "local_moodlemobileapp",
|
||||||
|
"core.nopermissionerror": "local_moodlemobileapp",
|
||||||
"core.nopermissions": "error",
|
"core.nopermissions": "error",
|
||||||
"core.noresults": "moodle",
|
"core.noresults": "moodle",
|
||||||
"core.notapplicable": "local_moodlemobileapp",
|
"core.notapplicable": "local_moodlemobileapp",
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- User can view all submissions (teacher). -->
|
<!-- User can view all submissions (teacher). -->
|
||||||
<ion-card *ngIf="assign && canViewSubmissions" class="core-list-align-detail-right">
|
<ion-card *ngIf="assign && canViewAllSubmissions" class="core-list-align-detail-right">
|
||||||
<ion-item text-wrap *ngIf="timeRemaining">
|
<ion-item text-wrap *ngIf="timeRemaining">
|
||||||
<h2>{{ 'addon.mod_assign.timeremaining' | translate }}</h2>
|
<h2>{{ 'addon.mod_assign.timeremaining' | translate }}</h2>
|
||||||
<p>{{ timeRemaining }}</p>
|
<p>{{ timeRemaining }}</p>
|
||||||
|
@ -82,6 +82,6 @@
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
<!-- If it's a student, display his submission. -->
|
<!-- If it's a student, display his submission. -->
|
||||||
<addon-mod-assign-submission *ngIf="loaded && !canViewSubmissions" [courseId]="courseId" [moduleId]="module.id"></addon-mod-assign-submission>
|
<addon-mod-assign-submission *ngIf="loaded && !canViewAllSubmissions && canViewOwnSubmission" [courseId]="courseId" [moduleId]="module.id"></addon-mod-assign-submission>
|
||||||
|
|
||||||
</core-loading>
|
</core-loading>
|
||||||
|
|
|
@ -37,7 +37,8 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
moduleName = 'assign';
|
moduleName = 'assign';
|
||||||
|
|
||||||
assign: any; // The assign object.
|
assign: any; // The assign object.
|
||||||
canViewSubmissions: boolean; // Whether the user can view all submissions.
|
canViewAllSubmissions: boolean; // Whether the user can view all submissions.
|
||||||
|
canViewOwnSubmission: boolean; // Whether the user can view their own submission.
|
||||||
timeRemaining: string; // Message about time remaining to submit.
|
timeRemaining: string; // Message about time remaining to submit.
|
||||||
lateSubmissions: string; // Message about late submissions.
|
lateSubmissions: string; // Message about late submissions.
|
||||||
showNumbers = true; // Whether to show number of submissions with each status.
|
showNumbers = true; // Whether to show number of submissions with each status.
|
||||||
|
@ -79,16 +80,16 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.canViewSubmissions) {
|
if (this.canViewAllSubmissions) {
|
||||||
// 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.
|
// User can see all submissions, log grading view.
|
||||||
this.assignProvider.logGradingView(this.assign.id).catch(() => {
|
this.assignProvider.logGradingView(this.assign.id).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
});
|
});
|
||||||
|
} else if (this.canViewOwnSubmission) {
|
||||||
|
// User can only see their own submission, log view the user submission.
|
||||||
|
this.assignProvider.logSubmissionView(this.assign.id).catch(() => {
|
||||||
|
// Ignore errors.
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
return this.assignProvider.getSubmissions(this.assign.id).then((data) => {
|
return this.assignProvider.getSubmissions(this.assign.id).then((data) => {
|
||||||
const time = this.timeUtils.timestamp();
|
const time = this.timeUtils.timestamp();
|
||||||
|
|
||||||
this.canViewSubmissions = data.canviewsubmissions;
|
this.canViewAllSubmissions = data.canviewsubmissions;
|
||||||
|
|
||||||
if (data.canviewsubmissions) {
|
if (data.canviewsubmissions) {
|
||||||
|
|
||||||
|
@ -203,6 +204,17 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the user can view their own submission.
|
||||||
|
return this.assignProvider.getSubmissionStatus(this.assign.id).then(() => {
|
||||||
|
this.canViewOwnSubmission = true;
|
||||||
|
}).catch((error) => {
|
||||||
|
this.canViewOwnSubmission = false;
|
||||||
|
|
||||||
|
if (error.errorcode !== 'nopermission') {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// All data obtained, now fill the context menu.
|
// All data obtained, now fill the context menu.
|
||||||
|
@ -260,7 +272,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
if (this.assign) {
|
if (this.assign) {
|
||||||
promises.push(this.assignProvider.invalidateAllSubmissionData(this.assign.id));
|
promises.push(this.assignProvider.invalidateAllSubmissionData(this.assign.id));
|
||||||
|
|
||||||
if (this.canViewSubmissions) {
|
if (this.canViewAllSubmissions) {
|
||||||
promises.push(this.assignProvider.invalidateSubmissionStatusData(this.assign.id));
|
promises.push(this.assignProvider.invalidateSubmissionStatusData(this.assign.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,16 @@ export class AddonModAssignPrefetchHandler extends CoreCourseActivityPrefetchHan
|
||||||
canUseCheckUpdates(module: any, courseId: number): boolean | Promise<boolean> {
|
canUseCheckUpdates(module: any, courseId: number): boolean | Promise<boolean> {
|
||||||
// Teachers cannot use the WS because it doesn't check student submissions.
|
// Teachers cannot use the WS because it doesn't check student submissions.
|
||||||
return this.assignProvider.getAssignment(courseId, module.id).then((assign) => {
|
return this.assignProvider.getAssignment(courseId, module.id).then((assign) => {
|
||||||
return this.assignProvider.getSubmissions(assign.id);
|
return this.assignProvider.getSubmissions(assign.id).then((data) => {
|
||||||
}).then((data) => {
|
if (data.canviewsubmissions) {
|
||||||
return !data.canviewsubmissions;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the user can view their own submission.
|
||||||
|
return this.assignProvider.getSubmissionStatus(assign.id).then(() => {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -322,10 +329,16 @@ export class AddonModAssignPrefetchHandler extends CoreCourseActivityPrefetchHan
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// Student.
|
// Student.
|
||||||
promises.push(this.assignProvider.getSubmissionStatus(assign.id, userId, false, true, false, siteId)
|
promises.push(
|
||||||
.then((subm) => {
|
this.assignProvider.getSubmissionStatus(assign.id, userId, false, true, false, siteId).then((subm) => {
|
||||||
return this.prefetchSubmission(assign, courseId, moduleId, subm, userId, siteId);
|
return this.prefetchSubmission(assign, courseId, moduleId, subm, userId, siteId);
|
||||||
}));
|
}).catch((error) => {
|
||||||
|
// Ignore if the user can't view their own submission.
|
||||||
|
if (error.errorcode != 'nopermission') {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
promises.push(this.groupsProvider.activityHasGroups(assign.cmid));
|
promises.push(this.groupsProvider.activityHasGroups(assign.cmid));
|
||||||
|
|
|
@ -1518,6 +1518,7 @@
|
||||||
"core.nograde": "No grade",
|
"core.nograde": "No grade",
|
||||||
"core.none": "None",
|
"core.none": "None",
|
||||||
"core.nopasswordchangeforced": "You cannot proceed without changing your password.",
|
"core.nopasswordchangeforced": "You cannot proceed without changing your password.",
|
||||||
|
"core.nopermissionerror": "Sorry, but you do not currently have permissions to do that",
|
||||||
"core.nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
"core.nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
||||||
"core.noresults": "No results",
|
"core.noresults": "No results",
|
||||||
"core.notapplicable": "n/a",
|
"core.notapplicable": "n/a",
|
||||||
|
|
|
@ -671,6 +671,16 @@ export class CoreSite {
|
||||||
// This should not happen.
|
// This should not happen.
|
||||||
error.message = this.translate.instant('core.unicodenotsupported');
|
error.message = this.translate.instant('core.unicodenotsupported');
|
||||||
|
|
||||||
|
return Promise.reject(error);
|
||||||
|
} else if (error.exception === 'required_capability_exception' || error.errorcode === 'nopermission') {
|
||||||
|
if (error.message === 'error/nopermission') {
|
||||||
|
// This error message is returned by some web services but the string does not exist.
|
||||||
|
error.message = this.translate.instant('core.nopermissionerror');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the error instead of deleting the cache entry so the same content is displayed in offline.
|
||||||
|
this.saveToCache(method, data, error, preSets);
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
} else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) {
|
} else if (typeof preSets.emergencyCache !== 'undefined' && !preSets.emergencyCache) {
|
||||||
this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`);
|
this.logger.debug(`WS call '${method}' failed. Emergency cache is forbidden, rejecting.`);
|
||||||
|
@ -695,6 +705,13 @@ export class CoreSite {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}).then((response) => {
|
||||||
|
// Check if the response is an error, this happens if the error was stored in the cache.
|
||||||
|
if (response && typeof response.exception !== 'undefined') {
|
||||||
|
return Promise.reject(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@
|
||||||
"nograde": "No grade",
|
"nograde": "No grade",
|
||||||
"none": "None",
|
"none": "None",
|
||||||
"nopasswordchangeforced": "You cannot proceed without changing your password.",
|
"nopasswordchangeforced": "You cannot proceed without changing your password.",
|
||||||
|
"nopermissionerror": "Sorry, but you do not currently have permissions to do that",
|
||||||
"nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
"nopermissions": "Sorry, but you do not currently have permissions to do that ({{$a}})",
|
||||||
"noresults": "No results",
|
"noresults": "No results",
|
||||||
"notapplicable": "n/a",
|
"notapplicable": "n/a",
|
||||||
|
|
Loading…
Reference in New Issue