public JsonResult NewCategory(quesOptionViewModel quesOption)
        {
            Question objQuestion = new Question();

            objQuestion.Question_Text  = quesOption.Question_Text;
            objQuestion.QuesCategoryId = quesOption.CategoryId;

            db.Questions.Add(objQuestion);
            db.SaveChanges();

            int questionid = objQuestion.QuestionID;

            System.Diagnostics.Debug.WriteLine("OPTION  11  : " + quesOption);
            foreach (var item in quesOption.ListOfOptions)
            {
                Option objOption = new Option();
                objOption.OptionName = item;
                objOption.OptQuesId  = questionid;
                System.Diagnostics.Debug.WriteLine("OPTION  : " + objOption.OptionName);
                db.Options.Add(objOption);
                db.SaveChanges();
            }

            Answer objAns = new Answer();

            objAns.AnswerText = quesOption.AnswerText;
            objAns.AnsQuesId  = questionid;
            db.Answers.Add(objAns);
            db.SaveChanges();



            return(Json(data: new { message = "Question Successfully Added.", success = true }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult TeacherListForStudentadd(int tid)
        {
            int sID = Convert.ToInt32(Session["StudentId"]);
            FriendListForStudnet AF = new FriendListForStudnet();

            AF.studentid = sID;
            AF.teacherid = tid;
            AF.timedate  = DateTime.UtcNow.Date;
            db.FriendListForStudnets.Add(AF);
            db.SaveChanges();
            TempData["msg"] = "Teacher successfully added!";

            return(RedirectToAction("TeacherListForStudent"));
        }
        public ActionResult TeacherRegister(Teacher tch)
        {
            if (tch.FullName == null || tch.Email == null || tch.TeacherName == null || tch.Passwords == null || tch.FullName == null || tch.Institute == null || tch.Designation == null)
            {
                return(RedirectToAction("TeacherRegister", "TRegistration"));
            }

            int count = db.Teachers.Where(u => u.TeacherName == tch.TeacherName).Count();

            if (count > 0)
            {
                return(RedirectToAction("TeacherRegister"));
            }


            Teacher t = new Teacher();

            t.FullName    = tch.FullName;
            t.Email       = tch.Email;
            t.TeacherName = tch.TeacherName;
            t.Passwords   = tch.Passwords;
            t.FullName    = tch.FullName;
            t.Institute   = tch.Institute;
            t.Designation = tch.Designation;
            t.Contact     = tch.Contact;
            db.Teachers.Add(t);
            db.SaveChanges();

            return(RedirectToAction("TLogin", "TeacherLogin"));
        }
예제 #4
0
        public ActionResult StudentRegister(Student stv)
        {
            if (stv.StudentName == null || stv.ID == null || stv.Passwords == null || stv.Email == null || stv.Department == null || stv.Semester == null || stv.Contact == null || stv.Institute == null)
            {
                return(RedirectToAction("StudentRegister", "SRegistration"));
            }

            int count = db.Students.Where(u => u.Email == stv.Email).Count();

            if (count > 0)
            {
                return(RedirectToAction("StudentRegister"));
            }


            Student s = new Student();

            s.StudentName = stv.StudentName;
            s.ID          = stv.ID;
            s.Passwords   = stv.Passwords;
            s.Email       = stv.Email;
            s.Department  = stv.Department;
            s.Semester    = stv.Semester;
            s.Contact     = stv.Contact;
            s.Institute   = stv.Institute;
            db.Students.Add(s);
            db.SaveChanges();
            return(RedirectToAction("SLogin", "StudentLogin"));
        }
예제 #5
0
        [HttpPost] ///fetching and showing the inserted categories

        public ActionResult Addcategory(Category cat)
        {
            List <Category> li = db.Categories.OrderByDescending(x => x.CategoryId).ToList();

            ViewData["list"] = li;


            Category c = new Category();

            c.CategoryName    = cat.CategoryName;
            c.CategoryTeacher = Convert.ToInt32(Session["TeacherID"].ToString());

            if (c.CategoryName == null)
            {
                return(RedirectToAction("Addcategory", "Category"));
            }
            else
            {
                db.Categories.Add(c);
                db.SaveChanges();
            }


            return(RedirectToAction("Addcategory", "Category"));
        }
예제 #6
0
        public ActionResult makeavailable(int cid, int available)
        {
            var del = (from OnlineQuizSystem in db.Categories
                       where OnlineQuizSystem.CategoryId == cid
                       select OnlineQuizSystem).FirstOrDefault();


            int questionCount = db.Questions.Where(u => u.QuesCategoryId == cid).Count();



            if (available == 1)
            {
                if (questionCount > 1)
                {
                    del.available = 1;
                    db.SaveChanges();
                }
            }
            else
            {
                del.available = 0;
                db.SaveChanges();
            }

            return(RedirectToAction("ViewQuestion"));
        }
        public ActionResult QuizStudent(int CategoryId)
        {
            int sID = Convert.ToInt32(Session["StudentId"]);

            if (CategoryId == null)
            {
                return(RedirectToAction("QuizStudent", "Quiz"));
            }

            IEnumerable <Question> qus = db.Questions.Where(u => u.QuesCategoryId == CategoryId);

            foreach (var data in qus)
            {
                IEnumerable <Result> resultAll = db.Results
                                                 .Where(u => u.ResQuesId == data.QuestionID && u.ResStudent == sID);

                if (resultAll.Count() >= 1)
                {
                    return(RedirectToAction("QuizStudent", "Quiz"));
                }
            }


            Session["StdQuestionAnswer"] = null;
            ExamStudent objstudent = new ExamStudent();

            objstudent.ID            = Convert.ToString(sID);
            objstudent.StuCategoryId = CategoryId;

            db.ExamStudents.Add(objstudent);
            db.SaveChanges();
            Session["ID"]            = sID;
            Session["StuCategoryId"] = CategoryId;
            Session["ExamineeID"]    = objstudent.ExamineeID;
            return(View("ExamStudent"));
        }