<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate"></ion-back-button>
        </ion-buttons>
        <ion-title>
            <h1>
                <core-format-text *ngIf="quiz" [text]="quiz.name" contextLevel="module" [contextInstanceId]="quiz.coursemodule"
                    [courseId]="courseId">
                </core-format-text>
            </h1>
        </ion-title>
    </ion-toolbar>
</ion-header>
<ion-content class="limited-width">
    <ion-refresher slot="fixed" [disabled]="!loaded" (ionRefresh)="doRefresh($event.target)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="loaded">
        <ion-list *ngIf="attempt">
            <ion-item class="ion-text-wrap">
                <ion-label>
                    <p class="item-heading">{{ 'addon.mod_quiz.attemptnumber' | translate }}</p>
                    <p *ngIf="attempt.preview">{{ 'addon.mod_quiz.preview' | translate }}</p>
                    <p *ngIf="!attempt.preview">{{ attempt.attempt }}</p>
                </ion-label>
            </ion-item>
            <ion-item class="ion-text-wrap">
                <ion-label>
                    <p class="item-heading">{{ 'addon.mod_quiz.attemptstate' | translate }}</p>
                    <p *ngFor="let sentence of attempt.readableState">{{ sentence }}</p>
                </ion-label>
            </ion-item>
            <ion-item class="ion-text-wrap" *ngIf="quiz!.showMarkColumn && attempt.readableMark !== ''">
                <ion-label>
                    <p class="item-heading">{{ 'addon.mod_quiz.marks' | translate }} / {{ quiz!.sumGradesFormatted }}</p>
                    <p>{{ attempt.readableMark }}</p>
                </ion-label>
            </ion-item>
            <ion-item class="ion-text-wrap" *ngIf="quiz!.showGradeColumn && attempt.readableGrade !== ''">
                <ion-label>
                    <p class="item-heading">{{ 'addon.mod_quiz.grade' | translate }} / {{ quiz!.gradeFormatted }}</p>
                    <p>{{ attempt.readableGrade }}</p>
                </ion-label>
            </ion-item>
            <ion-item class="ion-text-wrap" *ngIf="quiz!.showFeedbackColumn && feedback">
                <ion-label>
                    <p class="item-heading">{{ 'addon.mod_quiz.feedback' | translate }}</p>
                    <p>
                        <core-format-text [component]="component" [componentId]="componentId" [text]="feedback" contextLevel="module"
                            [contextInstanceId]="cmId" [courseId]="courseId">
                        </core-format-text>
                    </p>
                </ion-label>
            </ion-item>

            <ion-item class="ion-text-wrap core-danger-item" *ngIf="!showReviewColumn">
                <ion-label>
                    <p>{{ 'addon.mod_quiz.noreviewattempt' | translate }}</p>
                </ion-label>
            </ion-item>
        </ion-list>

        <div collapsible-footer appearOnBottom *ngIf="loaded && attempt && showReviewColumn && attempt.finished" slot="fixed">
            <div class="list-item-limited-width">
                <ion-button class="ion-margin ion-text-wrap" expand="block" (click)="reviewAttempt()">
                    <ion-icon name="fas-magnifying-glass" slot="start" aria-hidden="true"></ion-icon>
                    {{ 'addon.mod_quiz.review' | translate }}
                </ion-button>
            </div>
        </div>
    </core-loading>
</ion-content>
