diff --git a/src/addons/mod/assign/classes/submissions-source.ts b/src/addons/mod/assign/classes/submissions-source.ts index 9fd25f21d..8a5ef3441 100644 --- a/src/addons/mod/assign/classes/submissions-source.ts +++ b/src/addons/mod/assign/classes/submissions-source.ts @@ -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[] = 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), - 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, ); diff --git a/src/addons/mod/assign/services/assign-helper.ts b/src/addons/mod/assign/services/assign-helper.ts index 25653194c..cb062c240 100644 --- a/src/addons/mod/assign/services/assign-helper.ts +++ b/src/addons/mod/assign/services/assign-helper.ts @@ -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; }); diff --git a/src/core/components/loading/loading.scss b/src/core/components/loading/loading.scss index 3861b04e2..ef26afe30 100644 --- a/src/core/components/loading/loading.scss +++ b/src/core/components/loading/loading.scss @@ -44,7 +44,6 @@ } .core-loading-content { - display: contents; @include core-transition(opacity, 200ms); }