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,21 +120,23 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad
let hasErrors = false;
form.fields.forEach((field, idx) => {
const grade = parseInt(currentValues[idx].grade, 10);
if (!isNaN(grade) && grade >= 0) {
data['grade__idx_' + idx] = grade;
} else {
errors['grade_' + idx] = this.translate.instant('addon.mod_workshop_assessment_accumulative.mustchoosegrade');
hasErrors = true;
}
if (idx < form.dimenssionscount) {
const grade = parseInt(currentValues[idx].grade, 10);
if (!isNaN(grade) && grade >= 0) {
data['grade__idx_' + idx] = grade;
} else {
errors['grade_' + idx] = this.translate.instant('addon.mod_workshop_assessment_accumulative.mustchoosegrade');
hasErrors = true;
}
if (currentValues[idx].peercomment) {
data['peercomment__idx_' + idx] = currentValues[idx].peercomment;
}
if (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);
data['weight__idx_' + idx] = parseInt(field.weight, 10) || 0;
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,15 +102,17 @@ export class AddonModWorkshopAssessmentStrategyCommentsHandler implements AddonW
let hasErrors = false;
form.fields.forEach((field, idx) => {
if (currentValues[idx].peercomment) {
data['peercomment__idx_' + idx] = currentValues[idx].peercomment;
} else {
errors['peercomment_' + idx] = this.translate.instant('core.err_required');
hasErrors = true;
}
if (idx < form.dimenssionscount) {
if (currentValues[idx].peercomment) {
data['peercomment__idx_' + idx] = currentValues[idx].peercomment;
} else {
errors['peercomment_' + idx] = this.translate.instant('core.err_required');
hasErrors = true;
}
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
}
});
if (hasErrors) {

View File

@ -106,21 +106,23 @@ export class AddonModWorkshopAssessmentStrategyNumErrorsHandler implements Addon
let hasErrors = false;
form.fields.forEach((field, idx) => {
const grade = parseInt(currentValues[idx].grade);
if (!isNaN(grade) && grade >= 0) {
data['grade__idx_' + idx] = grade;
} else {
errors['grade_' + idx] = this.translate.instant('core.required');
hasErrors = true;
}
if (idx < form.dimenssionscount) {
const grade = parseInt(currentValues[idx].grade);
if (!isNaN(grade) && (grade == 1 || grade == -1)) {
data['grade__idx_' + idx] = grade;
} else {
errors['grade_' + idx] = this.translate.instant('core.required');
hasErrors = true;
}
if (currentValues[idx].peercomment) {
data['peercomment__idx_' + idx] = currentValues[idx].peercomment;
}
if (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);
data['weight__idx_' + idx] = parseInt(field.weight, 10) || 0;
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,16 +102,18 @@ export class AddonModWorkshopAssessmentStrategyRubricHandler implements AddonWor
let hasErrors = false;
form.fields.forEach((field, idx) => {
const id = parseInt(currentValues[idx].chosenlevelid, 10);
if (!isNaN(id) && id >= 0) {
data['chosenlevelid__idx_' + idx] = id;
} else {
errors['chosenlevelid_' + idx] = this.translate.instant('addon.mod_workshop_assessment_rubric.mustchooseone');
hasErrors = true;
}
if (idx < form.dimenssionscount) {
const id = parseInt(currentValues[idx].chosenlevelid, 10);
if (!isNaN(id) && id >= 0) {
data['chosenlevelid__idx_' + idx] = id;
} else {
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['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
data['gradeid__idx_' + idx] = parseInt(form.current[idx].gradeid, 10) || 0;
data['dimensionid__idx_' + idx] = parseInt(field.dimensionid, 10);
}
});
if (hasErrors) {