From 44f548c388ba609e680f372e60b8ec793d157588 Mon Sep 17 00:00:00 2001 From: Arpan Gupta Date: Thu, 13 Jul 2023 13:16:00 +0530 Subject: [PATCH] Issue #42 feat: Added an interface for match the following type question --- .../src/lib/interfaces/MtfForm.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 projects/questionset-editor-library/src/lib/interfaces/MtfForm.ts diff --git a/projects/questionset-editor-library/src/lib/interfaces/MtfForm.ts b/projects/questionset-editor-library/src/lib/interfaces/MtfForm.ts new file mode 100644 index 00000000..489d3f99 --- /dev/null +++ b/projects/questionset-editor-library/src/lib/interfaces/MtfForm.ts @@ -0,0 +1,56 @@ +import * as _ from "lodash-es"; + +export class MtfOption { + constructor(public leftOption: string, public rightOption: string) {} +} + +export interface MtfData { + question: string; + options: Array; + answer?: object; + learningOutcome?: string; + complexityLevel?: string; + maxScore?: number; +} + +export interface MtfConfig { + templateId?: string; + numberOfOptions?: number; + maximumOptions?: number; + +} + +export class MtfForm { + public question: string; + public options: Array; + public templateId: string; + public answer: object; + public learningOutcome?: string; + public complexityLevel?: string; + public maxScore?: number; + public maximumOptions; + public numberOfOptions; + + constructor({question, options, answer, learningOutcome, complexityLevel, maxScore,}: MtfData,{ templateId, numberOfOptions, maximumOptions }: MtfConfig) { + this.question = question; + this.options = options || []; + this.templateId = templateId; + this.answer = answer || {}; + this.learningOutcome = learningOutcome; + this.complexityLevel = complexityLevel; + this.numberOfOptions = numberOfOptions || 2; + this.maximumOptions = maximumOptions || 4; + this.maxScore = maxScore; + if (!this.options || !this.options.length) { + _.times(this.numberOfOptions, index => this.options.push(new MtfOption("",""))); + } + } + + addOptions() { + this.options.push(new MtfOption("", "")); + } + + deleteOptions(position: number) { + this.options.splice(position, 1); + } +}