Beispiel #1
0
        public ActionResult Addquestion(TBL_QUESTIONS q)
        {
            int sid = Convert.ToInt32(Session["ad_id"]);
            List <tbl_categroy> li = db.tbl_categroy.Where(x => x.cat_fk_adid == sid).ToList();

            ViewBag.list = new SelectList(li, "cat_id", "cat_name");

            TBL_QUESTIONS QA = new TBL_QUESTIONS();

            QA.Q_TEXT     = q.Q_TEXT;
            QA.OPA        = q.OPA;
            QA.OPB        = q.OPB;
            QA.OPC        = q.OPC;
            QA.OPD        = q.OPD;
            QA.COP        = q.COP;
            QA.q_fk_catid = q.q_fk_catid;



            db.TBL_QUESTIONS.Add(QA);
            db.SaveChanges();
            TempData["msg"] = "Question added successfully....";
            TempData.Keep();
            return(RedirectToAction("Addquestion"));
        }
Beispiel #2
0
        public ActionResult AddQuestion(TBL_QUESTIONS queGet)
        {
            List <TBL_CATEGORY> list = db.TBL_CATEGORY.ToList();

            ViewBag.List = new SelectList(list, "CAT_ID", "CAT_NAME");

            TBL_QUESTIONS queVar = new TBL_QUESTIONS();

            queVar.Q_TEXT = queGet.Q_TEXT;

            queVar.OPA = queGet.OPA;

            queVar.OPB = queGet.OPB;

            queVar.OPC = queGet.OPC;

            queVar.OPD = queGet.OPD;

            queVar.COP = queGet.COP;

            queVar.Q_FK_CATID = queGet.Q_FK_CATID;

            db.TBL_QUESTIONS.Add(queVar);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult QuizStart()
        {
            if (Session["std_id"] == null)
            {
                return(RedirectToAction("slogin"));
            }
            TBL_QUESTIONS q = null;

            if (TempData["questions"] != null)
            {
                Queue <TBL_QUESTIONS> qlist = (Queue <TBL_QUESTIONS>)TempData["questions"];
                if (qlist.Count > 0)
                {
                    q = qlist.Peek();
                    qlist.Dequeue();
                    TempData["questions"] = qlist;
                    TempData.Keep();
                }
                else
                {
                    return(RedirectToAction("EndExam"));
                }
            }
            else
            {
                return(RedirectToAction("StudentExam"));
            }

            return(View());
        }
        public ActionResult Addquestion(TBL_QUESTIONS q)
        {
            try
            {
                int sid = Convert.ToInt32(Session["AD_ID"]);
                List <TBL_CATEGORY> li = db.TBL_CATEGORY.Where(x => x.CAT_FK_ADID == sid).ToList();
                ViewBag.list = new SelectList(li, "CAT_ID", "CAT_NAME");

                TBL_QUESTIONS QA = new TBL_QUESTIONS();
                QA.Q_TEXT     = q.Q_TEXT;
                QA.OPA        = q.OPA;
                QA.OPB        = q.OPB;
                QA.OPC        = q.OPC;
                QA.OPD        = q.OPD;
                QA.COP        = q.COP;
                QA.Q_FK_CATID = q.Q_FK_CATID;


                db.TBL_QUESTIONS.Add(QA);
                db.SaveChanges();
                TempData["msg"] = "Question has been added successfully!";
                TempData.Keep();
                return(RedirectToAction("Addquestion"));
            }
            catch (Exception)
            {
                return(RedirectToAction("Addquestion"));
            }
        }
Beispiel #5
0
        public ActionResult AddQuestion(TBL_QUESTIONS questions)
        {
            try
            {
                int sid = Convert.ToInt32(Session["AD_ID"]);
                List <TBL_CATEGORY> li = db.TBL_CATEGORY.Where(x => x.CAT_FK_ADMIN_ID == sid).ToList();
                ViewBag.list = new SelectList(li, "CAT_ID", "CAT_NAME");

                TBL_QUESTIONS QA = new TBL_QUESTIONS();
                QA.Q_TEXT            = questions.Q_TEXT;
                QA.OPA               = questions.OPA;
                QA.OPB               = questions.OPB;
                QA.OPC               = questions.OPC;
                QA.OPD               = questions.OPD;
                QA.COP               = questions.COP;
                QA.QUESTION_FK_CATID = questions.QUESTION_FK_CATID;

                db.TBL_QUESTIONS.Add(QA);
                db.SaveChanges();
                TempData["msg"] = "Question Added Successfully.....";
            }
            catch (Exception)
            {
                TempData["msg"] = "You are entering same question again...please enter different question.";
            }
            return(RedirectToAction("AddQuestion"));
        }
Beispiel #6
0
        public ActionResult EditQuestion(TBL_QUESTIONS qGet)
        {
            List <TBL_CATEGORY> list = db.TBL_CATEGORY.ToList();

            ViewBag.List = new SelectList(list, "CAT_ID", "CAT_NAME");

            var qList = db.TBL_QUESTIONS.Where(model => model.QUESTION_ID == qGet.QUESTION_ID).FirstOrDefault();

            qList.Q_FK_CATID = qGet.Q_FK_CATID;

            qList.Q_TEXT = qGet.Q_TEXT;

            qList.OPA = qGet.OPA;

            qList.OPB = qGet.OPB;

            qList.OPC = qGet.OPC;

            qList.OPD = qGet.OPD;

            qList.COP = qGet.COP;

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public ActionResult QuizStart(TBL_QUESTIONS 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("QuizStart"));
        }
Beispiel #8
0
        public ActionResult DeleteConfirmed(int?id)
        {
            TBL_QUESTIONS questions = db.TBL_QUESTIONS.Find(id);

            db.TBL_QUESTIONS.Remove(questions);
            db.SaveChanges();
            return(RedirectToAction("ViewAllQuestions"));
        }
        public ActionResult QuizStart()
        {
            if (Session["STD_ID"] == null)
            {
                return(RedirectToAction("slogin"));
            }

            TBL_QUESTIONS q = null;

            if (TempData["questions"] != null)
            {
                Queue <TBL_QUESTIONS> qlist = (Queue <TBL_QUESTIONS>)TempData["questions"];
                if (qlist.Count > 0)
                {
                    q = qlist.Peek();
                    qlist.Dequeue();
                    TempData["questions"] = qlist;
                    TempData.Keep();
                }
                else
                {
                    return(RedirectToAction("EndExam"));
                }
            }
            else
            {
                return(RedirectToAction("StudentExam"));
            }
            return(View(q));
            //if (Session["STD_ID"] == null)
            //{
            //    return RedirectToAction("slogin");
            //}
            //try
            //{
            //    TBL_QUESTIONS q = null;
            //    int examid = Convert.ToInt32(TempData["examid"].ToString());

            //    if (TempData["qid"] == null)
            //    {
            //        q = db.TBL_QUESTIONS.First(x => x.Q_FK_CATID == examid);
            //        TempData["qid"] = ++q.QUESTION_ID;
            //    }
            //    else
            //    {
            //        int qid = Convert.ToInt32(TempData["qid"].ToString());
            //        q = db.TBL_QUESTIONS.Where(x => x.QUESTION_ID == qid && x.Q_FK_CATID == examid).SingleOrDefault();
            //        TempData["qid"] = ++q.QUESTION_ID;
            //    }
            //    TempData.Keep();
            //    return View(q);
            //}
            //catch (Exception)
            //{
            //    return RedirectToAction("EndExam");
            //}
        }
Beispiel #10
0
        public ActionResult DelQuestion(int id)
        {
            TBL_QUESTIONS _id = db.TBL_QUESTIONS.Find(id);

            db.TBL_QUESTIONS.Remove(_id);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #11
0
        public ActionResult Delete(int?id)
        {
            TBL_QUESTIONS getquestion = db.TBL_QUESTIONS.Find(id);

            if (getquestion == null)
            {
                return(HttpNotFound());
            }
            return(View(getquestion));
        }
Beispiel #12
0
        public ActionResult Edit(int?id)
        {
            TBL_QUESTIONS questions = db.TBL_QUESTIONS.Find(id);

            if (questions == null)
            {
                return(HttpNotFound());
            }
            return(View(questions));
        }
Beispiel #13
0
 public ActionResult Edit(TBL_QUESTIONS questions)
 {
     //int sid = Convert.ToInt32(Session["AD_ID"]);
     // List<TBL_CATEGORY> li = db.TBL_CATEGORY.Where(x => x.CAT_FK_ADMIN_ID == sid).ToList();
     //ViewBag.list = new SelectList(li);
     if (ModelState.IsValid)
     {
         db.Entry(questions).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ViewAllQuestions"));
     }
     return(View(questions));
 }
        //posting  a question
        public IHttpActionResult PostQuestion(Questions tquestion)
        {
            TBL_QUESTIONS tbObj = new TBL_QUESTIONS();

            if (ModelState.IsValid)
            {
                tbObj.QID       = Guid.NewGuid();
                tbObj.QUESTION  = tquestion.QUESTION;
                tbObj.USERNAME  = tquestion.USERNAME;
                tbObj.TIMESTAMP = DateTime.Now;
                dbObj.TBL_QUESTIONS.Add(tbObj);
                var user = dbObj.TBL_SIGNUP.ToList().Find(x => x.USERNAME == tquestion.USERNAME);
                user.POINTS += 2;
                dbObj.SaveChanges();
                return(Ok());
            }
            ModelState.Clear();
            return(BadRequest());
        }
Beispiel #15
0
        public ActionResult QuizStart()
        {
            if (TempData["i"] == null)
            {
                TempData["i"] = 1;
            }
            if (Session["std_id"] == null)
            {
                return(RedirectToAction("slogin"));
            }

            try
            {
                TBL_QUESTIONS q      = null;
                int           examid = Convert.ToInt32(TempData["exampid"].ToString());
                if (TempData["qid"] == null)
                {
                    q = db.TBL_QUESTIONS.First(x => x.q_fk_catid == examid);
                    var list = db.TBL_QUESTIONS.Skip(Convert.ToInt32(TempData["i"].ToString()));
                    int qid  = list.First().QUESTION_ID;
                    TempData["qid"] = qid;
                }
                else
                {
                    int qid = Convert.ToInt32(TempData["qid"].ToString());
                    q = db.TBL_QUESTIONS.Where(x => x.QUESTION_ID == qid && x.q_fk_catid == examid).SingleOrDefault();

                    var list = db.TBL_QUESTIONS.Skip(Convert.ToInt32(TempData["i"].ToString()));
                    qid             = list.First().QUESTION_ID;
                    TempData["qid"] = qid;
                    TempData["i"]   = Convert.ToInt32(TempData["i"].ToString()) + 1;
                }
                TempData.Keep();
                return(View(q));
            }
            catch (Exception)
            {
                return(RedirectToAction("StudentExam"));
            }
        }
Beispiel #16
0
 public ActionResult QuizStart(TBL_QUESTIONS q)
 {
     return(RedirectToAction("QuizStart"));
 }