This repository has been archived on 2025-02-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
iu-quiz-app/plugins/open-ended-question.js
2022-10-28 21:47:02 +02:00

29 lines
952 B
JavaScript

export class OpenEndedQuestion {
constructor (id, question, solution, creator, created, ratings, difficulty) {
this.id = id
this.question = question
this.solution = solution
this.creator = creator
this.created = created
this.ratings = ratings
this.difficulty = difficulty
}
}
// Firestore data converter
export const OpenEndedQuestionConverter = {
toFirestore: (openEndedQuestion) => {
return {
frage: openEndedQuestion.question,
musterloesung: openEndedQuestion.solution,
ersteller: openEndedQuestion.creator,
erstellt: openEndedQuestion.created,
bewertungen: openEndedQuestion.ratings,
schwierigkeit: openEndedQuestion.difficulty
}
},
fromFirestore: (snapshot, options) => {
const data = snapshot.data(options)
return new OpenEndedQuestion(snapshot.id, data.frage, data.musterloesung, data.ersteller, data.erstellt, data.bewertungen, data.schwierigkeit)
}
}