MOBILE-3939 feedback: rename respondents
parent
4fb700b985
commit
00a12df79b
|
@ -72,7 +72,7 @@
|
|||
</ion-select-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<ion-item class="ion-text-wrap" (click)="openRespondents()" [class.hide-detail]="!(access.canviewreports && completedCount > 0)"
|
||||
<ion-item class="ion-text-wrap" (click)="openAttempts()" [class.hide-detail]="!(access.canviewreports && completedCount > 0)"
|
||||
detail="true" [button]="access.canviewreports && completedCount > 0">
|
||||
<ion-label>
|
||||
<h2>{{ 'addon.mod_feedback.completed_feedbacks' | translate }}</h2>
|
||||
|
|
|
@ -400,15 +400,15 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
}
|
||||
|
||||
/**
|
||||
* Open respondents page.
|
||||
* Open attempts page.
|
||||
*/
|
||||
openRespondents(): void {
|
||||
openAttempts(): void {
|
||||
if (!this.access!.canviewreports || this.completedCount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/respondents`,
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`,
|
||||
{
|
||||
params: {
|
||||
group: this.group,
|
||||
|
|
|
@ -17,7 +17,7 @@ import { RouterModule, Routes } from '@angular/router';
|
|||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { AddonModFeedbackComponentsModule } from './components/components.module';
|
||||
import { AddonModFeedbackIndexPage } from './pages/index/index';
|
||||
import { AddonModFeedbackRespondentsPage } from './pages/respondents/respondents';
|
||||
import { AddonModFeedbackAttemptsPage } from './pages/attempts/attempts';
|
||||
import { conditionalRoutes } from '@/app/app-routing.module';
|
||||
import { CoreScreen } from '@services/screen';
|
||||
|
||||
|
@ -40,11 +40,11 @@ const commonRoutes: Routes = [
|
|||
const mobileRoutes: Routes = [
|
||||
...commonRoutes,
|
||||
{
|
||||
path: ':courseId/:cmId/respondents',
|
||||
component: AddonModFeedbackRespondentsPage,
|
||||
path: ':courseId/:cmId/attempts',
|
||||
component: AddonModFeedbackAttemptsPage,
|
||||
},
|
||||
{
|
||||
path: ':courseId/:cmId/respondents/attempt/:attemptId',
|
||||
path: ':courseId/:cmId/attempts/:attemptId',
|
||||
loadChildren: () => import('./pages/attempt/attempt.module').then(m => m.AddonModFeedbackAttemptPageModule),
|
||||
},
|
||||
];
|
||||
|
@ -52,11 +52,11 @@ const mobileRoutes: Routes = [
|
|||
const tabletRoutes: Routes = [
|
||||
...commonRoutes,
|
||||
{
|
||||
path: ':courseId/:cmId/respondents',
|
||||
component: AddonModFeedbackRespondentsPage,
|
||||
path: ':courseId/:cmId/attempts',
|
||||
component: AddonModFeedbackAttemptsPage,
|
||||
children: [
|
||||
{
|
||||
path: 'attempt/:attemptId',
|
||||
path: ':attemptId',
|
||||
loadChildren: () => import('./pages/attempt/attempt.module').then(m => m.AddonModFeedbackAttemptPageModule),
|
||||
},
|
||||
],
|
||||
|
@ -76,7 +76,7 @@ const routes: Routes = [
|
|||
],
|
||||
declarations: [
|
||||
AddonModFeedbackIndexPage,
|
||||
AddonModFeedbackRespondentsPage,
|
||||
AddonModFeedbackAttemptsPage,
|
||||
],
|
||||
})
|
||||
export class AddonModFeedbackLazyModule {}
|
||||
|
|
|
@ -29,14 +29,15 @@
|
|||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ng-container *ngIf="responses.responses.total > 0">
|
||||
<ng-container *ngIf="attempts.identifiable.total > 0">
|
||||
<ion-item-divider>
|
||||
<ion-label>
|
||||
<h2>{{ 'addon.mod_feedback.non_anonymous_entries' | translate : {$a: responses.responses.total } }}</h2>
|
||||
<h2>{{ 'addon.mod_feedback.non_anonymous_entries' | translate : {$a: attempts.identifiable.total } }}
|
||||
</h2>
|
||||
</ion-label>
|
||||
</ion-item-divider>
|
||||
<ion-item *ngFor="let attempt of responses.responses.attempts" class="ion-text-wrap" button detail="true"
|
||||
(click)="responses.select(attempt)" [attr.aria-current]="responses.getItemAriaCurrent(attempt)">
|
||||
<ion-item *ngFor="let attempt of attempts.identifiable.items" class="ion-text-wrap" button detail="true"
|
||||
(click)="attempts.select(attempt)" [attr.aria-current]="attempts.getItemAriaCurrent(attempt)">
|
||||
<core-user-avatar [user]="attempt" slot="start"></core-user-avatar>
|
||||
<ion-label>
|
||||
<p class="item-heading">{{ attempt.fullname }}</p>
|
||||
|
@ -45,36 +46,36 @@
|
|||
</ion-item>
|
||||
|
||||
<!-- Button and spinner to show more attempts. -->
|
||||
<ion-button *ngIf="responses.responses.canLoadMore && !loadingMore" class="ion-margin" expand="block"
|
||||
<ion-button *ngIf="attempts.identifiable.canLoadMore && !loadingMore" class="ion-margin" expand="block"
|
||||
(click)="loadAttempts()">
|
||||
{{ 'core.loadmore' | translate }}
|
||||
</ion-button>
|
||||
<ion-item *ngIf="responses.responses.canLoadMore && loadingMore" class="ion-text-center">
|
||||
<ion-item *ngIf="attempts.identifiable.canLoadMore && loadingMore" class="ion-text-center">
|
||||
<ion-label>
|
||||
<ion-spinner [attr.aria-label]="'core.loading' | translate"></ion-spinner>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="responses.anonResponses.total > 0">
|
||||
<ng-container *ngIf="attempts.anonymous.total > 0">
|
||||
<ion-item-divider>
|
||||
<ion-label>
|
||||
<h2>{{ 'addon.mod_feedback.anonymous_entries' |translate : {$a: responses.anonResponses.total } }}</h2>
|
||||
<h2>{{ 'addon.mod_feedback.anonymous_entries' |translate : {$a: attempts.anonymous.total } }}</h2>
|
||||
</ion-label>
|
||||
</ion-item-divider>
|
||||
<ion-item *ngFor="let attempt of responses.anonResponses.attempts" class="ion-text-wrap" button detail="true"
|
||||
(click)="responses.select(attempt)" [attr.aria-current]="responses.getItemAriaCurrent(attempt)">
|
||||
<ion-item *ngFor="let attempt of attempts.anonymous.items" class="ion-text-wrap" button detail="true"
|
||||
(click)="attempts.select(attempt)" [attr.aria-current]="attempts.getItemAriaCurrent(attempt)">
|
||||
<ion-label>
|
||||
<h2>{{ 'addon.mod_feedback.response_nr' |translate }}: {{attempt.number}}</h2>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<!-- Button and spinner to show more attempts. -->
|
||||
<ion-button *ngIf="responses.anonResponses.canLoadMore && !loadingMore" class="ion-margin" expand="block"
|
||||
<ion-button *ngIf="attempts.anonymous.canLoadMore && !loadingMore" class="ion-margin" expand="block"
|
||||
(click)="loadAttempts()">
|
||||
{{ 'core.loadmore' | translate }}
|
||||
</ion-button>
|
||||
<ion-item *ngIf="responses.anonResponses.canLoadMore && loadingMore" class="ion-text-center">
|
||||
<ion-item *ngIf="attempts.anonymous.canLoadMore && loadingMore" class="ion-text-center">
|
||||
<ion-label>
|
||||
<ion-spinner [attr.aria-label]="'core.loading' | translate"></ion-spinner>
|
||||
</ion-label>
|
|
@ -30,13 +30,13 @@ import {
|
|||
import { AddonModFeedbackHelper, AddonModFeedbackResponsesAnalysis } from '../../services/feedback-helper';
|
||||
|
||||
/**
|
||||
* Page that displays feedback respondents.
|
||||
* Page that displays feedback attempts.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'page-addon-mod-feedback-respondents',
|
||||
templateUrl: 'respondents.html',
|
||||
selector: 'page-addon-mod-feedback-attempts',
|
||||
templateUrl: 'attempts.html',
|
||||
})
|
||||
export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
||||
export class AddonModFeedbackAttemptsPage implements AfterViewInit {
|
||||
|
||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||
|
||||
|
@ -45,7 +45,7 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
|||
protected page = 0;
|
||||
protected feedback?: AddonModFeedbackWSFeedback;
|
||||
|
||||
responses: AddonModFeedbackResponsesManager;
|
||||
attempts: AddonModFeedbackAttemptsManager;
|
||||
selectedGroup!: number;
|
||||
groupInfo?: CoreGroupInfo;
|
||||
loaded = false;
|
||||
|
@ -54,7 +54,7 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
|||
constructor(
|
||||
route: ActivatedRoute,
|
||||
) {
|
||||
this.responses = new AddonModFeedbackResponsesManager(
|
||||
this.attempts = new AddonModFeedbackAttemptsManager(
|
||||
route.component,
|
||||
);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
|||
|
||||
await this.fetchData();
|
||||
|
||||
this.responses.start(this.splitView);
|
||||
this.attempts.start(this.splitView);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
|||
*/
|
||||
async fetchData(refresh: boolean = false): Promise<void> {
|
||||
this.page = 0;
|
||||
this.responses.resetItems();
|
||||
this.attempts.resetItems();
|
||||
|
||||
try {
|
||||
this.feedback = await AddonModFeedback.getFeedback(this.courseId, this.cmId);
|
||||
|
@ -121,17 +121,17 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
|||
} else {
|
||||
this.selectedGroup = groupId;
|
||||
this.page = 0;
|
||||
this.responses.resetItems();
|
||||
this.attempts.resetItems();
|
||||
}
|
||||
|
||||
try {
|
||||
const responses = await AddonModFeedbackHelper.getResponsesAnalysis(this.feedback!.id, {
|
||||
const attempts = await AddonModFeedbackHelper.getResponsesAnalysis(this.feedback!.id, {
|
||||
groupId: this.selectedGroup,
|
||||
page: this.page,
|
||||
cmId: this.cmId,
|
||||
});
|
||||
|
||||
this.responses.setResponses(responses);
|
||||
this.attempts.setAttempts(attempts);
|
||||
} finally {
|
||||
this.loadingMore = false;
|
||||
this.loaded = true;
|
||||
|
@ -183,16 +183,16 @@ type EntryItem = AddonModFeedbackWSAttempt | AddonModFeedbackWSAnonAttempt;
|
|||
/**
|
||||
* Entries manager.
|
||||
*/
|
||||
class AddonModFeedbackResponsesManager extends CorePageItemsListManager<EntryItem> {
|
||||
class AddonModFeedbackAttemptsManager extends CorePageItemsListManager<EntryItem> {
|
||||
|
||||
responses: AddonModFeedbackResponses = {
|
||||
attempts: [],
|
||||
identifiable: AddonModFeedbackIdentifiableAttempts = {
|
||||
items: [],
|
||||
total: 0,
|
||||
canLoadMore: false,
|
||||
};
|
||||
|
||||
anonResponses: AddonModFeedbackAnonResponses = {
|
||||
attempts: [],
|
||||
anonymous: AddonModFeedbackAnonymousAttempts = {
|
||||
items: [],
|
||||
total: 0,
|
||||
canLoadMore: false,
|
||||
};
|
||||
|
@ -202,25 +202,25 @@ class AddonModFeedbackResponsesManager extends CorePageItemsListManager<EntryIte
|
|||
}
|
||||
|
||||
/**
|
||||
* Update responses.
|
||||
* Update attempts.
|
||||
*
|
||||
* @param responses Responses.
|
||||
* @param attempts Attempts.
|
||||
*/
|
||||
setResponses(responses: AddonModFeedbackResponsesAnalysis): void {
|
||||
this.responses.total = responses.totalattempts;
|
||||
this.anonResponses.total = responses.totalanonattempts;
|
||||
setAttempts(attempts: AddonModFeedbackResponsesAnalysis): void {
|
||||
this.identifiable.total = attempts.totalattempts;
|
||||
this.anonymous.total = attempts.totalanonattempts;
|
||||
|
||||
if (this.anonResponses.attempts.length < responses.totalanonattempts) {
|
||||
this.anonResponses.attempts = this.anonResponses.attempts.concat(responses.anonattempts);
|
||||
if (this.anonymous.items.length < attempts.totalanonattempts) {
|
||||
this.anonymous.items = this.anonymous.items.concat(attempts.anonattempts);
|
||||
}
|
||||
if (this.responses.attempts.length < responses.totalattempts) {
|
||||
this.responses.attempts = this.responses.attempts.concat(responses.attempts);
|
||||
if (this.identifiable.items.length < attempts.totalattempts) {
|
||||
this.identifiable.items = this.identifiable.items.concat(attempts.attempts);
|
||||
}
|
||||
|
||||
this.anonResponses.canLoadMore = this.anonResponses.attempts.length < responses.totalanonattempts;
|
||||
this.responses.canLoadMore = this.responses.attempts.length < responses.totalattempts;
|
||||
this.anonymous.canLoadMore = this.anonymous.items.length < attempts.totalanonattempts;
|
||||
this.identifiable.canLoadMore = this.identifiable.items.length < attempts.totalattempts;
|
||||
|
||||
this.setItems((<EntryItem[]> this.responses.attempts).concat(this.anonResponses.attempts));
|
||||
this.setItems((<EntryItem[]> this.identifiable.items).concat(this.anonymous.items));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,29 +228,29 @@ class AddonModFeedbackResponsesManager extends CorePageItemsListManager<EntryIte
|
|||
*/
|
||||
resetItems(): void {
|
||||
super.resetItems();
|
||||
this.responses.total = 0;
|
||||
this.responses.attempts = [];
|
||||
this.anonResponses.total = 0;
|
||||
this.anonResponses.attempts = [];
|
||||
this.identifiable.total = 0;
|
||||
this.identifiable.items = [];
|
||||
this.anonymous.total = 0;
|
||||
this.anonymous.items = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected getItemPath(entry: EntryItem): string {
|
||||
return `attempt/${entry.id}`;
|
||||
return entry.id.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type AddonModFeedbackResponses = {
|
||||
attempts: AddonModFeedbackWSAttempt[];
|
||||
type AddonModFeedbackIdentifiableAttempts = {
|
||||
items: AddonModFeedbackWSAttempt[];
|
||||
total: number;
|
||||
canLoadMore: boolean;
|
||||
};
|
||||
|
||||
type AddonModFeedbackAnonResponses = {
|
||||
attempts: AddonModFeedbackWSAnonAttempt[];
|
||||
type AddonModFeedbackAnonymousAttempts = {
|
||||
items: AddonModFeedbackWSAnonAttempt[];
|
||||
total: number;
|
||||
canLoadMore: boolean;
|
||||
};
|
|
@ -184,7 +184,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
if (params.showcompleted === undefined) {
|
||||
// Param showcompleted not defined. Show entry list.
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/respondents`,
|
||||
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/attempts`,
|
||||
{ siteId },
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue