示例#1
0
        public Question Update(Question question)
        {
            this.questions.Update(question);
            this.questions.SaveChanges();

            return question;
        }
示例#2
0
        public List<Question> GetListQuestions()
        {
            List<Question> questionsList = new List<Question>();
            XmlDocument doc = new XmlDocument();
            doc.Load("Quiz.xml");
            XmlNode node = doc.SelectSingleNode("quiz");
            XmlNodeList questions = node.SelectNodes("question");
            foreach (XmlNode question in questions)
            {
                Question _question = new Question();
                _question.QuestionText = question.FirstChild.InnerText;

                for (int i = 0; i < question.LastChild.ChildNodes.Count; i++)
                {

                    _question.Answers[i] = question.LastChild.ChildNodes[i].InnerText;
                    if (question.LastChild.ChildNodes[i].Name == "correctAnswer")
                        _question.CorrectAnswer = i+1;

                }
                questionsList.Add(_question);
            }

            return questionsList;
        }
示例#3
0
        public Question Add(Question question)
        {
            this.questions.Add(question);
            this.questions.SaveChanges();

            return question;
        }
示例#4
0
        public void QuizReturnNotNullTest()
        {
            Question question = new Question();
            List<Question> questions = question.GetListQuestions();

            Assert.IsNotNull(questions);
        }
        public IHttpActionResult PutQuestion(int id, Question question)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != question.ID)
            {
                return BadRequest();
            }

            db.Entry(question).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuestionExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostQuestion(Question question)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Questions.Add(question);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = question.ID }, question);
        }
示例#7
0
        public Question GetNext(Question question, string possibleAnswerContent)
        {
            string nextQuestionContent;

            if (question.IsDependsOn)
            {
                nextQuestionContent = question.Content + "|" + possibleAnswerContent;
            }
            else
            {
                nextQuestionContent = question.Content;
            }

            return this.questions.All()
                               .FirstOrDefault(q => q.ParentContent == nextQuestionContent && q.SurveyId == question.SurveyId);
        }
        void GotoNextQuestion()
        {
            if (question_nr >= questions.Count - 1)
            {
                this.specialButton1.Enabled = true;
                this.specialButton2.Enabled = false;
            }

            currentQuestion = LoadQuestions(question_nr);
            this.r1.Text = currentQuestion.Answers[0];
            this.r2.Text = currentQuestion.Answers[1];
            this.r3.Text = currentQuestion.Answers[2];
            this.r4.Text = currentQuestion.Answers[3];
            this.richTextBox1.Text = currentQuestion.QuestionText;

            question_nr++;
        }
 private List<Question> LoadAllQuestion()
 {
     Question question = new Question();
     return question.GetListQuestions();
 }