From b25e5b3ec1bf791478c5df9b7a4b2eb5cde465c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 31 May 2018 16:58:35 +0200 Subject: [PATCH] MOBILE-2354 workshop: Submission component --- .../addon-mod-assign-feedback-comments.html | 2 +- .../workshop/components/components.module.ts | 9 +- .../mod/workshop/components/index/index.html | 38 +++-- .../components/submission/submission.html | 82 +++++++++++ .../components/submission/submission.scss | 35 +++++ .../components/submission/submission.ts | 132 ++++++++++++++++++ .../components/list/addon-notes-list.html | 2 +- src/app/app.ios.scss | 8 ++ src/app/app.md.scss | 9 ++ src/app/app.wp.scss | 8 ++ 10 files changed, 306 insertions(+), 19 deletions(-) create mode 100644 src/addon/mod/workshop/components/submission/submission.html create mode 100644 src/addon/mod/workshop/components/submission/submission.scss create mode 100644 src/addon/mod/workshop/components/submission/submission.ts diff --git a/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html b/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html index 3732d55bb..62f3857f9 100644 --- a/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html +++ b/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html @@ -11,7 +11,7 @@ - + {{ 'core.notsent' | translate }} diff --git a/src/addon/mod/workshop/components/components.module.ts b/src/addon/mod/workshop/components/components.module.ts index 6111f4bb4..cdcf3f5e6 100644 --- a/src/addon/mod/workshop/components/components.module.ts +++ b/src/addon/mod/workshop/components/components.module.ts @@ -18,12 +18,15 @@ import { IonicModule } from 'ionic-angular'; import { TranslateModule } from '@ngx-translate/core'; import { CoreComponentsModule } from '@components/components.module'; import { CoreDirectivesModule } from '@directives/directives.module'; +import { CorePipesModule } from '@pipes/pipes.module'; import { CoreCourseComponentsModule } from '@core/course/components/components.module'; import { AddonModWorkshopIndexComponent } from './index/index'; +import { AddonModWorkshopSubmissionComponent } from './submission/submission'; @NgModule({ declarations: [ - AddonModWorkshopIndexComponent + AddonModWorkshopIndexComponent, + AddonModWorkshopSubmissionComponent ], imports: [ CommonModule, @@ -31,12 +34,14 @@ import { AddonModWorkshopIndexComponent } from './index/index'; TranslateModule.forChild(), CoreComponentsModule, CoreDirectivesModule, + CorePipesModule, CoreCourseComponentsModule ], providers: [ ], exports: [ - AddonModWorkshopIndexComponent + AddonModWorkshopIndexComponent, + AddonModWorkshopSubmissionComponent ], entryComponents: [ AddonModWorkshopIndexComponent diff --git a/src/addon/mod/workshop/components/index/index.html b/src/addon/mod/workshop/components/index/index.html index 15f9ed06c..c8a039a5b 100644 --- a/src/addon/mod/workshop/components/index/index.html +++ b/src/addon/mod/workshop/components/index/index.html @@ -14,7 +14,7 @@ - +

{{ phases[selectedPhase].title }}

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

@@ -27,8 +27,8 @@
- - + + @@ -56,13 +56,15 @@ - +

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

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

- + + +
@@ -89,15 +91,17 @@
- +

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

- + + +
- +

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

@@ -115,7 +119,7 @@
- +

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

@@ -129,16 +133,18 @@
- +

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

- + + +
- +

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

@@ -153,9 +159,11 @@ - + + + - + - diff --git a/src/addon/mod/workshop/components/submission/submission.html b/src/addon/mod/workshop/components/submission/submission.html new file mode 100644 index 000000000..b2cda93ed --- /dev/null +++ b/src/addon/mod/workshop/components/submission/submission.html @@ -0,0 +1,82 @@ + +
+ + + + +

{{submission.title}}

+

{{profile.fullname}}

+

+ {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.submissiongrade}} +

+

+ {{ 'addon.mod_workshop.gradeover' | translate }}: {{submission.submissiongradeover}} +

+

+ {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}} +

+ + {{ 'core.notsent' | translate }} + + + {{submission.timemodified | coreDateDayOrTime}} + {{ 'core.notsent' | translate }} + {{ 'core.deletedoffline' | translate }} + +
+ + + + + + + + + + + + +

{{ 'addon.mod_workshop.feedbackby' | translate : {$a: evaluateByProfile.fullname} }}

+ +
+ + + +
+ + + + + + +

{{submission.title}}

+

{{profile.fullname}}

+

+ {{ 'addon.mod_workshop.receivedgrades' | translate }}: {{submission.reviewedbycount}} / {{submission.reviewedby.length}} +

+

+ {{ 'addon.mod_workshop.givengrades' | translate }}: {{submission.reviewerofcount}} / {{submission.reviewerof.length}} +

+

+ {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.submissiongrade}} +

