Example #1
0
 public List<Result> getAllResultsByQuestion(Question qu)
 {
     var result = (from r in dc.Results
                   where r.FK_Question == qu.Question_Id
                   select r).ToList<Result>();
     return result;
 }
Example #2
0
        public void setQuestion(Question qst)
        {
            question = qst;

            //clear the lists and recreate the values
            answers.Clear();
            answers = gm.getAllAnswers(question);
        }
Example #3
0
        public PlayableQuestion(Question qst)
        {
            //set the question
            question = qst;

            //get the answers
            answers = gm.getAllAnswers(question);
        }
Example #4
0
 public List<Answer> getAllAnswers(Question qu)
 {
     if (qu == null)
     {
         throw new Exception("Question must be given...");
     }
     var result = (from a in dc.Answers
                   where a.FK_Question == qu.Question_Id
                   select a).ToList<Answer>();
     return result;
 }
Example #5
0
        public CompleteResult(Result res)
        {
            //set the result
            result = res;

            try
            {
                //get the question
                question.Question_Id = res.FK_Question;
                question = gm.getQuestion(question);

                //get the answer
                answer.Answer_Id = res.FK_Answer;
                answer = gm.getAnswer(answer);
                isRight = (answer.Answer_value == 1);

                //if needed, get the right answer
                if (!isRight)
                {
                    Question q = new Question();
                    q.Question_Id = answer.FK_Question;
                    rightAnswer = gm.getRightAnswer(q);
                }

                //get the quiz
                quiz.Quiz_Id = res.FK_Quiz;
                quiz = gm.getQuiz(quiz);

                //get the user
                user.User_Id = res.FK_User;
                user = um.getUser(user.User_Id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #6
0
        public int InsertResultByValues(User user, Question question, Answer answer, Quiz quiz)
        {
            /**
             * User komt van Sessie,
             * Question ook (of uit controller)
             * Answer komt van controller (ajax post)
             * Quiz komt van sessie (of controller)
             **/

            //result aanmaken
            Result r = new Result();
            r.FK_User = user.User_Id;
            r.FK_Question = question.Question_Id;
            r.FK_Answer = answer.Answer_Id;
            r.FK_Quiz = quiz.Quiz_Id;

            //posten naar database
            dc.Results.InsertOnSubmit(r);
            dc.SubmitChanges();

            return r.Result_Id;
        }
Example #7
0
 public Answer getRightAnswer(Question qu)
 {
     if (qu == null)
     {
         throw new Exception("Question must be given...");
     }
     var result = (from a in dc.Answers
                   where a.FK_Question == qu.Question_Id && a.Answer_value == 1
                   select a).SingleOrDefault();
     return (Answer)result;
 }
Example #8
0
 public Question getQuestion(Question qu)
 {
     if (qu == null)
     {
         throw new Exception("Question must be given...");
     }
     var result = (from q in dc.Questions
                   where q.Question_Id == qu.Question_Id
                   select q).SingleOrDefault();
     return (Question)result;
 }
Example #9
0
        public int updateQuestion(Question question)
        {
            //query naar database om waarde te vinden
            Question result = (from q in dc.Questions
                            where q.Question_Id == question.Question_Id
                            select q).Single();

            //veranderingen aanbrengen
            if (question.Question_Text != null) result.Question_Text = question.Question_Text;
            if (question.FK_Round != null) result.FK_Round = question.FK_Round;

            //updaten in db
            try
            {
                dc.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception("Value couldn't be updated...");
            }

            return result.Question_Id;
        }
Example #10
0
        public int insertQuestion(Question q)
        {
            dc.Questions.InsertOnSubmit(q);
            try
            {
                dc.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception("Query couldn't be executed...");
            }

            return q.Question_Id;
        }
Example #11
0
		private void detach_Questions(Question entity)
		{
			this.SendPropertyChanging();
			entity.Round = null;
		}
Example #12
0
		private void attach_Questions(Question entity)
		{
			this.SendPropertyChanging();
			entity.Round = this;
		}
Example #13
0
 partial void DeleteQuestion(Question instance);
Example #14
0
 partial void UpdateQuestion(Question instance);
Example #15
0
 partial void InsertQuestion(Question instance);