Merge pull request #1438 from dpalou/MOBILE-2503

Mobile 2503
main
Juan Leyva 2018-08-21 14:29:13 +01:00 committed by GitHub
commit a30bd282de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 7 deletions

View File

@ -23,7 +23,7 @@
<ion-item-divider *ngIf="item.typ == 'pagebreak'" color="light"></ion-item-divider> <ion-item-divider *ngIf="item.typ == 'pagebreak'" color="light"></ion-item-divider>
<ion-item text-wrap *ngIf="item.typ != 'pagebreak'" [color]="item.dependitem > 0 ? 'light' : ''"> <ion-item text-wrap *ngIf="item.typ != 'pagebreak'" [color]="item.dependitem > 0 ? 'light' : ''">
<h2 *ngIf="item.name" [core-mark-required]="item.required"> <h2 *ngIf="item.name" [core-mark-required]="item.required">
<span *ngIf="item.itemnumber">{{item.itemnumber}}. </span><core-format-text [component]="component" [componentId]="componentId" [text]="item.name"></core-format-text> <span *ngIf="feedback.autonumbering && item.itemnumber">{{item.itemnumber}}. </span><core-format-text [component]="component" [componentId]="componentId" [text]="item.name"></core-format-text>
</h2> </h2>
<p *ngIf="item.submittedValue"><core-format-text [component]="component" [componentId]="componentId" [text]=" item.submittedValue"></core-format-text></p> <p *ngIf="item.submittedValue"><core-format-text [component]="component" [componentId]="componentId" [text]=" item.submittedValue"></core-format-text></p>
</ion-item> </ion-item>

View File

@ -30,7 +30,9 @@ import { CoreTextUtilsProvider } from '@providers/utils/text';
export class AddonModFeedbackAttemptPage { export class AddonModFeedbackAttemptPage {
protected feedbackId: number; protected feedbackId: number;
protected courseId: number;
feedback: any;
attempt: any; attempt: any;
items: any; items: any;
componentId: number; componentId: number;
@ -41,6 +43,7 @@ export class AddonModFeedbackAttemptPage {
protected domUtils: CoreDomUtilsProvider, protected feedbackHelper: AddonModFeedbackHelperProvider, protected domUtils: CoreDomUtilsProvider, protected feedbackHelper: AddonModFeedbackHelperProvider,
protected textUtils: CoreTextUtilsProvider) { protected textUtils: CoreTextUtilsProvider) {
this.feedbackId = navParams.get('feedbackId') || 0; this.feedbackId = navParams.get('feedbackId') || 0;
this.courseId = navParams.get('courseId');
this.attempt = navParams.get('attempt') || false; this.attempt = navParams.get('attempt') || false;
this.componentId = navParams.get('moduleId'); this.componentId = navParams.get('moduleId');
} }
@ -58,7 +61,12 @@ export class AddonModFeedbackAttemptPage {
* @return {Promise<any>} Promise resolved when done. * @return {Promise<any>} Promise resolved when done.
*/ */
fetchData(): Promise<any> { fetchData(): Promise<any> {
return this.feedbackProvider.getItems(this.feedbackId).then((items) => { // Get the feedback to be able to now if questions should be autonumbered.
return this.feedbackProvider.getFeedbackById(this.courseId, this.feedbackId).then((feedback) => {
this.feedback = feedback;
return this.feedbackProvider.getItems(this.feedbackId);
}).then((items) => {
// Add responses and format items. // Add responses and format items.
this.items = items.items.map((item) => { this.items = items.items.map((item) => {
if (item.typ == 'label') { if (item.typ == 'label') {
@ -67,7 +75,6 @@ export class AddonModFeedbackAttemptPage {
for (const x in this.attempt.responses) { for (const x in this.attempt.responses) {
if (this.attempt.responses[x].id == item.id) { if (this.attempt.responses[x].id == item.id) {
item.submittedValue = this.attempt.responses[x].printval; item.submittedValue = this.attempt.responses[x].printval;
delete this.attempt.responses[x];
break; break;
} }
} }

View File

@ -16,7 +16,7 @@
<ion-item-divider *ngIf="item.typ == 'pagebreak'" color="light"></ion-item-divider> <ion-item-divider *ngIf="item.typ == 'pagebreak'" color="light"></ion-item-divider>
<ion-item text-wrap *ngIf="item.typ != 'pagebreak'" [color]="item.dependitem > 0 ? 'light' : ''" [class.core-danger-item]="item.isEmpty || item.hasError"> <ion-item text-wrap *ngIf="item.typ != 'pagebreak'" [color]="item.dependitem > 0 ? 'light' : ''" [class.core-danger-item]="item.isEmpty || item.hasError">
<ion-label *ngIf="item.name" [core-mark-required]="item.required" stacked> <ion-label *ngIf="item.name" [core-mark-required]="item.required" stacked>
<span *ngIf="item.itemnumber">{{item.itemnumber}}. </span> <span *ngIf="feedback.autonumbering && item.itemnumber">{{item.itemnumber}}. </span>
<core-format-text [component]="component" [componentId]="componentId" [text]="item.name"></core-format-text> <core-format-text [component]="component" [componentId]="componentId" [text]="item.name"></core-format-text>
</ion-label> </ion-label>
<div item-content class="addon-mod_feedback-form-content" *ngIf="item.template"> <div item-content class="addon-mod_feedback-form-content" *ngIf="item.template">

View File

@ -38,7 +38,7 @@
<ion-item-divider color="light"> <ion-item-divider color="light">
{{ 'addon.mod_feedback.anonymous_entries' |translate : {$a: anonResponses.total } }} {{ 'addon.mod_feedback.anonymous_entries' |translate : {$a: anonResponses.total } }}
</ion-item-divider> </ion-item-divider>
<a *ngFor="let attempt of anonResponses.attempts" ion-item text-wrap (click)="gotoAttempt(attempt)"> <a *ngFor="let attempt of anonResponses.attempts" ion-item text-wrap (click)="gotoAttempt(attempt)" [class.core-split-item-selected]="attempt.id == attemptId">
<h2>{{ 'addon.mod_feedback.response_nr' |translate }}: {{attempt.number}}</h2> <h2>{{ 'addon.mod_feedback.response_nr' |translate }}: {{attempt.number}}</h2>
</a> </a>
<ion-item padding text-center *ngIf="anonResponses.canLoadMore"> <ion-item padding text-center *ngIf="anonResponses.canLoadMore">

View File

@ -165,7 +165,8 @@ export class AddonModFeedbackRespondentsPage {
attemptId: attempt.id, attemptId: attempt.id,
attempt: attempt, attempt: attempt,
feedbackId: this.feedbackId, feedbackId: this.feedbackId,
moduleId: this.moduleId moduleId: this.moduleId,
courseId: this.courseId
}); });
} }

View File

@ -70,7 +70,8 @@ export class AddonModFeedbackShowEntriesLinkHandler extends CoreContentLinksHand
moduleId: module.id, moduleId: module.id,
attempt: attempt, attempt: attempt,
attemptId: attempt.id, attemptId: attempt.id,
feedbackId: module.instance feedbackId: module.instance,
courseId: module.course
}; };
return this.linkHelper.goInSite(navCtrl, 'AddonModFeedbackAttemptPage', stateParams, siteId); return this.linkHelper.goInSite(navCtrl, 'AddonModFeedbackAttemptPage', stateParams, siteId);