Skip to content

Commit 90d3dbb

Browse files
authored
Merge pull request #1970 from albertgasset/MOBILE-3039
Mobile 3039
2 parents 56ec20b + 9aff138 commit 90d3dbb

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/addon/mod/workshop/assessment/accumulative/providers/handler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad
6363
field.dimtitle = this.translate.instant(
6464
'addon.mod_workshop_assessment_accumulative.dimensionnumber', {$a: field.number});
6565

66-
const scale = parseInt(field.grade, 10) < 0 ? form.dimensionsinfo[n].scale : null;
67-
6866
if (!form.current[n]) {
6967
form.current[n] = {};
7068
}
@@ -76,7 +74,11 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad
7674

7775
form.current[n].grade = form.current[n].grade ? parseInt(form.current[n].grade, 10) : -1;
7876

79-
promises.push(this.gradesHelper.makeGradesMenu(field.grade, workshopId, defaultGrade, -1, scale).then((grades) => {
77+
const gradingType = parseInt(field.grade, 10);
78+
const dimension = form.dimensionsinfo.find((dimension) => dimension.id == field.dimensionid);
79+
const scale = dimension && gradingType < 0 ? dimension.scale : null;
80+
81+
promises.push(this.gradesHelper.makeGradesMenu(gradingType, undefined, defaultGrade, -1, scale).then((grades) => {
8082
field.grades = grades;
8183
originalValues[n].grade = form.current[n].grade;
8284
}));

src/addon/mod/workshop/components/index/addon-mod-workshop-index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ <h2>{{ 'addon.mod_workshop.assignedassessments' | translate }}</h2>
127127
<ion-item text-wrap *ngIf="!assessments || !assessments.length">
128128
<p>{{ 'addon.mod_workshop.assignedassessmentsnone' | translate }}</p>
129129
</ion-item>
130-
<ng-container *ngFor="let assessment of assessments">
130+
<ng-container *ngFor="let assessment of (assessments || [])">
131131
<addon-mod-workshop-submission [submission]="assessment.submission" [assessment]="assessment" [courseId]="workshop.course" [module]="module" [workshop]="workshop" [access]="access" summary="true"></addon-mod-workshop-submission>
132132
</ng-container>
133133
</ion-card >

src/addon/mod/workshop/pages/assessment/assessment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy {
182182

183183
if (accessData.canoverridegrades) {
184184
defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden');
185-
promise = this.gradesHelper.makeGradesMenu(this.workshop.gradinggrade, this.workshopId, defaultGrade,
186-
-1).then((grades) => {
185+
promise = this.gradesHelper.makeGradesMenu(this.workshop.gradinggrade, undefined, defaultGrade, -1)
186+
.then((grades) => {
187187
this.evaluationGrades = grades;
188188
});
189189
} else {

src/addon/mod/workshop/pages/submission/submission.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
202202
this.workshop.phase < AddonModWorkshopProvider.PHASE_CLOSED && this.access.canoverridegrades;
203203
this.ownAssessment = false;
204204

205-
if (this.access.canviewallassessments || this.currentUserId == this.userId) {
205+
if (this.access.canviewallassessments) {
206206
// Get new data, different that came from stateParams.
207207
promises.push(this.workshopProvider.getSubmissionAssessments(this.workshopId, this.submissionId)
208208
.then((subAssessments) => {
@@ -259,8 +259,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
259259

260260
const defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden');
261261

262-
promises.push(this.gradesHelper.makeGradesMenu(this.workshop.grade, this.workshopId, defaultGrade, -1)
263-
.then((grades) => {
262+
promises.push(this.gradesHelper.makeGradesMenu(this.workshop.grade, undefined, defaultGrade, -1).then((grades) => {
264263
this.evaluationGrades = grades;
265264

266265
this.evaluate.grade = {

src/core/course/providers/course.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ export class CoreCourseProvider {
467467
/**
468468
* Gets a module basic grade info by module ID.
469469
*
470+
* If the user does not have permision to manage the activity false is returned.
471+
*
470472
* @param {number} moduleId Module ID.
471473
* @param {string} [siteId] Site ID. If not defined, current site.
472474
* @return {Promise<any>} Promise resolved with the module's grade info.

src/core/grades/providers/helper.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,25 +559,28 @@ export class CoreGradesHelperProvider {
559559
* Taken from make_grades_menu on moodlelib.php
560560
*
561561
* @param {number} gradingType If positive, max grade you can provide. If negative, scale Id.
562-
* @param {number} moduleId Module Id needed to retrieve the scale.
562+
* @param {number} [moduleId] Module ID. Used to retrieve the scale items when they are not passed as parameter.
563+
* If the user does not have permision to manage the activity an empty list is returned.
563564
* @param {string} [defaultLabel] Element that will become default option, if not defined, it won't be added.
564565
* @param {any} [defaultValue] Element that will become default option value. Default ''.
565566
* @param {string} [scale] Scale csv list String. If not provided, it will take it from the module grade info.
566567
* @return {Promise<any[]>} Array with objects with value and label to create a propper HTML select.
567568
*/
568-
makeGradesMenu(gradingType: number, moduleId: number, defaultLabel: string = '', defaultValue: any = '', scale?: string):
569+
makeGradesMenu(gradingType: number, moduleId?: number, defaultLabel: string = '', defaultValue: any = '', scale?: string):
569570
Promise<any[]> {
570571
if (gradingType < 0) {
571572
if (scale) {
572573
return Promise.resolve(this.utils.makeMenuFromList(scale, defaultLabel, undefined, defaultValue));
573-
} else {
574+
} else if (moduleId) {
574575
return this.courseProvider.getModuleBasicGradeInfo(moduleId).then((gradeInfo) => {
575576
if (gradeInfo.scale) {
576577
return this.utils.makeMenuFromList(gradeInfo.scale, defaultLabel, undefined, defaultValue);
577578
}
578579

579580
return [];
580581
});
582+
} else {
583+
return Promise.resolve([]);
581584
}
582585
}
583586

0 commit comments

Comments
 (0)