diff --git a/ui/src/app/exam/editor/sections/section-question.component.html b/ui/src/app/exam/editor/sections/section-question.component.html index d5937c401..26c2f9a47 100644 --- a/ui/src/app/exam/editor/sections/section-question.component.html +++ b/ui/src/app/exam/editor/sections/section-question.component.html @@ -43,6 +43,7 @@
+
diff --git a/ui/src/app/exam/editor/sections/section-question.component.ts b/ui/src/app/exam/editor/sections/section-question.component.ts index 08a326d39..b66d913f8 100644 --- a/ui/src/app/exam/editor/sections/section-question.component.ts +++ b/ui/src/app/exam/editor/sections/section-question.component.ts @@ -40,6 +40,7 @@ export class SectionQuestionComponent { @Input() examId = 0; @Output() removed = new EventEmitter(); @Output() updated = new EventEmitter(); + @Output() copied = new EventEmitter(); constructor( private http: HttpClient, @@ -73,6 +74,12 @@ export class SectionQuestionComponent { this.translate.instant('sitnet_remove_question'), ).subscribe({ next: () => this.removed.emit(this.sectionQuestion), error: (err) => this.toast.error(err) }); + copyQuestion = () => + this.Confirmation.open$( + this.translate.instant('sitnet_confirm'), + this.translate.instant('sitnet_copy_question'), + ).subscribe({ next: () => this.copied.emit(this.sectionQuestion), error: (err) => this.toast.error(err) }); + determineClaimOptionType(examOption: ExamSectionQuestionOption) { return this.Question.determineClaimOptionTypeForExamQuestionOption(examOption); } diff --git a/ui/src/app/exam/editor/sections/section.component.html b/ui/src/app/exam/editor/sections/section.component.html index c57558f72..64320a13e 100644 --- a/ui/src/app/exam/editor/sections/section.component.html +++ b/ui/src/app/exam/editor/sections/section.component.html @@ -235,6 +235,7 @@ [lotteryOn]="section.lotteryOn" (removed)="removeQuestion($event)" (updated)="updateQuestion($event)" + (copied)="copyQuestion($event)" > diff --git a/ui/src/app/exam/editor/sections/section.component.ts b/ui/src/app/exam/editor/sections/section.component.ts index 632fdef71..74707cd87 100644 --- a/ui/src/app/exam/editor/sections/section.component.ts +++ b/ui/src/app/exam/editor/sections/section.component.ts @@ -180,6 +180,15 @@ export class SectionComponent { }); }; + copyQuestion = (sq: ExamSectionQuestion) => + this.http.post(`/app/question/${sq.question.id}`, {}).subscribe({ + next: (copy) => { + this.insertExamQuestion(copy, sq.sequenceNumber); + this.toast.info(this.translate.instant('sitnet_question_copied')); + }, + error: (err) => this.toast.error(err), + }); + updateQuestion = (sq: ExamSectionQuestion) => { const index = this.section.sectionQuestions.findIndex((q) => q.id == sq.id); this.section.sectionQuestions[index] = sq;