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; }
public void setQuestion(Question qst) { question = qst; //clear the lists and recreate the values answers.Clear(); answers = gm.getAllAnswers(question); }
public PlayableQuestion(Question qst) { //set the question question = qst; //get the answers answers = gm.getAllAnswers(question); }
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; }
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); } }
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; }
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; }
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; }
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; }
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; }
private void detach_Questions(Question entity) { this.SendPropertyChanging(); entity.Round = null; }
private void attach_Questions(Question entity) { this.SendPropertyChanging(); entity.Round = this; }
partial void DeleteQuestion(Question instance);
partial void UpdateQuestion(Question instance);
partial void InsertQuestion(Question instance);