MOBILE-3787 assign: Apply grading status when grades are found

main
Pau Ferrer Ocaña 2022-01-13 12:23:03 +01:00
parent c5ef18183b
commit 4fc3c8b0d0
3 changed files with 22 additions and 17 deletions

View File

@ -164,11 +164,14 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
this.submissionsData.submissions,
this.groupId,
);
// 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 })
: [];
// 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.
if (this.SELECTED_STATUS == AddonModAssignListFilterName.NEED_GRADING) {
const promises: Promise<void>[] = submissions.map(async (submission: AddonModAssignSubmissionForList) => {
@ -195,17 +198,15 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
// Load offline grades.
const notSynced = !!gradeData && submission.timemodified < gradeData.timemodified;
if (submission.gradingstatus == AddonModAssignGradingStates.GRADED && !assign.markingworkflow) {
if (!assign.markingworkflow) {
// Get the last grade of the submission.
const grade = grades
.filter((grade) => grade.userid == submission.userid)
.reduce(
(a, b) => (a && a.timemodified > b.timemodified ? a : b),
<AddonModAssignGrade | undefined> undefined,
);
const grade = grades.find((grade) => grade.userid == submission.userid);
if (grade && grade.timemodified < submission.timemodified) {
submission.gradingstatus = AddonModAssignGradingStates.GRADED_FOLLOWUP_SUBMIT;
if (grade) {
// Override status if grade is found.
submission.gradingstatus = grade.timemodified < submission.timemodified
? AddonModAssignGradingStates.GRADED_FOLLOWUP_SUBMIT
: AddonModAssignGradingStates.GRADED;
}
}
submission.statusColor = AddonModAssign.getSubmissionStatusColor(submission.status);
@ -222,7 +223,7 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
submission.gradingColor = '';
} else if (submission.statusColor != 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.gradingstatus,
);

View File

@ -150,7 +150,7 @@ export class AddonModAssignHelperProvider {
attemptnumber: 0,
timecreated: 0,
timemodified: 0,
status: '',
status: AddonModAssignSubmissionStatusValues.NEW,
groupid: 0,
};
}
@ -404,13 +404,18 @@ export class AddonModAssignHelperProvider {
const blind = !!assign.blindmarking && !assign.revealidentities;
const teamsubmission = !!assign.teamsubmission;
if (teamsubmission) {
// On team submission discard user submissions.
submissions = submissions.filter((submission) => submission.userid == 0);
}
return participants.map((participant) => {
const groupId = participant.groupid ??
(participant.groups && participant.groups[0] ? participant.groups[0].id : 0);
const foundSubmission = submissions.find((submission) => {
if (teamsubmission) {
return submission.userid == 0 && submission.groupid == groupId;
return submission.groupid == groupId;
}
const submitId = submission.userid && submission.userid > 0 ? submission.userid : submission.blindid;
@ -423,6 +428,9 @@ export class AddonModAssignHelperProvider {
// Create submission if none.
submission = this.createEmptySubmission();
submission.groupid = groupId;
submission.status = participant.submitted
? AddonModAssignSubmissionStatusValues.SUBMITTED
: AddonModAssignSubmissionStatusValues.NEW;
} else {
submission = Object.assign({}, foundSubmission);
}
@ -444,9 +452,6 @@ export class AddonModAssignHelperProvider {
submission.groupname = participant.groupname;
}
submission.status = submission.status ?? (participant.submitted ? AddonModAssignSubmissionStatusValues.SUBMITTED :
AddonModAssignSubmissionStatusValues.NEW);
return submission;
});

View File

@ -44,7 +44,6 @@
}
.core-loading-content {
display: contents;
@include core-transition(opacity, 200ms);
}