diff --git a/src/addon/mod/workshop/assessment/accumulative/providers/handler.ts b/src/addon/mod/workshop/assessment/accumulative/providers/handler.ts index e361727b0..40505af47 100644 --- a/src/addon/mod/workshop/assessment/accumulative/providers/handler.ts +++ b/src/addon/mod/workshop/assessment/accumulative/providers/handler.ts @@ -63,8 +63,6 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad field.dimtitle = this.translate.instant( 'addon.mod_workshop_assessment_accumulative.dimensionnumber', {$a: field.number}); - const scale = parseInt(field.grade, 10) < 0 ? form.dimensionsinfo[n].scale : null; - if (!form.current[n]) { form.current[n] = {}; } @@ -76,7 +74,11 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad form.current[n].grade = form.current[n].grade ? parseInt(form.current[n].grade, 10) : -1; - promises.push(this.gradesHelper.makeGradesMenu(field.grade, workshopId, defaultGrade, -1, scale).then((grades) => { + const gradingType = parseInt(field.grade, 10); + const dimension = form.dimensionsinfo.find((dimension) => dimension.id == field.dimensionid); + const scale = dimension && gradingType < 0 ? dimension.scale : null; + + promises.push(this.gradesHelper.makeGradesMenu(gradingType, undefined, defaultGrade, -1, scale).then((grades) => { field.grades = grades; originalValues[n].grade = form.current[n].grade; })); diff --git a/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html b/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html index 0e2e89af6..2c9f9be19 100644 --- a/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html +++ b/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html @@ -127,7 +127,7 @@

{{ 'addon.mod_workshop.assignedassessmentsnone' | translate }}

- + diff --git a/src/addon/mod/workshop/pages/assessment/assessment.ts b/src/addon/mod/workshop/pages/assessment/assessment.ts index 09b6a1e3f..6c1783e35 100644 --- a/src/addon/mod/workshop/pages/assessment/assessment.ts +++ b/src/addon/mod/workshop/pages/assessment/assessment.ts @@ -182,8 +182,8 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy { if (accessData.canoverridegrades) { defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden'); - promise = this.gradesHelper.makeGradesMenu(this.workshop.gradinggrade, this.workshopId, defaultGrade, - -1).then((grades) => { + promise = this.gradesHelper.makeGradesMenu(this.workshop.gradinggrade, undefined, defaultGrade, -1) + .then((grades) => { this.evaluationGrades = grades; }); } else { diff --git a/src/addon/mod/workshop/pages/submission/submission.ts b/src/addon/mod/workshop/pages/submission/submission.ts index 77d82fec2..1158e5df5 100644 --- a/src/addon/mod/workshop/pages/submission/submission.ts +++ b/src/addon/mod/workshop/pages/submission/submission.ts @@ -202,7 +202,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy { this.workshop.phase < AddonModWorkshopProvider.PHASE_CLOSED && this.access.canoverridegrades; this.ownAssessment = false; - if (this.access.canviewallassessments || this.currentUserId == this.userId) { + if (this.access.canviewallassessments) { // Get new data, different that came from stateParams. promises.push(this.workshopProvider.getSubmissionAssessments(this.workshopId, this.submissionId) .then((subAssessments) => { @@ -259,8 +259,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy { const defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden'); - promises.push(this.gradesHelper.makeGradesMenu(this.workshop.grade, this.workshopId, defaultGrade, -1) - .then((grades) => { + promises.push(this.gradesHelper.makeGradesMenu(this.workshop.grade, undefined, defaultGrade, -1).then((grades) => { this.evaluationGrades = grades; this.evaluate.grade = { diff --git a/src/core/course/providers/course.ts b/src/core/course/providers/course.ts index 1815352ea..bb4a55c5a 100644 --- a/src/core/course/providers/course.ts +++ b/src/core/course/providers/course.ts @@ -467,6 +467,8 @@ export class CoreCourseProvider { /** * Gets a module basic grade info by module ID. * + * If the user does not have permision to manage the activity false is returned. + * * @param {number} moduleId Module ID. * @param {string} [siteId] Site ID. If not defined, current site. * @return {Promise} Promise resolved with the module's grade info. diff --git a/src/core/grades/providers/helper.ts b/src/core/grades/providers/helper.ts index 3032f20e3..5df58c9dd 100644 --- a/src/core/grades/providers/helper.ts +++ b/src/core/grades/providers/helper.ts @@ -559,18 +559,19 @@ export class CoreGradesHelperProvider { * Taken from make_grades_menu on moodlelib.php * * @param {number} gradingType If positive, max grade you can provide. If negative, scale Id. - * @param {number} moduleId Module Id needed to retrieve the scale. + * @param {number} [moduleId] Module ID. Used to retrieve the scale items when they are not passed as parameter. + * If the user does not have permision to manage the activity an empty list is returned. * @param {string} [defaultLabel] Element that will become default option, if not defined, it won't be added. * @param {any} [defaultValue] Element that will become default option value. Default ''. * @param {string} [scale] Scale csv list String. If not provided, it will take it from the module grade info. * @return {Promise} Array with objects with value and label to create a propper HTML select. */ - makeGradesMenu(gradingType: number, moduleId: number, defaultLabel: string = '', defaultValue: any = '', scale?: string): + makeGradesMenu(gradingType: number, moduleId?: number, defaultLabel: string = '', defaultValue: any = '', scale?: string): Promise { if (gradingType < 0) { if (scale) { return Promise.resolve(this.utils.makeMenuFromList(scale, defaultLabel, undefined, defaultValue)); - } else { + } else if (moduleId) { return this.courseProvider.getModuleBasicGradeInfo(moduleId).then((gradeInfo) => { if (gradeInfo.scale) { return this.utils.makeMenuFromList(gradeInfo.scale, defaultLabel, undefined, defaultValue); @@ -578,6 +579,8 @@ export class CoreGradesHelperProvider { return []; }); + } else { + return Promise.resolve([]); } }