Merge pull request #1469 from crazyserver/MOBILE-2487

MOBILE-2487 workshop: Show phase plan instead of selector
main
Juan Leyva 2018-08-22 14:46:15 +01:00 committed by GitHub
commit 7c437c8c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 202 additions and 197 deletions

View File

@ -70,14 +70,14 @@
<ion-row align-items-center>
<ion-col *ngIf="search.page > 0">
<button ion-button block outline icon-start (click)="searchEntries(search.page - 1)">
<ion-icon name="arrow-back"></ion-icon>
<ion-icon name="arrow-back" md="ios-arrow-back"></ion-icon>
{{ 'core.previous' | translate }}
</button>
</ion-col>
<ion-col *ngIf="hasNextPage">
<button ion-button block icon-end (click)="searchEntries(search.page + 1)">
{{ 'core.next' | translate }}
<ion-icon name="arrow-forward"></ion-icon>
<ion-icon name="arrow-forward" md="ios-arrow-forward"></ion-icon>
</button>
</ion-col>
</ion-row>

View File

@ -38,14 +38,14 @@
<ion-row align-items-center>
<ion-col *ngIf="previousId">
<button ion-button block outline icon-start (click)="gotoEntry(previousId)">
<ion-icon name="arrow-back"></ion-icon>
<ion-icon name="arrow-back" md="ios-arrow-back"></ion-icon>
{{ 'core.previous' | translate }}
</button>
</ion-col>
<ion-col *ngIf="nextId">
<button ion-button block icon-end (click)="gotoEntry(nextId)">
{{ 'core.next' | translate }}
<ion-icon name="arrow-forward"></ion-icon>
<ion-icon name="arrow-forward" md="ios-arrow-forward"></ion-icon>
</button>
</ion-col>
</ion-row>

View File

