<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate"></ion-back-button>
        </ion-buttons>
        <ion-title>
            <core-format-text [text]="title" contextLevel="module" [contextInstanceId]="moduleId"  [courseId]="courseId">
            </core-format-text>
        </ion-title>

        <ion-buttons slot="end"></ion-buttons>
    </ion-toolbar>
</ion-header>

<ion-content>
    <core-split-view>
        <ion-refresher slot="fixed" [disabled]="!loaded || !submissions.loaded" (ionRefresh)="refreshList($event.target)">
            <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
        </ion-refresher>
        <core-loading [hideUntil]="loaded && submissions.loaded">
            <core-empty-box *ngIf="!submissions || submissions.empty" icon="fas-file-signature"
                [message]="'addon.mod_assign.submissionstatus_' | translate">
            </core-empty-box>

            <ion-list>
                <ion-item class="ion-text-wrap" *ngIf="(groupInfo.separateGroups || groupInfo.visibleGroups)">
                    <ion-label id="addon-assign-groupslabel" *ngIf="groupInfo.separateGroups">
                        {{ 'core.groupsseparate' | translate }}
                    </ion-label>
                    <ion-label id="addon-assign-groupslabel" *ngIf="groupInfo.visibleGroups">
                        {{ 'core.groupsvisible' | translate }}
                    </ion-label>
                    <ion-select [(ngModel)]="groupId" (ionChange)="setGroup(groupId)" aria-labelledby="addon-assign-groupslabel"
                        interface="action-sheet" slot="end">
                        <ion-select-option *ngFor="let groupOpt of groupInfo.groups" [value]="groupOpt.id">
                            {{groupOpt.name}}
                        </ion-select-option>
                    </ion-select>
                </ion-item>
                <!-- List of submissions. -->
                <ng-container *ngFor="let submission of submissions.items">
                    <ion-item class="ion-text-wrap" (click)="submissions.select(submission)" button
                        [attr.aria-current]="submissions.getItemAriaCurrent(submission)">
                        <core-user-avatar [user]="submission" [linkProfile]="false" slot="start"></core-user-avatar>
                        <ion-label>
                            <h2 *ngIf="submission.userfullname">{{submission.userfullname}}</h2>
                            <h2 *ngIf="!submission.userfullname">
                                {{ 'addon.mod_assign.hiddenuser' | translate }}{{submission.blindid}}
                            </h2>
                            <p *ngIf="assign && assign!.teamsubmission">
                                <span *ngIf="submission.groupname">{{submission.groupname}}</span>
                                <span *ngIf="assign!.preventsubmissionnotingroup && !submission.groupname && submission.noGroups
                                    && !submission.blindid" class="text-danger">
                                    {{ 'addon.mod_assign.noteam' | translate }}
                                </span>
                                <span *ngIf="assign!.preventsubmissionnotingroup && !submission.groupname && submission.manyGroups
                                    && !submission.blindid" class="text-danger">
                                    {{ 'addon.mod_assign.multipleteams' | translate }}
                                </span>
                                <span *ngIf="!assign!.preventsubmissionnotingroup && !submission.groupname">
                                    {{ 'addon.mod_assign.defaultteam' | translate }}
                                </span>
                            </p>
                            <ion-badge class="ion-text-center ion-text-wrap" [color]="submission.statusColor"
                                *ngIf="submission.statusTranslated">
                                {{ submission.statusTranslated }}
                            </ion-badge>
                            <ion-badge class="ion-text-center ion-text-wrap" [color]="submission.gradingColor"
                                *ngIf="submission.gradingStatusTranslationId">
                                {{ submission.gradingStatusTranslationId | translate }}
                            </ion-badge>
                        </ion-label>
                    </ion-item>
                </ng-container>

                <ion-card class="ion-text-wrap core-warning-card" *ngIf="!haveAllParticipants">
                    <ion-item>
                        <ion-icon name="fas-exclamation-triangle" slot="start" aria-hidden="true"></ion-icon>
                        <ion-label>{{ 'addon.mod_assign.notallparticipantsareshown' | translate }}</ion-label>
                    </ion-item>
                </ion-card>
            </ion-list>
        </core-loading>
    </core-split-view>
</ion-content>