+

+ {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.submissiongradeover}} +

+

+ {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}} +

+ + {{ 'addon.mod_workshop.assessedsubmission' | translate }} + {{ 'addon.mod_workshop.notassessed' | translate }} + + + {{submission.timemodified | coreDateDayOrTime}} +
{{ 'core.notsent' | translate }}
+
{{ 'core.deletedoffline' | translate }}
+
+
+
diff --git a/src/addon/mod/workshop/components/submission/submission.scss b/src/addon/mod/workshop/components/submission/submission.scss new file mode 100644 index 000000000..9c1f97329 --- /dev/null +++ b/src/addon/mod/workshop/components/submission/submission.scss @@ -0,0 +1,35 @@ +addon-mod-workshop-submission { + .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-submission { + .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; + } +} \ No newline at end of file diff --git a/src/addon/mod/workshop/components/submission/submission.ts b/src/addon/mod/workshop/components/submission/submission.ts new file mode 100644 index 000000000..eb6220555 --- /dev/null +++ b/src/addon/mod/workshop/components/submission/submission.ts @@ -0,0 +1,132 @@ +// (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 { AddonModWorkshopProvider } from '../../providers/workshop'; +import { AddonModWorkshopHelperProvider } from '../../providers/helper'; +import { AddonModWorkshopOfflineProvider } from '../../providers/offline'; + +/** + * Component that displays workshop submission. + */ +@Component({ + selector: 'addon-mod-workshop-submission', + templateUrl: 'submission.html', +}) +export class AddonModWorkshopSubmissionComponent implements OnInit { + @Input() submission: any; + @Input() module: any; + @Input() workshop: any; + @Input() access: any; + @Input() courseId: number; + @Input() assessment?: any; + @Input() summary?: boolean; + + component = AddonModWorkshopProvider.COMPONENT; + componentId: number; + userId: number; + loaded = false; + offline = false; + viewDetails = false; + profile: any; + showGrade: any; + evaluateByProfile: any; + + constructor(private workshopOffline: AddonModWorkshopOfflineProvider, private workshopHelper: AddonModWorkshopHelperProvider, + private navCtrl: NavController, private userProvider: CoreUserProvider, sitesProvider: CoreSitesProvider) { + this.userId = sitesProvider.getCurrentSiteUserId(); + this.showGrade = this.workshopHelper.showGrade; + } + + /** + * Component being initialized. + */ + ngOnInit(): void { + this.componentId = this.module.instance; + this.userId = this.submission.authorid || this.submission.userid || this.userId; + this.submission.title = this.submission.title || this.submission.submissiontitle; + this.submission.timemodified = this.submission.timemodified || this.submission.submissionmodified; + this.submission.id = this.submission.id || this.submission.submissionid; + + if (this.workshop.phase == AddonModWorkshopProvider.PHASE_ASSESSMENT) { + if (this.submission.reviewedby && this.submission.reviewedby.length) { + this.submission.reviewedbycount = this.submission.reviewedby.reduce((a, b) => { + return a + (b.grade ? 1 : 0); + }, 0); + } + + if (this.submission.reviewerof && this.submission.reviewerof.length) { + this.submission.reviewerofcount = this.submission.reviewerof.reduce((a, b) => { + return a + (b.grade ? 1 : 0); + }, 0); + } + } + + const promises = []; + + this.offline = (this.submission && this.submission.offline) || (this.assessment && this.assessment.offline); + + if (this.submission.id) { + promises.push(this.workshopOffline.getEvaluateSubmission(this.workshop.id, this.submission.id) + .then((offlineSubmission) => { + this.submission.submissiongradeover = offlineSubmission.gradeover; + this.offline = true; + }).catch(() => { + // Ignore errors. + })); + } + + if (this.userId) { + promises.push(this.userProvider.getProfile(this.userId, this.courseId, true).then((profile) => { + this.profile = profile; + })); + } + + this.viewDetails = !this.summary && this.workshop.phase == AddonModWorkshopProvider.PHASE_CLOSED && + this.navCtrl.getActive().name !== 'AddonModWorkshopSubmissionPage'; + + if (this.viewDetails && this.submission.gradeoverby) { + promises.push(this.userProvider.getProfile(this.submission.gradeoverby, this.courseId, true).then((profile) => { + this.evaluateByProfile = profile; + })); + } + + Promise.all(promises).finally(() => { + this.loaded = true; + }); + } + + /** + * Navigate to the submission. + */ + gotoSubmission(): void { + if (this.submission.timemodified) { + const params = { + module: this.module, + workshop: this.workshop, + access: this.access, + courseId: this.courseId, + profile: this.profile, + submission: this.submission, + assessment: this.assessment, + submissionId: this.submission.id + }; + + this.navCtrl.push('AddonModWorkshopSubmissionPage', params); + } + } +} diff --git a/src/addon/notes/components/list/addon-notes-list.html b/src/addon/notes/components/list/addon-notes-list.html index 5b2fd8ebc..21f24aba2 100644 --- a/src/addon/notes/components/list/addon-notes-list.html +++ b/src/addon/notes/components/list/addon-notes-list.html @@ -32,7 +32,7 @@

