MOBILE-2354 workshop: Assessment component
parent
af51fb8a7e
commit
aef3f53528
|
@ -0,0 +1,27 @@
|
|||
<core-loading [hideUntil]="loaded">
|
||||
<ion-item *ngIf="summary" text-wrap [attr.detail-push]="canViewAssessment && !canSelfAssess? true : null" (click)="gotoAssessment()">
|
||||
<ion-avatar item-start>
|
||||
<img [src]="profile && profile.profileimageurl" core-external-content [alt]="'core.pictureof' | translate:{$a: profile && profile.fullname}" core-user-link [courseId]="courseId" [userId]="profile && profile.id" role="presentation" onError="this.src='assets/img/user-avatar.png'">
|
||||
</ion-avatar>
|
||||
|
||||
<h2 *ngIf="profile && profile.fullname">{{profile.fullname}}</h2>
|
||||
<p *ngIf="showGrade(assessment.grade)">
|
||||
{{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{assessment.grade}}
|
||||
</p>
|
||||
<p *ngIf="access.canviewallsubmissions && !showGrade(assessment.gradinggradeover) && showGrade(assessment.gradinggrade)">
|
||||
{{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{assessment.gradinggrade}}
|
||||
</p>
|
||||
<p *ngIf="access.canviewallsubmissions && showGrade(assessment.gradinggradeover)" class="core-overriden-grade">
|
||||
{{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{assessment.gradinggradeover}}
|
||||
</p>
|
||||
<p *ngIf="assessment.weight && assessment.weight != 1">
|
||||
{{ 'addon.mod_workshop.weightinfo' | translate:{$a: assessment.weight } }}
|
||||
</p>
|
||||
<ion-badge *ngIf="!assessment.grade" color="danger">{{ 'addon.mod_workshop.notassessed' | translate }}</ion-badge>
|
||||
<button ion-button block *ngIf="canSelfAssess && !showGrade(assessment.grade)" (click)="gotoOwnAssessment()">{{ 'addon.mod_workshop.assess' | translate }}</button>
|
||||
<button ion-button block *ngIf="canSelfAssess && showGrade(assessment.grade)" (click)="gotoOwnAssessment()">{{ 'addon.mod_workshop.reassess' | translate }}</button>
|
||||
<ion-note item-end *ngIf="offline">
|
||||
<ion-icon name="time"></ion-icon>{{ 'core.notsent' | translate }}
|
||||
</ion-note>
|
||||
</ion-item>
|
||||
</core-loading>
|
|
@ -0,0 +1,35 @@
|
|||
addon-mod-workshop-assessment {
|
||||
.item-md.item-block .item-inner {
|
||||
border-bottom: 1px solid $list-md-border-color;
|
||||
}
|
||||
|
||||
.item-ios.item-block .item-inner {
|
||||
border-bottom: $hairlines-width solid $list-ios-border-color;
|
||||
}
|
||||
|
||||
.item-wp.item-block .item-inner {
|
||||
border-bottom: 1px solid $list-wp-border-color;
|
||||
}
|
||||
|
||||
&:last-child .item .item-inner {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.card.with-borders addon-mod-workshop-assessment {
|
||||
.item-md.item-block .item-inner {
|
||||
border-bottom: 1px solid $list-md-border-color;
|
||||
}
|
||||
|
||||
.item-ios.item-block .item-inner {
|
||||
border-bottom: $hairlines-width solid $list-ios-border-color;
|
||||
}
|
||||
|
||||
.item-wp.item-block .item-inner {
|
||||
border-bottom: 1px solid $list-wp-border-color;
|
||||
}
|
||||
|
||||
&:last-child .item .item-inner {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
// (C) Copyright 2015 Martin Dougiamas
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { NavController } from 'ionic-angular';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreUserProvider } from '@core/user/providers/user';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { AddonModWorkshopHelperProvider } from '../../providers/helper';
|
||||
import { AddonModWorkshopOfflineProvider } from '../../providers/offline';
|
||||
|
||||
/**
|
||||
* Component that displays workshop assessment.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'addon-mod-workshop-assessment',
|
||||
templateUrl: 'assessment.html',
|
||||
})
|
||||
export class AddonModWorkshopAssessmentComponent implements OnInit {
|
||||
@Input() assessment: any;
|
||||
@Input() summary?: boolean;
|
||||
@Input() courseId: number;
|
||||
@Input() submission: any;
|
||||
@Input() module?: any;
|
||||
@Input() workshop: any;
|
||||
@Input() access: any;
|
||||
|
||||
canViewAssessment = false;
|
||||
canSelfAssess = false;
|
||||
profile: any;
|
||||
showGrade: any;
|
||||
offline = false;
|
||||
loaded = false;
|
||||
|
||||
protected currentUserId: number;
|
||||
protected assessmentId: number;
|
||||
|
||||
constructor(private workshopOffline: AddonModWorkshopOfflineProvider, private workshopHelper: AddonModWorkshopHelperProvider,
|
||||
private navCtrl: NavController, private userProvider: CoreUserProvider, private domUtils: CoreDomUtilsProvider,
|
||||
sitesProvider: CoreSitesProvider) {
|
||||
this.currentUserId = sitesProvider.getCurrentSiteUserId();
|
||||
this.showGrade = this.workshopHelper.showGrade;
|
||||
}
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
const canAssess = this.access && this.access.assessingallowed,
|
||||
userId = this.assessment.userid || this.assessment.reviewerid,
|
||||
promises = [];
|
||||
|
||||
this.assessmentId = this.assessment.assessmentid || this.assessment.id;
|
||||
this.canViewAssessment = this.assessment.grade;
|
||||
this.canSelfAssess = canAssess && userId == this.currentUserId;
|
||||
|
||||
if (userId) {
|
||||
promises.push(this.userProvider.getProfile(userId, this.courseId, true).then((profile) => {
|
||||
this.profile = profile;
|
||||
}));
|
||||
}
|
||||
|
||||
let assessOffline;
|
||||
if (userId == this.currentUserId) {
|
||||
assessOffline = this.workshopOffline.getAssessment(this.workshop.id, this.assessmentId) .then((offlineAssess) => {
|
||||
this.offline = true;
|
||||
this.assessment.weight = offlineAssess.inputdata.weight;
|
||||
});
|
||||
} else {
|
||||
assessOffline = this.workshopOffline.getEvaluateAssessment(this.workshop.id, this.assessmentId)
|
||||
.then((offlineAssess) => {
|
||||
this.offline = true;
|
||||
this.assessment.gradinggradeover = offlineAssess.gradinggradeover;
|
||||
this.assessment.weight = offlineAssess.weight;
|
||||
});
|
||||
}
|
||||
|
||||
promises.push(assessOffline.catch(() => {
|
||||
this.offline = false;
|
||||
// Ignore errors.
|
||||
}));
|
||||
|
||||
Promise.all(promises).finally(() => {
|
||||
this.loaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the assessment.
|
||||
*/
|
||||
gotoAssessment(): void {
|
||||
if (!this.canSelfAssess && this.canViewAssessment) {
|
||||
const params = {
|
||||
assessment: this.assessment,
|
||||
submission: this.submission,
|
||||
profile: this.profile,
|
||||
courseId: this.courseId,
|
||||
assessmentId: this.assessmentId
|
||||
};
|
||||
|
||||
if (!this.submission) {
|
||||
const modal = this.domUtils.showModalLoading('core.sending', true);
|
||||
|
||||
this.workshopHelper.getSubmissionById(this.workshop.id, this.assessment.submissionid)
|
||||
.then((submissionData) => {
|
||||
|
||||
params.submission = submissionData;
|
||||
this.navCtrl.push('AddonModWorkshopAssessmentPage', params);
|
||||
}).catch((message) => {
|
||||
this.domUtils.showErrorModalDefault(message, 'Cannot load submission');
|
||||
}).finally(() => {
|
||||
modal.dismiss();
|
||||
});
|
||||
} else {
|
||||
this.navCtrl.push('AddonModWorkshopAssessmentPage', params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to my own assessment.
|
||||
*/
|
||||
gotoOwnAssessment(): void {
|
||||
if (this.canSelfAssess) {
|
||||
const params = {
|
||||
module: this.module,
|
||||
workshop: this.workshop,
|
||||
access: this.access,
|
||||
courseId: this.courseId,
|
||||
profile: this.profile,
|
||||
submission: this.submission,
|
||||
assessment: this.assessment
|
||||
};
|
||||
|
||||
this.navCtrl.push('AddonModWorkshopSubmissionPage', params);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,11 +22,13 @@ import { CorePipesModule } from '@pipes/pipes.module';
|
|||
import { CoreCourseComponentsModule } from '@core/course/components/components.module';
|
||||
import { AddonModWorkshopIndexComponent } from './index/index';
|
||||
import { AddonModWorkshopSubmissionComponent } from './submission/submission';
|
||||
import { AddonModWorkshopAssessmentComponent } from './assessment/assessment';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AddonModWorkshopIndexComponent,
|
||||
AddonModWorkshopSubmissionComponent
|
||||
AddonModWorkshopSubmissionComponent,
|
||||
AddonModWorkshopAssessmentComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
@ -41,7 +43,8 @@ import { AddonModWorkshopSubmissionComponent } from './submission/submission';
|
|||
],
|
||||
exports: [
|
||||
AddonModWorkshopIndexComponent,
|
||||
AddonModWorkshopSubmissionComponent
|
||||
AddonModWorkshopSubmissionComponent,
|
||||
AddonModWorkshopAssessmentComponent
|
||||
],
|
||||
entryComponents: [
|
||||
AddonModWorkshopIndexComponent
|
||||
|
|
|
@ -48,21 +48,23 @@
|
|||
<ion-item text-wrap>
|
||||
<h2>{{ 'addon.mod_workshop.yourassessment' | translate }}</h2>
|
||||
</ion-item>
|
||||
<!--<addon-mod-workshop-assessment [submission]="submission" [assessment]="ownAssessment" [courseId]="courseId" summary="true" [access]="access" [module]="module" [workshop]="workshop"></addon-mod-workshop-assessment>-->
|
||||
<addon-mod-workshop-assessment [submission]="submission" [assessment]="ownAssessment" [courseId]="courseId" summary="true" [access]="access" [module]="module" [workshop]="workshop"></addon-mod-workshop-assessment>
|
||||
</ion-list>
|
||||
|
||||
<ion-list *ngIf="submissionInfo && submissionInfo.reviewedby && submissionInfo.reviewedby.length && !assessment">
|
||||
<ion-item text-wrap>
|
||||
<h2>{{ 'addon.mod_workshop.receivedgrades' | translate }}</h2>
|
||||
</ion-item>
|
||||
<!--<addon-mod-workshop-assessment *ngFor="let reviewer of submissionInfo.reviewedby" *ngIf="!reviewer.ownAssessment" [submission]="submission" [assessment]="reviewer" [courseId]="courseId" summary="true" [access]="access" [workshop]="workshop"></addon-mod-workshop-assessment>-->
|
||||
<ng-container *ngFor="let reviewer of submissionInfo.reviewedby">
|
||||
<addon-mod-workshop-assessment *ngIf="!reviewer.ownAssessment" [submission]="submission" [assessment]="reviewer" [courseId]="courseId" summary="true" [access]="access" [workshop]="workshop"></addon-mod-workshop-assessment>
|
||||
</ng-container>
|
||||
</ion-list>
|
||||
|
||||
<ion-list *ngIf="submissionInfo && submissionInfo.reviewerof && submissionInfo.reviewerof.length && !assessment">
|
||||
<ion-item text-wrap>
|
||||
<h2>{{ 'addon.mod_workshop.givengrades' | translate }}</h2>
|
||||
</ion-item>
|
||||
<!--<addon-mod-workshop-assessment *ngFor="let reviewer of submissionInfo.reviewerof" [assessment]="reviewer" [courseId]="courseId" summary="true" [workshop]="workshop" [access]="access"></addon-mod-workshop-assessment>-->
|
||||
<addon-mod-workshop-assessment *ngFor="let reviewer of submissionInfo.reviewerof" [assessment]="reviewer" [courseId]="courseId" summary="true" [workshop]="workshop" [access]="access"></addon-mod-workshop-assessment>
|
||||
</ion-list>
|
||||
|
||||
<form ion-list [formGroup]="feedbackForm" *ngIf="canAddFeedback">
|
||||
|
|
|
@ -36,7 +36,7 @@ import { AddonModWorkshopSyncProvider } from '../../providers/sync';
|
|||
*/
|
||||
@IonicPage({ segment: 'addon-mod-workshop-submission' })
|
||||
@Component({
|
||||
selector: 'page-addon-mod-workshop-submission',
|
||||
selector: 'page-addon-mod-workshop-submission-page',
|
||||
templateUrl: 'submission.html',
|
||||
})
|
||||
export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
addon-mod-workshop-submission,
|
||||
addon-mod-workshop-assessment, // TODO, change names
|
||||
addon-mod-workshop-assessment {
|
||||
addon-mod-workshop-submission-page,
|
||||
addon-mod-workshop-assessment,
|
||||
addon-mod-workshop-assessment-page {
|
||||
|
||||
p.addon-overriden-grade {
|
||||
color: color($colors, success);
|
||||
|
|
Loading…
Reference in New Issue