protected void rptrQuestion_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Down": { QUESTION self = DALQUESTION.Get(Int32.Parse(e.CommandArgument.ToString())); QUESTION upper = DALQUESTION.GetBySort(self.SORT + 1); self.SORT++; upper.SORT--; DALQUESTION.Update(self); DALQUESTION.Update(upper); fillQuestion(); break; } case "Up": { QUESTION self = DALQUESTION.Get(Int32.Parse(e.CommandArgument.ToString())); QUESTION upper = DALQUESTION.GetBySort(self.SORT - 1); self.SORT--; upper.SORT++; DALQUESTION.Update(self); DALQUESTION.Update(upper); fillQuestion(); break; } } }
void SetLbQuestions() { LbQuestions.ItemsSource = null; var obj = db.QUESTION.Where(d => d.TESTID == _IdTest).OrderBy(f => f.QUESTIONID); List <QUESTION> listQuest = new List <QUESTION>(); foreach (var f in obj) { QUESTION row = new QUESTION(); row.QA = new List <QA>(); row.TEST = new TEST(); row.QUESTIONTEXT = f.QUESTIONTEXT; row.QUESTIONID = f.QUESTIONID; row.TEST.TESTID = _IdTest; var qa = db.QA.Where(l => l.QUESTIONID == f.QUESTIONID); foreach (var item in qa) { var a = db.ANSWER.Where(l => l.ANSWERID == item.ANSWERID).First(); QA qaNew = new QA { ANSWERID = item.ANSWERID, CORRECTANSWER = item.CORRECTANSWER, QUESTIONID = row.QUESTIONID, ANSWER = a }; row.QA.Add(qaNew); } listQuest.Add(row); } LbQuestions.ItemsSource = listQuest; }
public ActionResult CreateForGrid([DataSourceRequest] DataSourceRequest request, QuestionViewModel question, long _testid) { if (!db.TESTS.Get().Any(t => t.ID == _testid)) { ModelState.AddModelError("QUESTION", "Невозможно добавить данный вопрос!<br> Ошибка: Тест не обнаружен в базе данных!"); } if (ModelState.IsValid) { question.testid = _testid; question.ordernum = (short)(db.QUESTIONS.Get().Where(q => q.TESTID == _testid).Count() + 1); QUESTION entity = question.ToEntity(new QUESTION()); try { db.QUESTIONS.Create(entity); question.id = entity.ID; } catch (Exception ex) { ModelState.AddModelError("QUESTION", ex.Message); } } return(Json(new[] { question }.ToDataSourceResult(request, ModelState))); }
public ActionResult TestStart() { if (Session["std_id"] == null) { return(RedirectToAction("slogin")); } if (TempData["questions"] == null) { return(RedirectToAction("StudentExam")); } TempData.Keep(); QUESTION q = null; if (TempData["questions"] != null) { Queue <QUESTION> qlist = (Queue <QUESTION>)TempData["questions"]; if (qlist.Count > 0) { q = qlist.Peek(); qlist.Dequeue(); TempData["questions"] = qlist; return(View(q)); } else { return(RedirectToAction("EndExam")); } } return(View()); }
public ActionResult TestStart(QUESTION q) { string correct_ans = null; if (q.OPTIONA == null && q.OPTIONB == null && q.OPTIONC == null && q.OPTIOND == null) { Response.Write("<script>alert('Please Select One Option...')</script>"); } else { if (q.OPTIONA != null) { correct_ans = "A"; } else if (q.OPTIONB != null) { correct_ans = "B"; } else if (q.OPTIONC != null) { correct_ans = "C"; } else if (q.OPTIOND != null) { correct_ans = "D"; } if (correct_ans.Equals(q.COREECT_OPTION)) { TempData["score"] = Convert.ToInt32(TempData["score"]) + 1; } } TempData.Keep(); return(RedirectToAction("TestStart")); }
protected void btnDelete_Click(object sender, EventArgs e) { try { QUESTION rec = DALQUESTION.Get(Int32.Parse(Request.QueryString["ID"])); if (rec != null) { DALQUESTION.Delete(rec.ID); } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ClosePage", "CloseModal(true);", true); NotificationAdd(NotificationType.success, "Kayıt Silindi."); } catch (Exception ex) { if (ex is SqlException) { if ((ex as SqlException).Number == 547) { NotificationAdd(NotificationType.error, "Kayıt başka yerlerde kullanıdı."); } } else { throw ex; } } }
protected void Button1_Click(object sender, EventArgs e) { QuestionBankEntities db = new QuestionBankEntities(); FILLINTHEBLANK ft = new FILLINTHEBLANK(); QUESTION qt = new QUESTION(); Label1.Text = qt.QUESTIONTEXT; Label2.Text = ft.ANSWER; // db.QUESTIONS.Where(w => w.ID ).First(); //List<Question> lst = db.Questions.Where(w => w.id > 1 && w.id < 10).ToList(); //Question questiontoFetch = db.Questions.Where(w => w.id == 5).First(); // submit //Label1.Text = f.Question; //Label2.Text = f.Answer; //if (Session["data"] != null) //{ // list = (List<FITB>)Session["data"]; //} //if (f.Question != null && f.Answer != null) //{ // list.Add(f); //} //Session["data"] =list; Button1.Visible = false; }
protected void btnSave_Click(object sender, EventArgs e) { if (ValidateItem()) { QUESTION rec = new QUESTION(); if (RECid > 0) { rec = DALQUESTION.Get(RECid); rec.ISACTIVE = chkActive.Checked; rec.ANSWER = Server.HtmlEncode(hdnDescription.Value); rec.TITLE = txtQuestion.Text; DALQUESTION.Update(rec); } else { rec.SORT = Convert.ToInt16(DALQUESTION.GetLastSort() + 1); rec.ISACTIVE = chkActive.Checked; rec.ANSWER = Server.HtmlEncode(hdnDescription.Value); rec.TITLE = txtQuestion.Text; DALQUESTION.Insert(rec); } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ClosePage", "CloseModal(true);", true); btnDelete.Visible = false; btnCancel.Visible = false; } }
public ActionResult examstart() { if (Session["us_id"] == null) { return(RedirectToAction("ulogin")); } if (TempData["questions"] == null) { return(RedirectToAction("uexam")); } TempData.Keep(); QUESTION Q = null; if (TempData["questions"] != null) { Queue <QUESTION> qlist = (Queue <QUESTION>)TempData["questions"]; if (qlist.Count > 0) { Q = qlist.Peek(); qlist.Dequeue(); TempData["questions"] = qlist; return(View(Q)); } else { return(RedirectToAction("endexam")); } } return(View()); }
public ActionResult examstart(QUESTION q) { string correctans = null; if (q.OPA != null) { correctans = "A"; } else if (q.OPB != null) { correctans += "B"; } else if (q.OPC != null) { correctans += "C"; } else if (q.OPD != null) { correctans += "D"; } if (correctans.Equals(q.COP)) { TempData["score"] = Convert.ToInt32(TempData["score"]) + 1; } TempData.Keep(); return(RedirectToAction("examstart")); }
//private void _lessonmenu(OOPEZZ_DBEntities db, BotMessageReceivedRequest botMessage) //{ // ///thua // List<LESSION> lessionlist = db.LESSION.ToList(); // List<PayloadElements> listelement = new List<PayloadElements>(); // foreach (LESSION ls in lessionlist) // { // PayloadElements element = new PayloadElements() // { // title = ls.NAME, // //image_url = ls.IMAGE, // subtitle = ls.DESCRIPTION, // buttons = new List<ResponseButtons> // { // new ResponseButtons // { // type = "web_url", // title = "View", // url = "https://www.facebook.com/pg/OOP-Ezz-108722340761918" // } // }, // default_action = new PayloadElementDefautAction // { // type = "web_url", // url = "https://www.facebook.com/pg/OOP-Ezz-108722340761918" // } // }; // listelement.Add(element); // } // List<ResponseButtons> lbt = new List<ResponseButtons>() // { // new ResponseButtons // { // title = "View More", // type = "postback", // payload = "payload view more" // } // }; // //listelement.RemoveAt(1); // String json = fbTemplate.ListTemplate(botMessage.sender.id, listelement); // _post(json); //} private void _rqQuestion(OOPEZZ_DBEntities db, BotMessageReceivedRequest botMessage) { String mess = botMessage.message.text.Remove(0, 6); mess = mess.Trim(); mess = Ulti.replaceKeyword(db, mess); USER user = db.USER.Where(x => x.TOKEN == botMessage.sender.id).FirstOrDefault(); int userpkseq = -1; if (user == null) { UserControl control = new UserControl(); userpkseq = control.CreateUser(db, botMessage.sender.id); } else { userpkseq = user.PK_SEQ; } QUESTION ques = new QUESTION() { BEST_ANSWER_FK = 0, QUESTION_TEXT = mess, QUESTION_USER_FK = userpkseq, STATUS = 0 }; db.QUESTION.Add(ques); db.SaveChanges(); String json = fbTemplate.SimpleTextTemplate(botMessage.sender.id, "Oki đã ghi nhận nào có câu trả lời mình sẽ trả lời ngay"); _post(json); }
private void _postQuestion(OOPEZZ_DBEntities db, QUESTION question, BotMessageReceivedRequest mess) { ANSWER answer = db.ANSWER.Where(x => x.QUESTION_FK == question.PK_SEQ).OrderByDescending(x => x.STATUS).First(); String json = ""; json = fbTemplate.SimpleTextTemplate(mess.sender.id, "Câu hỏi : "); _post(json); json = fbTemplate.SimpleTextTemplate(mess.sender.id, question.QUESTION_TEXT); _post(json); String answer_pkseq_contents = answer.ANSWER_TEXT; char[] charac = { '#' }; List <String> pkseqs = answer_pkseq_contents.Split(charac).ToList(); List <CONTENT> contents = new List <CONTENT>(); foreach (String pkseq in pkseqs) { int pk = int.Parse(pkseq); CONTENT ct = db.CONTENT.Where(x => x.PK_SEQ == pk).First(); contents.Add(ct); } _sendContentList(db, contents, mess.sender.id); //json = fbTemplate.ButtonTemplate(mess.sender.id, "Bấm nút bên dưới để tiếp tục bài học nhé", new List<ResponseButtons>() { // new ResponseButtons() // { // type = "postback", // title = "Tiếp tục bài học", // payload = "" // } //}); }
public JsonResult SetOrder(long id, short step) { QUESTION entityFrom = db.QUESTIONS.Get().FirstOrDefault(q => q.ID == id); if (entityFrom != null) { QUESTION entityTo = db.QUESTIONS.Get().FirstOrDefault(q => q.TESTID == entityFrom.TESTID && q.ORDERNUM == entityFrom.ORDERNUM + step); if (entityTo != null) { try { entityFrom.ORDERNUM = (short)(entityFrom.ORDERNUM + step); db.QUESTIONS.Update(entityFrom); entityTo.ORDERNUM = (short)(entityTo.ORDERNUM - step); db.QUESTIONS.Update(entityTo); } catch (Exception ex) { return(Json(new { result = "errors", errors = "Ошибка: " + ex.Message }, JsonRequestBehavior.AllowGet)); } } return(Json(new { result = "OK" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = "errors", errors = "Ошибка: Вопрос не обнаружен в базе данных!" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 获取类别 /// </summary> /// <param name="categoryID">类别ID</param> /// <param name="nQuestions">题目集合</param> void GetCategory(int categoryID, List <QUESTION> nQuestions) { nowQuestions = nQuestions.Where(q => q.CategoryId == categoryID && q.Choises.Count > 0).ToList() ?? new List <QUESTION>(); //if (questions.Count < 75) // MessageBox.Show("题库数量不足75,请及时补充题库。"); if (nowQuestions.Count > 0) { dicOption = new Dictionary <int, string>(); dicAnswer = new Dictionary <int, string>(); int tempCount = nowQuestions.Count; for (int i = 0; i < tempCount; i++) { int tempInt = new Random().Next(0, nowQuestions.Count); if (panelQuestions.Controls.Count >= i + 1) { panelQuestions.Controls[i].Tag = nowQuestions[tempInt]; } else { Button btn = new Button(); btn.Size = new Size(45, 45); btn.Text = (i + 1).ToString(); btn.Tag = nowQuestions[tempInt]; btn.Font = new Font(Font.FontFamily, 17); btn.Click += btnQuestion_Click; panelQuestions.Controls.Add(btn); } dicOption.Add(i, ""); dicAnswer.Add(i, nowQuestions[tempInt].Answer); nowQuestions.Remove(nowQuestions[tempInt]); if (i >= 74) { break; } } if (panelQuestions.Controls.Count != dicAnswer.Count) { for (int i = panelQuestions.Controls.Count; i > dicAnswer.Count; i--) { panelQuestions.Controls.RemoveAt(i - 1); } } } foreach (Control control in panelQuestions.Controls) { if (control.Text != "1") { continue; } _question = (QUESTION)control.Tag; control.BackColor = Color.Aqua; this.Text = $"咸鱼考试 -- {_question.Category.Name}"; BindFormData(_question); break; } }
public ActionResult DeleteConfirmed(int id) { QUESTION q = db.QUESTIONS.Find(id); db.QUESTIONS.Remove(q); db.SaveChanges(); return(RedirectToAction("Addcategory")); }
public ActionResult DeleteConfirmed(int id) { QUESTION qUESTION = db.QUESTION.Find(id); db.QUESTION.Remove(qUESTION); db.SaveChanges(); return(RedirectToAction("Index")); }
private void _postAnswerfromQuestion(OOPEZZ_DBEntities db, BotMessageReceivedRequest mess) { char[] spa = { '_' }; String content = mess.postback.payload.Split(spa)[2]; int content_pk = int.Parse(content); QUESTION qs = db.QUESTION.Where(x => x.PK_SEQ == content_pk).First(); _postQuestion(db, qs, mess); }
/// <summary> /// 题目按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuestion_Click(object sender, EventArgs e) { Button btn = sender as Button; questionIndex = Convert.ToInt32(btn.Text) - 1; _question = btn.Tag as QUESTION; BindFormData(_question); btn.BackColor = Color.Aqua; //当前选中颜色 }
public ActionResult Edit([Bind(Include = "idQuestion,author,startdate,content")] QUESTION qUESTION) { if (ModelState.IsValid) { db.Entry(qUESTION).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(qUESTION)); }
public QuestionProxy(QUESTION model) { if (model != null) { Id = model.ID; Text = model.TEXT; Type = model.TYPE; NextQuestionId = model.NEXT_QUESTION_ID != null ? model.NEXT_QUESTION_ID.Value : 0; } }
public QUESTION ToEntity(QUESTION question) { question.ID = this.id; question.ORDERNUM = this.ordernum; question.TEXT = this.text; question.RATING = this.rating; question.TESTID = this.testid; return(question); }
public ActionResult Edit(QUESTION question) { db.Entry(question).State = System.Data.Entity.EntityState.Modified; db.Entry(question).Property(e => e.CREATEBY).IsModified = false; db.Entry(question).Property(e => e.CREATEDATE).IsModified = false; question.MODIFYBY = NAMESURNAME; question.MODIFYDATE = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "QUESTION_ID,QUESTION_TEXT,OPTIONA,OPTIONB,OPTIONC,OPTIOND,COREECT_OPTION,QUE_FKEY_CATEGORYID")] QUESTION Q) { if (ModelState.IsValid) { db.Entry(Q).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Addcategory")); } return(View(Q)); }
public ActionResult Create([Bind(Include = "idQuestion,author,startdate,content")] QUESTION qUESTION) { if (ModelState.IsValid) { db.QUESTION.Add(qUESTION); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(qUESTION)); }
private void MyButtonClick(object sender, EventArgs e) { Button btn = sender as Button; Count = Convert.ToInt32(btn.Text) - 1; _question = btn.Tag as QUESTION; if (_question.Choises.Where(o => o.IsCheck == 0).Count() > 0) { btn.BackColor = Color.White; } BindFormData(_question); }
public void BindFormData(QUESTION question) { lblQuestionName.Text = $"{Count + 1}、{question.Name}"; rbA.Text = $"A: {question.Choises[0].Name}"; rbA.Checked = question.Choises[0].IsCheck == 0 ? true : false; rbB.Text = $"B: {question.Choises[1].Name}"; rbB.Checked = question.Choises[1].IsCheck == 0 ? true : false; rbC.Text = $"C: {question.Choises[2].Name}"; rbC.Checked = question.Choises[2].IsCheck == 0 ? true : false; rbD.Text = $"D: {question.Choises[3].Name}"; rbD.Checked = question.Choises[3].IsCheck == 0 ? true : false; }
private Grammar ERI() { if (eof) { return(null); } SkipNewLine(); Grammar grammar; switch (lookAhead) { case Sym.PERIOD: grammar = new CONCATENATION(); match(Sym.PERIOD); grammar.addFirst(ERI()); grammar.addSecond(ERI()); break; case Sym.OR: grammar = new OR(); match(Sym.OR); grammar.addFirst(ERI()); grammar.addSecond(ERI()); break; case Sym.QUESTION_MARK: grammar = new QUESTION(); match(Sym.QUESTION_MARK); grammar.addFirst(ERI()); break; case Sym.TIMES: grammar = new Times(); match(Sym.TIMES); grammar.addFirst(ERI()); break; case Sym.PLUS: grammar = new Plus(); match(Sym.PLUS); grammar.addFirst(ERI()); break; case Sym.OPEN_CB: grammar = LEAF(); break; case Sym.STRING: grammar = LEAF(); break; default: grammar = null; ERROR(); Sync(); break; } return(grammar); }
public ActionResult UpdateQuestionDB(QUESTION question) { QuestionService questionService = new QuestionService(); if (questionService.update(question)) { return(RedirectToAction("ShowQuestions", "Manager")); } else { return(RedirectToAction("ShowQuestions", "Manager")); } }
// GET: QUESTIONs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QUESTION qUESTION = db.QUESTION.Find(id); if (qUESTION == null) { return(HttpNotFound()); } return(View(qUESTION)); }
public IHttpActionResult Post(QUESTION question) { try { Calculation response = nursingSvc.CalcEvaluation(question); return(Ok(response)); } catch (Exception ex) { LogHelper.WriteError(ex.ToString()); return(Ok(new BaseResponse <string> { ResultCode = (int)EnumResponseStatus.ExceptionHappened, ResultMessage = "操作异常" })); } }