diff --git a/ui/src/app/examination/examination.module.ts b/ui/src/app/examination/examination.module.ts index 012fa757a..80d1de2b0 100644 --- a/ui/src/app/examination/examination.module.ts +++ b/ui/src/app/examination/examination.module.ts @@ -38,5 +38,6 @@ import { ExaminationSectionComponent } from './section/examination-section.compo DynamicClozeTestComponent, ], providers: [ExaminationService, ExaminationStatusService], + exports: [ExaminationQuestionComponent], }) export class ExaminationModule {} diff --git a/ui/src/app/examination/question/examination-essay-question.component.html b/ui/src/app/examination/question/examination-essay-question.component.html index 3271e4d1c..24473318a 100644 --- a/ui/src/app/examination/question/examination-essay-question.component.html +++ b/ui/src/app/examination/question/examination-essay-question.component.html @@ -36,7 +36,7 @@ {{ sq.derivedMaxScore }} {{ 'sitnet_unit_points' | translate }} -
+
{{ sq.essayAnswer?.attachment?.fileName | uppercase }}
-
+
{{ 'sitnet_no_attachment' | translate }} diff --git a/ui/src/app/examination/question/examination-essay-question.component.ts b/ui/src/app/examination/question/examination-essay-question.component.ts index 824135631..6df6a2996 100644 --- a/ui/src/app/examination/question/examination-essay-question.component.ts +++ b/ui/src/app/examination/question/examination-essay-question.component.ts @@ -26,7 +26,7 @@ import { ExaminationService } from '../examination.service'; }) export class ExaminationEssayQuestionComponent implements OnInit { @Input() sq!: Omit & { essayAnswer: EssayAnswer }; - @Input() exam!: Examination; + @Input() exam?: Examination; @Input() isPreview = false; questionTitle!: string; @@ -48,10 +48,11 @@ export class ExaminationEssayQuestionComponent implements OnInit { const decodedString = doc.documentElement.innerText; this.questionTitle = decodedString; } - saveAnswer = () => this.Examination.saveTextualAnswer$(this.sq, this.exam.hash, false, false).subscribe(); + saveAnswer = () => this.Examination.saveTextualAnswer$(this.sq, this.exam?.hash || '', false, false).subscribe(); + removeQuestionAnswerAttachment = () => { const answeredQuestion = this.sq as AnsweredQuestion; // TODO: no casting - if (this.exam.external) { + if (this.exam?.external) { this.Attachment.removeExternalQuestionAnswerAttachment(answeredQuestion, this.exam.hash); return; } @@ -59,11 +60,11 @@ export class ExaminationEssayQuestionComponent implements OnInit { }; selectFile = () => { - if (this.isPreview) { + if (this.isPreview || !this.exam) { return; } this.Attachment.selectFile(false).then((data) => { - if (this.exam.external) { + if (this.exam?.external) { this.Files.uploadAnswerAttachment( '/app/iop/attachment/question/answer', data.$value.attachmentFile, diff --git a/ui/src/app/examination/question/examination-question.component.html b/ui/src/app/examination/question/examination-question.component.html index d55270a52..f73d68e79 100644 --- a/ui/src/app/examination/question/examination-question.component.html +++ b/ui/src/app/examination/question/examination-question.component.html @@ -30,6 +30,7 @@
+
@@ -93,16 +94,16 @@ @@ -111,9 +112,9 @@
diff --git a/ui/src/app/examination/question/examination-question.component.ts b/ui/src/app/examination/question/examination-question.component.ts index f27ee5ab0..86d430f29 100644 --- a/ui/src/app/examination/question/examination-question.component.ts +++ b/ui/src/app/examination/question/examination-question.component.ts @@ -26,7 +26,7 @@ type ClozeTestAnswer = { [key: string]: string }; templateUrl: './examination-question.component.html', }) export class ExaminationQuestionComponent implements OnInit, AfterViewInit { - @Input() exam!: Examination; + @Input() exam?: Examination; @Input() question!: ExaminationQuestion; @Input() isPreview = false; @Input() isCollaborative = false; @@ -67,12 +67,15 @@ export class ExaminationQuestionComponent implements OnInit, AfterViewInit { }; downloadQuestionAttachment = () => { - if (this.exam.external) { - this.Attachment.downloadExternalQuestionAttachment(this.exam, this.sq); - } else if (this.isCollaborative) { - this.Attachment.downloadCollaborativeQuestionAttachment(this.exam.id, this.sq); - } else { - this.Attachment.downloadQuestionAttachment(this.sq.question); + if (this.exam) { + if (this.exam.external) { + this.Attachment.downloadExternalQuestionAttachment(this.exam, this.sq); + } else if (this.isCollaborative) { + this.Attachment.downloadCollaborativeQuestionAttachment(this.exam.id, this.sq); + } else { + this.Attachment.downloadQuestionAttachment(this.sq.question); + } + console.error('Cannot retrieve attachment without exam.'); } }; diff --git a/ui/src/app/question/basequestion/question-body.component.ts b/ui/src/app/question/basequestion/question-body.component.ts index afd54e2be..ef2835df1 100644 --- a/ui/src/app/question/basequestion/question-body.component.ts +++ b/ui/src/app/question/basequestion/question-body.component.ts @@ -36,7 +36,7 @@ export class QuestionBodyComponent implements OnInit { @Input() currentOwners: User[] = []; @Input() lotteryOn = false; @Input() examId = 0; - @Input() sectionQuestion!: ExamSectionQuestion; + @Input() sectionQuestion?: ExamSectionQuestion; @Input() collaborative = false; isInPublishedExam = false; @@ -128,7 +128,7 @@ export class QuestionBodyComponent implements OnInit { }); downloadQuestionAttachment = () => { - if (this.question.attachment && this.question.attachment.externalId) { + if (this.question.attachment && this.question.attachment.externalId && this.sectionQuestion) { this.Attachment.downloadCollaborativeQuestionAttachment(this.examId, this.sectionQuestion); return; } diff --git a/ui/src/app/question/basequestion/question.component.html b/ui/src/app/question/basequestion/question.component.html index caa820d39..8d2b0e5a7 100644 --- a/ui/src/app/question/basequestion/question.component.html +++ b/ui/src/app/question/basequestion/question.component.html @@ -35,6 +35,22 @@
+
+ +
+
+
+
+ +
+
+
+
`, +}) +export class QuestionPreviewDialogComponent { + @Input() question?: ExaminationQuestion; + + constructor(public activeModal: NgbActiveModal) {} + runme = () => { + console.log('test question:'); + console.log(this.question); //TODO DELETEME + console.log(this.question?.question.question); + return true; + }; +} diff --git a/ui/src/app/question/question.module.ts b/ui/src/app/question/question.module.ts index 0c5a3fc11..6f62f6500 100644 --- a/ui/src/app/question/question.module.ts +++ b/ui/src/app/question/question.module.ts @@ -15,6 +15,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { ExaminationModule } from '../examination/examination.module'; import { SharedModule } from '../shared/shared.module'; import { ClaimChoiceEditorComponent } from './basequestion/claim-choice.component'; import { EssayEditorComponent } from './basequestion/essay.component'; @@ -34,11 +35,12 @@ import { LibraryOwnersComponent } from './library/owners/library-owners.componen import { LibraryResultsComponent } from './library/results/library-results.component'; import { LibrarySearchComponent } from './library/search/library-search.component'; import { QuestionSelectorComponent } from './picker/question-picker.component'; +import { QuestionPreviewDialogComponent } from './previewquestion/preview-question'; import { QuestionService } from './question.service'; import { TagPickerComponent } from './tags/tag-picker.component'; @NgModule({ - imports: [SharedModule, NgbModule, RouterModule], + imports: [SharedModule, NgbModule, RouterModule, ExaminationModule], declarations: [ LibraryComponent, LibrarySearchComponent, @@ -58,6 +60,7 @@ import { TagPickerComponent } from './tags/tag-picker.component'; MultipleChoiceOptionEditorComponent, WeightedMultipleChoiceOptionEditorComponent, TagPickerComponent, + QuestionPreviewDialogComponent, ], bootstrap: [QuestionSelectorComponent, BaseQuestionEditorComponent, ExamQuestionEditorComponent], providers: [LibraryService, QuestionService], diff --git a/ui/src/assets/i18n/en.json b/ui/src/assets/i18n/en.json index ac2a62687..73d36baab 100644 --- a/ui/src/assets/i18n/en.json +++ b/ui/src/assets/i18n/en.json @@ -1148,5 +1148,10 @@ "sitnet_waiting_room_title": "Waiting room", "sitnet_wrong_room_title": "Wrong room", "sitnet_wrong_machine_title": "Wrong computer", - "sitnet_examination_logout_title": "Examination logout" + "sitnet_examination_logout_title": "Examination logout", + "sitnet_go_back": "Back", + "sitnet_preview_question": "Question Preview", + "sitnet_button_preview": "Preview question", + "sitnet_no_preview_available": "No preview available", + "sitnet_used_in_exams": "Used in exams" } diff --git a/ui/src/assets/i18n/fi.json b/ui/src/assets/i18n/fi.json index 27097157e..cba5c6fb2 100644 --- a/ui/src/assets/i18n/fi.json +++ b/ui/src/assets/i18n/fi.json @@ -1148,5 +1148,10 @@ "sitnet_waiting_room_title": "Tentin odotushuone", "sitnet_wrong_room_title": "Väärä tenttitila", "sitnet_wrong_machine_title": "Väärä tenttikone", - "sitnet_examination_logout_title": "Tentin uloskirjautuminen" + "sitnet_examination_logout_title": "Tentin uloskirjautuminen", + "sitnet_go_back": "Takaisin", + "sitnet_preview_question": "Kysymyksen esikatselu", + "sitnet_button_preview": "Esikatsele kysymys", + "sitnet_no_preview_available": "Kysymyksen esikatselu ei ole saatavilla", + "sitnet_used_in_exams": "Käytössä tenteissä" } diff --git a/ui/src/assets/i18n/sv.json b/ui/src/assets/i18n/sv.json index 36b92d0a9..050ae6660 100644 --- a/ui/src/assets/i18n/sv.json +++ b/ui/src/assets/i18n/sv.json @@ -1148,5 +1148,10 @@ "sitnet_waiting_room_title": "Tentin odotushuone SV", "sitnet_wrong_room_title": "Fel tentamensutrymme", "sitnet_wrong_machine_title": "Fel dator", - "sitnet_examination_logout_title": "Utloggning" + "sitnet_examination_logout_title": "Utloggning", + "sitnet_go_back": "Back SV", + "sitnet_preview_question": "Question Preview SV", + "sitnet_button_preview": "Preview question SV", + "sitnet_no_preview_available": "No preview available SV", + "sitnet_used_in_exams": "Käytössä tenteissä SV" }