diff --git a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-detail.component.ts b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-detail.component.ts index 9ca9b4796321..6caa91f19a16 100644 --- a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-detail.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-detail.component.ts @@ -1,5 +1,5 @@ import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { ApollonEditor, ApollonMode, Locale, UMLModel } from '@ls1intum/apollon'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; @@ -52,6 +52,7 @@ export class ApollonDiagramDetailComponent implements OnInit, OnDestroy { private languageHelper: JhiLanguageHelper, private modalService: NgbModal, private route: ActivatedRoute, + private router: Router, ) {} /** @@ -153,6 +154,7 @@ export class ApollonDiagramDetailComponent implements OnInit, OnDestroy { */ async generateExercise() { if (!this.hasInteractive) { + this.alertService.error('artemisApp.apollonDiagram.create.validationError'); return; } @@ -165,6 +167,7 @@ export class ApollonDiagramDetailComponent implements OnInit, OnDestroy { const result = await modalRef.result; if (result) { this.alertService.success('artemisApp.apollonDiagram.create.success', { title: result.title }); + this.router.navigate(['course-management', this.courseId, 'quiz-exercises', result.id, 'edit']); } } catch (error) { this.alertService.error('artemisApp.apollonDiagram.create.error'); diff --git a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts index 10128f71a4d1..0222ed96cf77 100644 --- a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts +++ b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts @@ -68,9 +68,9 @@ export async function generateDragAndDropQuizExercise( const quizExercise = createDragAndDropQuizExercise(course, title, dragAndDropQuestion); // Save the quiz exercise - await lastValueFrom(quizExerciseService.create(quizExercise)); + const creationResponse = await lastValueFrom(quizExerciseService.create(quizExercise)); - return quizExercise; + return creationResponse.body ?? quizExercise; } /** diff --git a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.html b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.html index 08f652e0df4a..6f8f8d96dfb7 100644 --- a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.html +++ b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.html @@ -96,6 +96,7 @@

(onDragOver)="preventDefault($event)" (onDragLeave)="preventDefault($event)" cdkDropList + [cdkDropListAutoScrollStep]="60" > -
+
@@ -244,6 +245,7 @@

(onDragOver)="preventDefault($event)" (onDragLeave)="preventDefault($event)" cdkDropList + [cdkDropListAutoScrollStep]="60" > { return { width: 0, height: 0 }; }; -const question1 = { id: 1, type: QuizQuestionType.DRAG_AND_DROP, points: 1 } as QuizQuestion; -const question2 = { id: 2, type: QuizQuestionType.MULTIPLE_CHOICE, points: 2, answerOptions: [], invalid: false, exportQuiz: false, randomizeOrder: true } as QuizQuestion; -const question3 = { id: 3, type: QuizQuestionType.SHORT_ANSWER, points: 3 } as QuizQuestion; -const now = dayjs(); - -const quizExercise = { - id: 1, - quizQuestions: [question1, question2, question3], - releaseDate: dayjs(now).subtract(2, 'minutes'), - dueDate: dayjs(now).add(2, 'minutes'), - quizStarted: true, -} as QuizExercise; - describe('QuizExercise Generator', () => { let quizExerciseService: QuizExerciseService; let fileUploaderService: FileUploaderService; @@ -80,7 +66,7 @@ describe('QuizExercise Generator', () => { configureServices(); const examplePath = '/path/to/file'; jest.spyOn(fileUploaderService, 'uploadFile').mockReturnValue(Promise.resolve({ path: examplePath })); - jest.spyOn(quizExerciseService, 'create').mockReturnValue(of({ body: quizExercise } as HttpResponse)); + jest.spyOn(quizExerciseService, 'create').mockImplementation((generatedExercise) => of({ body: generatedExercise } as HttpResponse)); jest.spyOn(svgRenderer, 'convertRenderedSVGToPNG').mockReturnValue(new Blob()); // @ts-ignore const classDiagram: UMLModel = testClassDiagram as UMLModel;