import { defineStore } from 'pinia'

export const useAnswersStore = defineStore({
    id: 'answers',
    state: () => ({
        answers: [],
        quizCurrent: null
    }),
    actions: {
        isAnswered(index) {
            if (!Array.isArray(this.answers[index]) ) {
                return this.answers[index] != null
            } else {
                return this.answers[index].length > 0
            }
        },
        makeArray(index, selectNumber) {
            if (selectNumber > 1 && !Array.isArray(this.answers[index])) {
                this.answers[index] = [ ]
            }
        }
    }
})