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);
     }
 }