forked from Sunbird-inQuiry/editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue Sunbird-inQuiry#42 feat: Added an interface for match the follo…
…wing type question
- Loading branch information
Arpan Gupta
committed
Jul 13, 2023
1 parent
ef5f5f6
commit 44f548c
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
projects/questionset-editor-library/src/lib/interfaces/MtfForm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MtfOption>; | ||
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<MtfOption>; | ||
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); | ||
} | ||
} |