Merge pull request #1970 from albertgasset/MOBILE-3039

Mobile 3039
main
Juan Leyva 2019-06-06 16:02:45 +02:00 committed by GitHub
commit 90d3dbbe2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 12 deletions

View File

@ -63,8 +63,6 @@ export class AddonModWorkshopAssessmentStrategyAccumulativeHandler implements Ad
field.dimtitle = this.translate.instant( field.dimtitle = this.translate.instant(
'addon.mod_workshop_assessment_accumulative.dimensionnumber', {$a: field.number}); '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]) { if (!form.current[n]) {
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; 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; field.grades = grades;
originalValues[n].grade = form.current[n].grade; originalValues[n].grade = form.current[n].grade;
})); }));

View File

@ -127,7 +127,7 @@
<ion-item text-wrap *ngIf="!assessments || !assessments.length"> <ion-item text-wrap *ngIf="!assessments || !assessments.length">
<p>{{ 'addon.mod_workshop.assignedassessmentsnone' | translate }}</p> <p>{{ 'addon.mod_workshop.assignedassessmentsnone' | translate }}</p>
</ion-item> </ion-item>
<ng-container *ngFor="let assessment of assessments"> <ng-container *ngFor="let assessment of (assessments || [])">
<addon-mod-workshop-submission [submission]="assessment.submission" [assessment]="assessment" [courseId]="workshop.course" [module]="module" [workshop]="workshop" [access]="access" summary="true"></addon-mod-workshop-submission> <addon-mod-workshop-submission [submission]="assessment.submission" [assessment]="assessment" [courseId]="workshop.course" [module]="module" [workshop]="workshop" [access]="access" summary="true"></addon-mod-workshop-submission>
</ng-container> </ng-container>
</ion-card > </ion-card >

View File

@ -182,8 +182,8 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy {
if (accessData.canoverridegrades) { if (accessData.canoverridegrades) {
defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden'); defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden');
promise = this.gradesHelper.makeGradesMenu(this.workshop.gradinggrade, this.workshopId, defaultGrade, promise = this.gradesHelper.makeGradesMenu(this.workshop.gradinggrade, undefined, defaultGrade, -1)
-1).then((grades) => { .then((grades) => {
this.evaluationGrades = grades; this.evaluationGrades = grades;
}); });
} else { } else {

View File

@ -202,7 +202,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
this.workshop.phase < AddonModWorkshopProvider.PHASE_CLOSED && this.access.canoverridegrades; this.workshop.phase < AddonModWorkshopProvider.PHASE_CLOSED && this.access.canoverridegrades;
this.ownAssessment = false; this.ownAssessment = false;
if (this.access.canviewallassessments || this.currentUserId == this.userId) { if (this.access.canviewallassessments) {
// Get new data, different that came from stateParams. // Get new data, different that came from stateParams.
promises.push(this.workshopProvider.getSubmissionAssessments(this.workshopId, this.submissionId) promises.push(this.workshopProvider.getSubmissionAssessments(this.workshopId, this.submissionId)
.then((subAssessments) => { .then((subAssessments) => {
@ -259,8 +259,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
const defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden'); const defaultGrade = this.translate.instant('addon.mod_workshop.notoverridden');
promises.push(this.gradesHelper.makeGradesMenu(this.workshop.grade, this.workshopId, defaultGrade, -1) promises.push(this.gradesHelper.makeGradesMenu(this.workshop.grade, undefined, defaultGrade, -1).then((grades) => {
.then((grades) => {
this.evaluationGrades = grades; this.evaluationGrades = grades;
this.evaluate.grade = { this.evaluate.grade = {

View File

@ -467,6 +467,8 @@ export class CoreCourseProvider {
/** /**
* Gets a module basic grade info by module ID. * 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 {number} moduleId Module ID.
* @param {string} [siteId] Site ID. If not defined, current site. * @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved with the module's grade info. * @return {Promise<any>} Promise resolved with the module's grade info.

View File

@ -559,18 +559,19 @@ export class CoreGradesHelperProvider {
* Taken from make_grades_menu on moodlelib.php * Taken from make_grades_menu on moodlelib.php
* *
* @param {number} gradingType If positive, max grade you can provide. If negative, scale Id. * @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 {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 {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. * @param {string} [scale] Scale csv list String. If not provided, it will take it from the module grade info.
* @return {Promise<any[]>} Array with objects with value and label to create a propper HTML select. * @return {Promise<any[]>} 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<any[]> { Promise<any[]> {
if (gradingType < 0) { if (gradingType < 0) {
if (scale) { if (scale) {
return Promise.resolve(this.utils.makeMenuFromList(scale, defaultLabel, undefined, defaultValue)); return Promise.resolve(this.utils.makeMenuFromList(scale, defaultLabel, undefined, defaultValue));
} else { } else if (moduleId) {
return this.courseProvider.getModuleBasicGradeInfo(moduleId).then((gradeInfo) => { return this.courseProvider.getModuleBasicGradeInfo(moduleId).then((gradeInfo) => {
if (gradeInfo.scale) { if (gradeInfo.scale) {
return this.utils.makeMenuFromList(gradeInfo.scale, defaultLabel, undefined, defaultValue); return this.utils.makeMenuFromList(gradeInfo.scale, defaultLabel, undefined, defaultValue);
@ -578,6 +579,8 @@ export class CoreGradesHelperProvider {
return []; return [];
}); });
} else {
return Promise.resolve([]);
} }
} }