Add plugin

This commit is contained in:
2022-10-28 21:47:02 +02:00
parent 2053c12eee
commit 58fac72355
5 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
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)
}
}