Skip to content

Commit

Permalink
Issue Sunbird-inQuiry#42 feat: Added an interface for match the follo…
Browse files Browse the repository at this point in the history
…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.
56 changes: 56 additions & 0 deletions projects/questionset-editor-library/src/lib/interfaces/MtfForm.ts
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);
}
}

0 comments on commit 44f548c

Please sign in to comment.