Ejemplo n.º 1
0
        public static Quiz GetQuiz()
        {
            Quiz q = new Quiz();
            QuizItemContainer q1  = new QuizItemContainer();
            Question          qe1 = new Question("Q1", false);

            qe1.Answers.AddRange(new List <Answer> {
                new Answer("A1", false), new Answer("A2", true)
            });
            Question qe2 = new Question("Q2", true);

            qe2.Answers.AddRange(new List <Answer> {
                new Answer("A1", false), new Answer("A2", true), new Answer("A3", true)
            });
            q1.Add(qe1);
            q1.Add(qe2);
            Question qe3 = new Question("Q2", true);

            qe3.Answers.AddRange(new List <Answer> {
                new Answer("A1", true), new Answer("A2", true), new Answer("A3", false)
            });
            q.Add(q1);
            q.Add(qe3);

            q.Title = "Test";
            return(q);
        }
 public Quiz Deserialize(string filepath)
 {
     string jsonstring = File.ReadAllText(Properties.Settings.Default.FilePath);
     var jsondto = new List<Dto>();
     jsondto = JsonConvert.DeserializeObject<List<Dto>>(jsonstring);
     var quiz = new Quiz();
     foreach (var VARIABLE in jsondto)
     {
         var Question = new QuestionAnswer();
         Question.Question = VARIABLE.Question;
         Question.A = VARIABLE.A;
         Question.B = VARIABLE.B;
         Question.C = VARIABLE.C;
         Question.D = VARIABLE.D;
         Question.RightAnswer = VARIABLE.RightAnswer;
         quiz.Add(Question);
     }
     return quiz;
 }
Ejemplo n.º 3
0
        public Quiz Deserialize(string filepath)
        {
            string jsonstring = File.ReadAllText(Properties.Settings.Default.FilePath);
            var    jsondto    = new List <Dto>();

            jsondto = JsonConvert.DeserializeObject <List <Dto> >(jsonstring);
            var quiz = new Quiz();

            foreach (var VARIABLE in jsondto)
            {
                var Question = new QuestionAnswer();
                Question.Question    = VARIABLE.Question;
                Question.A           = VARIABLE.A;
                Question.B           = VARIABLE.B;
                Question.C           = VARIABLE.C;
                Question.D           = VARIABLE.D;
                Question.RightAnswer = VARIABLE.RightAnswer;
                quiz.Add(Question);
            }
            return(quiz);
        }