<ion-header>
    <ion-navbar core-back-button>
        <ion-title>{{ 'addon.mod_feedback.responses' |translate }}</ion-title>
    </ion-navbar>
</ion-header>
<ion-content>
    <ion-refresher [enabled]="feedbackLoaded" (ionRefresh)="refreshFeedback($event)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="feedbackLoaded">
        <ion-list no-margin>
            <ion-item text-wrap *ngIf="groupInfo.separateGroups || groupInfo.visibleGroups">
                <ion-label id="addon-feedback-groupslabel" *ngIf="groupInfo.separateGroups">{{ 'core.groupsseparate' | translate }}</ion-label>
                <ion-label id="addon-feedback-groupslabel" *ngIf="groupInfo.visibleGroups">{{ 'core.groupsvisible' | translate }}</ion-label>
                <ion-select [(ngModel)]="selectedGroup" (ionChange)="loadAttempts(selectedGroup)" aria-labelledby="addon-feedback-groupslabel" interface="popover">
                    <ion-option *ngFor="let groupOpt of groupInfo.groups" [value]="groupOpt.id">{{groupOpt.name}}</ion-option>
                </ion-select>
            </ion-item>
            <ion-item-divider color="light">
                {{ 'addon.mod_feedback.non_respondents_students' | translate : {$a: total } }}
            </ion-item-divider>
            <ng-container *ngIf="total > 0">
                <ion-item *ngFor="let user of users" text-wrap>
                    <ion-avatar item-start>
                        <img [src]="user.profileimageurl" [alt]="'core.pictureof' | translate:{$a: user.fullname}" core-external-content onError="this.src='assets/img/user-avatar.png'">
                    </ion-avatar>
                    <h2><core-format-text [text]="user.fullname"></core-format-text></h2>
                    <p>
                        <ion-badge color="success" *ngIf="user.started">
                            {{ 'addon.mod_feedback.started' | translate}}
                        </ion-badge>
                        <ion-badge color="danger" *ngIf="!user.started">
                            {{ 'addon.mod_feedback.not_started' | translate}}
                        </ion-badge>
                    </p>
                </ion-item>
            </ng-container>
            <ion-item padding text-center *ngIf="canLoadMore">
                <!-- Button and spinner to show more attempts. -->
                <button ion-button block *ngIf="!loadingMore" (click)="loadAttempts()">{{ 'core.loadmore' | translate }}</button>
                <ion-spinner *ngIf="loadingMore"></ion-spinner>
            </ion-item>
        </ion-list>
    </core-loading>
</ion-content>
