Exemplo n.º 1
0
        public JsonResult GetList(string examTimeCode)
        {
            var ret = 0;
            //Khai báo lấy dữ liệu
            EXAMFORM_BUS     bus  = new EXAMFORM_BUS();
            List <fieldpara> lipa = new List <fieldpara>
            {
                new fieldpara("EXAMTIMECODE", examTimeCode, 0)
            };

            lipa.Add(new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));
            //order by theorder, with pagesize and the page
            var li = bus.getAllBy2("NAME", lipa.ToArray());

            if (li == null)
            {
                ret = -1;
            }
            bus.CloseConnection();
            return(Json(new
            {
                lst = li, //Danh sách
                ret = ret //ok
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public JsonResult Delete(List <string> listCode)
        {
            var ret = 0;

            if (listCode == null)
            {
                ret = -1;
            }
            else
            {
                var bus = new EXAMFORM_BUS();
                foreach (string t in listCode)
                {
                    if (t != null)
                    {
                        var item = bus.GetByID(new EXAMFORM_OBJ.BusinessObjectID(t));
                        if (item == null)
                        {
                            ret = -2; continue;
                        }
                        if (ret >= 0)
                        {
                            ret = bus.delete(item._ID);
                        }
                    }
                }
                bus.CloseConnection();
            }
            return(Json(new
            {
                ret
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Tạo đề thi với đợt thi, với cấu trúc đề thi, số lượng đề thi theo quy định; Trả về danh sách đề thi
        /// Mr. Uyen viết
        /// </summary>
        /// <param name="examTimeCode"></param>
        /// <param name="testStructCode"></param>
        public List <EXAMFORM_OBJ> CreateExamForm(EXAMTIME_OBJ objExamtime, int testcount, out int ret)
        {
            List <EXAMFORM_OBJ> liExamform = new List <EXAMFORM_OBJ>();

            ret = 0;
            // get examtime
            EXAMFORM_BUS bus         = new EXAMFORM_BUS();
            EXAMFORM_OBJ obj         = new EXAMFORM_OBJ();
            string       currentCode = bus.genNextCode(obj);//Mã đầu tiên

            for (int i = 0; i < testcount; i++)
            {
                // create examform
                obj = new EXAMFORM_OBJ
                {
                    EXAMTIMECODE   = objExamtime.CODE,
                    SUBJECTCODE    = objExamtime.SUBJECTCODE,
                    TESTSTRUCTCODE = objExamtime.TESTSTRUCTCODE,
                    EDITTIME       = DateTime.Now,
                    EDITUSER       = _ses.loginCode,
                    LOCK           = 0,
                    NAME           = objExamtime.NAME + "(" + (i + 1).ToString() + ")"
                };
                obj.CODE     = currentCode;
                currentCode  = bus.genNextCode(obj, currentCode);
                obj.CODEVIEW = (i + 1).ToString();
                obj.LOCKDATE = DateTime.Now;
                liExamform.Add(obj);
            }
            //            ret = bus.InsertMultiItems(liExamform);
            bus.CloseConnection();
            return(liExamform);
        }
Exemplo n.º 4
0
        public JsonResult CheckCodeViewExit(string code, string codeView)
        {
            int                 ret;
            EXAMFORM_BUS        bus = new EXAMFORM_BUS();
            List <EXAMFORM_OBJ> li  = bus.getAllBy2(new fieldpara("CODEVIEW", codeView, 0), new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));

            bus.CloseConnection();
            int count = li.Count;

            if (count == 0)
            {
                ret = 0;
            }
            else
            {
                if (code != "" && code == li[0].CODE)
                {
                    ret = 0;
                }
                else
                {
                    ret = 1;
                }
            }
            return(Json(new { sussess = ret }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public JsonResult GetByExamtime(string examtimecode)
        {
            var              ret  = 0;
            EXAMFORM_BUS     bus  = new EXAMFORM_BUS();
            List <fieldpara> lipa = new List <fieldpara>();

            lipa.Add(new fieldpara("EXAMTIMECODE", examtimecode, 0));
            lipa.Add(new fieldpara("LOCK", "0", 0));
            var data = bus.getAllBy2("CODE", lipa.ToArray());

            if (data == null)
            {
                ret = -1;
            }
            bus.CloseConnection();
            return(Json(new { ret, lst = data }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public int ProcessExamFormAuto(string examtimecode, string coursecode, int testcount)
        {
            int ret = 0;
            //Lấy được đợt thi
            EXAMTIME_BUS        bus        = new EXAMTIME_BUS();
            EXAMTIME_OBJ        obj        = bus.GetByID(new EXAMTIME_OBJ.BusinessObjectID(examtimecode));
            EXAMFORM_BUS        busExamfom = new EXAMFORM_BUS();
            List <EXAMFORM_OBJ> liExamform = new List <EXAMFORM_OBJ>();

            bus.CloseConnection();
            if (obj == null)
            {
                ret = -1;
            }
            //Lấy được lớp học
            MARK_BUS        busMark = new MARK_BUS();
            List <MARK_OBJ> liMark  = busMark.getAllBy2(new fieldpara("COURSECODE", coursecode));

            busMark.CloseConnection();

            if (ret >= 0)
            {
                liExamform = CreateExamForm(obj, testcount, out ret);
            }
            EXAMFORMDETAIL_BUS        busExamformdetail = new EXAMFORMDETAIL_BUS();
            EXAMFORMDETAIL_OBJ        objExamformdetail = new EXAMFORMDETAIL_OBJ();
            List <EXAMFORMDETAIL_OBJ> liExamformdetail  = new List <EXAMFORMDETAIL_OBJ>();
            //Danh sách cấu trúc đề
            TESTSTRUCTDETAIL_BUS        busTeststructdetail = new TESTSTRUCTDETAIL_BUS();
            List <TESTSTRUCTDETAIL_OBJ> liTestStructDetail  = busTeststructdetail.getByTestStruct(obj.TESTSTRUCTCODE, _ses.gUNIVERSITYCODE);

            busTeststructdetail.CloseConnection();

            string currentCode = busExamformdetail.genNextCode(objExamformdetail);

            if (ret >= 0)
            {
                foreach (EXAMFORM_OBJ objtem in liExamform)
                {
                    ret = CreateExamFormDetail(ref liExamformdetail, objtem, liTestStructDetail, ref currentCode);
                    if (ret < 0)
                    {
                        break;
                    }
                }
            }
            //Gán sinh viên vào danh sách đề
            List <EXAMHALLSTUDENT_OBJ> liExamhallstudent  = new List <EXAMHALLSTUDENT_OBJ>();
            EXAMHALLSTUDENT_BUS        busExamhallstudent = new EXAMHALLSTUDENT_BUS();
            EXAMHALLSTUDENT_OBJ        objExamhallstudent = new EXAMHALLSTUDENT_OBJ();

            currentCode = busExamhallstudent.genNextCode(objExamhallstudent);
            int i = 0;

            //Thêm tất cả sinh viên
            foreach (MARK_OBJ objMar in liMark)
            {
                //Gán sinh viên vào examhall student
                objExamhallstudent              = new EXAMHALLSTUDENT_OBJ();
                objExamhallstudent.CODE         = currentCode;
                currentCode                     = busExamhallstudent.genNextCode(objExamhallstudent, currentCode);
                objExamhallstudent.COURSECODE   = coursecode;
                objExamhallstudent.EDITTIME     = DateTime.Now;
                objExamhallstudent.EDITUSER     = _ses.loginCode;
                objExamhallstudent.EXAMFORMCODE = liExamform[i % testcount].CODE;
                objExamhallstudent.EXAMTIMECODE = examtimecode;
                i++;
                objExamhallstudent.EXAMHALLCODE   = "";
                objExamhallstudent.MARKCODE       = objMar.CODE;
                objExamhallstudent.UNIVERSITYCODE = _ses.gUNIVERSITYCODE;
                liExamhallstudent.Add(objExamhallstudent);
            }
            if (ret >= 0)
            {
                busExamfom.BeginTransaction();
                busExamformdetail.setConnection(busExamfom);
                busExamhallstudent.setConnection(busExamfom);
                ret = busExamfom.InsertMultiItems(liExamform);
                if (ret >= 0)
                {
                    ret = busExamformdetail.InsertMultiItems(liExamformdetail);
                }
                if (ret >= 0)
                {
                    ret = busExamhallstudent.InsertMultiItems(liExamhallstudent);
                }
                if (ret >= 0)
                {
                    busExamfom.CommitTransaction();
                }
                else
                {
                    busExamfom.RollbackTransaction();
                }
            }
            busExamfom.CloseConnection();
            return(ret);
        }
Exemplo n.º 7
0
        public JsonResult Update(EXAMFORM_OBJ obj)
        {
            EXAMFORM_BUS bus = new EXAMFORM_BUS();
            int          ret;
            int          add = 0;
            EXAMFORM_OBJ objTemp;

            //kiểm tra tồn tại cho trường hợp sửa
            if (!string.IsNullOrEmpty(obj.CODE))//edit
            {
                objTemp = bus.GetByID(new EXAMFORM_OBJ.BusinessObjectID(obj.CODE));
                if (objTemp == null)
                {
                    ret = -4;
                    bus.CloseConnection();
                    //ban ghi sửa đã bị xóa
                    return(Json(new { sussess = ret }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                objTemp = new EXAMFORM_OBJ();
            }

            //hết kiểm tra tồn tại bản ghi
            objTemp.EDITTIME       = DateTime.Now;   //Thời điểm sủa bản ghi
            objTemp.EDITUSER       = _ses.loginCode; //Người sửa bản ghi
            objTemp.CODEVIEW       = obj.CODEVIEW;
            objTemp.NAME           = obj.NAME;
            objTemp.SUBJECTCODE    = obj.SUBJECTCODE;
            objTemp.EXAMTIMECODE   = obj.EXAMTIMECODE;
            objTemp.NOTE           = obj.NOTE;
            objTemp.TESTSTRUCTCODE = obj.TESTSTRUCTCODE;
            //Kiểm tra tình trạng sửa hay là thêm mới
            if (string.IsNullOrEmpty(obj.CODE))
            {
                //Thêm mới
                add = 1;
                //Sinh mã
                objTemp.CODE     = bus.genNextCode(obj);
                objTemp.LOCKDATE = DateTime.Now;
            }
            if (add == 1)
            {
                ret = bus.insert(objTemp);
            }
            else
            {
                //gán _ID để xác định bản ghi sẽ được cập nhật
                objTemp._ID.CODE = obj.CODE;
                ret = bus.update(objTemp);
            }
            int pagecount   = 0;
            int currentpage = 0;

            if (ret >= 0)
            {
                objTemp._ID.CODE = objTemp.CODE;
                ret = bus.checkPage(objTemp._ID, "CODE", AppConfig.item4page(), out pagecount, out currentpage);
            }
            bus.CloseConnection();
            //some thing like that
            return(Json(new { ret, pagecount, currentpage }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        /// <summary>
        /// lấy chi tiết 1 đề thi
        /// </summary>
        /// <param name="examformcode">mã đề thi</param>
        /// <returns></returns>
        public JsonResult Preview(string examformcode)
        {
            int          ret            = 0;
            int          numberQuestion = 0;
            EXAMFORM_BUS busExamform    = new EXAMFORM_BUS();
            EXAMFORM_OBJ objExamform    = busExamform.GetByID((new EXAMFORM_OBJ.BusinessObjectID(examformcode)));

            busExamform.CloseConnection();
            if (objExamform == null)
            {
                ret = -2;
            }
            //Danh sachs cau truc
            EXAMFORMDETAIL_BUS        busExamformdetail = new EXAMFORMDETAIL_BUS();
            List <EXAMFORMDETAIL_OBJ> liExamformdetail  = new List <EXAMFORMDETAIL_OBJ>();

            if (ret >= 0)
            {
                if (objExamform != null)
                {
                    liExamformdetail = busExamformdetail.getAllBy2("THEORDER", new fieldpara("EXAMFORMCODE", objExamform.CODE));
                }
                busExamformdetail.CloseConnection();
                if (liExamformdetail == null)
                {
                    ret = -3;
                }
            }
            List <fieldpara> lipa   = new List <fieldpara>();
            List <jointable> lijoin = new List <jointable>();
            //Lay danh sach cac nhom cau hoi
            QUESTIONGROUP_BUS        busQuestiongroup = new QUESTIONGROUP_BUS();
            List <QUESTIONGROUP_OBJ> liQuestiongroup  = new List <QUESTIONGROUP_OBJ>();

            if (ret >= 0)
            {
                if (objExamform != null)
                {
                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "CODE", "QUESTIONGROUPCODE", new fieldpara("EXAMFORMCODE", objExamform.CODE)));
                }
                liQuestiongroup = busQuestiongroup.getAllBy2("CODE", lipa, lijoin);
                if (liQuestiongroup == null)
                {
                    ret = -4;
                }
                busQuestiongroup.CloseConnection();
            }
            //Lay danh sach cau hoi
            QUESTION_BUS        busQuestion        = new QUESTION_BUS();
            List <QUESTION_OBJ> listQuestionreturn = new List <QUESTION_OBJ>();

            if (ret >= 0)
            {
                lijoin.Clear();
                if (objExamform != null)
                {
                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE", "QUESTIONGROUPCODE",
                                             new fieldpara("examformcode", objExamform.CODE)));
                }
                var liQuestion = busQuestion.getAllBy2("CODE", lipa, lijoin);
                if (liQuestion == null)
                {
                    ret = -5;
                }
                else
                {
                    foreach (var objQuestion in liQuestion)
                    {
                        QUESTION_OBJ objTemp = new QUESTION_OBJ();
                        objTemp.CODE               = objQuestion.CODE;
                        objTemp.ANSWERCODE         = null;
                        objTemp.CONTENT            = objQuestion.CONTENT;
                        objTemp.QUESTIONGROUPCODE  = objQuestion.QUESTIONGROUPCODE;
                        objTemp._QUESTIONGROUPCODE = objQuestion._QUESTIONGROUPCODE;
                        objTemp._ID = objQuestion._ID;
                        listQuestionreturn.Add(objTemp);
                    }
                    numberQuestion = liQuestion.Count;
                }
                busQuestion.CloseConnection();
            }
            //Lay danh danh cac dap an
            ANSWER_BUS        busAnswer = new ANSWER_BUS();
            List <ANSWER_OBJ> liAnswer  = new List <ANSWER_OBJ>();

            if (ret >= 0)
            {
                lijoin.Clear();
                if (objExamform != null)
                {
                    lijoin.Add((new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE", "QUESTIONGROUPCODE",
                                              new fieldpara("examformcode", objExamform.CODE))));
                }
                liAnswer = busAnswer.getAllBy2("CODE", lipa, lijoin);
                if (liAnswer == null)
                {
                    ret = -6;
                }
                busAnswer.CloseConnection();
            }
            var jsonResult = Json(new
            {
                numberQuestion,                      //so luong cau hoi
                ObjexamForm      = objExamform,      //examform
                liExamformDetail = liExamformdetail, //Danh sách examdetail
                liQuestiongroup,                     //danh sach nhom cau hoi
                li_question = listQuestionreturn,    //danh sach cac cau hoi
                li_answer   = liAnswer,              //danh sach tat ca cac cau tra loi
                ret                                  //ok
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Lấy ra chi tiết của một bài thi dựa vào mã sinh viên trong bảng điểm lớp môn học và mã học kì
        /// </summary>
        /// <param name="markcode">mã sinh viên trong lớp môn học</param>
        /// <param name="examtimecode">mã học kì </param>
        /// <returns></returns>
        public JsonResult GetDetailExam(string markcode, string examtimecode)
        {
            if (string.IsNullOrEmpty(markcode))
            {
                markcode = "1708310001";
            }
            int ret            = 0;
            int numberQuestion = 0;


            MARK_BUS markbus = new MARK_BUS();
            MARK_OBJ objmark = markbus.GetByID(new MARK_OBJ.BusinessObjectID(markcode));//markbus.GetByKey(new fieldpar("STUDENTCODE", _ses.loginCode, 0),new fieldpara("COURSECODE", courseCode, 0));

            markbus.CloseConnection();
            if (objmark == null)
            {
                ret = -7;
            }
            EXAMHALLSTUDENT_OBJ obj = new EXAMHALLSTUDENT_OBJ();

            if (ret >= 0)
            {
                EXAMHALLSTUDENT_BUS bus = new EXAMHALLSTUDENT_BUS();
                if (objmark != null)
                {
                    obj = bus.GetByKey(new fieldpara("MARKCODE", objmark.CODE, 0),
                                       new fieldpara("examtimecode", examtimecode));
                }
                bus.CloseConnection();
            }
            //Lấy được một lần thi
            if (obj == null)
            {
                ret = -1;
            }
            EXAMFORM_BUS busExamform = new EXAMFORM_BUS();
            EXAMFORM_OBJ objExamform = null;

            //Lấy đề thi
            if (ret >= 0)
            {
                if (obj != null)
                {
                    objExamform = busExamform.GetByID((new EXAMFORM_OBJ.BusinessObjectID(obj.EXAMFORMCODE)));
                }
                busExamform.CloseConnection();
                if (objExamform == null)
                {
                    ret = -2;
                }
            }
            //Danh sachs cau truc
            EXAMFORMDETAIL_BUS        busExamformdetail = new EXAMFORMDETAIL_BUS();
            List <EXAMFORMDETAIL_OBJ> liExamformdetail  = new List <EXAMFORMDETAIL_OBJ>();

            if (ret >= 0)
            {
                if (objExamform != null)
                {
                    liExamformdetail = busExamformdetail.getAllBy2("THEORDER", new fieldpara("EXAMFORMCODE", objExamform.CODE));
                }
                busExamformdetail.CloseConnection();
                if (liExamformdetail == null)
                {
                    ret = -3;
                }
            }
            List <fieldpara> lipa   = new List <fieldpara>();
            List <jointable> lijoin = new List <jointable>();
            //Lay danh sach cac nhom cau hoi
            QUESTIONGROUP_BUS        busQuestiongroup = new QUESTIONGROUP_BUS();
            List <QUESTIONGROUP_OBJ> liQuestiongroup  = new List <QUESTIONGROUP_OBJ>();

            if (ret >= 0)
            {
                if (objExamform != null)
                {
                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "CODE", "QUESTIONGROUPCODE", new fieldpara("EXAMFORMCODE", objExamform.CODE)));
                }
                liQuestiongroup = busQuestiongroup.getAllBy2("CODE", lipa, lijoin);
                if (liQuestiongroup == null)
                {
                    ret = -4;
                }
                busQuestiongroup.CloseConnection();
            }
            //Lay danh sach cau hoi
            QUESTION_BUS        busQuestion        = new QUESTION_BUS();
            List <QUESTION_OBJ> listQuestionreturn = new List <QUESTION_OBJ>();

            if (ret >= 0)
            {
                lijoin.Clear();
                if (objExamform != null)
                {
                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE", "QUESTIONGROUPCODE",
                                             new fieldpara("examformcode", objExamform.CODE)));
                }
                var liQuestion = busQuestion.getAllBy2("CODE", lipa, lijoin);
                if (liQuestion == null)
                {
                    ret = -5;
                }
                else
                {
                    foreach (var objQuestion in liQuestion)
                    {
                        QUESTION_OBJ objTemp = new QUESTION_OBJ();
                        objTemp.CODE               = objQuestion.CODE;
                        objTemp.ANSWERCODE         = null;
                        objTemp.CONTENT            = objQuestion.CONTENT;
                        objTemp.QUESTIONGROUPCODE  = objQuestion.QUESTIONGROUPCODE;
                        objTemp._QUESTIONGROUPCODE = objQuestion._QUESTIONGROUPCODE;
                        objTemp._ID = objQuestion._ID;
                        listQuestionreturn.Add(objTemp);
                    }
                    numberQuestion = liQuestion.Count;
                }
                busQuestion.CloseConnection();
            }
            //Lay danh danh cac dap an
            ANSWER_BUS        busAnswer = new ANSWER_BUS();
            List <ANSWER_OBJ> liAnswer  = new List <ANSWER_OBJ>();

            if (ret >= 0)
            {
                lijoin.Clear();
                if (objExamform != null)
                {
                    lijoin.Add((new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE", "QUESTIONGROUPCODE",
                                              new fieldpara("examformcode", objExamform.CODE))));
                }
                liAnswer = busAnswer.getAllBy2("CODE", lipa, lijoin);
                if (liAnswer == null)
                {
                    ret = -6;
                }
                busAnswer.CloseConnection();
            }
            //get list exam result in case student lost the internet
            EXAMRESULT_BUS        busExamresult = new EXAMRESULT_BUS();
            List <EXAMRESULT_OBJ> liExamresult  = new List <EXAMRESULT_OBJ>();

            if (ret >= 0)
            {
                if (obj != null)
                {
                    liExamresult = busExamresult.getAllBy2(new fieldpara("examhallstudentcode", obj.CODE));
                }
                busExamresult.CloseConnection();
            }
            var jsonResult = Json(new
            {
                numberQuestion,                        //so luong cau hoi
                ObjexamHallstudent = obj,              //examhallstudent code
                ObjexamForm        = objExamform,      //examform
                liExamformDetail   = liExamformdetail, //Danh sách examdetail
                liQuestiongroup,                       //danh sach nhom cau hoi
                li_question = listQuestionreturn,      //danh sach cac cau hoi
                li_answer   = liAnswer,                //danh sach tat ca cac cau tra loi
                liExamresult,                          //danh sach tat ca cac dap an da tra loi cu sinh vien
                ret                                    //ok
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 10
0
        /// <summary>
        /// logic: truyền vào coursecode và examtimecode
        /// từ coursecode và examtimecode -> tìm được examhallstudent tương ứng -> lấy ra được examformcode chính là đề thi mà sinh viên đó làm
        /// lấy ra danh sách các nhóm câu hỏi của đề thi đấy (dữ liệu trong bảng examformdetail)
        /// lấy danh sách các câu hỏi
        /// </summary>
        /// <param name="coursecode">mã lớp môn học</param>
        /// <param name="examtimecode"></param>
        /// <returns></returns>
        public JsonResult ShowExamResult(string coursecode, string examtimecode)
        {
            if (string.IsNullOrEmpty(coursecode))
            {
                coursecode = "1708310001";
            }
            if (string.IsNullOrEmpty(examtimecode))
            {
                examtimecode = "1712250004";
            }
            var    ret         = 0;
            string studentcode = "";
            List <QUESTION_OBJ>       liQuestion       = null;
            List <ANSWER_OBJ>         liAnswer         = null;
            List <EXAMRESULT_OBJ>     liExamresult     = null;
            EXAMFORM_OBJ              objExamform      = null;
            List <EXAMFORMDETAIL_OBJ> liExamformdetail = null;
            List <QUESTIONGROUP_OBJ>  liQuestiongroup  = null;
            int numberQuestion = 0; // số câu hỏi
            EXAMHALLSTUDENT_OBJ examhallstudentObj = new EXAMHALLSTUDENT_OBJ();

            if (_ses.loginType.Equals("STUDENT"))
            {
                studentcode = _ses.loginCode;
            }
            else
            {
                ret = -1;
            }
            if (ret >= 0)
            {
                List <fieldpara> lipa = new List <fieldpara>();
                // get mark
                MARK_BUS markBus = new MARK_BUS();
                lipa.Add(new fieldpara("STUDENTCODE", studentcode, 0));
                lipa.Add(new fieldpara("COURSECODE", coursecode, 0));
                lipa.Add(new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));
                var mark = markBus.GetByKey(lipa.ToArray());
                markBus.CloseConnection();
                if (mark != null)
                {
                    EXAMHALLSTUDENT_BUS bus = new EXAMHALLSTUDENT_BUS();
                    examhallstudentObj = bus.GetByKey(new fieldpara("MARKCODE", mark.CODE, 0),
                                                      new fieldpara("EXAMTIMECODE", examtimecode));
                    bus.CloseConnection();
                    if (examhallstudentObj != null)
                    {
                        // lấy đề thi
                        EXAMFORM_BUS busExamform = new EXAMFORM_BUS();
                        objExamform = busExamform.GetByID((new EXAMFORM_OBJ.BusinessObjectID(examhallstudentObj.EXAMFORMCODE)));
                        busExamform.CloseConnection();
                        if (objExamform != null)
                        {
                            // lấy danh sách chi tiết đề thi
                            EXAMFORMDETAIL_BUS busExamformdetail = new EXAMFORMDETAIL_BUS();
                            liExamformdetail = busExamformdetail.getAllBy2("THEORDER", new fieldpara("EXAMFORMCODE", objExamform.CODE));
                            busExamformdetail.CloseConnection();
                            if (liExamformdetail != null)
                            {
                                lipa = new List <fieldpara>();
                                List <jointable> lijoin = new List <jointable>();
                                //Lay danh sach cac nhom cau hoi
                                QUESTIONGROUP_BUS busQuestiongroup = new QUESTIONGROUP_BUS();
                                lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "CODE", "QUESTIONGROUPCODE",
                                                         new fieldpara("EXAMFORMCODE", objExamform.CODE)));
                                liQuestiongroup = busQuestiongroup.getAllBy2("CODE", lipa, lijoin);
                                busQuestiongroup.CloseConnection();
                                if (liQuestiongroup != null)
                                {
                                    //Lay danh sach cau hoi
                                    QUESTION_BUS busQuestion = new QUESTION_BUS();
                                    lijoin.Clear();
                                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE",
                                                             "QUESTIONGROUPCODE", new fieldpara("examformcode", objExamform.CODE)));
                                    liQuestion     = busQuestion.getAllBy2("CODE", lipa, lijoin);
                                    numberQuestion = liQuestion.Count;
                                    busQuestion.CloseConnection();
                                    // lấy danh sách các câu trả lời
                                    lijoin.Clear();
                                    ANSWER_BUS busAnswer = new ANSWER_BUS();
                                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE",
                                                             "QUESTIONGROUPCODE", new fieldpara("examformcode", objExamform.CODE)));
                                    liAnswer = busAnswer.getAllBy2("CODE", lipa, lijoin);
                                    busAnswer.CloseConnection();
                                    // lấy danh sách kết quả thi của sinh vên đó
                                    EXAMRESULT_BUS busExamresult = new EXAMRESULT_BUS();
                                    liExamresult = busExamresult.getAllBy2(new fieldpara("examhallstudentcode",
                                                                                         examhallstudentObj.CODE));
                                    busExamresult.CloseConnection();
                                    if (liAnswer == null || liExamresult == null)
                                    {
                                        ret = -7;
                                    }
                                }
                                else
                                {
                                    ret = -6;
                                }
                            }
                            else
                            {
                                ret = -5;
                            }
                        }
                        else
                        {
                            ret = -4;
                        }
                    }
                    else
                    {
                        ret = -3;
                    }
                }
                else
                {
                    ret = -2;
                }
            }
            else
            {
                ret = -1;
            }
            var jsonResult = Json(new
            {
                numberQuestion,                          //so luong cau hoi
                ObjexamHallstudent = examhallstudentObj, //examhallstudent code
                ObjexamForm        = objExamform,        //examform
                liExamformDetail   = liExamformdetail,   //Danh sách examdetail
                liQuestiongroup,
                li_question   = liQuestion,
                li_answer     = liAnswer,
                li_examresult = liExamresult,//danh sách đáp án
                ret
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 11
0
        /// <summary>
        /// lấy kết quả bài thi dựa trên mark code
        /// </summary>
        /// <param name="markcode"></param>
        /// <returns></returns>
        /// show questiongroup
        /// show question
        /// show answer
        /// put data//hide other answer
        public JsonResult ShowData(string markcode)
        {
            var ret = -1;

            int numberQuestion = 0;
            //dựa vào mã sinh viên thuộc lớp môn học nào sẽ xác định mã sinh bài thi của phòng nào đó cho môn học đó
            EXAMHALLSTUDENT_BUS bus = new EXAMHALLSTUDENT_BUS();
            EXAMHALLSTUDENT_OBJ obj = bus.GetByKey(new fieldpara("MARKCODE", markcode, 0));

            bus.CloseConnection();
            //bài kiểm tra
            EXAMFORM_BUS busExamform = new EXAMFORM_BUS();
            EXAMFORM_OBJ objExamform = null;

            if (ret >= 0)
            {
                objExamform = busExamform.GetByID((new EXAMFORM_OBJ.BusinessObjectID(obj.EXAMFORMCODE)));
                busExamform.CloseConnection();
                if (objExamform == null)
                {
                    ret = -2;
                }
            }
            //Danh sachs cau truc
            EXAMFORMDETAIL_BUS        busExamformdetail = new EXAMFORMDETAIL_BUS();
            List <EXAMFORMDETAIL_OBJ> liExamformdetail  = new List <EXAMFORMDETAIL_OBJ>();

            if (ret >= 0)
            {
                if (objExamform != null)
                {
                    liExamformdetail = busExamformdetail.getAllBy2("THEORDER", new fieldpara("EXAMFORMCODE", objExamform.CODE));
                }
                busExamformdetail.CloseConnection();
                if (liExamformdetail == null)
                {
                    ret = -3;
                }
            }
            List <fieldpara> lipa   = new List <fieldpara>();
            List <jointable> lijoin = new List <jointable>();
            //Lay danh sach cac nhom cau hoi
            QUESTIONGROUP_BUS        busQuestiongroup = new QUESTIONGROUP_BUS();
            List <QUESTIONGROUP_OBJ> liQuestiongroup  = new List <QUESTIONGROUP_OBJ>();

            if (ret >= 0)
            {
                if (objExamform != null)
                {
                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "CODE", "QUESTIONGROUPCODE", new fieldpara("EXAMFORMCODE", objExamform.CODE)));
                }
                liQuestiongroup = busQuestiongroup.getAllBy2("CODE", lipa, lijoin);
                if (liQuestiongroup == null)
                {
                    ret = -4;
                }
                busQuestiongroup.CloseConnection();
            }
            //Lay danh sach cau hoi
            QUESTION_BUS        busQuestion = new QUESTION_BUS();
            List <QUESTION_OBJ> liQuestion  = new List <QUESTION_OBJ>();

            if (ret >= 0)
            {
                lijoin.Clear();
                if (objExamform != null)
                {
                    lijoin.Add(new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE", "QUESTIONGROUPCODE",
                                             new fieldpara("examformcode", objExamform.CODE)));
                }

                liQuestion = busQuestion.getAllBy2("CODE", lipa, lijoin);

                if (liQuestion == null)
                {
                    ret = -5;
                }
                else
                {
                    numberQuestion = liQuestion.Count;
                }
                busQuestion.CloseConnection();
            }
            //Lay danh danh cac dap an
            ANSWER_BUS        busAnswer = new ANSWER_BUS();
            List <ANSWER_OBJ> liAnswer  = new List <ANSWER_OBJ>();

            if (ret >= 0)
            {
                lijoin.Clear();
                if (objExamform != null)
                {
                    lijoin.Add((new jointable(typeof(EXAMFORMDETAIL_OBJ), "QUESTIONGROUPCODE", "QUESTIONGROUPCODE", new fieldpara("examformcode", objExamform.CODE))));
                }
                liAnswer = busAnswer.getAllBy2("CODE", lipa, lijoin);
                if (liAnswer == null)
                {
                    ret = -6;
                }
                busAnswer.CloseConnection();
            }

            var jsonResult = Json(new
            {
                numberQuestion,                        //so luong cau hoi
                ObjexamHallstudent = obj,              //examhallstudent code
                ObjexamForm        = objExamform,      //examform
                liExamformDetail   = liExamformdetail, //Danh sách   examdetail
                liQuestiongroup,
                li_question = liQuestion,
                li_answer   = liAnswer,
                ret//ok
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }