<ion-header>
    <ion-navbar core-back-button>
        <ion-title><core-format-text [text]="title"></core-format-text></ion-title>

        <ion-buttons end></ion-buttons>
    </ion-navbar>
</ion-header>
<core-split-view>
    <ion-content>
        <ion-refresher [enabled]="loaded" (ionRefresh)="refreshList($event)">
            <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
        </ion-refresher>
        <core-loading [hideUntil]="loaded">
            <core-empty-box *ngIf="!submissions || submissions.length == 0" icon="paper" [message]="'addon.mod_assign.submissionstatus_' | translate">
            </core-empty-box>

            <ion-list>
                <ion-item 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">
                        <ion-option *ngFor="let groupOpt of groupInfo.groups" [value]="groupOpt.id">{{groupOpt.name}}</ion-option>
                    </ion-select>
                </ion-item>
                <!-- List of submissions. -->
                <ng-container *ngFor="let submission of submissions">
                    <a ion-item text-wrap (click)="loadSubmission(submission)" [class.core-split-item-selected]="submission.submitid == selectedSubmissionId">
                        <ion-avatar core-user-avatar [user]="submission" [linkProfile]="false" item-start></ion-avatar>
                        <h2 *ngIf="submission.userfullname">{{submission.userfullname}}</h2>
                        <h2 *ngIf="!submission.userfullname">{{ 'addon.mod_assign.hiddenuser' | translate }}{{submission.blindid}}</h2>
                        <p *ngIf="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 text-center text-wrap [color]="submission.statusColor" *ngIf="submission.statusTranslated">
                            {{ submission.statusTranslated }}
                        </ion-badge>
                        <ion-badge text-center text-wrap [color]="submission.gradingColor" *ngIf="submission.gradingStatusTranslationId">
                            {{ submission.gradingStatusTranslationId | translate }}
                        </ion-badge>
                    </a>
                </ng-container>

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