Merge pull request #3752 from NoelDeMartin/MOBILE-4272
MOBILE-4272: Workshop tests
This commit is contained in:
		
						commit
						81d1da39ca
					
				| @ -111,7 +111,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS | ||||
|      * | ||||
|      * @param text The new text. | ||||
|      */ | ||||
|     onChange(text: string): void { | ||||
|     onChange(text?: string | null): void { | ||||
|         // Count words if needed.
 | ||||
|         if (this.wordLimitEnabled) { | ||||
|             // Cancel previous wait.
 | ||||
|  | ||||
| @ -332,8 +332,8 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges | ||||
|      * | ||||
|      * @param text The new text. | ||||
|      */ | ||||
|     onMessageChange(text: string): void { | ||||
|         this.formData.message = text; | ||||
|     onMessageChange(text?: string | null): void { | ||||
|         this.formData.message = text ?? null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -511,8 +511,8 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | ||||
|      * | ||||
|      * @param text The new text. | ||||
|      */ | ||||
|     onMessageChange(text: string): void { | ||||
|         this.newDiscussion.message = text; | ||||
|     onMessageChange(text?: string | null): void { | ||||
|         this.newDiscussion.message = text ?? null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -173,8 +173,8 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { | ||||
|      * | ||||
|      * @param text The new text. | ||||
|      */ | ||||
|     onDefinitionChange(text: string): void { | ||||
|         this.data.definition = text; | ||||
|     onDefinitionChange(text?: string | null): void { | ||||
|         this.data.definition = text ?? ''; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -129,9 +129,7 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandlerService implem | ||||
|                     hasErrors = true; | ||||
|                 } | ||||
| 
 | ||||
|                 if (currentValues[idx].peercomment) { | ||||
|                     data['peercomment__idx_' + idx] = currentValues[idx].peercomment; | ||||
|                 } | ||||
|                 data['peercomment__idx_' + idx] = currentValues[idx].peercomment ?? ''; | ||||
| 
 | ||||
|                 data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; | ||||
|                 data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); | ||||
|  | ||||
| @ -112,9 +112,7 @@ export class AddonModWorkshopAssessmentStrategyNumErrorsHandlerService implement | ||||
|                     hasErrors = true; | ||||
|                 } | ||||
| 
 | ||||
|                 if (currentValues[idx].peercomment) { | ||||
|                     data['peercomment__idx_' + idx] = currentValues[idx].peercomment; | ||||
|                 } | ||||
|                 data['peercomment__idx_' + idx] = currentValues[idx].peercomment ?? ''; | ||||
| 
 | ||||
|                 data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; | ||||
|                 data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); | ||||
|  | ||||
| @ -403,8 +403,8 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe | ||||
|      * | ||||
|      * @param text The new text. | ||||
|      */ | ||||
|     onFeedbackChange(text: string): void { | ||||
|         this.feedbackText = text; | ||||
|     onFeedbackChange(text?: string | null): void { | ||||
|         this.feedbackText = text ?? ''; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -23,12 +23,16 @@ | ||||
|             phases[workshop!.phase].tasks.length"> | ||||
|             <ion-item button class="ion-text-wrap" *ngFor="let task of phases[workshop!.phase].tasks" | ||||
|                 [class.item-dimmed]="task.code == 'submit' && !showSubmit" (click)="runTask(task)" detail="false"> | ||||
|                 <ion-icon slot="start" name="far-circle" *ngIf="task.completed == null" aria-hidden="true"></ion-icon> | ||||
|                 <ion-icon slot="start" name="fas-circle-xmark" color="danger" *ngIf="task.completed == ''" aria-hidden="true"> | ||||
|                 <ion-icon slot="start" name="far-circle" *ngIf="task.completed == null" | ||||
|                     [attr.aria-label]="'addon.mod_workshop.tasktodo' | translate"></ion-icon> | ||||
|                 <ion-icon slot="start" name="fas-circle-xmark" color="danger" *ngIf="task.completed == ''" | ||||
|                     [attr.aria-label]="'addon.mod_workshop.taskfail' | translate"> | ||||
|                 </ion-icon> | ||||
|                 <ion-icon slot="start" name="fas-circle-info" color="info" *ngIf="task.completed == 'info'" aria-hidden="true"> | ||||
|                 <ion-icon slot="start" name="fas-circle-info" color="info" *ngIf="task.completed == 'info'" | ||||
|                     [attr.aria-label]="'addon.mod_workshop.taskinfo' | translate"> | ||||
|                 </ion-icon> | ||||
|                 <ion-icon slot="start" name="fas-circle-check" color="success" *ngIf="task.completed == '1'" aria-hidden="true"> | ||||
|                 <ion-icon slot="start" name="fas-circle-check" color="success" *ngIf="task.completed == '1'" | ||||
|                     [attr.aria-label]="'addon.mod_workshop.taskdone' | translate"> | ||||
|                 </ion-icon> | ||||
|                 <ion-label> | ||||
|                     <p class="item-heading">{{task.title}}</p> | ||||
|  | ||||
| @ -19,7 +19,7 @@ import { FileEntry } from '@ionic-native/file/ngx'; | ||||
| import { CoreFile } from '@services/file'; | ||||
| import { CoreFileEntry } from '@services/file-helper'; | ||||
| import { CoreSites } from '@services/sites'; | ||||
| import { CoreTextUtils } from '@services/utils/text'; | ||||
| import { CoreTextUtils, CoreTextFormat } from '@services/utils/text'; | ||||
| import { CoreUtils } from '@services/utils/utils'; | ||||
| import { makeSingleton, Translate } from '@singletons'; | ||||
| import { CoreFormFields } from '@singletons/form'; | ||||
| @ -531,6 +531,7 @@ export class AddonModWorkshopHelperProvider { | ||||
|             (await AddonWorkshopAssessmentStrategyDelegate.prepareAssessmentData(workshop.strategy ?? '', selectedValues, form)) || | ||||
|             {}; | ||||
|         data.feedbackauthor = feedbackText; | ||||
|         data.feedbackauthorformat = CoreTextFormat.FORMAT_HTML; | ||||
|         data.feedbackauthorattachmentsid = attachmentsId; | ||||
|         data.nodims = form.dimenssionscount; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										115
									
								
								src/addons/mod/workshop/tests/behat/basic_usage.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								src/addons/mod/workshop/tests/behat/basic_usage.feature
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| @mod @mod_workshop @app @javascript | ||||
| Feature: Test basic usage of workshop activity in app | ||||
| 
 | ||||
|   Background: | ||||
|     Given the following "courses" exist: | ||||
|       | fullname | shortname | | ||||
|       | Course 1 | C1        | | ||||
|     And the following "users" exist: | ||||
|       | username | firstname | lastname | | ||||
|       | student1 | First     | Student  | | ||||
|       | student2 | Second    | Student  | | ||||
|       | teacher1 | First     | Teacher  | | ||||
|     And the following "course enrolments" exist: | ||||
|       | user     | course | role    | | ||||
|       | student1 | C1     | student | | ||||
|       | student2 | C1     | student | | ||||
|       | teacher1 | C1     | editingteacher | | ||||
|     And the following "activities" exist: | ||||
|       | activity   | name          | intro                 | course | idnumber | | ||||
|       | workshop   | Test workshop | Workshop description  | C1     | workshop | | ||||
| 
 | ||||
|   Scenario: Take a workshop | ||||
| 
 | ||||
|     # Setup phase | ||||
|     Given I entered the workshop activity "workshop" on course "Course 1" as "teacher1" in the app | ||||
|     Then I should find "Setup phase" in the app | ||||
|     And I should find "Task done" within "Provide instructions for submission" "ion-item" in the app | ||||
|     And I should find "Task done" within "Set the workshop description" "ion-item" in the app | ||||
|     And I should find "Task to do" within "Edit assessment form" "ion-item" in the app | ||||
|     And I should find "Task to do" within "Switch to the next phase" "ion-item" in the app | ||||
| 
 | ||||
|     When I press "Edit assessment form" in the app | ||||
|     And I press "OK" in the app | ||||
|     And I switch to the browser tab opened by the app | ||||
|     And I log in as "teacher1" | ||||
|     And I set the field "id_description__idx_0_editor" to "Was the submission good?" | ||||
|     And I press "Save and close" | ||||
|     And I change phase in workshop "Test workshop" to "Submission phase" | ||||
|     And I close the browser tab opened by the app | ||||
|     And I pull to refresh in the app | ||||
|     Then I should find "Submission phase" in the app | ||||
|     And I should find "Task done" within "Provide instructions for assessment" "ion-item" in the app | ||||
|     And I should find "Task to do" within "Allocate submissions" "ion-item" in the app | ||||
|     And I should find "expected: 2" within "Allocate submissions" "ion-item" in the app | ||||
|     And I should find "submitted: 0" within "Allocate submissions" "ion-item" in the app | ||||
|     And I should find "to allocate: 0" within "Allocate submissions" "ion-item" in the app | ||||
| 
 | ||||
|     # Submission phase | ||||
|     Given I entered the workshop activity "workshop" on course "Course 1" as "student1" in the app | ||||
|     Then I should find "Task to do" within "Submit your work" "ion-item" in the app | ||||
| 
 | ||||
|     When I press "Edit submission" in the app | ||||
|     And I set the field "Title" to "The Answer" in the app | ||||
|     And I set the field "Submission content" to "42" in the app | ||||
|     And I press "Save" in the app | ||||
|     Then I should find "Task done" within "Submit your work" "ion-item" in the app | ||||
|     And I should find "The Answer" in the app | ||||
|     And I should find "42" in the app | ||||
| 
 | ||||
|     Given I entered the workshop activity "workshop" on course "Course 1" as "teacher1" in the app | ||||
|     When I pull to refresh in the app | ||||
|     Then I should find "Submission phase" in the app | ||||
|     And I should find "Task done" within "Provide instructions for assessment" "ion-item" in the app | ||||
|     And I should find "Task to do" within "Allocate submissions" "ion-item" in the app | ||||
|     And I should find "expected: 2" within "Allocate submissions" "ion-item" in the app | ||||
|     And I should find "submitted: 1" within "Allocate submissions" "ion-item" in the app | ||||
|     And I should find "to allocate: 1" within "Allocate submissions" "ion-item" in the app | ||||
| 
 | ||||
|     When I press "Allocate submissions" in the app | ||||
|     And I press "OK" in the app | ||||
|     And I switch to the browser tab opened by the app | ||||
|     And I allocate submissions in workshop "Test workshop" as: | ||||
|       | Participant   | Reviewer       | | ||||
|       | First Student | Second Student | | ||||
|     And I change phase in workshop "Test workshop" to "Assessment phase" | ||||
|     And I close the browser tab opened by the app | ||||
|     And I pull to refresh in the app | ||||
|     Then I should find "Assessment phase" in the app | ||||
| 
 | ||||
|     # Assessment phase | ||||
|     Given I entered the workshop activity "workshop" on course "Course 1" as "student2" in the app | ||||
|     Then I should find "Task to do" within "Assess peers" "ion-item" in the app | ||||
| 
 | ||||
|     When I press "The Answer" in the app | ||||
|     And I press "Grade for Aspect 01" in the app | ||||
|     And I press "10 / 10" in the app | ||||
|     And I press "Save" in the app | ||||
|     Then I should find "Assessed submission" in the app | ||||
| 
 | ||||
|     # Grading evaluation phase | ||||
|     Given I entered the workshop activity "workshop" on course "Course 1" as "teacher1" in the app | ||||
|     And I press "Switch to the next phase" in the app | ||||
|     And I press "OK" in the app | ||||
|     And I switch to the browser tab opened by the app | ||||
|     And I press "Continue" | ||||
|     Then I should see "Grading evaluation phase" | ||||
| 
 | ||||
|     When I press "Re-calculate grades" | ||||
|     Then I should see "calculated: 1" | ||||
| 
 | ||||
|     When I close the browser tab opened by the app | ||||
|     And I pull to refresh in the app | ||||
|     Then I should find "Grading evaluation phase" in the app | ||||
| 
 | ||||
|     # Closed | ||||
|     When I press "Switch to the next phase" in the app | ||||
|     And I press "OK" in the app | ||||
|     And I switch to the browser tab opened by the app | ||||
|     And I press "Continue" | ||||
|     Then I should see "Closed" | ||||
| 
 | ||||
|     When I close the browser tab opened by the app | ||||
|     And I pull to refresh in the app | ||||
|     Then I should find "Closed" in the app | ||||
|     And I should find "Conclusion 1" in the app | ||||
| @ -332,7 +332,7 @@ export class CoreTextUtilsProvider { | ||||
|      * @param text Text to count. | ||||
|      * @returns Number of words. | ||||
|      */ | ||||
|     countWords(text: string): number { | ||||
|     countWords(text?: string | null): number { | ||||
|         if (!text || typeof text != 'string') { | ||||
|             return 0; | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user