@ -12,32 +12,24 @@
<!-- Content. -->
<core-loading [hideUntil]="loaded" class="core-loading-center">
<core-course-module-description *ngIf="description && selectedPhase == workshopPhases.PHASE_SETUP" [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
<core-course-module-description *ngIf="description" [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
<ion-card class="with-borders" *ngIf="phases">
<a ion-item (click)="selectPhase()" detail-none>
<h2 stacked text-wrap>{{ phases[selectedPhase].title }}</h2>
<p text-wrap *ngIf="phases[selectedPhase].code == workshop.phase">{{ 'addon.mod_workshop.userplancurrentphase' | translate }}</p>
<ion-icon item-end name="arrow-dropdown"></ion-icon>
<a ion-item (click)="viewPhaseInfo()">
<h2 stacked text-wrap>{{ phases[workshop.phase].title }}</h2>
</a>
<a ion-item text-wrap *ngIf="phases[selectedPhase].switchUrl" [href]="phases[selectedPhase].switchUrl" detail-none>
<ion-icon item-start name="swap"></ion-icon>
{{ 'addon.mod_workshop.switchphase' + selectedPhase | translate }}
<ion-icon item-end name="open"></ion-icon>
</a>
</ion-card>
<ng-container *ngIf="phases && phases[workshop.phase] && phases[workshop.phase].tasks && phases[workshop.phase].tasks.length">
<a ion-item text-wrap *ngFor="let task of phases[workshop.phase].tasks" (click)="runTask(task)" detail-none>
<ion-icon item-start name="radio-button-off" *ngIf="task.completed == null"></ion-icon>
<ion-icon item-start name="close-circle" color="danger" *ngIf="task.completed == ''"></ion-icon>
<ion-icon item-start name="information-circle" color="info" *ngIf="task.completed == 'info'"></ion-icon>
<ion-icon item-start name="checkmark-circle" color="success" *ngIf="task.completed == '1'"></ion-icon>
<ion-card class="with-borders" *ngIf="phases && phases[selectedPhase] && phases[selectedPhase].tasks && phases[selectedPhase].tasks.length">
<a ion-item text-wrap *ngFor="let task of phases[selectedPhase].tasks" [class.item-dimmed]="selectedPhase != workshop.phase" (click)="runTask(task)" detail-none>
<ion-icon item-start name="radio-button-off" *ngIf="task.completed == null"></ion-icon>
<ion-icon item-start name="close-circle" color="danger" *ngIf="task.completed == ''"></ion-icon>
<ion-icon item-start name="information-circle" color="info" *ngIf="task.completed == 'info'"></ion-icon>
<ion-icon item-start name="checkmark-circle" color="success" *ngIf="task.completed == '1'"></ion-icon>
<h2>{{task.title}}</h2>
<p *ngIf="task.details"><core-format-text [text]="task.details"></core-format-text></p>
<ion-icon item-end *ngIf="task.link && !task.support" name="open"></ion-icon>
</a>
<h2>{{task.title}}</h2>
<p *ngIf="task.details"><core-format-text [text]="task.details"></core-format-text></p>
<ion-icon item-end *ngIf="task.link && task.code != 'submit'" name="open"></ion-icon>
</a>
</ng-container>
</ion-card>
<!-- Has something offline. -->
@ -46,72 +38,9 @@
{{ 'core.hasdatatosync' | translate: {$a: moduleName} }}
</div>
<div *ngIf="access && workshop && workshop.phase >= selectedPhase">
<!-- SUBMISSION PHASE -->
<ng-container *ngIf="selectedPhase == workshopPhases.PHASE_SUBMISSION">
<ion-card *ngIf="workshop.instructauthors">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.areainstructauthors' | translate }}</h2>
<core-format-text fullOnClick="true" [component]="component" [componentId]="workshop.cmid" [text]="workshop.instructauthors"></core-format-text>
</ion-item>
</ion-card>
<ion-card class="with-borders" *ngIf="canSubmit">
<ion-item text-wrap *ngIf="!submission">
<h2>{{ 'addon.mod_workshop.yoursubmission' | translate }}</h2>
<p>{{ 'addon.mod_workshop.noyoursubmission' | translate }}</p>
</ion-item>
<ng-container *ngIf="submission">
<addon-mod-workshop-submission [submission]="submission" [courseId]="workshop.course" [module]="module" [workshop]="workshop" [access]="access"></addon-mod-workshop-submission>
</ng-container>
</ion-card>
<!-- Show only on current phase -->
<ng-container *ngIf="workshop.phase == selectedPhase">
<ion-item text-wrap *ngIf="canSubmit && ((access.creatingsubmissionallowed && !submission) || (access.modifyingsubmissionallowed && submission))">
<button ion-button icon-start block *ngIf="access.creatingsubmissionallowed && !submission" (click)="runTaskByCode('submit')">
<ion-icon name="add"></ion-icon>
{{ 'addon.mod_workshop.createsubmission' | translate }}
</button>
<button ion-button icon-start block *ngIf="access.modifyingsubmissionallowed && submission" (click)="runTaskByCode('submit')">
<ion-icon name="create"></ion-icon>
{{ 'addon.mod_workshop.editsubmission' | translate }}
</button>
</ion-item>
</ng-container>
</ng-container>
<!-- ASSESSMENT PHASE -->
<ng-container *ngIf="selectedPhase == workshopPhases.PHASE_ASSESSMENT">
<ion-card *ngIf="workshop.instructreviewers">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.areainstructreviewers' | translate }}</h2>
<core-format-text fullOnClick="true" [component]="component" [componentId]="workshop.cmid" [text]="workshop.instructreviewers"></core-format-text>
</ion-item>
</ion-card>
<ion-card class="with-borders" *ngIf="canAssess && assessments && assessments.length">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.assignedassessments' | translate }}</h2>
</ion-item>
<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>
</ng-container>
</ion-card >
</ng-container>
<ion-card class="with-borders" *ngIf="!access.canviewallsubmissions && selectedPhase == workshop.phase && (canSubmit || canAssess) && selectedPhase == workshopPhases.PHASE_EVALUATION">
<a ion-item text-wrap *ngIf="submission" (click)="switchPhase(workshopPhases.PHASE_SUBMISSION)" detail-push>
<h2>{{ 'addon.mod_workshop.yoursubmission' | translate }}</h2>
</a>
<a ion-item text-wrap *ngIf="canAssess" (click)="switchPhase(workshopPhases.PHASE_ASSESSMENT)" detail-push>
<h2>{{ 'addon.mod_workshop.assignedassessments' | translate }}</h2>
</a>
</ion-card>
<div *ngIf="access && workshop && workshop.phase >= workshopPhases.PHASE_SUBMISSION">
<!-- CLOSED PHASE -->
<ng-container *ngIf="selectedPhase == workshopPhases.PHASE_CLOSED">
<ng-container *ngIf="workshop.phase >= workshopPhases.PHASE_CLOSED">
<ion-card *ngIf="workshop.conclusion">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.conclusion' | translate }}</h2>
@ -123,34 +52,91 @@
<ion-item-divider color="light" text-wrap>
<h2>{{ 'addon.mod_workshop.yourgrades' | translate }}</h2>
</ion-item-divider>
<a ion-item text-wrap *ngIf="userGrades.submissionlongstrgrade" (click)="switchPhase(workshopPhases.PHASE_SUBMISSION)" detail-push>
<ion-item text-wrap *ngIf="userGrades.submissionlongstrgrade">
<h2>{{ 'addon.mod_workshop.submissiongrade' | translate }}</h2>
<core-format-text [text]="userGrades.submissionlongstrgrade"></core-format-text>
</a>
<a ion-item text-wrap *ngIf="userGrades.assessmentlongstrgrade" (click)="switchPhase(workshopPhases.PHASE_ASSESSMENT)" detail-push>
</ion-item>
<ion-item text-wrap *ngIf="userGrades.assessmentlongstrgrade">
<h2>{{ 'addon.mod_workshop.gradinggrade' | translate }}</h2>
<core-format-text [text]="userGrades.assessmentlongstrgrade"></core-format-text>
</a>
</ion-card>
<ion-card class="with-borders" *ngIf="publishedSubmissions && publishedSubmissions.length">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.publishedsubmissions' | translate }}</h2>
</ion-item>
</ion-card>
</ng-container>
<!-- SUBMISSION PHASE -->
<ion-card *ngIf="workshop.phase == workshopPhases.PHASE_SUBMISSION && workshop.instructauthors">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.areainstructauthors' | translate }}</h2>
<core-format-text fullOnClick="true" [component]="component" [componentId]="workshop.cmid" [text]="workshop.instructauthors"></core-format-text>
</ion-item>
</ion-card>
<ion-card *ngIf="canSubmit">
<ion-item text-wrap *ngIf="!submission">
<h2>{{ 'addon.mod_workshop.yoursubmission' | translate }}</h2>
<p>{{ 'addon.mod_workshop.noyoursubmission' | translate }}</p>
</ion-item>
<ng-container *ngIf="submission">
<ion-item-divider color="light" text-wrap>
<h2>{{ 'addon.mod_workshop.yoursubmission' | translate }}</h2>
</ion-item-divider>
<addon-mod-workshop-submission [submission]="submission" [courseId]="workshop.course" [module]="module" [workshop]="workshop" [access]="access"></addon-mod-workshop-submission>
</ng-container>
</ion-card>
<!-- Show only on current phase -->
<ng-container *ngIf="workshop.phase == workshopPhases.PHASE_SUBMISSION">
<ion-item text-wrap *ngIf="canSubmit && ((access.creatingsubmissionallowed && !submission) || (access.modifyingsubmissionallowed && submission))">
<button ion-button icon-start block *ngIf="access.creatingsubmissionallowed && !submission" (click)="gotoSubmit()">
<ion-icon name="add"></ion-icon>
{{ 'addon.mod_workshop.createsubmission' | translate }}
</button>
<button ion-button icon-start block *ngIf="access.modifyingsubmissionallowed && submission" (click)="gotoSubmit()">
<ion-icon name="create"></ion-icon>
{{ 'addon.mod_workshop.editsubmission' | translate }}
</button>
</ion-item>
</ng-container>
<ng-container *ngIf="workshop.phase >= workshopPhases.PHASE_CLOSED">
<ion-card class="with-borders" *ngIf="publishedSubmissions && publishedSubmissions.length">
<ion-item-divider color="light" text-wrap>
<h2>{{ 'addon.mod_workshop.publishedsubmissions' | translate }}</h2>
</ion-item-divider>
<ng-container *ngFor="let submission of publishedSubmissions">
<addon-mod-workshop-submission [submission]="submission" [courseId]="workshop.course" [module]="module" [workshop]="workshop" [access]="access" summary="true"></addon-mod-workshop-submission>
</ng-container>
</ion-card>
</ng-container>
<!-- ASSESSMENT PHASE -->
<ng-container *ngIf="workshop.phase >= workshopPhases.PHASE_ASSESSMENT">
<ion-card *ngIf="workshop.phase == workshopPhases.PHASE_ASSESSMENT && workshop.instructreviewers">
<ion-item text-wrap>
<h2>{{ 'addon.mod_workshop.areainstructreviewers' | translate }}</h2>
<core-format-text fullOnClick="true" [component]="component" [componentId]="workshop.cmid" [text]="workshop.instructreviewers"></core-format-text>
</ion-item>
</ion-card>
<ion-card class="with-borders" *ngIf="canAssess && assessments && assessments.length">
<ion-item-divider color="light" text-wrap>
<h2>{{ 'addon.mod_workshop.assignedassessments' | translate }}</h2>
</ion-item-divider>
<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>
</ng-container>
</ion-card >
</ng-container>
<!-- MULTIPLE PHASES SUBMISSION OR GREATER only teachers -->
<ion-card class="with-borders" *ngIf="workshop.phase == selectedPhase && access.canviewallsubmissions && selectedPhase >= workshopPhases.PHASE_SUBMISSION && grades && grades.length">
<ion-item text-wrap *ngIf="selectedPhase == workshopPhases.PHASE_SUBMISSION">
<ion-card class="with-borders" *ngIf="access.canviewallsubmissions && workshop.phase >= workshopPhases.PHASE_SUBMISSION && grades && grades.length">
<ion-item-divider color="light" text-wrap *ngIf="workshop.phase == workshopPhases.PHASE_SUBMISSION">
<h2>{{ 'addon.mod_workshop.submissionsreport' | translate }}</h2>
</ion-item>
<ion-item text-wrap *ngIf="selectedPhase > workshopPhases.PHASE_SUBMISSION">
</ion-item-divider>
<ion-item-divider color="light" text-wrap *ngIf="workshop.phase > workshopPhases.PHASE_SUBMISSION">
<h2>{{ 'addon.mod_workshop.gradesreport' | translate }}</h2>
</ion-item>
</ion-item-divider>
<ion-item text-wrap *ngIf="groupInfo && (groupInfo.separateGroups || groupInfo.visibleGroups)">
<ion-label id="addon-workshop-groupslabel" *ngIf="groupInfo.separateGroups">{{ 'core.groupsseparate' | translate }}</ion-label>
<ion-label id="addon-workshop-groupslabel" *ngIf="groupInfo.visibleGroups">{{ 'core.groupsvisible' | translate }}</ion-label>
@ -166,15 +152,15 @@
<ion-grid *ngIf="page > 0 || hasNextPage">
<ion-row align-items-center>
<ion-col *ngIf="page > 0">
<button ion-button block outline icon-start (click)="gotoSubmissionsPage(page - 1)">>
<ion-icon name="arrow-back"></ion-icon>
<button ion-button block outline icon-start (click)="gotoSubmissionsPage(page - 1)">
<ion-icon name="arrow-back" md="ios-arrow-back"></ion-icon>
{{ 'core.previous' | translate }}
</button>
</ion-col>
<ion-col *ngIf="hasNextPage">
<button ion-button block icon-end (click)="gotoSubmissionsPage(page + 1)">
{{ 'core.next' | translate }}
<ion-icon name="arrow-forward"></ion-icon>
<ion-icon name="arrow-forward" md="ios-arrow-forward"></ion-icon>
</button>
</ion-col>
</ion-row>

View File

@ -41,7 +41,6 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
assessments: any;
userGrades: any;
publishedSubmissions: any;
selectedPhase: number;
submission: any;
groupInfo: CoreGroupInfo = {
groups: [],
@ -61,9 +60,6 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
};
protected offlineSubmissions = [];
protected supportedTasks = { // Add here native supported tasks.
submit: true
};
protected obsSubmissionChanged: any;
protected obsAssessmentSaved: any;
protected appResumeSubscription: any;
@ -189,8 +185,6 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
return this.workshopProvider.getWorkshop(this.courseId, this.module.id).then((workshop) => {
this.workshop = workshop;
this.selectedPhase = workshop.phase;
this.description = workshop.intro || workshop.description;
this.dataRetrieved.emit(workshop);
@ -225,21 +219,12 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
}).then((phases) => {
this.phases = phases;
// Treat phases.
for (const x in phases) {
phases[x].tasks.forEach((task) => {
if (!task.link && (task.code == 'examples' || task.code == 'prepareexamples')) {
// Add links to manage examples.
task.link = this.externalUrl;
} else if (task.link && typeof this.supportedTasks[task.code] !== 'undefined') {
task.support = true;
}
});
const action = phases[x].actions.find((action) => {
return action.url && action.type == 'switchphase';
});
phases[x].switchUrl = action ? action.url : '';
}
phases[this.workshop.phase].tasks.forEach((task) => {
if (!task.link && (task.code == 'examples' || task.code == 'prepareexamples')) {
// Add links to manage examples.
task.link = this.externalUrl;
}
});
// Check if there are info stored in offline.
return this.workshopOffline.hasWorkshopOfflineData(this.workshop.id).then((hasOffline) => {
@ -295,47 +280,42 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
* @param {any} task Task to be done.
*/
runTask(task: any): void {
if (task.support) {
if (task.code == 'submit' && this.canSubmit && ((this.access.creatingsubmissionallowed && !this.submission) ||
(this.access.modifyingsubmissionallowed && this.submission))) {
const params = {
module: this.module,
access: this.access,
courseId: this.courseId,
submissionId: this.submission && this.submission.id
};
this.navCtrl.push('AddonModWorkshopEditSubmissionPage', params);
}
if (task.code == 'submit') {
this.gotoSubmit();
} else if (task.link) {
this.utils.openInBrowser(task.link);
}
}
/**
* Run task link on current phase.
*
* @param {string} taskCode Code related to the task to run.
* Go to submit page.
*/
runTaskByCode(taskCode: string): void {
const task = this.workshopHelper.getTask(this.phases[this.workshop.phase].tasks, taskCode);
gotoSubmit(): void {
if (this.canSubmit && ((this.access.creatingsubmissionallowed && !this.submission) ||
(this.access.modifyingsubmissionallowed && this.submission))) {
const params = {
module: this.module,
access: this.access,
courseId: this.courseId,
submissionId: this.submission && this.submission.id
};
return task ? this.runTask(task) : null;
this.navCtrl.push('AddonModWorkshopEditSubmissionPage', params);
}
}
/**
* Select Phase to be shown.
* View Phase info.
*/
selectPhase(): void {
viewPhaseInfo(): void {
if (this.phases) {
const modal = this.modalCtrl.create('AddonModWorkshopPhaseSelectorPage', {
const modal = this.modalCtrl.create('AddonModWorkshopPhaseInfoPage', {
phases: this.utils.objectToArray(this.phases),
selected: this.selectedPhase,
workshopPhase: this.workshop.phase
workshopPhase: this.workshop.phase,
externalUrl: this.externalUrl
});
modal.onDidDismiss((phase) => {
// Add data to search object.
typeof phase != 'undefined' && this.switchPhase(phase);
modal.onDidDismiss((goSubmit) => {
goSubmit && this.gotoSubmit();
});
modal.present();
}
@ -442,16 +422,6 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
return Promise.all(promises);
}
/**
* Switch shown phase.
*
* @param {number} phase Selected phase.
*/
switchPhase(phase: number): void {
this.selectedPhase = phase;
this.page = 0;
}
/**
* Performs the sync of the activity.
*

View File

@ -34,7 +34,9 @@
<core-local-file *ngIf="attachment.name" [file]="attachment"></core-local-file>
</ion-item>
<ion-item text-wrap *ngIf="viewDetails && submission.feedbackauthor">
<img [src]="evaluateByProfile && evaluateByProfile.profileimageurl" core-external-content core-user-link [courseId]="courseId" [userId]="evaluateByProfile && evaluateByProfile.id" [alt]="'core.pictureof' | translate:{$a: evaluateByProfile && evaluateByProfile.fullname}" role="presentation" onError="this.src='assets/img/user-avatar.png'"/>
<ion-avatar item-start *ngIf="evaluateByProfile">
<img [src]="evaluateByProfile.profileimageurl" core-external-content core-user-link [courseId]="courseId" [userId]="evaluateByProfile.id" [alt]="'core.pictureof' | translate:{$a: evaluateByProfile.fullname}" role="presentation" onError="this.src='assets/img/user-avatar.png'">
</ion-avatar>
<h2 *ngIf="evaluateByProfile && evaluateByProfile.fullname">{{ 'addon.mod_workshop.feedbackby' | translate : {$a: evaluateByProfile.fullname} }}</h2>
<core-format-text [text]="submission.feedbackauthor"></core-format-text>

View File

@ -35,7 +35,6 @@
"publishsubmission_help": "Published submissions are available to the others when the workshop is closed.",
"reassess": "Re-assess",
"receivedgrades": "Grades received",
"selectphase": "Select phase",
"submissionattachment": "Attachment",
"submissioncontent": "Submission content",
"submissiondeleteconfirm": "Are you sure you want to delete the following submission?",
@ -50,6 +49,7 @@
"switchphase30": "Switch to the assessment phase",
"switchphase40": "Switch to the evaluation phase",
"switchphase50": "Close workshop",
"userplan": "Workshop planner",
"userplancurrentphase": "Current phase",
"warningassessmentmodified": "The submission was modified on the site.",
"warningsubmissionmodified": "The assessment was modified on the site.",

View File

@ -1,6 +1,6 @@
<ion-header>
<ion-navbar core-back-button>
<ion-title>{{ 'addon.mod_workshop.selectphase' | translate }}</ion-title>
<ion-title>{{ 'addon.mod_workshop.userplan' | translate }}</ion-title>
<ion-buttons end>
<button ion-button icon-only (click)="closeModal()" [attr.aria-label]="'core.close' | translate">
<ion-icon name="close"></ion-icon>
@ -9,17 +9,27 @@
</ion-navbar>
</ion-header>
<ion-content>
<ion-list radio-group [(ngModel)]="selected" (ionChange)="switchPhase()">
<ion-list>
<ng-container *ngFor="let phase of phases">
<ion-item *ngIf="workshopPhase >= phase.code || phase.tasks.length || phase.switchUrl">
<ion-label>{{ phase.title }}
<p text-wrap *ngIf="workshopPhase == phase.code">{{ 'addon.mod_workshop.userplancurrentphase' | translate }}</p>
</ion-label>
<ion-radio [value]="phase.code"></ion-radio>
</ion-item>
<ion-item *ngIf="!(workshopPhase >= phase.code || phase.tasks.length || phase.switchUrl)">
{{ phase.title }}
</ion-item>
<ion-item-divider color="light" [class.core-workshop-phase-selected]="workshopPhase == phase.code">
<h2>{{ phase.title }}</h2>
<p text-wrap *ngIf="workshopPhase == phase.code">{{ 'addon.mod_workshop.userplancurrentphase' | translate }}</p>
</ion-item-divider>
<a ion-item text-wrap *ngIf="phase.switchUrl" [href]="phase.switchUrl" detail-none>
<ion-icon item-start name="swap"></ion-icon>
{{ 'addon.mod_workshop.switchphase' + phase.code | translate }}
<ion-icon item-end name="open"></ion-icon>
</a>
<a ion-item text-wrap *ngFor="let task of phase.tasks" [class.item-dimmed]="phase.code != workshopPhase" (click)="runTask(task)" detail-none>
<ion-icon item-start name="radio-button-off" *ngIf="task.completed == null"></ion-icon>
<ion-icon item-start name="close-circle" color="danger" *ngIf="task.completed == ''"></ion-icon>
<ion-icon item-start name="information-circle" color="info" *ngIf="task.completed == 'info'"></ion-icon>
<ion-icon item-start name="checkmark-circle" color="success" *ngIf="task.completed == '1'"></ion-icon>
<h2 text-wrap>{{task.title}}</h2>
<p *ngIf="task.details"><core-format-text [text]="task.details"></core-format-text></p>
<ion-icon item-end *ngIf="task.link && task.code != 'submit'" name="open"></ion-icon>
</a>
</ng-container>
</ion-list>
</ion-content>

View File

@ -16,18 +16,18 @@ import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreDirectivesModule } from '@directives/directives.module';
import { AddonModWorkshopPhaseSelectorPage } from './phase';
import { AddonModWorkshopPhaseInfoPage } from './phase';
import { CoreCompileHtmlComponentModule } from '@core/compile/components/compile-html/compile-html.module';
@NgModule({
declarations: [
AddonModWorkshopPhaseSelectorPage,
AddonModWorkshopPhaseInfoPage,
],
imports: [
CoreDirectivesModule,
CoreCompileHtmlComponentModule,
IonicPageModule.forChild(AddonModWorkshopPhaseSelectorPage),
IonicPageModule.forChild(AddonModWorkshopPhaseInfoPage),
TranslateModule.forChild()
],
})
export class AddonModWorkshopPhaseSelectorPageModule {}
export class AddonModWorkshopPhaseInfoPageModule {}

View File

@ -0,0 +1,22 @@
page-addon-mod-workshop-phase-info {
.core-workshop-phase-selected {
background-color: $white;
@include ltr() {
border-left: 5px solid $core-splitview-selected;
}
@include rtl() {
border-right: 5px solid $core-splitview-selected;
}
&.item-md {
@include padding(null, null, null, $item-md-padding-start - 5px);
}
&.item-ios {
@include padding(null, null, null, $item-ios-padding-start - 5px);
}
&.item-wp {
@include padding(null, null, null, $item-wp-padding-start - 5px);
}
}
}

View File

@ -14,26 +14,38 @@
import { Component } from '@angular/core';
import { IonicPage, NavParams, ViewController } from 'ionic-angular';
import { CoreUtilsProvider } from '@providers/utils/utils';
/**
* Page that displays the phase selector modal.
* Page that displays the phase info modal.
*/
@IonicPage({ segment: 'addon-mod-workshop-phase-selector' })
@IonicPage({ segment: 'addon-mod-workshop-phase-info' })
@Component({
selector: 'page-addon-mod-workshop-phase-selector',
selector: 'page-addon-mod-workshop-phase-info',
templateUrl: 'phase.html',
})
export class AddonModWorkshopPhaseSelectorPage {
selected: number;
export class AddonModWorkshopPhaseInfoPage {
phases: any;
workshopPhase: number;
protected original: number;
constructor(params: NavParams, private viewCtrl: ViewController) {
this.selected = params.get('selected');
this.original = this.selected;
constructor(params: NavParams, private viewCtrl: ViewController, private utils: CoreUtilsProvider) {
this.phases = params.get('phases');
this.workshopPhase = params.get('workshopPhase');
const externalUrl = params.get('externalUrl');
// Treat phases.
for (const x in this.phases) {
this.phases[x].tasks.forEach((task) => {
if (!task.link && (task.code == 'examples' || task.code == 'prepareexamples')) {
// Add links to manage examples.
task.link = externalUrl;
}
});
const action = this.phases[x].actions.find((action) => {
return action.url && action.type == 'switchphase';
});
this.phases[x].switchUrl = action ? action.url : '';
}
}
/**
@ -44,13 +56,16 @@ export class AddonModWorkshopPhaseSelectorPage {
}
/**
* Select phase.
* Open task.
*
* @param {any} task Task to be done.
*/
switchPhase(): void {
// This is a quick hack to avoid the first switch phase call done just when opening the modal.
if (this.original != this.selected) {
this.viewCtrl.dismiss(this.selected);
runTask(task: any): void {
if (task.code == 'submit') {
// This will close the modal and go to the submit.
this.viewCtrl.dismiss(true);
} else if (task.link) {
this.utils.openInBrowser(task.link);
}
this.original = null;
}
}