MOBILE-3787 assign: Apply grading status when grades are found
parent
c5ef18183b
commit
4fc3c8b0d0
|
@ -164,11 +164,14 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
|
||||||
this.submissionsData.submissions,
|
this.submissionsData.submissions,
|
||||||
this.groupId,
|
this.groupId,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get assignment grades only if workflow is not enabled to check grading date.
|
// Get assignment grades only if workflow is not enabled to check grading date.
|
||||||
const grades = !assign.markingworkflow
|
let grades = !assign.markingworkflow
|
||||||
? await AddonModAssign.getAssignmentGrades(assign.id, { cmId: assign.cmid })
|
? await AddonModAssign.getAssignmentGrades(assign.id, { cmId: assign.cmid })
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
// Remove grades (not graded) and sort by timemodified DESC to allow finding quicker.
|
||||||
|
grades = grades.filter((grade) => parseInt(grade.grade, 10) >= 0).sort((a, b) => b.timemodified - a.timemodified);
|
||||||
// Filter the submissions to get only the ones with the right status and add some extra data.
|
// Filter the submissions to get only the ones with the right status and add some extra data.
|
||||||
if (this.SELECTED_STATUS == AddonModAssignListFilterName.NEED_GRADING) {
|
if (this.SELECTED_STATUS == AddonModAssignListFilterName.NEED_GRADING) {
|
||||||
const promises: Promise<void>[] = submissions.map(async (submission: AddonModAssignSubmissionForList) => {
|
const promises: Promise<void>[] = submissions.map(async (submission: AddonModAssignSubmissionForList) => {
|
||||||
|
@ -195,17 +198,15 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
|
||||||
// Load offline grades.
|
// Load offline grades.
|
||||||
const notSynced = !!gradeData && submission.timemodified < gradeData.timemodified;
|
const notSynced = !!gradeData && submission.timemodified < gradeData.timemodified;
|
||||||
|
|
||||||
if (submission.gradingstatus == AddonModAssignGradingStates.GRADED && !assign.markingworkflow) {
|
if (!assign.markingworkflow) {
|
||||||
// Get the last grade of the submission.
|
// Get the last grade of the submission.
|
||||||
const grade = grades
|
const grade = grades.find((grade) => grade.userid == submission.userid);
|
||||||
.filter((grade) => grade.userid == submission.userid)
|
|
||||||
.reduce(
|
|
||||||
(a, b) => (a && a.timemodified > b.timemodified ? a : b),
|
|
||||||
<AddonModAssignGrade | undefined> undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (grade && grade.timemodified < submission.timemodified) {
|
if (grade) {
|
||||||
submission.gradingstatus = AddonModAssignGradingStates.GRADED_FOLLOWUP_SUBMIT;
|
// Override status if grade is found.
|
||||||
|
submission.gradingstatus = grade.timemodified < submission.timemodified
|
||||||
|
? AddonModAssignGradingStates.GRADED_FOLLOWUP_SUBMIT
|
||||||
|
: AddonModAssignGradingStates.GRADED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
submission.statusColor = AddonModAssign.getSubmissionStatusColor(submission.status);
|
submission.statusColor = AddonModAssign.getSubmissionStatusColor(submission.status);
|
||||||
|
@ -222,7 +223,7 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
|
||||||
submission.gradingColor = '';
|
submission.gradingColor = '';
|
||||||
} else if (submission.statusColor != CoreIonicColorNames.DANGER ||
|
} else if (submission.statusColor != CoreIonicColorNames.DANGER ||
|
||||||
submission.gradingColor != CoreIonicColorNames.DANGER) {
|
submission.gradingColor != CoreIonicColorNames.DANGER) {
|
||||||
// Show grading status if one of the statuses is not done.
|
// Show grading status if one of the statuses is not done.
|
||||||
submission.gradingStatusTranslationId = AddonModAssign.getSubmissionGradingStatusTranslationId(
|
submission.gradingStatusTranslationId = AddonModAssign.getSubmissionGradingStatusTranslationId(
|
||||||
submission.gradingstatus,
|
submission.gradingstatus,
|
||||||
);
|
);
|
||||||
|
|
|
@ -150,7 +150,7 @@ export class AddonModAssignHelperProvider {
|
||||||
attemptnumber: 0,
|
attemptnumber: 0,
|
||||||
timecreated: 0,
|
timecreated: 0,
|
||||||
timemodified: 0,
|
timemodified: 0,
|
||||||
status: '',
|
status: AddonModAssignSubmissionStatusValues.NEW,
|
||||||
groupid: 0,
|
groupid: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -404,13 +404,18 @@ export class AddonModAssignHelperProvider {
|
||||||
const blind = !!assign.blindmarking && !assign.revealidentities;
|
const blind = !!assign.blindmarking && !assign.revealidentities;
|
||||||
const teamsubmission = !!assign.teamsubmission;
|
const teamsubmission = !!assign.teamsubmission;
|
||||||
|
|
||||||
|
if (teamsubmission) {
|
||||||
|
// On team submission discard user submissions.
|
||||||
|
submissions = submissions.filter((submission) => submission.userid == 0);
|
||||||
|
}
|
||||||
|
|
||||||
return participants.map((participant) => {
|
return participants.map((participant) => {
|
||||||
const groupId = participant.groupid ??
|
const groupId = participant.groupid ??
|
||||||
(participant.groups && participant.groups[0] ? participant.groups[0].id : 0);
|
(participant.groups && participant.groups[0] ? participant.groups[0].id : 0);
|
||||||
|
|
||||||
const foundSubmission = submissions.find((submission) => {
|
const foundSubmission = submissions.find((submission) => {
|
||||||
if (teamsubmission) {
|
if (teamsubmission) {
|
||||||
return submission.userid == 0 && submission.groupid == groupId;
|
return submission.groupid == groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitId = submission.userid && submission.userid > 0 ? submission.userid : submission.blindid;
|
const submitId = submission.userid && submission.userid > 0 ? submission.userid : submission.blindid;
|
||||||
|
@ -423,6 +428,9 @@ export class AddonModAssignHelperProvider {
|
||||||
// Create submission if none.
|
// Create submission if none.
|
||||||
submission = this.createEmptySubmission();
|
submission = this.createEmptySubmission();
|
||||||
submission.groupid = groupId;
|
submission.groupid = groupId;
|
||||||
|
submission.status = participant.submitted
|
||||||
|
? AddonModAssignSubmissionStatusValues.SUBMITTED
|
||||||
|
: AddonModAssignSubmissionStatusValues.NEW;
|
||||||
} else {
|
} else {
|
||||||
submission = Object.assign({}, foundSubmission);
|
submission = Object.assign({}, foundSubmission);
|
||||||
}
|
}
|
||||||
|
@ -444,9 +452,6 @@ export class AddonModAssignHelperProvider {
|
||||||
submission.groupname = participant.groupname;
|
submission.groupname = participant.groupname;
|
||||||
}
|
}
|
||||||
|
|
||||||
submission.status = submission.status ?? (participant.submitted ? AddonModAssignSubmissionStatusValues.SUBMITTED :
|
|
||||||
AddonModAssignSubmissionStatusValues.NEW);
|
|
||||||
|
|
||||||
return submission;
|
return submission;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.core-loading-content {
|
.core-loading-content {
|
||||||
display: contents;
|
|
||||||
@include core-transition(opacity, 200ms);
|
@include core-transition(opacity, 200ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue