public QuestionBusiness(MardisContext mardisContext) : base(mardisContext)
 {
     _typePollDao     = new TypePollDao(mardisContext);
     _questionDao     = new QuestionDao(mardisContext);
     _answerDao       = new AnswerDao(mardisContext);
     _answerDetailDao = new AnswerDetailDao(mardisContext);
 }
示例#2
0
        public ActionResult Edit(int id)
        {
            var lesson = new QuestionDao().ViewDeatil(id);

            SetViewBags();
            return(View(lesson));
        }
示例#3
0
        public ActionResult QEdit(int id)
        {
            var dao     = new AdminDao();
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 2)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;


            var dao1 = new QuestionDao().ViewDetail(id);

            if (dao1 == null || dao1.is_essay == 1)
            {
                return(View("Error"));
            }
            else
            {
                var dao3 = new ThematicDao().ViewDetail(dao1.id_thematic);
                var dao2 = new SubjectDao().ViewDetail(dao3.id_subject);
                dao.UpdateLastLogin(session.id_admin);
                dao.UpdateLastSeen("Sửa câu hỏi của môn " + dao2.subject_name, "/Admin/Subject/QEdit/" + id, session.id_admin);
                TempData["subject_name"] = dao2.subject_name;
                TempData["id_subject"]   = dao2.id_subject;
                //dao1.img = Server.MapPath("~/Assets/img_questions/") + dao1.img;
                SetViewBag(dao3.id_subject, dao1.id_thematic);
                return(View(dao1));
            }
        }
示例#4
0
        public ActionResult Vote(VoteModel model)
        {
            if (!ModelState.IsValid)
            {
                model = initVoteModel(model.questionID);
                return(View(model));
            }
            VoteDao votedao = new VoteDao();
            //检查用户是否已经投过票了 否则在原来的基础上更改
            User     u = new UserDao().getById(model.userID);
            Question q = new QuestionDao().getById(model.questionID);

            Vote v = votedao.getByUserAndQuestion(u, q);

            if (v == null)
            {
                v = new Models.Vote();
            }
            v.queID       = new QuestionDao().getById(model.questionID);
            v.userID      = u;
            v.voteComment = model.voteComment;
            v.voteTime    = DateTime.Now;
            v.voteRecord  = model.voteRecord;
            if (v.ID != 0)
            {
                votedao.update(v);
            }
            else
            {
                votedao.add(v);
            }
            return(RedirectToAction("Index"));
        }
示例#5
0
        public ActionResult Publish(publishModel model)
        {
            if (!ModelState.IsValid)
            {
                model = initPublishModel();
                return(View(model));
            }
            //添加问题
            Question question = new Models.Question();

            question.userID    = new UserDao().getById(model.userID);
            question.title     = model.title;
            question.queDes    = model.queDes;
            question.postTime  = model.postTime;
            question.endTime   = model.endTime;
            question.optionNum = model.optionNum;
            question.tags      = model.tags;
            question.queOption = model.options;

            QuestionDao questiondao = new QuestionDao();

            questiondao.add(question);

            return(RedirectToAction("MyPublish"));
        }
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new QuestionDao();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
 public ServiceDetailBusiness(MardisContext mardisContext) : base(mardisContext)
 {
     _serviceDetailDao  = new ServiceDetailDao(mardisContext);
     _questionDao       = new QuestionDao(mardisContext);
     _questionDetailDao = new QuestionDetailDao(mardisContext);
     _answerDao         = new AnswerDao(mardisContext);
     _answerDetailDao   = new AnswerDetailDao(mardisContext);
 }
        public ActionResult Edit(int?id)
        {
            SetViewBag();
            var model = new QuestionDao().getById(id);
            var list  = new QuestionModel().litsAnswer(id);

            ViewData["ListAnswer"] = list;
            return(View(model));
        }
示例#9
0
        public ActionResult AddQuest(HttpPostedFileBase file, int id_subject, int id_thematic)
        {
            try
            {
                var dao     = new QuestionDao();
                var session = (AdminLogin)Session[CommonConstants.USER_SESSION];
                if (session.id_permission == 2)
                {
                    return(View("Error"));
                }
                ViewBag.AdminName = session.name;

                var ad = new ImportExport();
                HttpPostedFileBase upload = Request.Files["file"];
                string             path   = Path.Combine(Server.MapPath("~/App_Data/uploads"), "cauhoi.xlsx");
                if (file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                    file.SaveAs(path);
                }
                var data = ad.ReadFromExcelfile(path, "");

                int id = dao.InsertList(data, id_thematic);
                if (id > 0)
                {
                    SetViewBag(id_subject);
                    //để thông báo thêm thành công
                    SetNotice("Hệ thống đã thêm thành công " + id.ToString() + " câu hỏi", "success");
                    return(RedirectToAction("QDetail", new { id = id_subject }));
                }
                else
                {
                    var dao2 = new SubjectDao().ViewDetail(id_subject);
                    TempData["subject_name"] = dao2.subject_name;
                    TempData["id_subject"]   = id_subject;
                    SetViewBag(id_subject);
                    ModelState.AddModelError("", "Thêm câu hỏi không thành công.");
                }
            }
            catch
            {
                var dao2 = new SubjectDao().ViewDetail(id_subject);
                TempData["subject_name"] = dao2.subject_name;
                TempData["id_subject"]   = id_subject;
                SetViewBag(id_subject);
                ModelState.AddModelError("", "Thêm câu hỏi không thành công. Vui lòng kiểm tra file!");
            }

            var dao3 = new SubjectDao().ViewDetail(id_subject);

            TempData["subject_name"] = dao3.subject_name;
            TempData["id_subject"]   = id_subject;
            SetViewBag(id_subject);
            return(View());
        }
示例#10
0
 public ServiceBusiness(MardisContext mardisContext) : base(mardisContext)
 {
     _serviceDao        = new ServiceDao(mardisContext);
     _serviceDetailDao  = new ServiceDetailDao(mardisContext);
     _questionDao       = new QuestionDao(mardisContext);
     _questionDetailDao = new QuestionDetailDao(mardisContext);
     _typePollDao       = new TypePollDao(mardisContext);
     _sequenceBusiness  = new SequenceBusiness(mardisContext);
     _typeServiceDao    = new TypeServiceDao(mardisContext);
     _customerDao       = new CustomerDao(mardisContext);
 }
示例#11
0
 public ServiceBusiness(MardisContext mardisContext, RedisCache distributedCache) : base(mardisContext)
 {
     _serviceDao        = new ServiceDao(mardisContext);
     _serviceDetailDao  = new ServiceDetailDao(mardisContext);
     _questionDao       = new QuestionDao(mardisContext);
     _questionDetailDao = new QuestionDetailDao(mardisContext);
     _typePollDao       = new TypePollDao(mardisContext);
     _sequenceBusiness  = new SequenceBusiness(mardisContext);
     _typeServiceDao    = new TypeServiceDao(mardisContext);
     _customerDao       = new CustomerDao(mardisContext);
     _redisCache        = distributedCache;
 }
        public void Can_GeAll_Questions()
        {
            // Arrange

            var questionDao = new QuestionDao();

            //Action
            var result = questionDao.GetAll();

            // AAsserts
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count() > 0);
        }
示例#13
0
        //查看已发布的问题
        public ActionResult MyPublish()
        {
            MyPublishModel model = new MyPublishModel();

            UserDao     userdao     = new UserDao();
            User        user        = userdao.getById(int.Parse(Request.Cookies["Menber"].Values["ID"]));
            QuestionDao questiondao = new QuestionDao();

            model.questions = questiondao.getByUser(user);

            TypeDao typedao = new TypeDao();

            model.types = typedao.getTypeList();

            return(View(model));
        }
示例#14
0
        public ActionResult Index()
        {
            IndexModel model   = new IndexModel();
            TypeDao    typedao = new TypeDao();

            model.types = typedao.getTypeList();

            QuestionDao questiondao = new QuestionDao();

            model.questions = questiondao.getAll(0, 6);
            for (int i = 0; i < model.questions.Count; i++)
            {
                model.questions[i].optionData = questiondao.getOptionData(model.questions[i]).Replace(" ", "").Replace("\n", "").Replace("\t", "").Replace("\r", "");
                model.questions[i].voteCount  = questiondao.getVoteCount(model.questions[i]);
            }
            return(View(model));
        }
