Merge pull request #1782 from crazyserver/MOBILE-2876

MOBILE-2876 workshop: Fix check more dimensions than given
main
Juan Leyva 2019-02-26 10:45:32 +01:00 committed by GitHub
commit d129c23d54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 43 deletions

View File

@ -120,6 +120,7 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad
let hasErrors = false;
form.fields.forEach((field, idx) => {
if (idx < form.dimenssionscount) {
const grade = parseInt(currentValues[idx].grade, 10);
if (!isNaN(grade) && grade >= 0) {
data['grade__idx_' + idx] = grade;
@ -135,6 +136,7 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
data['weight__idx_' + idx] = parseInt(field.weight, 10) || 0;
}
});
if (hasErrors) {

View File

@ -102,6 +102,7 @@ export class AddonModWorkshopAssessmentStrategyCommentsHandler implements AddonW
let hasErrors = false;
form.fields.forEach((field, idx) => {
if (idx < form.dimenssionscount) {
if (currentValues[idx].peercomment) {
data['peercomment__idx_' + idx] = currentValues[idx].peercomment;
} else {
@ -111,6 +112,7 @@ export class AddonModWorkshopAssessmentStrategyCommentsHandler implements AddonW
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
}
});
if (hasErrors) {

View File

@ -106,8 +106,9 @@ export class AddonModWorkshopAssessmentStrategyNumErrorsHandler implements Addon
let hasErrors = false;
form.fields.forEach((field, idx) => {
if (idx < form.dimenssionscount) {
const grade = parseInt(currentValues[idx].grade);
if (!isNaN(grade) && grade >= 0) {
if (!isNaN(grade) && (grade == 1 || grade == -1)) {
data['grade__idx_' + idx] = grade;
} else {
errors['grade_' + idx] = this.translate.instant('core.required');
@ -121,6 +122,7 @@ export class AddonModWorkshopAssessmentStrategyNumErrorsHandler implements Addon
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
data['weight__idx_' + idx] = parseInt(field.weight, 10) || 0;
}
});
if (hasErrors) {

View File

@ -102,6 +102,7 @@ export class AddonModWorkshopAssessmentStrategyRubricHandler implements AddonWor
let hasErrors = false;
form.fields.forEach((field, idx) => {
if (idx < form.dimenssionscount) {
const id = parseInt(currentValues[idx].chosenlevelid, 10);
if (!isNaN(id) && id >= 0) {
data['chosenlevelid__idx_' + idx] = id;
@ -112,6 +113,7 @@ export class AddonModWorkshopAssessmentStrategyRubricHandler implements AddonWor
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
}
});
if (hasErrors) {