コード例 #1
0
 public void TestInit()
 {
     surveydb           = Database.GetConnection();
     surveyDal          = new SurveyDAL();
     userDAL            = new UserDAL();
     questionDAL        = new QuestionDAL();
     user               = new users();
     user.User_name     = userName;
     user.User_password = password;
     HelperDAL.AddUser(user);
     survey      = new surveys();
     survey.Name = surveyName;
     //survey.users = user;
     survey.User_name   = userName;
     SurveyCode         = HelperDAL.GenerateRandomSurveyCode();
     survey.Survey_code = SurveyCode;
     HelperDAL.AddSurvey(survey);
     question = new questions();
     question.Question_name = questionName;
     question.Surveys_id    = survey.Id;
     question.Input_type_id = 2;
     this.questionDAL.AddQuestion(question);
     this.optionChoicesDAL                 = new OptionChoicesDAL();
     this.optionChoice                     = new option_choices();
     this.optionChoice.Question_id         = question.Id;
     this.optionChoice.Option_choices_name = OptionChoiceName;
     this.optionChoicesDAL.AddOptionChoice(optionChoice);
     this.answersDAL                = new AnswersDAL();
     this.answer                    = new answers();
     this.answer.User_name          = userName;
     this.answer.Question_option_id = optionChoice.Id;
 }
コード例 #2
0
        /**
         * param name="answer"
         * param name="q"
         * returns trả về true, false kiểm  tra đáp án đùng không
         * example
         */
        public static bool checkAnswer(Question q, string answer)
        {
            var answersDAL = new AnswersDAL();

            return(answersDAL.checkAnswer(q.QuestionID, answer));
        }