From ac677b5af748536f82e32a47be48dd01efc9bbbf Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Fri, 25 Apr 2025 11:22:20 +0200 Subject: [PATCH] MOBILE-4626 grades: Display grade penalties --- .../edit-feedback-modal.html | 26 +++++-- .../edit-feedback-modal.scss | 21 ++++++ .../edit-feedback-modal.ts | 4 ++ .../addon-mod-assign-submission.html | 24 ++++++- .../components/submission/submission.scss | 19 ++++++ .../components/submission/submission.ts | 4 ++ .../tests/behat/grade_penalties.feature | 68 +++++++++++++++++++ .../module-summary/module-summary.html | 34 +++++++--- .../module-summary/module-summary.scss | 20 ++++++ .../features/grades/pages/course/course.html | 30 ++++++-- .../features/grades/pages/course/course.scss | 22 +++++- .../features/grades/services/grades-helper.ts | 21 ++++++ .../tests/behat/grade_penalties.feature | 50 ++++++++++++++ 13 files changed, 317 insertions(+), 26 deletions(-) create mode 100644 src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.scss create mode 100644 src/addons/mod/assign/tests/behat/grade_penalties.feature create mode 100644 src/core/features/grades/tests/behat/grade_penalties.feature diff --git a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.html b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.html index 238495a69bb..c03fbd11754 100644 --- a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.html +++ b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.html @@ -59,13 +59,27 @@

{{'core.gradenoun' | translate}}

{{ 'addon.mod_assign.currentgrade' | translate }}

-

- {{ grade.gradebookGrade }} +

+ @if (grade.gradebookGrade) { + @if (grade.penalty) { +

-

- {{ grade.scale[grade.gradebookGrade].label }} -

-

-

+ @if (grade.penalty) { +

+ {{ grade.penalty }} +

+ }
diff --git a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.scss b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.scss new file mode 100644 index 00000000000..085a4e4c721 --- /dev/null +++ b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.scss @@ -0,0 +1,21 @@ +:host { + + .core-grading-summary-grade { + display: flex; + align-items: center; + gap: 0.25rem; + + ion-icon { + flex-shrink: 0; + } + + .penalty-indicator-icon { + display: none; + } + } + + .core-grading-summary-penalty { + color: var(--danger); + font-size: 0.75em; + } +} diff --git a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts index 1b02e19c3b5..c850a8f1564 100644 --- a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts +++ b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts @@ -53,6 +53,7 @@ import { CoreFormFields, CoreForms } from '@singletons/form'; @Component({ selector: 'addon-mod-assign-edit-feedback-modal', templateUrl: 'edit-feedback-modal.html', + styleUrl: 'edit-feedback-modal.scss', standalone: true, imports: [ CoreSharedModule, @@ -359,6 +360,8 @@ export class AddonModAssignEditFeedbackModalComponent implements OnDestroy, OnIn }); gradeInfo.disabled = grade.gradeislocked || grade.gradeisoverridden; } + + this.grade.penalty = CoreGradesHelper.getPenaltyFromGrade(grade.gradeformatted); }); gradeInfo.outcomes = outcomes; @@ -599,6 +602,7 @@ type AddonModAssignSubmissionGrade = { lang: string; disabled: boolean; unreleasedGrade?: SafeNumber | string; + penalty?: string; // Parsed from grade. }; type AddonModAssignGradeInfo = Omit & { diff --git a/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html b/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html index b07a3739751..a0d2d7d8b0b 100644 --- a/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html +++ b/src/addons/mod/assign/components/submission/addon-mod-assign-submission.html @@ -262,9 +262,19 @@

{{'addon.mod_assign.feedback' | translate}}

{{ 'core.gradenoun' | translate }}

-

- +

+ @if (feedback.penalty) { +

+ @if (feedback.penalty) { +

+ {{ feedback.penalty }} +

+ }
@if (feedback.advancedgrade) { {{'core.gradenoun' | translate}}

{{ 'core.gradenoun' | translate }}

-

+

+ @if (attempt.penalty) { +

+ @if (attempt.penalty) { +

+ {{ attempt.penalty }} +

+ }
@if (attempt.advancedgrade) { submissions" exist: + | assign | user | onlinetext | + | Test assignment name | student1 | I'm the student first submission | + And I am on the "Test assignment name" Activity page logged in as teacher1 + And I go to "Student 1" "Test assignment name" activity advanced grading page + And I set the following fields to these values: + | Grade out of 100 | 50 | + | Notify student | 0 | + | Allow another attempt | 1 | + And I press "Save changes" + And I log out + + Scenario: View submission with grade penalty as student + Given I entered the assign activity "Test assignment name" on course "Course 1" as "student1" in the app + When I press "Attempt 1" in the app + Then I should find "Late penalty applied -10.00 marks" within "Feedback" "ion-card" in the app + And I should find "Late penalty applied -10.00 marks" within "Attempt 1" "ion-accordion" in the app + + Scenario: View activity summary with grade penalty as student + Given I entered the assign activity "Test assignment name" on course "Course 1" as "student1" in the app + When I press "Information" "ion-button" in the app + And I press "Grade" "ion-item" in the app + Then I should find "Late penalty applied -10.00 marks" within "Gradebook" "ion-card" in the app + + Scenario: View submission with grade penalty as teacher + Given I entered the assign activity "Test assignment name" on course "Course 1" as "teacher1" in the app + When I press "Participants" in the app + And I press "Student 1" in the app + And I press "Attempt 1" in the app + Then I should find "Late penalty applied -10.00 marks" within "Feedback" "ion-card" in the app + And I should find "Late penalty applied -10.00 marks" within "Attempt 1" "ion-accordion" in the app + + Scenario: Edit feedback with grade penalty as teacher + Given I entered the assign activity "Test assignment name" on course "Course 1" as "teacher1" in the app + When I press "Participants" in the app + And I press "Student 1" in the app + And I press "Grade" "ion-button" in the app + Then I should find "Late penalty applied -10.00 marks" in the app diff --git a/src/core/features/course/components/module-summary/module-summary.html b/src/core/features/course/components/module-summary/module-summary.html index 760668e4fcb..3adbb2b7c08 100644 --- a/src/core/features/course/components/module-summary/module-summary.html +++ b/src/core/features/course/components/module-summary/module-summary.html @@ -69,22 +69,34 @@