<core-loading [hideUntil]="loaded">
    <div *ngIf="!summary">
        <ion-item class="ion-text-wrap addon-workshop-submission-title">
            <core-user-avatar [user]="profile" [courseId]="courseId" [userId]="profile?.id" slot="start">
            </core-user-avatar>
            <ion-label>
                <h2>
                    <core-format-text [text]="submission.title" contextLevel="module" [contextInstanceId]="module.id"
                        [courseId]="courseId">
                    </core-format-text>
                </h2>
                <p *ngIf="profile && profile?.fullname">{{profile.fullname}}</p>
                <p *ngIf="showGrade(submission.grade)"
                    [class.addon-has-overriden-grade]="showGrade(submission.gradeover)">
                    {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.grade}}
                </p>
                <p *ngIf="showGrade(submission.gradeover)" class="addon-overriden-grade">
                    {{ 'addon.mod_workshop.gradeover' | translate }}: {{submission.gradeover}}
                </p>
                <p *ngIf="access.canviewallsubmissions && showGrade(submission.gradinggrade)">
                    {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}}
                </p>
            </ion-label>
            <ion-note slot="end" *ngIf="!submission.timemodified">
                <ion-icon name="fas-clock" aria-hidden="true"></ion-icon> {{ 'core.notsent' | translate }}
            </ion-note>
            <ion-note slot="end" *ngIf="submission.timemodified">
                {{submission.timemodified | coreDateDayOrTime}}
                <ng-container *ngIf="submission.offline">
                    <ion-icon name="fas-clock" aria-hidden="true"></ion-icon> {{ 'core.notsent' | translate }}
                </ng-container>
                <ng-container *ngIf="submission.deleted">
                    <ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }}
                </ng-container>
            </ion-note>
        </ion-item>
        <ion-item class="ion-text-wrap" *ngIf="submission.content">
            <ion-label>
                <core-format-text [component]="component" [componentId]="componentId" [text]="submission.content"
                    contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId">
                </core-format-text>
            </ion-label>
        </ion-item>
        <core-files [files]="submission.attachmentfiles" [component]="component" [componentId]="componentId"></core-files>
        <ion-item class="ion-text-wrap" *ngIf="viewDetails && submission.feedbackauthor">
            <core-user-avatar *ngIf="evaluateByProfile" [user]="evaluateByProfile" slot="start" [courseId]="courseId"
                [userId]="evaluateByProfile.id"></core-user-avatar>

            <ion-label>
                <h2 *ngIf="evaluateByProfile && evaluateByProfile.fullname">
                    {{ 'addon.mod_workshop.feedbackby' | translate : {$a: evaluateByProfile.fullname} }}
                </h2>
                <core-format-text [text]="submission.feedbackauthor" contextLevel="module" [contextInstanceId]="module.id"
                    [courseId]="courseId">
                </core-format-text>
            </ion-label>
        </ion-item>
        <ion-item *ngIf="viewDetails">
            <ion-label>
                <ion-button expand="block" (click)="gotoSubmission()">
                    {{ 'core.showmore' | translate }}
                    <ion-icon name="fas-chevron-right" slot="end" aria-hidden="true"></ion-icon>
                </ion-button>
            </ion-label>
        </ion-item>
    </div>

    <ion-item class="ion-text-wrap" *ngIf="summary" [detail]="submission.timemodified" (click)="gotoSubmission()"
        [button]="submission.timemodified">
        <core-user-avatar [user]="profile" slot="start" [courseId]="courseId" [userId]="profile?.id">
        </core-user-avatar>
        <ion-label>
            <h2>
                <core-format-text [text]="submission.title" contextLevel="module" [contextInstanceId]="module.id"
                    [courseId]="courseId">
                </core-format-text>
            </h2>
            <p *ngIf="profile && profile.fullname">{{profile.fullname}}</p>
            <p *ngIf="submission.reviewedbydone">
                {{ 'addon.mod_workshop.receivedgrades' | translate }}: {{submission.reviewedbydone}} / {{submission.reviewedbycount}}
            </p>
            <p *ngIf="submission.reviewerofdone">
                {{ 'addon.mod_workshop.givengrades' | translate }}: {{submission.reviewerofdone}} / {{submission.reviewerofcount}}
            </p>
            <p *ngIf="!showGrade(submission.gradeover) && showGrade(submission.grade)">
                {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.grade}}
            </p>
            <p *ngIf="showGrade(submission.gradeover)" class="addon-overriden-grade">
                {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.gradeover}}
            </p>
            <p *ngIf="access.canviewallsubmissions && showGrade(submission.gradinggrade)">
                {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}}
            </p>

            <ion-badge *ngIf="assessment && (showGrade(assessment.grade) || assessment.offline)" color="success">
                {{ 'addon.mod_workshop.assessedsubmission' | translate }}
            </ion-badge>
            <ion-badge *ngIf="assessment && !showGrade(assessment.grade) && !assessment.offline" color="danger">
                {{ 'addon.mod_workshop.notassessed' | translate }}
            </ion-badge>

        </ion-label>
        <ion-note slot="end" *ngIf="submission.timemodified">
            {{submission.timemodified | coreDateDayOrTime}}
            <div *ngIf="offline"><ion-icon name="fas-clock" aria-hidden="true"></ion-icon> {{ 'core.notsent' | translate }}</div>
            <div *ngIf="submission.deleted">
                <ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }}
            </div>
        </ion-note>
    </ion-item>
</core-loading>