示例#15
0
        public ActionResult QDelete(int id)
        {
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 2)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;

            var result = new QuestionDao().Delete(id);

            if (result == true)
            {
            }
            return(RedirectToAction("Index"));
        }
示例#16
0
        public ActionResult QEssayCreate(Question collection, int id_subject)
        {
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 2)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;

            if (ModelState.IsValid)
            {
                var dao = new QuestionDao();

                collection.question_content = System.Net.WebUtility.HtmlDecode(collection.question_content);
                collection.A         = System.Net.WebUtility.HtmlDecode(collection.A);
                collection.is_essay  = 1;
                collection.is_change = 0;
                collection.B         = "-1";
                collection.C         = "-1";
                collection.D         = "-1";
                int id = dao.Insert(collection);
                if (id > 0)
                {
                    SetViewBag(id_subject);
                    //để thông báo thêm thành công
                    SetNotice("Hệ thống đã thêm thành công.", "success");
                    return(RedirectToAction("QDetail", new { id = id_subject }));
                }
                else
                {
                    var dao2 = new SubjectDao().ViewDetail(id_subject);
                    TempData["subject_name"] = dao2.subject_name;
                    TempData["id_subject"]   = id_subject;
                    SetViewBag(id_subject);
                    ModelState.AddModelError("", "Thêm câu hỏi tự luận không thành công.");
                }
            }
            var dao3 = new SubjectDao().ViewDetail(id_subject);

            TempData["subject_name"] = dao3.subject_name;
            TempData["id_subject"]   = id_subject;
            SetViewBag(id_subject);
            return(View());
        }
        public ActionResult Edit(Question ques)
        {
            if (ModelState.IsValid)
            {
                var dao = new QuestionDao();
                var res = dao.Update(ques);

                if (res)
                {
                    SetAlert("Sửa thành công", "success");
                    return(RedirectToAction("Index", "Question"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật thất bại");
                }
            }
            SetViewBag();
            return(View("Index"));
        }
示例#18
0
        public ActionResult QDetail(int id)
        {
            var dao     = new AdminDao();
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 2)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;


            var dao2 = new SubjectDao().ViewDetail(id);
            var dao1 = new QuestionDao().ListQuestionInSubject(id);

            if (dao2 == null)
            {
                return(View("Error"));
            }
            else
            {
                dao.UpdateLastLogin(session.id_admin);
                dao.UpdateLastSeen("Xem các câu hỏi của môn học " + dao2.subject_name, "/Admin/Subject/QDetail" + dao2.id_subject, session.id_admin);
                TempData["subject_name"] = dao2.subject_name;
                TempData["id_subject"]   = id;
                var list = dao1.ToList();
                foreach (var item in list)
                {
                    item.question_content = RemoveHtml(RemoveFomula(item.question_content));
                    if (item.question_content.Length >= 90)
                    {
                        item.question_content = item.question_content.Substring(0, 90) + "....";
                    }
                }

                return(View(list));
            }
        }
        public TaskCampaignBusiness(MardisContext mardisContext, RedisCache distributedCache)
            : base(mardisContext)
        {
            _taskCampaignDao           = new TaskCampaignDao(mardisContext);
            _questionDetailDao         = new QuestionDetailDao(mardisContext);
            _statusTaskBusiness        = new StatusTaskBusiness(mardisContext, distributedCache);
            _sequenceBusiness          = new SequenceBusiness(mardisContext);
            _campaignServicesDao       = new CampaignServicesDao(mardisContext);
            _branchDao                 = new BranchDao(mardisContext);
            _answerDao                 = new AnswerDao(mardisContext);
            _answerDetailDao           = new AnswerDetailDao(mardisContext);
            _branchImageBusiness       = new BranchImageBusiness(mardisContext);
            _userDao                   = new UserDao(mardisContext);
            _campaignDao               = new CampaignDao(mardisContext);
            _serviceDetailTaskBusiness = new ServiceDetailTaskBusiness(mardisContext);
            _personDao                 = new PersonDao(mardisContext);
            _profileDao                = new ProfileDao(mardisContext);
            _typeUserBusiness          = new TypeUserBusiness(mardisContext, distributedCache);
            _serviceDetailDao          = new ServiceDetailDao(mardisContext);
            _questionDao               = new QuestionDao(mardisContext);
            _redisCache                = distributedCache;
            _serviceDetailBusiness     = new ServiceDetailBusiness(mardisContext);

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Service, MyTaskServicesViewModel>()
                .ForMember(dest => dest.ServiceDetailCollection, opt => opt.MapFrom(src => src.ServiceDetails.OrderBy(sd => sd.Order)));
                cfg.CreateMap <ServiceDetail, MyTaskServicesDetailViewModel>()
                .ForMember(dest => dest.QuestionCollection, opt => opt.MapFrom(src => src.Questions.OrderBy(q => q.Order)))
                .ForMember(dest => dest.Sections, opt => opt.MapFrom(src => src.Sections.OrderBy(s => s.Order)));
                cfg.CreateMap <Question, MyTaskQuestionsViewModel>()
                .ForMember(dest => dest.HasPhoto, opt => opt.MapFrom(src => src.HasPhoto.IndexOf("S", StringComparison.Ordinal) >= 0))
                .ForMember(dest => dest.QuestionDetailCollection, opt => opt.MapFrom(src => src.QuestionDetails.OrderBy(qd => qd.Order)))
                .ForMember(dest => dest.CodeTypePoll, opt => opt.MapFrom(src => src.TypePoll.Code));
                cfg.CreateMap <QuestionDetail, MyTaskQuestionDetailsViewModel>();
            });
        }