{{note.userfullname}}

{{note.lastmodified | coreDateDayOrTime}}

-

{{ 'core.notsent' | translate }}

+

{{ 'core.notsent' | translate }}

diff --git a/src/app/app.ios.scss b/src/app/app.ios.scss index a7410863d..58b921be0 100644 --- a/src/app/app.ios.scss +++ b/src/app/app.ios.scss @@ -111,3 +111,11 @@ padding-left: 15px * $i + $item-ios-padding-start; } } + +// Recover borders on items inside cards. +.card-ios.with-borders .item-ios.item-block .item-inner { + border-bottom: $hairlines-width solid $list-ios-border-color; +} +.card-ios.with-borders .item-ios:last-child .item-inner { + border-bottom: 0; +} \ No newline at end of file diff --git a/src/app/app.md.scss b/src/app/app.md.scss index 866b98788..e39f28792 100644 --- a/src/app/app.md.scss +++ b/src/app/app.md.scss @@ -112,3 +112,12 @@ padding-left: 15px * $i + $item-md-padding-start; } } + + +// Recover borders on items inside cards. +.card-md.with-borders .item-md.item-block .item-inner { + border-bottom: 1px solid $list-md-border-color; +} +.card-md.with-borders .item-md:last-child .item-inner { + border-bottom: 0; +} \ No newline at end of file diff --git a/src/app/app.wp.scss b/src/app/app.wp.scss index 0e7342032..eda1dc65c 100644 --- a/src/app/app.wp.scss +++ b/src/app/app.wp.scss @@ -47,3 +47,11 @@ padding-left: 15px * $i + $item-wp-padding-start; } } + +// Recover borders on items inside cards. +.card-wp.with-borders .item-wp.item-block .item-inner { + border-bottom: 1px solid $list-wp-border-color; +} +.card-wp.with-borders .item-wp:last-child .item-inner { + border-bottom: 0; +} \ No newline at end of file