File
|
background
|
background: string
|
|
competences
|
competences: { id: number; name: string; }[]
|
|
difficulty
|
difficulty: Difficulty
|
|
feedback
|
feedback: string
|
|
feedback_html
|
feedback_html: string
|
export class QuizzQuestion {
id: number;
theme: string;
group: string;
text: string;
image: string;
feedback: string;
feedback_html: string;
difficulty: Difficulty;
answers: Array<QuizzAnswer>;
background: string;
competences: Array<{ id: number; name: string }>;
}
export enum QuizzAnswerStatus {
valid = "valid",
error = "error",
missing = "missing",
notValidNotSelected = "notValidNotSelected",
untouched = "untouched"
}
export class QuizzAnswer {
id: number;
text: string;
image: string;
isValid: boolean;
selected = false;
status = QuizzAnswerStatus.untouched;
public updateStatus = () => {
if (this.isValid) {
if (this.selected) {
console.error("answer ok");
this.status = QuizzAnswerStatus.valid;
} else {
console.error("answer missing");
this.status = QuizzAnswerStatus.missing;
}
} else {
if (this.selected && this.text.toLowerCase() !== "je ne sais pas") {
console.error("answer error");
this.status = QuizzAnswerStatus.error;
} else {
console.error("answer not valid / untouched");
this.status = QuizzAnswerStatus.notValidNotSelected;
}
}
};
}
export enum Difficulty {
easy = 1,
medium = 2,
hard = 3
}