示例#20
0
        public ActionResult QEssayEdit(Question collection, int id_subject)
        {
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 2)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;

            var dao = new QuestionDao();

            collection.correct_answer = System.Net.WebUtility.HtmlDecode(collection.question_content);
            collection.A = System.Net.WebUtility.HtmlDecode(collection.A);
            var id = dao.Update(collection);

            if (id)
            {
                SetNotice("Hệ thống đã sửa thành công câu hỏi có id " + collection.id_question + ".", "success");
                return(RedirectToAction("QDetail", new { id = id_subject }));
            }
            else
            {
                var dao2 = new SubjectDao().ViewDetail(id_subject);
                TempData["subject_name"] = dao2.subject_name;
                TempData["id_subject"]   = id_subject;
                SetNotice("Có lỗi xảy ra!!", "danger");
                ModelState.AddModelError("", "Cập nhật thông tin câu hỏi không thành công.");
            }
            var dao3 = new SubjectDao().ViewDetail(id_subject);

            TempData["subject_name"] = dao3.subject_name;
            TempData["id_subject"]   = id_subject;
            SetViewBag(id_subject);
            return(View());
        }
 public QuestionDetailBusiness(MardisContext mardisContext)
     : base(mardisContext)
 {
     _questionDetailDao = new QuestionDetailDao(mardisContext);
     _questionDao       = new QuestionDao(mardisContext);
 }
