예제 #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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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();
 }