Merge pull request #4010 from NoelDeMartin/MOBILE-4553
MOBILE-4553 quiz: Show grade item marks
This commit is contained in:
		
						commit
						4fd8be5ffb
					
				| @ -30,6 +30,14 @@ | |||||||
|                     <p *ngFor="let sentence of attempt.readableState">{{ sentence }}</p> |                     <p *ngFor="let sentence of attempt.readableState">{{ sentence }}</p> | ||||||
|                 </ion-label> |                 </ion-label> | ||||||
|             </ion-item> |             </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-item class="ion-text-wrap" *ngIf="quiz!.showMarkColumn && attempt.readableMark !== ''"> | ||||||
|                 <ion-label> |                 <ion-label> | ||||||
|                     <p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }} / {{ quiz!.sumGradesFormatted }}</p> |                     <p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }} / {{ quiz!.sumGradesFormatted }}</p> | ||||||
|  | |||||||
| @ -54,6 +54,12 @@ | |||||||
|                         <p>{{ overTime }}</p> |                         <p>{{ overTime }}</p> | ||||||
|                     </ion-label> |                     </ion-label> | ||||||
|                 </ion-item> |                 </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-item class="ion-text-wrap" *ngIf="readableMark"> | ||||||
|                     <ion-label> |                     <ion-label> | ||||||
|                         <p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }}</p> |                         <p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }}</p> | ||||||
|  | |||||||
| @ -66,6 +66,7 @@ export class AddonModQuizReviewPage implements OnInit { | |||||||
|     readableGrade?: string; |     readableGrade?: string; | ||||||
|     readableMark?: string; |     readableMark?: string; | ||||||
|     timeTaken?: string; |     timeTaken?: string; | ||||||
|  |     gradeItemMarks: { name: string; grade: string }[] = []; | ||||||
|     overTime?: string; |     overTime?: string; | ||||||
|     quiz?: AddonModQuizQuizWSData; // The quiz the attempt belongs to.
 |     quiz?: AddonModQuizQuizWSData; // The quiz the attempt belongs to.
 | ||||||
|     courseId!: number; // The course ID the quiz belongs to.
 |     courseId!: number; // The course ID the quiz belongs to.
 | ||||||
| @ -284,6 +285,15 @@ export class AddonModQuizReviewPage implements OnInit { | |||||||
|             this.timeTaken = undefined; |             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.
 |         // Treat grade.
 | ||||||
|         if (this.options && this.options.someoptions.marks >= AddonModQuizProvider.QUESTION_OPTIONS_MARK_AND_MAX && |         if (this.options && this.options.someoptions.marks >= AddonModQuizProvider.QUESTION_OPTIONS_MARK_AND_MAX && | ||||||
|                 AddonModQuiz.quizHasGrades(this.quiz)) { |                 AddonModQuiz.quizHasGrades(this.quiz)) { | ||||||
|  | |||||||
| @ -2048,6 +2048,11 @@ export type AddonModQuizAttemptWSData = { | |||||||
|     timemodifiedoffline?: number; // Last modified time via webservices.
 |     timemodifiedoffline?: number; // Last modified time via webservices.
 | ||||||
|     timecheckstate?: number; // Next time quiz cron should check attempt for state changes. NULL means never check.
 |     timecheckstate?: number; // Next time quiz cron should check attempt for state changes. NULL means never check.
 | ||||||
|     sumgrades?: SafeNumber | null; // Total marks for this attempt.
 |     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.
 | ||||||
|  |     }[]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | |||||||
| @ -27,10 +27,14 @@ Feature: Attempt a quiz in app | |||||||
|       | questioncategory | qtype       | name  | questiontext                | |       | questioncategory | qtype       | name  | questiontext                | | ||||||
|       | Test questions   | truefalse   | TF1   | Text of the first question  | |       | Test questions   | truefalse   | TF1   | Text of the first question  | | ||||||
|       | Test questions   | truefalse   | TF2   | Text of the second 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: |     And quiz "Quiz 1" contains the following questions: | ||||||
|       | question | page | |       | question | page | grade item | | ||||||
|       | TF1      | 1    | |       | TF1      | 1    | Logic      | | ||||||
|       | TF2      | 2    | |       | TF2      | 2    | Cognition  | | ||||||
|     And the following "activities" exist: |     And the following "activities" exist: | ||||||
|       | activity   | name   | intro              | course | idnumber | |       | activity   | name   | intro              | course | idnumber | | ||||||
|       | quiz       | Quiz 2 | Quiz 2 description | C1     | quiz2    | |       | 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 |     And I press "Submit" near "Once you submit" in the app | ||||||
|     Then I should find "Review" in the app |     Then I should find "Review" in the app | ||||||
|     And I should find "Started on" 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 "Completed on" in the app | ||||||
|     And I should find "Time taken" in the app |     And I should find "Time taken" in the app | ||||||
|     And I should find "Marks" in the app |     And I should find "Finished" within "State" "ion-item" in the app | ||||||
|     And I should find "Grade" 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 1" in the app | ||||||
|     And I should find "Question 2" 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: |     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_reviewed       | quiz     | Quiz 1       | Course 1 |              | | ||||||
|       | \mod_quiz\event\attempt_summary_viewed | 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) |   Scenario: Attempt a quiz (all question types) | ||||||
|     Given I entered the quiz activity "Quiz 2" on course "Course 1" as "student1" in the app |     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 |     When I press "Attempt quiz now" in the app | ||||||
|  | |||||||
| Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 36 KiB | 
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 36 KiB | 
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user