Exemplo n.º 1
0
        //copy constructor
        public Quiz(QuizViewModel model)
        {
            this.Name = model.Name;
            this.numberOfQustionsPerTry = model.NumberOdQuestionsPerTry;
            this.time = model.Time;

            this.Questions = new List <Question>();
            foreach (QuestionModel questionModel in model.Questions)
            {
                Question tempQuestion = new Question();
                tempQuestion.QuestionText = questionModel.QuestionText;
                tempQuestion.Points       = questionModel.Points;
                tempQuestion.Picture      = questionModel.PicturePath;
                foreach (BaseAnswerModel answer in questionModel.Answers)
                {
                    if (answer.type.Contains("text"))
                    {
                        TextAnswer temp = new TextAnswer(answer.text, answer.IsCorrect);
                        tempQuestion.Answers.Add(temp);
                    }
                    else if (answer.type.Contains("region"))
                    {
                        tempQuestion.Answers.Add(new RegionAnswer(answer.x1, answer.x2, answer.y1, answer.y2, answer.IsCorrect));
                    }
                }
                this.Questions.Add(tempQuestion);
            }
        }
Exemplo n.º 2
0
 public void update(EditQuestionModel model)
 {
     this.Points       = Points;
     this.QuestionText = model.QuestionText;
     foreach (editAnswer answerModel in model.Answers)
     {
         Answer tempAnswer = null;
         if (answerModel.type.ToLower().Contains("region"))
         {
             tempAnswer = new RegionAnswer(answerModel.x1, answerModel.x2, answerModel.y1, answerModel.y2, answerModel.IsCorrect);
         }
         else if (answerModel.type.ToLower().Contains("text"))
         {
             tempAnswer = new TextAnswer(answerModel.text, answerModel.IsCorrect);
         }
         //tempAnswer.ID = answerModel.ID;
         this.Answers.Add(tempAnswer);
     }
 }