Add plugin
This commit is contained in:
@@ -61,6 +61,10 @@ export default {
|
|||||||
firebaseAppCheckDebugToken: process.env.NODE_ENV !== 'production'
|
firebaseAppCheckDebugToken: process.env.NODE_ENV !== 'production'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
publicRuntimeConfig: {
|
||||||
|
NODE_ENV: process.env.NODE_ENV
|
||||||
|
},
|
||||||
|
|
||||||
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
|
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
|
||||||
vuetify: {
|
vuetify: {
|
||||||
customVariables: ['~/assets/variables.scss'],
|
customVariables: ['~/assets/variables.scss'],
|
||||||
|
|||||||
31
plugins/closed-ended-question.js
Normal file
31
plugins/closed-ended-question.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
export class ClosedEndedQuestion {
|
||||||
|
constructor (id, question, answers, correctAnswer, creator, created, comments, status) {
|
||||||
|
this.id = id
|
||||||
|
this.question = question
|
||||||
|
this.answers = answers
|
||||||
|
this.correctAnswer = correctAnswer
|
||||||
|
this.creator = creator
|
||||||
|
this.created = created
|
||||||
|
this.comments = comments
|
||||||
|
this.status = status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Firestore data converter
|
||||||
|
export const ClosedEndedQuestionConverter = {
|
||||||
|
toFirestore: (closedEndedQuestion) => {
|
||||||
|
return {
|
||||||
|
frage: closedEndedQuestion.question,
|
||||||
|
antworten: closedEndedQuestion.answers,
|
||||||
|
richtig: closedEndedQuestion.correctAnswer,
|
||||||
|
ersteller: closedEndedQuestion.creator,
|
||||||
|
erstellt: closedEndedQuestion.created,
|
||||||
|
kommentare: closedEndedQuestion.comments,
|
||||||
|
status: closedEndedQuestion.status
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fromFirestore: (snapshot, options) => {
|
||||||
|
const data = snapshot.data(options)
|
||||||
|
return new ClosedEndedQuestion(snapshot.id, data.frage, data.antworten, data.richtig, data.ersteller, data.erstellt, data.kommentare, data.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
37
plugins/game.js
Normal file
37
plugins/game.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
export class Game {
|
||||||
|
constructor (id, questions, created, player1id, player1name, player1answers, player2id, player2name, player2answers) {
|
||||||
|
this.id = id
|
||||||
|
this.questions = questions
|
||||||
|
this.created = created
|
||||||
|
this.player1id = player1id
|
||||||
|
this.player1name = player1name
|
||||||
|
this.player1answers = player1answers
|
||||||
|
this.player2id = player2id
|
||||||
|
this.player2name = player2name
|
||||||
|
this.player2answers = player2answers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Firestore data converter
|
||||||
|
export const GameConverter = {
|
||||||
|
toFirestore: (game) => {
|
||||||
|
return {
|
||||||
|
fragen: game.questions,
|
||||||
|
erstellt: game.created,
|
||||||
|
spieler1id: game.player1id,
|
||||||
|
spieler1name: game.player1name,
|
||||||
|
spieler1antworten: game.player1answers,
|
||||||
|
spieler2id: game.player2id,
|
||||||
|
spieler2name: game.player2name,
|
||||||
|
spieler2antworten: game.player2answers
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fromFirestore: (snapshot, options) => {
|
||||||
|
const data = snapshot.data(options)
|
||||||
|
return new Game(
|
||||||
|
snapshot.id, data.fragen, data.erstellt,
|
||||||
|
data.spieler1id, data.spieler1name, data.spieler1antworten,
|
||||||
|
data.spieler2id, data.spieler2name, data.spieler2antworten
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
29
plugins/open-ended-question.js
Normal file
29
plugins/open-ended-question.js
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
27
plugins/user.js
Normal file
27
plugins/user.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
export class User {
|
||||||
|
constructor (gamesStarted) {
|
||||||
|
this.gamesStarted = []
|
||||||
|
|
||||||
|
gamesStarted.forEach(e => {
|
||||||
|
this.gamesStarted.push({ course: e.kurs, game: e.spiel })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Firestore data converter
|
||||||
|
export const UserConverter = {
|
||||||
|
toFirestore: (user) => {
|
||||||
|
const spieleBegonnen = []
|
||||||
|
user.gamesStarted.forEach(e => {
|
||||||
|
spieleBegonnen.push({ kurs: e.course, spiel: e.game })
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
spieleBegonnen
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fromFirestore: (snapshot, options) => {
|
||||||
|
const data = snapshot.data(options)
|
||||||
|
return new User(data.spieleBegonnen)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user