Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/app/scenario/step.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ <h4 class="card-title">
@if (step.quiz) {
<div class="mt-3">
<quiz
#quizComponent
[quizId]="step.quiz"
[scenarioId]="scenario.id"
[scenarioName]="scenario.name | atob"
Expand Down Expand Up @@ -368,3 +369,27 @@ <h3 class="modal-title">Your session has expired!</h3>
<img src="{{ srcImgXlarge }}" alt="ImageMadeLarger" class="modal-image" />
</div>
</clr-modal>

<clr-modal
[(clrModalOpen)]="unsubmittedQuizModalOpen"
[clrModalClosable]="false"
>
<h3 class="modal-title">Quiz not submitted</h3>
<div class="modal-body">
<p>
Do you really want to finish without submitting your quiz? Your quiz
progress will not be saved.
</p>
</div>
<div class="modal-footer">
<button class="btn btn-outline" (click)="cancelUnsubmittedQuizFinish()">
Cancel
</button>
<button
class="btn btn-success-outline"
(click)="confirmUnsubmittedQuizFinish()"
>
Finish anyway
</button>
</div>
</clr-modal>
27 changes: 27 additions & 0 deletions src/app/scenario/step.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { Course } from '../course/course';
import { CourseService } from '../services/course.service';
import { LanguageCommandService } from './bashbrawl/languages/language-command.service';
import { SidenavService } from '../services/sidenav.service';
import { QuizComponent } from '../quiz/quiz.component';

type Service = {
name: string;
Expand Down Expand Up @@ -99,6 +100,7 @@ export class StepComponent implements OnInit, AfterViewInit, OnDestroy {

maxInterfaceTabs = 2;
private activeWebinterface: Service;
public unsubmittedQuizModalOpen = false;

public pauseOpen = false;

Expand All @@ -123,6 +125,7 @@ export class StepComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('pausemodal', { static: true }) private pauseModal: ClrModal;
@ViewChild('contentdiv', { static: false }) private contentDiv: ElementRef;
@ViewChild('divider', { static: true }) divider: SplitComponent;
@ViewChild('quizComponent', { static: false }) quizComponent?: QuizComponent;

constructor(
private route: ActivatedRoute,
Expand Down Expand Up @@ -402,6 +405,16 @@ export class StepComponent implements OnInit, AfterViewInit, OnDestroy {
}

public goFinish() {
console.log(this.quizComponent);
if (
this.quizComponent &&
this.quizComponent.isPersistent &&
!this.quizComponent.isSubmitted
) {
this.unsubmittedQuizModalOpen = true;
return;
}

if (this.isContentOnly) {
this.actuallyFinish();
return;
Expand Down Expand Up @@ -616,4 +629,18 @@ export class StepComponent implements OnInit, AfterViewInit, OnDestroy {
this.router.navigateByUrl('/app/home');
}
}
public cancelUnsubmittedQuizFinish() {
this.unsubmittedQuizModalOpen = false;
}

public confirmUnsubmittedQuizFinish() {
this.unsubmittedQuizModalOpen = false;

if (this.isContentOnly) {
this.actuallyFinish();
return;
}

this.finishOpen = true;
}
}
Loading