protected void Button1_Click(object sender, EventArgs e)
        {
            string      examtopic = (string)Session["Examtopic"];
            DataHandler hnd       = new DataHandler();
            //List<QuestionSetObj> qset = hnd.GetQuestionSet(examtopic);

            //int res = (from x in qset
            //           select x).Distinct().Count();
            //txtquestionset.Text = res.ToString();

            QuestionObj ques = new QuestionObj();

            ques.ExamTopic        = examtopic;
            ques.ExamNumber       = Convert.ToInt32(txtquestionset.Text);
            Session["examnumber"] = ques.ExamNumber;
            //ques.ExamNumber = res + 1;
            ques.QuestionNumber       = 1;
            Session["questionnumber"] = 1;
            ques.QuestionText         = TextBox1.Text;
            ques.Option1       = TextBox2.Text;
            ques.Option2       = TextBox3.Text;
            ques.Option3       = TextBox4.Text;
            ques.Option4       = TextBox5.Text;
            ques.CorrectAnswer = Convert.ToInt32(TextBox6.Text);

            hnd.InsertQuestion(ques);
            Response.Redirect("AddQuestion2.aspx");
        }
Esempio n. 2
0
        public List <QuestionObj> getQuestion(string examId)
        {
            List <QuestionObj> list = new List <QuestionObj>();
            DataSet            ds   = DAL.Constance.ExecuteQueryDataSet("proc_getQuestion", CommandType.StoredProcedure, new SqlParameter("@examid", examId));

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                QuestionObj question = new QuestionObj(row.ItemArray[0].ToString(), row.ItemArray[1].ToString());
                list.Add(question);
            }
            return(list);
        }
        public ActionResult QuestionUpload(FormCollection formCollection)
        {
            QuestionObj OneQuestion = new QuestionObj();

            OneQuestion.CourseID     = formCollection["Course_ID"];
            OneQuestion.question     = formCollection["question"];
            OneQuestion.outputformat = formCollection["outputformat"];
            OneQuestion.testinput    = formCollection["testinput"];
            OneQuestion.answer       = formCollection["answer"];
            OneQuestion.setCQID();
            this.CreateQuestionService.Create(OneQuestion);

            return(RedirectToAction("CreateQuestion"));
        }
Esempio n. 4
0
        public bool InsertQuestion(QuestionObj question)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ExamTopic", question.ExamTopic),
                new SqlParameter("@ExamNumber", question.ExamNumber),
                new SqlParameter("@QuestionNumber", question.QuestionNumber),
                new SqlParameter("@QuestionText", question.QuestionText),
                new SqlParameter("@Option1", question.Option1),
                new SqlParameter("@Option2", question.Option2),
                new SqlParameter("@Option3", question.Option3),
                new SqlParameter("@Option4", question.Option4),
                new SqlParameter("@CorrectAnswer", question.CorrectAnswer)
            };

            return(SqlDBHelper.ExecuteNonQuery("QuestionInsert", CommandType.StoredProcedure, parameters));
        }
Esempio n. 5
0
        public List <QuestionObj> GetQuestion(string ExamTopic, int ExamNumber)
        {
            List <QuestionObj> Questionset = null;

            SqlParameter[] parameter = new SqlParameter[] {
                new SqlParameter("@ExamTopic", ExamTopic),
                new SqlParameter("@ExamNumber", ExamNumber)
            };
            //Lets get the list of all employees in a datataable
            using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("QuestionGetByTopicAndNumber", CommandType.StoredProcedure, parameter))


            {
                //check if any record exist or not
                if (table.Rows.Count > 0)
                {
                    //Lets go ahead and create the list of employees
                    Questionset = new List <QuestionObj>();

                    //Now lets populate the employee details into the list of employees
                    foreach (DataRow row in table.Rows)
                    {
                        QuestionObj qs = new QuestionObj();

                        qs.ExamTopic      = row["ExamTopic"].ToString();
                        qs.ExamNumber     = Convert.ToInt32(row["ExamNumber"]);
                        qs.QuestionNumber = Convert.ToInt32(row["QuestionNumber"]);
                        qs.QuestionText   = row["QuestionText"].ToString();
                        qs.Option1        = row["Option1"].ToString();
                        qs.Option2        = row["Option2"].ToString();
                        qs.Option3        = row["Option3"].ToString();
                        qs.Option4        = row["Option4"].ToString();
                        qs.CorrectAnswer  = Convert.ToInt32(row["CorrectAnswer"]);

                        Questionset.Add(qs);
                    }
                }
            }

            return(Questionset);
        }
 public bool InsertQuestion(QuestionObj question)
 {
     return(DBAccess.InsertQuestion(question));
 }
Esempio n. 7
0
        public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            ConnectorClient   connector = new ConnectorClient(new Uri(activity.ServiceUrl));
            Activity          reply     = null;
            List <CardAction> cards     = new List <CardAction>();

            try
            {
                this.HandleSystemMessage(activity);

                // 設定語系的快取
                if (activity.Text == "English" || activity.Text == "繁體中文")
                {
                    memoryCache.Set(activity.Conversation.Id + "_LANG", activity.Text, DateTimeOffset.UtcNow.AddDays(1));
                }

                // 判斷是否為直接連絡真人的清單
                var strIsConnect = memoryCache.Get(activity.Conversation.Id);

                // 如果不在真人聯絡清單中,就找出問題的內容
                if (strIsConnect == null)
                {
                    if (activity.GetActivityType() == ActivityTypes.Message)
                    {
                        QuestionObj Question = new QuestionObj();

                        // 找出是否有答案
                        QuestionFile answer = Question.GetQuestionAnswer(activity.Text);

                        if (answer == null)
                        {
                            // 找不到問題,也找不到答案,後送QnA
                            // await Conversation.SendAsync(activity, () => new BasicQnAMakerDialog());
                            string strAnswer = QnAMaker.GetAnswer(activity.Text);
                            reply = this.ReplyOptions(activity, strAnswer, Question.GetQuestionCards(0));
                        }
                        else
                        {
                            // 如果是回到主選單,就取出根目錄的內容
                            if (activity.Text == "<-回主選單" || activity.Text == "<-Back to Menu")
                            {
                                cards = Question.GetQuestionCards(0);
                            }
                            else
                            {
                                cards = Question.GetNextQuestionCards(activity.Text);
                            }

                            // 找到問題,判斷是否有下一層,有下一層就產生選單
                            if (cards.Count > 0)
                            {
                                reply = this.ReplyOptions(activity, null, cards);
                            }
                            else
                            {
                                // 沒有下一層的話,就判斷回覆的內容是否往QnA送,並顯示相同層級的問題清單
                                // 一般問題就直接回覆
                                if (answer.AnswerType == "QnA")
                                {
                                    await Conversation.SendAsync(activity, () => new BasicQnAMakerDialog());

                                    // 我想聯絡小編就不發回覆
                                    if (activity.Text != "我想連絡小編" || activity.Text != "I want contact editor")
                                    {
                                        reply = this.ReplyOptions(activity, null, Question.GetSameLevelQuestion(activity.Text));
                                    }
                                }
                                else
                                {
                                    reply = this.ReplyOptions(activity, answer.Answer, Question.GetSameLevelQuestion(activity.Text));
                                }
                            }
                        }
                    }

                    await connector.Conversations.ReplyToActivityAsync(reply);
                }
            }
            catch (Exception e)
            {
                reply = this.ReplyOptions(activity, e.Message, null);
                await connector.Conversations.ReplyToActivityAsync(reply);
            }

            return(new HttpResponseMessage(System.Net.HttpStatusCode.Accepted));
        }