diff --git a/src/addons/mod/quiz/pages/attempt/attempt.html b/src/addons/mod/quiz/pages/attempt/attempt.html index 792851aea..819d51bb2 100644 --- a/src/addons/mod/quiz/pages/attempt/attempt.html +++ b/src/addons/mod/quiz/pages/attempt/attempt.html @@ -30,6 +30,14 @@

{{ sentence }}

+ + + +

{{ gradeItemMark.name }} / {{ gradeItemMark.maxgrade }}

+

{{ gradeItemMark.grade }}

+
+
+

{{ 'addon.mod_quiz.marks' | translate }} / {{ quiz!.sumGradesFormatted }}

diff --git a/src/addons/mod/quiz/pages/review/review.html b/src/addons/mod/quiz/pages/review/review.html index fa287af18..7a8ffb9ce 100644 --- a/src/addons/mod/quiz/pages/review/review.html +++ b/src/addons/mod/quiz/pages/review/review.html @@ -54,6 +54,12 @@

{{ overTime }}

+ + +

{{ gradeItemMark.name }}

+

{{ gradeItemMark.grade }}

+
+

{{ 'addon.mod_quiz.marks' | translate }}

diff --git a/src/addons/mod/quiz/pages/review/review.ts b/src/addons/mod/quiz/pages/review/review.ts index 2532af09a..90dddd231 100644 --- a/src/addons/mod/quiz/pages/review/review.ts +++ b/src/addons/mod/quiz/pages/review/review.ts @@ -66,6 +66,7 @@ export class AddonModQuizReviewPage implements OnInit { readableGrade?: string; readableMark?: string; timeTaken?: string; + gradeItemMarks: { name: string; grade: string }[] = []; overTime?: string; quiz?: AddonModQuizQuizWSData; // The quiz the attempt belongs to. courseId!: number; // The course ID the quiz belongs to. @@ -284,6 +285,15 @@ export class AddonModQuizReviewPage implements OnInit { this.timeTaken = undefined; } + // Treat grade item marks. + this.gradeItemMarks = this.attempt.gradeitemmarks?.map((gradeItemMark) => ({ + name: gradeItemMark.name, + grade: Translate.instant('addon.mod_quiz.outof', { $a: { + grade: AddonModQuiz.formatGrade(gradeItemMark.grade, this.quiz?.decimalpoints), + maxgrade: AddonModQuiz.formatGrade(gradeItemMark.maxgrade, this.quiz?.decimalpoints), + } }), + })) ?? []; + // Treat grade. if (this.options && this.options.someoptions.marks >= AddonModQuizProvider.QUESTION_OPTIONS_MARK_AND_MAX && AddonModQuiz.quizHasGrades(this.quiz)) { diff --git a/src/addons/mod/quiz/services/quiz.ts b/src/addons/mod/quiz/services/quiz.ts index b50123dbd..d8edc9157 100644 --- a/src/addons/mod/quiz/services/quiz.ts +++ b/src/addons/mod/quiz/services/quiz.ts @@ -2048,6 +2048,11 @@ export type AddonModQuizAttemptWSData = { timemodifiedoffline?: number; // Last modified time via webservices. timecheckstate?: number; // Next time quiz cron should check attempt for state changes. NULL means never check. sumgrades?: SafeNumber | null; // Total marks for this attempt. + gradeitemmarks?: { // @since 4.4. If the quiz has additional grades set up, the mark for each grade for this attempt. + name: string; // The name of this grade item. + grade: number; // The grade this attempt earned for this item. + maxgrade: number; // The total this grade is out of. + }[]; }; /** diff --git a/src/addons/mod/quiz/tests/behat/basic_usage.feature b/src/addons/mod/quiz/tests/behat/basic_usage.feature index 8cf359115..c30cf8298 100755 --- a/src/addons/mod/quiz/tests/behat/basic_usage.feature +++ b/src/addons/mod/quiz/tests/behat/basic_usage.feature @@ -27,10 +27,14 @@ Feature: Attempt a quiz in app | questioncategory | qtype | name | questiontext | | Test questions | truefalse | TF1 | Text of the first question | | Test questions | truefalse | TF2 | Text of the second question | + Given the following "mod_quiz > grade items" exist: + | quiz | name | + | Quiz 1 | Logic | + | Quiz 1 | Cognition | And quiz "Quiz 1" contains the following questions: - | question | page | - | TF1 | 1 | - | TF2 | 2 | + | question | page | grade item | + | TF1 | 1 | Logic | + | TF2 | 2 | Cognition | And the following "activities" exist: | activity | name | intro | course | idnumber | | quiz | Quiz 2 | Quiz 2 description | C1 | quiz2 | @@ -126,14 +130,26 @@ Feature: Attempt a quiz in app And I press "Submit" near "Once you submit" in the app Then I should find "Review" in the app And I should find "Started on" in the app - And I should find "State" in the app And I should find "Completed on" in the app And I should find "Time taken" in the app - And I should find "Marks" in the app - And I should find "Grade" in the app + And I should find "Finished" within "State" "ion-item" in the app + And I should find "0 out of 1" within "Logic" "ion-item" in the app + And I should find "0 out of 1" within "Cognition" "ion-item" in the app + And I should find "0/2" within "Marks" "ion-item" in the app + And I should find "0 out of 100" within "Grade" "ion-item" in the app And I should find "Question 1" in the app And I should find "Question 2" in the app + When I press the back button in the app + And I press "Finished" in the app + Then I should find "1" within "Attempt" "ion-item" in the app + And I should find "Finished" within "State" "ion-item" in the app + And I should find "0" within "Logic / 1" "ion-item" in the app + And I should find "0" within "Cognition / 1" "ion-item" in the app + And I should find "0" within "Marks / 2" "ion-item" in the app + And I should find "0" within "Grade / 100" "ion-item" in the app + And I should find "Review" in the app + Scenario: Attempt a quiz (all question types) Given I entered the quiz activity "Quiz 2" on course "Course 1" as "student1" in the app When I press "Attempt quiz now" in the app diff --git a/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_26.png b/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_27.png similarity index 100% rename from src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_26.png rename to src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_27.png diff --git a/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_38.png b/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_38.png deleted file mode 100644 index 658b31fec..000000000 Binary files a/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_38.png and /dev/null differ diff --git a/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_39.png b/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_39.png new file mode 100644 index 000000000..895e1dbef Binary files /dev/null and b/src/addons/mod/quiz/tests/behat/snapshots/attempt-a-quiz-in-app-submit-a-quiz--review-a-quiz-attempt_39.png differ