示例#1
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);
            }
        }
示例#2
0
 // --------------------------------------------------------- Result(s) Query's
 public Answer getAnswer(Answer ans)
 {
     if (ans == null)
     {
         throw new Exception("Answer must be given...");
     }
     var result = (from a in dc.Answers
                   where a.Answer_Id == ans.Answer_Id
                   select a).SingleOrDefault();
     return (Answer)result;
 }
示例#3
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;
        }
示例#4
0
        public int insertAnswer(Answer a)
        {
            dc.Answers.InsertOnSubmit(a);
            try
            {
                dc.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception("Query couldn't be executed...");
            }

            return a.Answer_Id;
        }
示例#5
0
        public int updateAnswer(Answer answer)
        {
            //query naar database om waarde te vinden
            Answer result = (from a in dc.Answers
                            where a.Answer_Id == answer.Answer_Id
                            select a).Single();

            //veranderingen aanbrengen
            if (answer.Answer_Text != null) result.Answer_Text = answer.Answer_Text;
            if (answer.FK_Question != null) result.FK_Question = answer.FK_Question;
            if (answer.FK_Type != null) result.FK_Type = answer.FK_Type;
            if (answer.Answer_value != null) result.Answer_value = answer.Answer_value;

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

            return result.Answer_Id;
        }
示例#6
0
		private void detach_Answers(Answer entity)
		{
			this.SendPropertyChanging();
			entity.Question = null;
		}
示例#7
0
		private void attach_Answers(Answer entity)
		{
			this.SendPropertyChanging();
			entity.Question = this;
		}
示例#8
0
 partial void DeleteAnswer(Answer instance);
示例#9
0
 partial void UpdateAnswer(Answer instance);
示例#10
0
 partial void InsertAnswer(Answer instance);