Merge pull request #4010 from NoelDeMartin/MOBILE-4553

MOBILE-4553 quiz: Show grade item marks
main
Dani Palou 2024-04-17 08:24:48 +02:00 committed by GitHub
commit 4fd8be5ffb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 51 additions and 6 deletions

View File

@ -30,6 +30,14 @@
<p *ngFor="let sentence of attempt.readableState">{{ sentence }}</p>
</ion-label>
</ion-item>
<ng-container *ngIf="attempt.finished">
<ion-item *ngFor="let gradeItemMark of attempt.gradeitemmarks ?? []" class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ gradeItemMark.name }} / {{ gradeItemMark.maxgrade }}</p>
<p>{{ gradeItemMark.grade }}</p>
</ion-label>
</ion-item>
</ng-container>
<ion-item class="ion-text-wrap" *ngIf="quiz!.showMarkColumn && attempt.readableMark !== ''">
<ion-label>
<p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }} / {{ quiz!.sumGradesFormatted }}</p>

View File

@ -54,6 +54,12 @@
<p>{{ overTime }}</p>
</ion-label>
</ion-item>
<ion-item *ngFor="let gradeItemMark of gradeItemMarks" class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ gradeItemMark.name }}</p>
<p>{{ gradeItemMark.grade }}</p>
</ion-label>
</ion-item>
<ion-item class="ion-text-wrap" *ngIf="readableMark">
<ion-label>
<p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }}</p>

View File

@ -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)) {

View File

@ -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.
}[];
};
/**

View File

@ -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,11 +130,13 @@ 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
And the following events should have been logged for "student1" in the app:
@ -144,6 +150,16 @@ Feature: Attempt a quiz in app
| \mod_quiz\event\attempt_reviewed | quiz | Quiz 1 | Course 1 | |
| \mod_quiz\event\attempt_summary_viewed | quiz | Quiz 1 | Course 1 | |
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