static Quiz CreateFillBlankQuiz(QuizTable table, string question, string answer, bool solved)
        {
            string start = table.Start;
            string end   = table.End;

            return(new FillBlankQuiz(question, answer, start, end, solved));
        }
        static Quiz CreateQuizDueToType(QuizTable table)
        {
            string type     = table.Type;
            string question = table.Question;
            string answer   = table.Answer;
            string options  = table.Options;
            int    min      = Convert.ToInt32(table.Min);
            int    max      = Convert.ToInt32(table.Max);
            int    step     = Convert.ToInt32(table.Step);
            bool   solved   = GetBooleanFromDatabase(table.Solved);

            switch (type)
            {
            case JsonAttributes.QuizTypes.AlphaPicker:
                return(new AlphaPickerQuiz(question, answer, solved));

            case JsonAttributes.QuizTypes.FillBlank:
                return(CreateFillBlankQuiz(table, question, answer, solved));

            case JsonAttributes.QuizTypes.FillTwoBlanks:
                return(CreateFillTwoBlanksQuiz(question, answer, solved));

            case JsonAttributes.QuizTypes.FourQuarter:
                return(CreateFourQuarterQuiz(question, answer, options, solved));

            case JsonAttributes.QuizTypes.MultiSelect:
                return(CreateMultiSelectQuiz(question, answer, options, solved));

            case JsonAttributes.QuizTypes.Picker:
                return(new PickerQuiz(question, Convert.ToInt32(answer), min, max, step, solved));

            case JsonAttributes.QuizTypes.SingleSelect:
            case JsonAttributes.QuizTypes.SingleSelectItem:
                return(CreateSelectItemQuiz(question, answer, options, solved));

            case JsonAttributes.QuizTypes.ToggleTranslate:
                return(CreateToggleTranslateQuiz(question, answer, options, solved));

            case JsonAttributes.QuizTypes.TrueFalse:
                return(CreateTrueFalseQuiz(question, answer, solved));

            default:
                throw new InvalidOperationException("Quiz type " + type + " is not supported");
            }
        }
 static void FillQuizzesForCategory(SQLiteConnection db, JToken quizzes, string categoryId)
 {
     foreach (var quizJson in quizzes)
     {
         var quiz = new QuizTable {
             Category = categoryId,
             Type     = quizJson [JsonAttributes.QuizFields.Type].ToString(),
             Question = quizJson [JsonAttributes.QuizFields.Question].ToString(),
             Answer   = quizJson [JsonAttributes.QuizFields.Answer].ToString(),
             Options  = quizJson [JsonAttributes.QuizFields.Options]?.ToString(),
             Min      = quizJson [JsonAttributes.QuizFields.Min]?.ToString(),
             Max      = quizJson [JsonAttributes.QuizFields.Max]?.ToString(),
             Start    = quizJson [JsonAttributes.QuizFields.Start]?.ToString(),
             End      = quizJson [JsonAttributes.QuizFields.End]?.ToString(),
             Step     = quizJson [JsonAttributes.QuizFields.Step]?.ToString(),
         };
         db.Insert(quiz);
     }
 }
 static void FillQuizzesForCategory(SQLiteConnection db, JToken quizzes, string categoryId)
 {
     foreach (var quizJson in quizzes)
     {
         var quiz = new QuizTable 
         {
             category = categoryId,
             type = quizJson[JsonAttributes.QuizFields.Type].ToString(),
             question = quizJson[JsonAttributes.QuizFields.Question].ToString(),
             answer = quizJson[JsonAttributes.QuizFields.Answer].ToString(),
             options = quizJson[JsonAttributes.QuizFields.Options]?.ToString(),
             min = quizJson[JsonAttributes.QuizFields.Min]?.ToString(),
             max = quizJson[JsonAttributes.QuizFields.Max]?.ToString(),
             start = quizJson[JsonAttributes.QuizFields.Start]?.ToString(),
             end = quizJson[JsonAttributes.QuizFields.End]?.ToString(),
             step = quizJson[JsonAttributes.QuizFields.Step]?.ToString(),
         };
         db.Insert(quiz);
     }
 }
 static Quiz CreateFillBlankQuiz(QuizTable table, string question, string answer,
     bool solved)
 {
     string start = table.start;
     string end = table.end;
     return new FillBlankQuiz(question, answer, start, end, solved);
 }
        static Quiz CreateQuizDueToType(QuizTable table)
        {
            string type = table.type;
            string question = table.question;
            string answer = table.answer;
            string options = table.options;
            int min = Convert.ToInt32(table.min);
            int max = Convert.ToInt32(table.max);
            int step = Convert.ToInt32(table.step);
            bool solved = GetBooleanFromDatabase(table.solved);

            switch (type)
            {
                case JsonAttributes.QuizTypes.AlphaPicker:
                    {
                        return new AlphaPickerQuiz(question, answer, solved);
                    }
                case JsonAttributes.QuizTypes.FillBlank:
                    {
                        return CreateFillBlankQuiz(table, question, answer, solved);
                    }
                case JsonAttributes.QuizTypes.FillTwoBlanks:
                    {
                        return CreateFillTwoBlanksQuiz(question, answer, solved);
                    }
                case JsonAttributes.QuizTypes.FourQuarter:
                    {
                        return CreateFourQuarterQuiz(question, answer, options, solved);
                    }
                case JsonAttributes.QuizTypes.MultiSelect:
                    {
                        return CreateMultiSelectQuiz(question, answer, options, solved);
                    }
                case JsonAttributes.QuizTypes.Picker:
                    {
                        return new PickerQuiz(question, Convert.ToInt32(answer), min, max, step, solved);
                    }
                case JsonAttributes.QuizTypes.SingleSelect:
                case JsonAttributes.QuizTypes.SingleSelectItem:
                    {
                        return CreateSelectItemQuiz(question, answer, options, solved);
                    }
                case JsonAttributes.QuizTypes.ToggleTranslate:
                    {
                        return CreateToggleTranslateQuiz(question, answer, options, solved);
                    }
                case JsonAttributes.QuizTypes.TrueFalse:
                    {
                        return CreateTrueFalseQuiz(question, answer, solved);

                    }
                default:
                    {
                        throw new InvalidOperationException("Quiz type " + type + " is not supported");
                    }
            }
        }