示例#22
0
        public ActionResult Create(Thread entity, FormCollection collection)
        {
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 0)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;
            if (ModelState.IsValid)
            {
                var dao        = new ThreadDao();
                var dao1       = new ThematicDao();
                var dao2       = new QuestionDao();
                var dao3       = new ExamDao();
                int id_subject = Convert.ToInt32(collection["id_subject"]);
                int total_exam = Convert.ToInt32(collection["total_exam"]);

                int id_thread = dao.Insert(entity);
                if (id_thread > 0)
                {
                    //tạo bộ câu hỏi cho đề thi
                    List <ThematicModel> list_thematic  = dao1.GetThematic(id_subject);
                    List <int>           idExamOfThread = new List <int>();
                    for (int i = 1; i <= total_exam; i++)
                    {
                        int id_exam = dao3.Insert(id_thread);
                        idExamOfThread.Add(id_exam);
                    }
                    foreach (ThematicModel thematic in list_thematic)
                    {
                        //lấy danh sách câu hỏi trắc nghiệm ngẫu nhiên
                        int             quest_of_thematic = Convert.ToInt32(collection["unit-" + thematic.id_thematic]);
                        List <Question> list_question     = dao2.GetQuestionsByThematic(thematic.id_thematic, quest_of_thematic);
                        foreach (Question item in list_question)
                        {
                            foreach (int id_exam in idExamOfThread)
                            {
                                dao2.AddQuestionsToExam(id_exam, item.id_question);
                            }
                        }
                        //lấy danh sách câu hỏi tự luận ngẫu nhiên
                        quest_of_thematic = Convert.ToInt32(collection["unit-essay-" + thematic.id_thematic]);
                        List <Question> list_essay = dao2.GetEssayByThematic(thematic.id_thematic, quest_of_thematic);
                        foreach (Question item in list_essay)
                        {
                            foreach (int id_exam in idExamOfThread)
                            {
                                dao2.AddEssaysToExam(item, id_exam);
                            }
                        }
                    }
                    //để thông báo thêm thành công
                    SetNotice("Hệ thống đã thêm thành công.", "success");
                    return(RedirectToAction("Create"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm kì thi không thành công.");
                }
            }
            var dao4 = new SubjectDao();

            ViewBag.ListSubject = dao4.ListAll();
            SetViewBag();
            return(View());
        }
示例#23
0
 public QuestionCRUDService(IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     _questionDao = new QuestionDao(unitOfWork);
 }
示例#24
0
        public ActionResult Qedit(Question collection, int id_subject, HttpPostedFileBase File)
        {
            var session = (AdminLogin)Session[CommonConstants.USER_SESSION];

            if (session.id_permission == 2)
            {
                return(View("Error"));
            }
            ViewBag.AdminName = session.name;
            try
            {
                if (File != null)
                {
                    string fileName = Path.GetFileName(File.FileName);
                    //Upload image
                    string path = Server.MapPath("~/Assets/img_questions/");
                    //Đuối hỗ trợ
                    var allowedExtensions = new[] { ".png", ".jpg" };
                    //Lấy phần mở rộng của file
                    string extensionName = Path.GetExtension(File.FileName).ToLower();
                    //Kiểm tra đuôi file
                    if (!allowedExtensions.Contains(extensionName))
                    {
                        ModelState.AddModelError("", "Chỉ chọn file ảnh đuôi .PNG .png .JPG .jpg");
                        var dao2 = new SubjectDao().ViewDetail(id_subject);
                        TempData["subject_name"] = dao2.subject_name;
                        TempData["id_subject"]   = id_subject;
                        SetViewBag(id_subject);
                        return(View());
                    }
                    else
                    {
                        // Tạo tên file ngẫu nhiên
                        collection.img = DateTime.Now.Ticks.ToString() + extensionName;
                        // Upload file lên server
                        File.SaveAs(path + collection.img);
                    }
                }
                else
                {
                    //  collection.
                }
            }
            catch (Exception) { }
            var dao = new QuestionDao();

            var id = dao.Update(collection);

            if (id)
            {
                SetNotice("Hệ thống đã sửa thành công câu hỏi có id " + collection.id_question + ".", "success");
                return(RedirectToAction("QDetail", new { id = id_subject }));
            }
            else
            {
                var dao2 = new SubjectDao().ViewDetail(id_subject);
                TempData["subject_name"] = dao2.subject_name;
                TempData["id_subject"]   = id_subject;
                SetNotice("Có lỗi xảy ra!!", "danger");
                ModelState.AddModelError("", "Cập nhật thông tin chuyên đề không thành công.");
            }
            var dao3 = new SubjectDao().ViewDetail(id_subject);

            TempData["subject_name"] = dao3.subject_name;
            TempData["id_subject"]   = id_subject;
            SetViewBag(id_subject);
            return(View());
        }
        public void SetViewBag(long?selectedId = null)  //hien thi danh sach cac question bang dropdowlist
        {
            var dao = new QuestionDao();

            ViewBag.QuestionId = new SelectList(dao.ListAll(), "QuestionId", "QuestionName", selectedId);
        }
 public TestsController()
 {
     _testDao     = new TestDao();
     _questionDao = new QuestionDao();
     _personDao   = new PersonDao();
 }
示例#27
0
 public PreparedPersonsTestsDataLocator()
 {
     _testDao     = new TestDao();
     _questionDao = new QuestionDao();
     _personDao   = new PersonDao();
 }
 /// <summary>
 /// конструктор
 /// </summary>
 public TestComponent()
 {
     _testDao     = new TestDao();
     _questionDao = new QuestionDao();
     _answerDao   = new AnswerDao();
 }