예제 #1
0
        private void GetQuestion()
        {
            string query = "SELECT  QUESTION_ID, QUESTION_USER_ID, QUESTION_TEXT, ROW_INDEX FROM TB_USER_QUESTION";

            using (DataTable dt = DBSqlite.GetSelectData(query))
            {
                if (dt.Rows.Count > 0)
                {
                    QuestionCollection.Clear();

                    foreach (DataRow dr in dt.Rows)
                    {
                        question Question = new question()
                        {
                            QUESTION_ID      = dr["QUESTION_ID"].ToString(),
                            QUESTION_USER_ID = dr["QUESTION_USER_ID"].ToString(),
                            QUESTION_TEXT    = dr["QUESTION_TEXT"].ToString(),
                            ROW_INDEX        = (int)dr["ROW_INDEX"]
                        };

                        QuestionCollection.Add(Question);
                    }
                }
            }
        }
예제 #2
0
        public static QuestionCollection GetByType(int type)
        {
            DataTable          dt     = DBLayer.ExecuteQuery(string.Format("select * from Question where question_type = {0}", type));
            QuestionCollection result = new QuestionCollection();

            if (dt.Rows.Count > 0)
            {
                int            questID  = Convert.ToInt32(dt.Rows[0]["id"].ToString());
                string         text     = dt.Rows[0]["question_text"].ToString();
                string         modelAns = dt.Rows[0]["question_modelAns"].ToString();
                int            courseID = Convert.ToInt32(dt.Rows[0]["Course_ID"].ToString());
                QuestionAnswer questans = new QuestionAnswer();
                questans.Answer = modelAns;
                Course course = new Course();
                course.Id = courseID;
                Question quest = new Question(questID, text, type, questans, course);
                result.Add(quest);
            }
            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public QuestionCollection GetAllQuestions()
        {
            try
            {
                QuestionCollection collection = new QuestionCollection();

                using (IDataReader dr = Database.ExecuteReader("UspGetAllQuestions", CommandType.StoredProcedure))
                {
                    while (dr.Read())
                    {
                        Question question = Populate(dr);

                        collection.Add(question);
                    }
                }

                return(collection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void ExecuteNewQuestionCommand(Object parameter)
        {
            var view = new TecherFormAddAndEditQuestions();
            var vm   = new AddEditQuestionViewModel();

            vm.Question      = new Question();
            vm.IsNewQuestion = true;
            vm.Window        = view;
            view.DataContext = vm;

            var result = view.ShowDialog();

            if (result.HasValue && result.Value)
            {
                vm.Question.Answers = new List <Answer>(vm.AnswerCollection);
                var questionid = DBDataSource.AddNewQuestion(vm.Question, NavigationHelper.CurrrentTest.Id);
                if (questionid > 0)
                {
                    //Добавление вопроса в UI
                    vm.Question.Id = questionid;
                    QuestionCollection.Add(vm.Question);
                }
            }
        }
예제 #5
0
 private void OneAnswerTestToolStripMenuItem_Click(object sender, EventArgs e)
 {
     lbQuestions.Enabled = true;
     collection.Add(new OneAnswerQuestion());
     lbQuestions.Items.Add("Вопрос " + collection.Count);
 }