Exemplo n.º 1
0
        /// <summary>
        /// Lấy về danh sách và phần tử ở đầu
        /// </summary>
        /// <param name="groupcode"></param>
        /// <returns></returns>
        public JsonResult GetQuestion(string groupcode)
        {
            var ret = 0;
            //Khai báo lấy dữ liệu
            QUESTION_BUS     bus  = new QUESTION_BUS();
            List <fieldpara> lipa = new List <fieldpara>
            {
                new fieldpara("QUESTIONGROUPCODE", groupcode, 0)
            };
            //order by theorder, with pagesize and the page
            List <QUESTION_OBJ> data          = bus.getAllBy2("CODEVIEW", lipa.ToArray());
            QUESTION_OBJ        firstquestion = null;

            if (data.Count > 0)
            {
                firstquestion = data[0];
            }
            bus.CloseConnection();
            //Chỉ số đầu tiên của trang hiện tại (đã trừ -1)

            var jsonResult = Json(new
            {
                firstquestion,
                data, //Danh sách
                ret   //ok
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 2
0
        public JsonResult CheckCodeViewExitQuestion(string questiongroup, string code, string codeView)
        {
            int          ret;
            QUESTION_BUS bus = new QUESTION_BUS();
            QUESTION_OBJ obj;

            if (!string.IsNullOrEmpty(code))
            {
                //check for update
                obj = bus.GetByKey(new fieldpara("CODEVIEW", codeView, 0),
                                   new fieldpara("QUESTIONGROUPCODE", questiongroup, 0),
                                   new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));

                if (obj == null)
                {
                    //change codeview
                    ret = 1;
                }
                else
                {
                    //change other feature,not codeview
                    ret = code == obj.CODE ? 1 : -1;
                }
            }
            else
            {
                obj = bus.GetByKey(new fieldpara("CODEVIEW", codeView, 0),
                                   new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));
                ret = obj == null ? 1 : -1;
            }
            bus.CloseConnection();
            return(Json(new { sussess = ret }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public JsonResult DeleteQuestion(List <string> code)
        {
            if (code != null)
            {
                var bus       = new QUESTION_BUS();
                var busAnswer = new ANSWER_BUS();
                foreach (string t in code)
                {
                    var item = bus.GetByID(new QUESTION_OBJ.BusinessObjectID(t));

                    List <ANSWER_OBJ> lianswer = busAnswer.getAllBy(new fieldpara("QUESTIONCODE", t));

                    foreach (var itemAnswer in lianswer)
                    {
                        busAnswer.delete(itemAnswer._ID);
                    }

                    if (t != null)
                    {
                        bus.delete(item._ID);
                    }
                }
                busAnswer.CloseConnection();
                bus.CloseConnection();
            }

            return(Json(new
            {
                ret = 0
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public JsonResult GetListQuestion(string groupcode, int page, int pageSize)
        {
            var ret = -1;

            //mặc định cho phần trang
            if (pageSize == 0)
            {
                pageSize = AppConfig.item4page();
            }
            if (page < 1)
            {
                page = 1;
            }
            //Khai báo lấy dữ liệu
            QUESTION_BUS     bus  = new QUESTION_BUS();
            List <fieldpara> lipa = new List <fieldpara>
            {
                new fieldpara("QUESTIONGROUPCODE", groupcode, 0)
            };
            int countpage;
            //order by theorder, with pagesize and the page
            List <QUESTION_OBJ> data = bus.getAllBy2("CODEVIEW", pageSize, page, out countpage, lipa.ToArray());
            // tất cả các bản ghi
            List <QUESTION_OBJ> totalData = bus.getAllBy2("CODEVIEW", lipa.ToArray());

            int totalItem = totalData.Count;

            bus.CloseConnection();
            //Chỉ số đầu tiên của trang hiện tại (đã trừ -1)
            int startpage = (page - 1) * pageSize;
            //Trả về client
            var    a             = JsonConvert.SerializeObject(data);
            string firstquestion = "";

            if (data.Count != 0)
            {
                firstquestion = JsonConvert.SerializeObject(data[0]);
            }
            if (totalItem > 0)
            {
                ret = 1;
            }
            var jsonResult = Json(new
            {
                firstquestion,
                data,                   //Danh sách
                data2 = a,
                totalItem,              //số lượng bản ghi
                totalPage  = countpage,
                startindex = startpage, //bắt đầu số trang
                ret                     //ok
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 5
0
        /// <summary>
        /// lấy chi tiết câu hỏi, câu trả lời theo nhóm câu hỏi
        /// </summary>
        /// <param name="questiongroupcode">mã nhóm câu hỏi</param>
        /// <returns></returns>
        public JsonResult GetById(string questiongroupcode)
        {
            var ret                        = 0;
            var numberQuestion             = 0;
            List <QUESTION_OBJ> liQuestion = new List <QUESTION_OBJ>();
            List <ANSWER_OBJ>   liAnswer   = new List <ANSWER_OBJ>();
            QUESTIONGROUP_BUS   bus        = new QUESTIONGROUP_BUS();
            var obj                        = bus.GetByID(new QUESTIONGROUP_OBJ.BusinessObjectID(questiongroupcode));

            if (obj != null)
            {
                // lấy danh sách câu hỏi tương ứng
                QUESTION_BUS questionBus = new QUESTION_BUS();
                liQuestion = questionBus.getAllBy2("CODE",
                                                   new fieldpara("QUESTIONGROUPCODE", questiongroupcode, 0));
                if (liQuestion != null)
                {
                    // lấy danh sách câu trả lời
                    ANSWER_BUS answerBus = new ANSWER_BUS();
                    liAnswer = answerBus.getAllBy2("CODE",
                                                   new fieldpara("QUESTIONGROUPCODE", questiongroupcode, 0));
                    if (liAnswer == null)
                    {
                        ret = -3;
                    }
                    answerBus.CloseConnection();
                }
                else
                {
                    ret = -2;
                }
                if (liQuestion != null)
                {
                    numberQuestion = liQuestion.Count;
                }
                questionBus.CloseConnection();
            }
            else
            {
                ret = -1;
            }

            bus.CloseConnection();
            var jsonResult = Json(new
            {
                numberQuestion,                  //so luong cau hoi
                ObjexamHallstudent = obj,        //examhallstudent code
                liQuestiongroup    = obj,        //danh sach nhom cau hoi
                li_question        = liQuestion, //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.º 6
0
        /// <summary>
        /// xóa danh sách các answer và question  mà trong đó các questiongroup được trả về để GetQuestionxóa,không cần thông báo, nếu có con thì không cho xóa, còn nếu không có thì xóa nó đi,thanks
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public JsonResult DeleteQgroup(List <string> code)
        {
            int ans = -1;

            if (code != null)
            {
                var bus = new QUESTIONGROUP_BUS();
                foreach (string t in code)
                {
                    var ret = 0;
                    if (t != null)
                    {
                        var item = bus.GetByID(new QUESTIONGROUP_OBJ.BusinessObjectID(t));
                        if (item == null)
                        {
                            continue;
                        }
                        if (ret >= 0)
                        {
                            QUESTION_BUS busQuestion = new QUESTION_BUS();
                            //check children
                            ret = busQuestion.checkCode(null, new fieldpara("QUESTIONGROUPCODE", t));
                            busQuestion.CloseConnection();
                            //check children
                            if (ret > 0)
                            {
                                ANSWER_BUS busAnswer = new ANSWER_BUS();
                                ret = busAnswer.checkCode(null, new fieldpara("QUESTIONGROUPCODE", t));
                                busAnswer.CloseConnection();
                            }
                            //exist children
                            if (ret != 0)
                            {
                                ret = -1;
                            }
                        }
                        if (ret == 0)
                        {
                            ans = 1;
                            bus.delete(item._ID);
                        }
                    }
                }
                bus.CloseConnection();
            }
            return(Json(new
            {
                ret = ans
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public JsonResult ListQuestionExam(string groupcode)
        {
            QUESTION_BUS     bus  = new QUESTION_BUS();
            List <fieldpara> lipa = new List <fieldpara>
            {
                new fieldpara("QUESTIONGROUPCODE", groupcode, 0)
            };
            //order by theorder, with pagesize and the page
            List <QUESTION_OBJ> data = bus.getAllBy("CODEVIEW", lipa.ToArray());
            // tất cả các bản ghi
            List <QUESTION_OBJ> totalData = bus.getAllBy2("CODEVIEW", lipa.ToArray());

            int totalItem = totalData.Count;

            bus.CloseConnection();
            //Chỉ số đầu tiên của trang hiện tại (đã trừ -1)

            //Trả về client
            var    a             = JsonConvert.SerializeObject(data);
            string firstquestion = "";

            if (data.Count != 0)
            {
                firstquestion = JsonConvert.SerializeObject(data[0]);
            }
            var jsonResult = Json(new
            {
                firstquestion,
                data,      //Danh sách
                data2 = a,
                totalItem, //số lượng bản ghi
                ret = 0    //ok
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 8
0
        public JsonResult UpdateQuestionF(QUESTION_OBJ obj, string questiontypeCodeView, string contentAnswer)
        {
            QUESTION_BUS bus = new QUESTION_BUS();
            int          ret;
            int          add       = 0;
            ANSWER_BUS   busAnswer = new ANSWER_BUS();
            ANSWER_OBJ   objAnswer = new ANSWER_OBJ();
            //kiểm tra tồn tại cho trường hợp sửa
            var objTemp = !string.IsNullOrEmpty(obj.CODE) ? bus.GetByID(new QUESTION_OBJ.BusinessObjectID(obj.CODE)) : new QUESTION_OBJ();

            //hết kiểm tra tồn tại bản ghi
            objTemp.CODEVIEW          = obj.CODEVIEW;
            objTemp.NAME              = obj.NAME;
            objTemp.CONTENTIMG        = obj.CONTENTIMG;
            objTemp.MARK              = obj.MARK;
            objTemp.ORD               = obj.ORD;
            objTemp.LOCK              = obj.LOCK;
            objTemp.CONTENT           = obj.CONTENT;
            objTemp.QUESTIONGROUPCODE = obj.QUESTIONGROUPCODE;
            objTemp.ANSWERCODE        = obj.ANSWERCODE;
            //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);
                objAnswer.CODE     = busAnswer.genNextCode(objAnswer);
                objTemp.ANSWERCODE = objAnswer.CODE;
            }
            if (add == 1)
            {
                ret = bus.insert(objTemp);
                //chỉ cần thêm mới chứ không cần cập nhật answer
                if (ret >= 0)
                {
                    objAnswer.QUESTIONCODE      = objTemp.CODE;
                    objAnswer.QUESTIONGROUPCODE = obj.QUESTIONGROUPCODE;
                    objAnswer.CODEVIEW          = "1";
                    objAnswer.THEORDER          = 1;
                    objAnswer.NAME       = objTemp.NAME;
                    objAnswer.CONTENT    = contentAnswer;
                    objAnswer.TRUEANSWER = 1;
                    ret = busAnswer.insert(objAnswer);
                }
            }
            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);
            }

            bus.CloseConnection();
            busAnswer.CloseConnection();
            return(Json(new
            {
                code = objTemp.CODE,
                ret
            },
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        public JsonResult UpdateQuestion(QUESTION_OBJ obj, string typeQuestion)
        {
            int ret = 0;

            int          add = 0;
            QUESTION_OBJ objTemp;
            string       codeAnswer = "";
            QUESTION_BUS bus        = new QUESTION_BUS();
            ANSWER_BUS   ansbus     = new ANSWER_BUS();

            if (!string.IsNullOrEmpty(obj.CODE)) //edit
            {
                objTemp = bus.GetByID(new QUESTION_OBJ.BusinessObjectID(obj.CODE));
                if (typeQuestion == "CO")
                {
                    List <ANSWER_OBJ> libegin = ansbus.getAllBy2(" CODE ", new fieldpara("QUESTIONCODE", obj.CODE, 0)
                                                                 , new fieldpara("QUESTIONGROUPCODE", obj.QUESTIONGROUPCODE, 0));
                    if (obj.ANSWERCODE != null)
                    {
                        foreach (ANSWER_OBJ item in libegin)
                        {
                            if (item.CODEVIEW.Split('_')[1] == obj.ANSWERCODE)
                            {
                                codeAnswer      = item.CODE;
                                item.TRUEANSWER = 1;
                                item._ID.CODE   = item.CODE;
                                ret             = ansbus.update(item);
                            }
                            else
                            {
                                item.TRUEANSWER = 0;
                                item._ID.CODE   = item.CODE;
                                ret             = ansbus.update(item);
                            }
                        }
                    }
                }
            }
            else //add
            {
                objTemp = new QUESTION_OBJ();
            }
            if (ret < 0)
            {
                //đóng kết nối trước khi trả về
                bus.CloseConnection();
                //ban ghi sửa đã bị xóa
                return(Json(new { ret }, JsonRequestBehavior.AllowGet));
            }
            //hết kiểm tra tồn tại bản ghi
            objTemp.CODEVIEW          = obj.CODEVIEW;
            objTemp.NAME              = obj.NAME;
            objTemp.CONTENTIMG        = obj.CONTENTIMG;
            objTemp.MARK              = obj.MARK;
            objTemp.ORD               = obj.ORD;
            objTemp.LOCK              = obj.LOCK;
            objTemp.CONTENT           = obj.CONTENT;
            objTemp.QUESTIONGROUPCODE = obj.QUESTIONGROUPCODE;
            //trong trường hợp là câu hỏi dạng CO thì cập nhật lại answercode bằng codeanswer không thì sẽ làm như bình thường objTemp.Answercode= obj.Answercode
            objTemp.ANSWERCODE = typeQuestion == "CO" ? codeAnswer : obj.ANSWERCODE;

            //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);
                if (typeQuestion == "CO")
                {
                    ANSWER_OBJ        objAnser          = new ANSWER_OBJ();
                    ANSWER_BUS        busAnswer         = new ANSWER_BUS();
                    string            answerCode        = busAnswer.genNextCode(objAnser);
                    List <ANSWER_OBJ> listAnswer        = new List <ANSWER_OBJ>();
                    List <string>     listContentAnswer = new List <string> {
                        "TRUE", "FALSE", "NOT GIVEN"
                    };
                    //Tự động sinh ra câu hỏi và là 3 đáp án true, false,
                    //Tự động sinh ra câu tra lời
                    for (int i = 0; i < listContentAnswer.Count; i++)
                    {
                        ANSWER_OBJ answer = new ANSWER_OBJ
                        {
                            CODE = answerCode
                        };
                        answerCode               = busAnswer.GenNextCode(answer, answerCode);
                        answer.QUESTIONCODE      = objTemp.CODE;
                        answer.QUESTIONGROUPCODE = obj.QUESTIONGROUPCODE;
                        answer.CODEVIEW          = "CO_" + i;
                        answer.THEORDER          = i + 1;
                        answer.NAME              = "CO" + (i + 1);
                        answer.CONTENT           = listContentAnswer[i];
                        if (int.Parse(obj.ANSWERCODE) == i)
                        {
                            objTemp.ANSWERCODE = answerCode;
                            answer.TRUEANSWER  = 1;
                        }
                        else
                        {
                            answer.TRUEANSWER = 0;
                        }

                        listAnswer.Add(answer);
                    }
                    busAnswer.BeginTransaction();
                    ret = busAnswer.InsertMultiItems(listAnswer);
                    if (ret < 0)
                    {
                        busAnswer.RollbackTransaction();
                    }
                    else
                    {
                        busAnswer.CommitTransaction();
                    }
                    busAnswer.CloseConnection();
                }
            }
            if (add == 1 && ret >= 0)
            {
                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);
            }
            bus.CloseConnection();
            ansbus.CloseConnection();

            return(Json(new
            {
                ret
            },
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
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.º 11
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.º 12
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.º 13
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);
        }