Skip to content

Commit

Permalink
Development: Fix an issue with the exercise selection when navigating…
Browse files Browse the repository at this point in the history
… into the course
  • Loading branch information
krusche committed Nov 3, 2024
1 parent bbf19a0 commit e0c4e47
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 207 deletions.
2 changes: 1 addition & 1 deletion src/main/webapp/app/lti/lti13-exercise-launch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Lti13ExerciseLaunchComponent implements OnInit {
}

replaceWindowLocationWrapper(url: string): void {
this.ltiService.setLti(true);
this.ltiService.setShownViaLti(true);
this.themeService.applyThemeExplicitly(Theme.LIGHT);
const path = new URL(url).pathname;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="d-flex justify-content-between horizontal-scroll">
@if (course) {
@if (!isLti) {
@if (!isShownViaLti) {
<div [ngClass]="{ 'sidebar-collapsed': isCollapsed }">
<jhi-sidebar
[itemSelected]="exerciseSelected"
Expand All @@ -14,7 +14,7 @@
}

@if (exerciseSelected) {
<div class="vw-100 module-bg rounded-3" [ngStyle]="isLti ? { height: '90vh', position: 'relative' } : {}">
<div class="vw-100 module-bg rounded-3" [ngStyle]="isShownViaLti ? { height: '90vh', position: 'relative' } : {}">
<router-outlet (deactivate)="onSubRouteDeactivate()" />
</div>
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class CourseExercisesComponent implements OnInit, OnDestroy {
sidebarData: SidebarData;
sidebarExercises: SidebarCardElement[] = [];
isCollapsed = false;
isLti = false;
isShownViaLti = false;

protected readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE;
protected readonly DEFAULT_SHOW_ALWAYS = DEFAULT_SHOW_ALWAYS;
Expand Down Expand Up @@ -88,8 +88,8 @@ export class CourseExercisesComponent implements OnInit, OnDestroy {

this.exerciseForGuidedTour = this.guidedTourService.enableTourForCourseExerciseComponent(this.course, courseExerciseOverviewTour, true);

this.ltiSubscription = this.ltiService.isLti$.subscribe((isLti) => {
this.isLti = isLti;
this.ltiSubscription = this.ltiService.isShownViaLti$.subscribe((isShownViaLti) => {
this.isShownViaLti = isShownViaLti;
});

// If no exercise is selected navigate to the lastSelected or upcoming exercise
Expand Down
380 changes: 193 additions & 187 deletions src/main/webapp/app/overview/course-overview.component.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main/webapp/app/overview/course-overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class CourseOverviewComponent implements OnInit, OnDestroy, AfterViewInit
isExamStarted = false;
private examStartedSubscription: Subscription;
readonly MIN_DISPLAYED_COURSES: number = 6;
isLti = false;
isShownViaLti = false;
private ltiSubscription: Subscription;

// Properties to track hidden items for dropdown menu
Expand Down Expand Up @@ -255,8 +255,8 @@ export class CourseOverviewComponent implements OnInit, OnDestroy, AfterViewInit
this.updateVisibleNavbarItems(window.innerHeight);
await this.updateRecentlyAccessedCourses();
this.isSidebarCollapsed = this.activatedComponentReference?.isCollapsed ?? false;
this.ltiSubscription = this.ltiService.isLti$.subscribe((isLti) => {
this.isLti = isLti;
this.ltiSubscription = this.ltiService.isShownViaLti$.subscribe((isShownViaLti) => {
this.isShownViaLti = isShownViaLti;
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/app/shared/layouts/main/main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<div
id="page-wrapper"
class="page-wrapper"
[ngClass]="{ 'footer-height-dev': !isProduction || isTestServer, 'no-padding': isLti }"
[ngClass]="{ 'footer-height-dev': !isProduction || isTestServer, 'no-padding': isShownViaLti }"
[ngStyle]="{ 'overflow-y': !isTestRunExam && isExamStarted ? 'hidden' : 'auto' }"
cdkScrollable
>
<jhi-page-ribbon />
@if (showSkeleton && !isLti) {
@if (showSkeleton && !isShownViaLti) {
<div class="sticky-top">
<router-outlet name="navbar" />
</div>
Expand All @@ -23,7 +23,7 @@
<router-outlet />
}
<jhi-notification-popup />
@if (showSkeleton && !isLti) {
@if (showSkeleton && !isShownViaLti) {
<div>
@if (isTestRunExam || !isExamStarted) {
<jhi-footer [ngClass]="{ 'footer-height-dev': !isProduction || isTestServer }" />
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/app/shared/layouts/main/main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class JhiMainComponent implements OnInit, OnDestroy {
isExamStarted: boolean = false;
isTestRunExam: boolean = false;
isCourseOverview: boolean = false;
isLti: boolean = false;
isShownViaLti: boolean = false;

constructor(
private jhiLanguageHelper: JhiLanguageHelper,
Expand Down Expand Up @@ -124,8 +124,8 @@ export class JhiMainComponent implements OnInit, OnDestroy {
this.isCourseOverview = isPresent;
});

this.ltiSubscription = this.ltiService.isLti$.subscribe((isLti) => {
this.isLti = isLti;
this.ltiSubscription = this.ltiService.isShownViaLti$.subscribe((isShownViaLti) => {
this.isShownViaLti = isShownViaLti;
});

this.themeService.initialize();
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/app/shared/service/lti.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { BehaviorSubject } from 'rxjs';
})
export class LtiService {
constructor() {}
private ltiSubject = new BehaviorSubject<boolean>(false);
isLti$ = this.ltiSubject.asObservable();
private shownViaLtiSubject = new BehaviorSubject<boolean>(false);
isShownViaLti$ = this.shownViaLtiSubject.asObservable();

setLti(isLti: boolean) {
this.ltiSubject.next(isLti);
setShownViaLti(shownViaLti: boolean) {
this.shownViaLtiSubject.next(shownViaLti);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('CourseOverviewComponent', () => {
.then(() => {
fixture = TestBed.createComponent(CourseOverviewComponent);
component = fixture.componentInstance;
component.isLti = false;
component.isShownViaLti = false;
courseSidebarService = TestBed.inject(CourseSidebarService);
courseService = TestBed.inject(CourseManagementService);
courseStorageService = TestBed.inject(CourseStorageService);
Expand Down

0 comments on commit e0c4e47

Please sign in to comment.