Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lectures: Remove guided mode exercise creation shortcut #10022

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ <h3>
<jhi-documentation-button [type]="documentationType" />
</div>
<div class="col text-end align-self-center">
@if (showBackToWizardModeButton) {
<button type="button" id="back-to-wizard" class="btn btn-secondary" (click)="goBackToWizardMode()">
<fa-icon [icon]="faHandshakeAngle" />&nbsp;{{ 'artemisApp.lecture.wizardMode.backToWizard' | artemisTranslate }}
</button>
}
<button id="toggleSearchButton" class="btn btn-primary" type="button" (click)="toggleSearch()">
{{ 'artemisApp.course.exercise.search.toggleButton.' + showSearch | artemisTranslate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
import { Component, ContentChild, OnInit, TemplateRef, inject } from '@angular/core';
import { Course } from 'app/entities/course.model';
import { CourseManagementService } from './course-management.service';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { ExerciseFilter } from 'app/entities/exercise-filter.model';
import { DocumentationType } from 'app/shared/components/documentation-button/documentation-button.component';
import { faHandshakeAngle } from '@fortawesome/free-solid-svg-icons';
import { ExerciseType } from 'app/entities/exercise.model';

@Component({
Expand All @@ -28,22 +26,13 @@ export class CourseManagementExercisesComponent implements OnInit {
filteredModelingExercisesCount = 0;
filteredFileUploadExercisesCount = 0;
exerciseFilter: ExerciseFilter;
showBackToWizardModeButton = false;
lectureIdForGoingBack: number;
lectureWizardStepForGoingBack: number;

faHandshakeAngle = faHandshakeAngle;

// extension points, see shared/extension-point
@ContentChild('overrideGenerateAndImportButton') overrideGenerateAndImportButton: TemplateRef<any>;
@ContentChild('overrideProgrammingExerciseCard') overrideProgrammingExerciseCard: TemplateRef<any>;
@ContentChild('overrideNonProgrammingExerciseCard') overrideNonProgrammingExerciseCard: TemplateRef<any>;

constructor(
private courseService: CourseManagementService,
private router: Router,
private route: ActivatedRoute,
) {}
private readonly route = inject(ActivatedRoute);

/**
* initializes course
Expand All @@ -55,12 +44,6 @@ export class CourseManagementExercisesComponent implements OnInit {
}
});

this.route.queryParams.subscribe((params) => {
this.showBackToWizardModeButton = params.shouldHaveBackButtonToWizard;
this.lectureIdForGoingBack = params.lectureId;
this.lectureWizardStepForGoingBack = params.step;
});

this.exerciseFilter = new ExerciseFilter('');
}

Expand Down Expand Up @@ -104,11 +87,4 @@ export class CourseManagementExercisesComponent implements OnInit {
shouldHideExerciseCard(type: string): boolean {
return !['all', type].includes(this.exerciseFilter.exerciseTypeSearch);
}

goBackToWizardMode() {
this.router.navigate(['/course-management', this.course.id, 'lectures', this.lectureIdForGoingBack, 'edit'], {
queryParams: { shouldBeInWizardMode: 'true', shouldOpenCreateExercise: 'true', step: this.lectureWizardStepForGoingBack },
queryParamsHandling: '',
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { FormulaAction } from 'app/shared/monaco-editor/model/actions/formula.ac
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FileUploadExerciseUpdateComponent implements AfterViewInit, OnDestroy, OnInit {
protected readonly faQuestionCircle = faQuestionCircle;

readonly IncludedInOverallScore = IncludedInOverallScore;
readonly documentationType: DocumentationType = 'FileUpload';

Expand All @@ -50,7 +52,6 @@ export class FileUploadExerciseUpdateComponent implements AfterViewInit, OnDestr
fileUploadExercise: FileUploadExercise;
backupExercise: FileUploadExercise;
isSaving: boolean;
goBackAfterSaving = false;
exerciseCategories: ExerciseCategory[];
existingCategories: ExerciseCategory[];
notificationText?: string;
Expand All @@ -59,19 +60,14 @@ export class FileUploadExerciseUpdateComponent implements AfterViewInit, OnDestr
isImport: boolean;
examCourseId?: number;

saveCommand: SaveExerciseCommand<FileUploadExercise>;

formStatusSections: FormSectionStatus[];

// Subcriptions
// Subscriptions
titleChannelNameComponentSubscription?: Subscription;
pointsSubscription?: Subscription;
bonusPointsSubscription?: Subscription;
teamSubscription?: Subscription;

// Icons
faQuestionCircle = faQuestionCircle;

constructor(
private fileUploadExerciseService: FileUploadExerciseService,
private modalService: NgbModal,
Expand Down Expand Up @@ -104,11 +100,6 @@ export class FileUploadExerciseUpdateComponent implements AfterViewInit, OnDestr
this.examCourseId = getCourseId(fileUploadExercise);
});

this.activatedRoute.queryParams.subscribe((params) => {
if (params.shouldHaveBackButtonToWizard) {
this.goBackAfterSaving = true;
}
});
this.activatedRoute.url
.pipe(
tap(
Expand Down Expand Up @@ -264,12 +255,6 @@ export class FileUploadExerciseUpdateComponent implements AfterViewInit, OnDestr
private onSaveSuccess(exercise: Exercise) {
this.isSaving = false;

if (this.goBackAfterSaving) {
this.navigationUtilService.navigateBack();

return;
}

this.navigationUtilService.navigateForwardFromExerciseUpdateOrCreation(exercise);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { HttpErrorResponse } from '@angular/common/http';
import { ModelingExercise } from 'app/entities/modeling-exercise.model';
import { ModelingExerciseService } from './modeling-exercise.service';
Expand Down Expand Up @@ -70,7 +70,6 @@ export class ModelingExerciseUpdateComponent implements AfterViewInit, OnDestroy
isImport: boolean;
isExamMode: boolean;
semiAutomaticAssessmentAvailable = true;
goBackAfterSaving = false;

formSectionStatus: FormSectionStatus[];

Expand All @@ -91,7 +90,6 @@ export class ModelingExerciseUpdateComponent implements AfterViewInit, OnDestroy
private exerciseGroupService: ExerciseGroupService,
private eventManager: EventManager,
private activatedRoute: ActivatedRoute,
private router: Router,
private navigationUtilService: ArtemisNavigationUtilService,
private changeDetectorRef: ChangeDetectorRef,
) {}
Expand Down Expand Up @@ -186,12 +184,6 @@ export class ModelingExerciseUpdateComponent implements AfterViewInit, OnDestroy
)
.subscribe();

this.activatedRoute.queryParams.subscribe((params) => {
if (params.shouldHaveBackButtonToWizard) {
this.goBackAfterSaving = true;
}
});

this.isSaving = false;
this.notificationText = undefined;
}
Expand Down Expand Up @@ -292,12 +284,6 @@ export class ModelingExerciseUpdateComponent implements AfterViewInit, OnDestroy
this.eventManager.broadcast({ name: 'modelingExerciseListModification', content: 'OK' });
this.isSaving = false;

if (this.goBackAfterSaving) {
this.navigationUtilService.navigateBack();

return;
}

this.navigationUtilService.navigateForwardFromExerciseUpdateOrCreation(exercise);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class QuizExerciseUpdateComponent extends QuizExerciseValidationDirective
notificationText?: string;

isImport = false;
goBackAfterSaving = false;

/** Constants for 'Add existing questions' and 'Import file' features **/
showExistingQuestions = false;
Expand Down Expand Up @@ -149,12 +148,6 @@ export class QuizExerciseUpdateComponent extends QuizExerciseValidationDirective
this.isImport = true;
}

this.route.queryParams.subscribe((params) => {
if (params.shouldHaveBackButtonToWizard) {
this.goBackAfterSaving = true;
}
});

/** Query the courseService for the participationId given by the params */
if (this.courseId) {
this.courseService.find(this.courseId).subscribe((response: HttpResponse<Course>) => {
Expand Down Expand Up @@ -520,12 +513,6 @@ export class QuizExerciseUpdateComponent extends QuizExerciseValidationDirective
this.savedEntity = cloneDeep(quizExercise);
this.changeDetector.detectChanges();

if (this.goBackAfterSaving) {
this.navigationUtilService.navigateBack();

return;
}

// Navigate back only if it's an import
// If we edit the exercise, a user might just want to save the current state of the added quiz questions without going back
if (this.isImport) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class TextExerciseUpdateComponent implements OnInit, OnDestroy, AfterView
examCourseId?: number;
isExamMode: boolean;
isImport = false;
goBackAfterSaving = false;
AssessmentType = AssessmentType;
isAthenaEnabled$: Observable<boolean> | undefined;

Expand Down Expand Up @@ -170,12 +169,6 @@ export class TextExerciseUpdateComponent implements OnInit, OnDestroy, AfterView
)
.subscribe();

this.activatedRoute.queryParams.subscribe((params) => {
if (params.shouldHaveBackButtonToWizard) {
this.goBackAfterSaving = true;
}
});

this.isAthenaEnabled$ = this.athenaService.isEnabled();

this.isSaving = false;
Expand Down Expand Up @@ -278,12 +271,6 @@ export class TextExerciseUpdateComponent implements OnInit, OnDestroy, AfterView
this.eventManager.broadcast({ name: 'textExerciseListModification', content: 'OK' });
this.isSaving = false;

if (this.goBackAfterSaving) {
this.navigationUtilService.navigateBack();

return;
}

this.navigationUtilService.navigateForwardFromExerciseUpdateOrCreation(exercise);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ <h2 jhiTranslate="artemisApp.exerciseUnit.createExerciseUnit.headline"></h2>
<fa-icon [icon]="faTimes" />&nbsp;<span jhiTranslate="entity.action.cancel"></span>
</button>
}
@if (hasCreateExerciseButton()) {
<button
id="createExerciseButton"
type="button"
class="btn btn-primary"
(click)="createNewExercise()"
jhiTranslate="artemisApp.lecture.wizardMode.newExercise"
></button>
}
<button
id="createButton"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ export class CreateExerciseUnitComponent implements OnInit {
@Input() lectureId: number | undefined;
@Input() courseId: number | undefined;
hasCancelButton = input<boolean>();
hasCreateExerciseButton = input<boolean>();
shouldNavigateOnSubmit = input<boolean>(true);
currentWizardStep = input<number>();

onCancel = output<void>();
onExerciseUnitCreated = output<void>();
Expand Down Expand Up @@ -123,11 +121,4 @@ export class CreateExerciseUnitComponent implements OnInit {
cancelForm() {
this.onCancel.emit();
}

createNewExercise() {
this.router.navigate(['/course-management', this.courseId, 'exercises'], {
queryParams: { shouldHaveBackButtonToWizard: 'true', lectureId: this.lectureId, step: this.currentWizardStep() },
queryParamsHandling: '',
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ <h4><span jhiTranslate="artemisApp.lecture.wizardMode.editLectureUnit"></span></
(onExerciseUnitCreated)="onExerciseUnitCreated()"
[lectureId]="lecture.id"
[courseId]="lecture.course?.id"
[currentWizardStep]="currentStep"
[hasCancelButton]="true"
[hasCreateExerciseButton]="true"
(onCancel)="onCloseLectureUnitForms()"
/>
}
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/i18n/de/lecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"newLectureUnit": "Neue Vorlesungseinheit",
"editLectureUnit": "Vorlesungseinheit bearbeiten",
"newExercise": "Neue Übung erstellen",
"backToWizard": "Zurück zur Vorlesung",
"competencyTitle": "Titel",
"competencyConnectedUnits": "Verknüpfte Einheiten",
"competencyNoConnectedUnits": "Keine verknüpften Einheiten"
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/i18n/en/lecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"newLectureUnit": "New Lecture Unit",
"editLectureUnit": "Edit Lecture Unit",
"newExercise": "Create new exercise",
"backToWizard": "Back to lecture",
"competencyTitle": "Title",
"competencyConnectedUnits": "Connected Units",
"competencyNoConnectedUnits": "No connected units"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ describe('TextExercise Management Update Component', () => {
route.params = of({ courseId });
route.url = of([{ path: 'import' } as UrlSegment]);
route.data = of({ textExercise });
route.queryParams = of({ shouldHaveBackButtonToWizard: true });
});

it('should set isImport and remove all dates', fakeAsync(() => {
Expand Down
Loading