示例#1
0
文件: Quiz.cs 项目: Mr-357/TestIT
        //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);
            }
        }
示例#2
0
文件: Question.cs 项目: Mr-357/TestIT
 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);
     }
 }