forked from CIT/Vmeda.Online
		
	Merge pull request #1782 from crazyserver/MOBILE-2876
MOBILE-2876 workshop: Fix check more dimensions than given
This commit is contained in:
		
						commit
						d129c23d54
					
				| @ -120,21 +120,23 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad | |||||||
|         let hasErrors = false; |         let hasErrors = false; | ||||||
| 
 | 
 | ||||||
|         form.fields.forEach((field, idx) => { |         form.fields.forEach((field, idx) => { | ||||||
|             const grade = parseInt(currentValues[idx].grade, 10); |             if (idx < form.dimenssionscount) { | ||||||
|             if (!isNaN(grade) && grade >= 0) { |                 const grade = parseInt(currentValues[idx].grade, 10); | ||||||
|                 data['grade__idx_' + idx] = grade; |                 if (!isNaN(grade) && grade >= 0) { | ||||||
|             } else { |                     data['grade__idx_' + idx] = grade; | ||||||
|                 errors['grade_' + idx] = this.translate.instant('addon.mod_workshop_assessment_accumulative.mustchoosegrade'); |                 } else { | ||||||
|                 hasErrors = true; |                     errors['grade_' + idx] = this.translate.instant('addon.mod_workshop_assessment_accumulative.mustchoosegrade'); | ||||||
|             } |                     hasErrors = true; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|             if (currentValues[idx].peercomment) { |                 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['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; | ||||||
|             data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); |                 data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); | ||||||
|             data['weight__idx_' + idx] = parseInt(field.weight, 10) ||  0; |                 data['weight__idx_' + idx] = parseInt(field.weight, 10) ||  0; | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         if (hasErrors) { |         if (hasErrors) { | ||||||
|  | |||||||
| @ -102,15 +102,17 @@ export class AddonModWorkshopAssessmentStrategyCommentsHandler implements AddonW | |||||||
|         let hasErrors = false; |         let hasErrors = false; | ||||||
| 
 | 
 | ||||||
|         form.fields.forEach((field, idx) => { |         form.fields.forEach((field, idx) => { | ||||||
|             if (currentValues[idx].peercomment) { |             if (idx < form.dimenssionscount) { | ||||||
|                 data['peercomment__idx_' + idx] = currentValues[idx].peercomment; |                 if (currentValues[idx].peercomment) { | ||||||
|             } else { |                     data['peercomment__idx_' + idx] = currentValues[idx].peercomment; | ||||||
|                 errors['peercomment_' + idx] = this.translate.instant('core.err_required'); |                 } else { | ||||||
|                 hasErrors = true; |                     errors['peercomment_' + idx] = this.translate.instant('core.err_required'); | ||||||
|             } |                     hasErrors = true; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|             data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; |                 data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; | ||||||
|             data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); |                 data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         if (hasErrors) { |         if (hasErrors) { | ||||||
|  | |||||||
| @ -106,21 +106,23 @@ export class AddonModWorkshopAssessmentStrategyNumErrorsHandler implements Addon | |||||||
|         let hasErrors = false; |         let hasErrors = false; | ||||||
| 
 | 
 | ||||||
|         form.fields.forEach((field, idx) => { |         form.fields.forEach((field, idx) => { | ||||||
|             const grade = parseInt(currentValues[idx].grade); |             if (idx < form.dimenssionscount) { | ||||||
|             if (!isNaN(grade) && grade >= 0) { |                 const grade = parseInt(currentValues[idx].grade); | ||||||
|                 data['grade__idx_' + idx] = grade; |                 if (!isNaN(grade) && (grade == 1 || grade == -1)) { | ||||||
|             } else { |                     data['grade__idx_' + idx] = grade; | ||||||
|                 errors['grade_' + idx] = this.translate.instant('core.required'); |                 } else { | ||||||
|                 hasErrors = true; |                     errors['grade_' + idx] = this.translate.instant('core.required'); | ||||||
|             } |                     hasErrors = true; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|             if (currentValues[idx].peercomment) { |                 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['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; | ||||||
|             data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); |                 data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); | ||||||
|             data['weight__idx_' + idx] = parseInt(field.weight, 10) ||  0; |                 data['weight__idx_' + idx] = parseInt(field.weight, 10) ||  0; | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         if (hasErrors) { |         if (hasErrors) { | ||||||
|  | |||||||
| @ -102,16 +102,18 @@ export class AddonModWorkshopAssessmentStrategyRubricHandler implements AddonWor | |||||||
|         let hasErrors = false; |         let hasErrors = false; | ||||||
| 
 | 
 | ||||||
|         form.fields.forEach((field, idx) => { |         form.fields.forEach((field, idx) => { | ||||||
|             const id = parseInt(currentValues[idx].chosenlevelid, 10); |             if (idx < form.dimenssionscount) { | ||||||
|             if (!isNaN(id) && id >= 0) { |                 const id = parseInt(currentValues[idx].chosenlevelid, 10); | ||||||
|                 data['chosenlevelid__idx_' + idx] = id; |                 if (!isNaN(id) && id >= 0) { | ||||||
|             } else { |                     data['chosenlevelid__idx_' + idx] = id; | ||||||
|                 errors['chosenlevelid_' + idx] = this.translate.instant('addon.mod_workshop_assessment_rubric.mustchooseone'); |                 } else { | ||||||
|                 hasErrors = true; |                     errors['chosenlevelid_' + idx] = this.translate.instant('addon.mod_workshop_assessment_rubric.mustchooseone'); | ||||||
|             } |                     hasErrors = true; | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|             data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; |                 data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0; | ||||||
|             data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); |                 data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10); | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         if (hasErrors) { |         if (hasErrors) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user