Exemplo n.º 1
0
 /// <summary>
 ///     填空题保存
 /// </summary>
 public int SubmitFillblankQuestion(int qID, tbQuestion question)
 {
     try
     {
         question.QuestionContent =
             Request.Form["hiddenQuestionContent"].Replace("(", "(")
             .Replace("(", "(")
             .Replace("(", "(")
             .Replace(")", ")")
             .Replace(")", ")")
             .Replace(")", ")");                                      //转换成英文括号,用于识别
         question.QuestionAnswer.Add(new QuestionAnswer
         {
             Answer     = Request.Form["txtQuestionAnswer"],
             AnswerFlag = 1,
             AnswerType = 1,
             Order      = 1
         });
         return(qID > 0 ? EQuestionBL.ModifyByID(question) : EQuestionBL.Insert(question));
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 问题编辑页面呈现
        /// 在编辑试卷时调用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="sortID"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public ActionResult AddQuestionToExampaper(int id = 0, int sortID = 0, int flag = 0)
        {
            Response.Expires = 0;
            tbQuestion qu;

            if (id > 0)
            {
                qu = EQuestionBL.GetSingleByID(id);
                ViewBag.fatherModel = ESortBL.GetAllQuestionSortDictionary(CurrentTenant.TenantId)[qu.QuestionSortID].Title;
            }
            else
            {
                qu = new tbQuestion();
                ViewBag.fatherModel = sortID == 0 ? CurrentTenant.TenantName : ESortBL.GetAllQuestionSortDictionary(CurrentTenant.TenantId)[sortID].Title;
            }
            ViewBag.id         = id;
            ViewBag.baseInfor  = qu;
            ViewBag.sortID     = sortID == 0 ? qu.QuestionSortID : sortID;
            ViewBag.backSortID = sortID;

            ViewBag.backUrl = Url.RetechAction("QuestionList", "Question");
            if (flag == 1)
            {
                ViewBag.backUrl = Url.RetechAction("QuestionManage", "Question");
            }
            else if (flag == 2)
            {
                ViewBag.backUrl = Url.RetechAction("ExampaperList", "Exampaper");
            }
            ViewBag.flag = flag;
            return(View());
        }
Exemplo n.º 3
0
        /// <summary>
        ///     问题编辑页面呈现
        /// </summary>
        public ActionResult QuestionEdit()
        {
            Response.Expires = 0;
            int id = Convert.ToInt32(Request.QueryString["id"]);

            if (id > 0)
            {
                tbQuestion qu = EQuestionBL.GetSingleByID(id);
                ViewData["BaseInfor"]   = qu;
                ViewData["fatherModel"] = ESortBL.GetAllQuestionSortDictionary()[qu.QuestionSortID].Title;
            }
            else
            {
                ViewData["BaseInfor"] = new tbQuestion();
                if (Request.QueryString["sortID"] != null)
                {
                    ViewData["fatherModel"] = Request.QueryString["sortID"] == "0"
                                                  ? "无"
                                                  : ESortBL.GetAllQuestionSortDictionary()[
                        Convert.ToInt32(Request.QueryString["sortID"])].Title;
                }
                else
                {
                    ViewData["fatherModel"] = "无";
                }
            }
            return(View());
        }
Exemplo n.º 4
0
 /// <summary>
 ///     多选题保存
 /// </summary>
 public int SubmitMultipeQuestion(int qID, tbQuestion question)
 {
     try
     {
         question.QuestionContent = Request.Form["hiddenQuestionContent"];
         string questionAnswer = Request.Form["hiddenQuestionAnswer"];
         if (questionAnswer != "")
         {
             int count = 1;
             foreach (
                 var qa in
                 questionAnswer.Split(new[] { "!!%!%!%!!" }, StringSplitOptions.RemoveEmptyEntries)
                 .Select(
                     quAnswer =>
                     quAnswer.Split(new[] { "***!!***" }, StringSplitOptions.RemoveEmptyEntries))
                 )
             {
                 question.QuestionAnswer.Add(new QuestionAnswer
                 {
                     Answer     = qa[0],
                     AnswerFlag = Convert.ToInt32(qa[1]),
                     AnswerType = 3,
                     Order      = count
                 });
                 count++;
             }
         }
         return(qID > 0 ? EQuestionBL.ModifyByID(question) : EQuestionBL.Insert(question));
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///     判断附件的状态
        /// </summary>
        private tbQuestion UpdateQuestionFiles(tbQuestion qu, IEnumerable <FileUpload> files)
        {
            List <string> noUpdateFile = Request.Form["noUpdateFile"] == ""
                                            ? new List <string>()
                                            : Request.Form["noUpdateFile"].Split(';').ToList();
            List <FileUpload> newfiles = qu.FileUpload.Where(file => noUpdateFile.Contains(file.FileName)).ToList();

            foreach (FileUpload f in files.Where(f => newfiles.All(p => p.FileName != f.FileName)))
            {
                newfiles.Add(f);
            }
            qu.FileUpload = newfiles;
            return(qu);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     添加多个题库
        /// </summary>
        public JsonResult GetQuestion()
        {
            string id        = Request.QueryString["id"];
            var    itemArray = new List <tbQuestion>();

            string[] idlist = id.Split(',');
            //获取题库信息
            for (int i = 0; i < idlist.Length - 1; i++)
            {
                tbQuestion QuestionInfor = qBL.GetSingleByID(Convert.ToInt32(idlist[i]));
                QuestionInfor.QuestionContent = QuestionInfor.QuestionContent;
                itemArray.Add(QuestionInfor);
            }
            return(Json(itemArray, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        /// <summary>
        ///     问答题编辑页面呈现
        /// </summary>
        public ActionResult QuestionSubjectEdit()
        {
            Response.Expires = 0;
            int id = Convert.ToInt32(Request.QueryString["id"]);

            if (id > 0)
            {
                tbQuestion qu = EQuestionBL.GetSingleByID(id);
                ViewData["BaseInfor"]     = qu;
                ViewData["QuestionInfor"] = qu.QuestionAnswer.OrderBy(p => p.Order).ToList();
            }
            else
            {
                ViewData["BaseInfor"]     = new tbQuestion();
                ViewData["QuestionInfor"] = new List <QuestionAnswer>();
            }
            return(View());
        }
Exemplo n.º 8
0
 public int SubmitSubjectQuestion(int qID, tbQuestion question)
 {
     try
     {
         question.QuestionContent = Request.Form["hiddenQuestionContent"];
         question.QuestionAnswer.Add(new QuestionAnswer
         {
             Answer     = Request.Form["txtQuestionAnswer"],
             AnswerFlag = 1,
             AnswerType = 1,
             Order      = 1
         });
         return(qID > 0 ? EQuestionBL.ModifyByID(question) : EQuestionBL.Insert(question));
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        ///     导入试题
        /// </summary>
        /// <param name="sortID">分类ID</param>
        /// <param name="ds">试题DataSet</param>
        /// <param name="message">错误信息</param>
        /// <param name="count">错误数目</param>
        /// <param name="totalCount">导入的总题数</param>
        /// <returns></returns>
        public List <MQuestionShow> ImportQuestion(int sortID, int key, DataTable dt, ref string message, ref int count,
                                                   ref int totalCount)
        {
            var newlist      = new List <MQuestionShow>();
            var questionList = new List <tbQuestion>();
            var question     = new tbQuestion();
            var rowList      = new List <int>();
            int rowCount     = 0; //记录行号
            Dictionary <int, tbQuestionSort> dicsort = ESortBL.GetAllQuestionSortDictionary();

            foreach (DataRow dr in dt.Rows)
            {
                rowCount++;
                //如果是空行跳过
                //if (dr[1].ToString() == "")
                //{
                //    message += message == "" ? (rowCount + 1).ToString() : ("、" + (rowCount + 1).ToString());
                //    continue;
                //}
                //为空的时候是答案
                if (dr[3].ToString() == string.Empty && dr[1].ToString() != "")
                {
                    if (question.QuestionType > 0)
                    {
                        questionList[questionList.Count - 1].QuestionAnswer.Add(new QuestionAnswer
                        {
                            Answer =
                                (question.QuestionType == 4
                                         ? (dr[1].ToString() == "正确" ? "0" : "1")
                                         : dr[1].ToString().Trim()),
                            AnswerFlag = dr[2].ToString() == "是" ? 1 : 0,
                        });
                    }
                }
                //保存试题,初始化model
                else
                {
                    if ((dr[3].ToString() == "问答题" || dr[3].ToString() == "填空题") && dr[6].ToString() == "")
                    {
                        message += message == "" ? (rowCount + 1).ToString() : ("、" + (rowCount + 1).ToString());
                    }
                    else
                    {
                        if (dr[1].ToString() != "" && dr[3].ToString() != "" && dr[4].ToString() != "")
                        {
                            question = new tbQuestion
                            {
                                QuestionAnswer     = new List <QuestionAnswer>(),
                                QuestionKey        = key,
                                QuestionAnswerKeys = dr[6].ToString(),
                                QuestionAnalysis   = dr[5].ToString(),
                                QuestionContent    =
                                    dr[1].ToString()
                                    .Replace("(", "(")
                                    .Replace("(", "(")
                                    .Replace("(", "(")
                                    .Replace(")", ")")
                                    .Replace(")", ")")
                                    .Replace(")", ")"),
                                QuestionLevel =
                                    (int)((QuestionLevel)Enum.Parse(typeof(QuestionLevel), dr[4].ToString())),
                                QuestionType =
                                    (int)((QuestionType)Enum.Parse(typeof(QuestionType), dr[3].ToString())),
                                Status         = 0,
                                LastUpdateTime = DateTime.Now,
                                CreateTime     = DateTime.Now,
                                QuestionSortID = sortID,
                                UserID         = CurrentUser.UserId,
                                FileUpload     = new List <FileUpload>(),
                            };
                            questionList.Add(question);
                            rowList.Add(rowCount + 1);
                        }
                        else
                        {
                            message += message == "" ? (rowCount + 1).ToString() : ("、" + (rowCount + 1).ToString());
                        }
                    }
                }
            }

            int quCount = 0;

            foreach (tbQuestion qu in questionList)
            {
                quCount++;
                int qID = 0;
                if ((qu.QuestionType == 1 && qu.QuestionAnswer.Count == 1) //问答
                    ||
                    (qu.QuestionType == 2 && qu.QuestionAnswer.Count > 1 && qu.QuestionAnswer.Count < 27 &&
                     qu.QuestionAnswer.Where(p => p.AnswerFlag == 1).Count() == 1) //单选
                    ||
                    (qu.QuestionType == 3 && qu.QuestionAnswer.Count > 1 && qu.QuestionAnswer.Count < 27 &&
                     qu.QuestionAnswer.Where(p => p.AnswerFlag == 1).Count() > 0) //多选
                    ||
                    (qu.QuestionType == 4 && qu.QuestionAnswer.Count == 2 &&
                     qu.QuestionAnswer.Where(p => p.AnswerFlag == 1).Count() == 1) //判断
                    )
                {
                    int c = 0;
                    qu.QuestionAnswer.ForEach(pz =>
                    {
                        pz.Order = ++c;
                    });
                    qID = EQuestionBL.Insert(qu);
                    var newQu = new MQuestionShow();
                    newQu.FileUpload      = new List <FileUpload>();
                    newQu.QuestionAnswer  = qu.QuestionAnswer;
                    newQu.QuestionContent = qu.QuestionContent;
                    newQu.id = qu._id;
                    newQu.QuestionLevelStr = ((QuestionLevel)qu.QuestionLevel).ToString();
                    newQu.QuestionTypeStr  = ((QuestionType)qu.QuestionType).ToString();
                    newQu.QuestionType     = qu.QuestionType;
                    newQu.QuestionLevel    = qu.QuestionLevel;
                    newQu.SortName         = dicsort[sortID].Title;
                    newlist.Add(newQu);
                }
                else if (qu.QuestionType == 5)
                {
                    //判断()的个数和答案数是否一致,
                    var answerNumber = qu.QuestionContent.Split(new[] { "()" }, StringSplitOptions.None).Length - 1;
                    if (qu.QuestionAnswer.Count == answerNumber)
                    {
                        //关键词的个数是否一样
                        if (qu.QuestionAnswerKeys.Split(' ').Length == answerNumber)
                        {
                            string anStr = "";
                            qu.QuestionAnswer.ForEach(p =>
                            {
                                anStr += anStr == "" ? p.Answer : ("!!%%!!" + p.Answer);
                            });
                            var answer = new QuestionAnswer
                            {
                                Answer     = anStr,
                                AnswerFlag = qu.QuestionAnswer[0].AnswerFlag
                            };
                            var list = new List <QuestionAnswer>();
                            list.Add(answer);
                            qu.QuestionAnswer = list;
                            qID = EQuestionBL.Insert(qu);
                            var newQu = new MQuestionShow();
                            newQu.FileUpload      = new List <FileUpload>();
                            newQu.QuestionAnswer  = qu.QuestionAnswer;
                            newQu.QuestionContent = qu.QuestionContent;
                            newQu.id = qu._id;
                            newQu.QuestionLevelStr = ((QuestionLevel)qu.QuestionLevel).ToString();
                            newQu.QuestionTypeStr  = ((QuestionType)qu.QuestionType).ToString();
                            newQu.QuestionType     = qu.QuestionType;
                            newQu.QuestionLevel    = qu.QuestionLevel;
                            newQu.SortName         = dicsort[sortID].Title;
                            newQu.Creater          = CurrentUser.Realname;
                            newlist.Add(newQu);
                        }
                        else
                        {
                            count++;
                            message += message == ""
                                           ? ((rowList[quCount - 1]).ToString())
                                           : ("、" + (rowList[quCount - 1]).ToString());
                        }
                    }
                    else
                    {
                        count++;
                        message += message == ""
                                       ? ((rowList[quCount - 1] + 1).ToString())
                                       : ("、" + (rowList[quCount - 1] + 1).ToString());
                    }
                }
                else
                {
                    count++;
                    message += message == ""
                                   ? ((rowList[quCount - 1] + 1).ToString())
                                   : ("、" + (rowList[quCount - 1] + 1).ToString());
                }

                totalCount++;
            }
            return(newlist);
        }
Exemplo n.º 10
0
        public JsonResult SubmitQuestion()
        {
            string content = Request.Form["hiddenQuestionContent"].NoHtml();

            if (content.Replace("&nbsp;", "").Trim() == "")
            {
                return(Json(new
                {
                    result = 0,
                    content = RetechWing.LanguageResources.Exam.Question.message16,
                }, "text/html", JsonRequestBehavior.AllowGet));
                //return Json(new
                //{
                //    result = 0,
                //    content = RetechWing.LanguageResources.Exam.Question.message16,
                //}, JsonRequestBehavior.AllowGet);
            }

            //ID
            int id = Convert.ToInt32(Request.Params["id"]);
            //类型
            int  qType    = Convert.ToInt32(Request.Form["hiddenSelQuestionType"]);
            int  newid    = 0;
            bool flag     = true;
            int  fileType = Convert.ToInt32(Request.Params["type"]); //0:图片,1:音频,2:视频

            if (qType == 6)
            {
                HttpFileCollectionBase files = Request.Files;
                for (int i = 0; i < files.Count; i++)
                {
                    if (((fileType != 0 && files[i].ContentLength > 8388608) ||
                         (fileType == 0 && files[i].ContentLength > 512000)) && flag)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            int questionType = Convert.ToInt32(Request.Form["hiddenSelQuestionType"]);

            if (flag)
            {
                List <FileUpload> listfileUpload = qType == 6 ? FileUpload(fileType) : new List <FileUpload>();
                tbQuestion        question       = id > 0
                                          ? EQuestionBL.GetSingleByID(id)
                                          : new tbQuestion
                {
                    Status         = 0,
                    LastUpdateTime = DateTime.Now,
                    _id            = id,
                    UserID         = CurrentUser.UserId,
                    FileUpload     = listfileUpload,
                    CreateTime     = DateTime.Now,
                    TenantId       = CurrentTenant.TenantId
                };
                if (question.TenantId != CurrentTenant.TenantId)
                {
                    return(Json(new
                    {
                        result = -1,
                        content = RetechWing.LanguageResources.Exam.Question.message17,
                    }, "text/html", JsonRequestBehavior.AllowGet));
                }
                question.QuestionAnswerKeys = Request.Form["txtQuestionAnswerKeys"] ?? "";
                question.QuestionLevel      = Convert.ToInt32(Request.Form["hiddenSelQuestionLevel"]);
                question.QuestionSortID     = Convert.ToInt32(Request.Form["hiddenSelQuestionSort"]);
                question.QuestionOpen       = Convert.ToInt32(Request.Form["hiddenQuestionOpen"]);
                question.QuestionAvailable  = Convert.ToInt32(Request.Form["hiddenQuestionAvailable"]);
                question.QuestionType       = questionType;
                question.QuestionAnalysis   = Request.Form["txtQuestionAnalysis"] ?? "";
                question.QuestionKey        = Request.Form["hiddenSelQuestionKey"].GetInt32();
                question.QuestionAnswer     = new List <QuestionAnswer>();
                question.LastUpdateTime     = DateTime.Now;

                if (qType == 6)
                {
                    question = UpdateQuestionFiles(question, listfileUpload);
                }

                switch (qType)
                {
                case 1:     //主观题
                    newid = SubmitSubjectQuestion(id, question);
                    break;

                case 2:     //单选题
                    newid = SubmitSingleQuestion(id, question);
                    break;

                case 3:     //多选题
                    newid = SubmitMultipeQuestion(id, question);
                    break;

                case 4:     //判断题
                    newid = SubmitJudgeQuestion(id, question);
                    break;

                case 5:     //填空题
                    newid = SubmitFillblankQuestion(id, question);
                    break;

                case 6:     //多媒体
                    newid = SubmitMultimediaQuestion(id, question);
                    break;
                }

                if (newid > 0)
                {
                    return(Json(new
                    {
                        result = 1,
                        questionID = newid,
                        content = RetechWing.LanguageResources.Common.SaveSuccess,
                    }, "text/html", JsonRequestBehavior.AllowGet));
                }
                return(Json(new
                {
                    result = 0,
                    content = RetechWing.LanguageResources.Common.SaveFailed,
                    url = ""
                }, "text/html", JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                result = -1,
                content = RetechWing.LanguageResources.Exam.Question.message18,
            }, "text/html", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        /// <summary>
        ///     根据 考生考试关联ID 获取考生答题详情
        /// </summary>
        /// <returns></returns>
        public JsonResult GetReStudentExamAnswerByExamUserId(int examUserId)
        {
            tbExamSendStudent examSendStudent = _examinationBL.GetExamSendStudent(examUserId);
            ExamBaseInforShow exam            = _examTestBL.GetExamBaseInforShow(examUserId);
            tbExampaper       examPaper       = _exampaperBL.GetExampaper(examSendStudent.ExamPaperID);
            var itemArray = new object[examSendStudent.StudentAnswerList.Count];
            int n         = 0;

            string questionTypeHtml = "";
            int    q1Count          = examSendStudent.StudentAnswerList.Count(q => q.QType == 1);
            int    q2Count          = examSendStudent.StudentAnswerList.Count(q => q.QType == 2);
            int    q3Count          = examSendStudent.StudentAnswerList.Count(q => q.QType == 3);
            int    q4Count          = examSendStudent.StudentAnswerList.Count(q => q.QType == 4);
            int    q5Count          = examSendStudent.StudentAnswerList.Count(q => q.QType == 5);
            int    q6Count          = examSendStudent.StudentAnswerList.Count(q => q.QType == 6);

            questionTypeHtml += q1Count > 0 ? "<span>问答题 ( " + q1Count + " )</span>" : "";
            questionTypeHtml += q2Count > 0 ? "<span>单选题 ( " + q2Count + " )</span>" : "";
            questionTypeHtml += q3Count > 0 ? "<span>多选题 ( " + q3Count + " )</span>" : "";
            questionTypeHtml += q4Count > 0 ? "<span>判断题 ( " + q4Count + " )</span>" : "";
            questionTypeHtml += q5Count > 0 ? "<span>填空题 ( " + q5Count + " )</span>" : "";
            questionTypeHtml += q6Count > 0 ? "<span>多媒体题 ( " + q6Count + " )</span>" : "";

            string answerCaseHtml = "";

            answerCaseHtml += "<span>答错: " + examSendStudent.StudentAnswerList.Count(p => p.GetScore == 0 && p.Answer != "") + "</span>";
            answerCaseHtml += "<span>未答: " + examSendStudent.StudentAnswerList.Count(p => p.Answer == "") + "</span>";
            answerCaseHtml += "<span>正确: " + examSendStudent.StudentAnswerList.Count(p => p.GetScore > 0) + "</span>";
            int totalScore = 0;

            foreach (ReStudentExamAnswer item in examSendStudent.StudentAnswerList)
            {
                //根据Qid 查Question表
                tbQuestion question        = _questionBL.GetSingleByID(item.Qid);
                string     multi_mediaHtml = "";
                if (question.QuestionType == 6)
                {
                    string name = question.FileUpload[0].FileName;
                    switch (question.FileUpload[0].FileType)
                    {
                    case 0:
                    {
                        multi_mediaHtml = "    <table class='all80 cen'>" +
                                          "<tr>" +
                                          "<td class='all20' align='center' valign='middle'>" +
                                          " <a id='k-prev' style='position:relative;' onclick='turnToNext(this,\"left\");' ></a>" +
                                          "</td>" +
                                          "<td id='imageCollection' align='center' style='height: 300px;'>" +
                                          "<input type='hidden' value='1' />";
                        for (int i = 0; i < question.FileUpload.Count; i++)
                        {
                            multi_mediaHtml += "<img src='../../ClientBin/UploadFile/" +
                                               question.FileUpload[i].FileName +
                                               "' style='width:250px; height:250px; " +
                                               (i == 0 ? " display:block; " : " display:none; ") + "' />";
                        }
                        multi_mediaHtml += "     </td>" +
                                           "<td class='all20' align='center' valign='middle'>" +
                                           "<a id='k-next' style='position:relative;' onclick='turnToNext(this,\"right\");' ></a>" +
                                           "</td>" +
                                           "</tr>" +
                                           "</table>";
                    }
                    break;

                    case 1:
                    {
                        multi_mediaHtml +=
                            @"<embed class='mLeft_2' src='../../Scripts/mp3player/player.swf?url=../../ClientBin/UploadFile/" + name + "&amp;autoplay=0;autostart=0' type='application/x-shockwave-flash' wmode='transparent'  allowscriptaccess='always' height='25' width='400'></embed>";
                    }
                    break;

                    case 2:
                    {
                        var id = name.Substring(0, name.Length - 4);
                        multi_mediaHtml +=
                            @"<input name='FlvName' value='" + name +
                            @"' type='hidden' /><div class='mLeft_2'><div id='" + id + "'></div></div>";
                    }
                    break;
                    }
                }

                ReStudentExamAnswer reStuExamAnswer =
                    examSendStudent.StudentAnswerList.Where(a => a.Qid == item.Qid).FirstOrDefault();
                string qUserAnswerHtml  = "";
                string qRightAnswerHtml = "";
                switch (item.QType)
                {
                case 1:
                    qUserAnswerHtml  = "<p><textarea class='Boxarea all60' disabled='disabled'>" + item.Answer + "</textarea></p>";
                    qRightAnswerHtml = question.QuestionAnswer[0].Answer;
                    break;

                case 2:
                case 3:
                    foreach (QuestionAnswer itemQueAnswer in question.QuestionAnswer.OrderBy(q => q.Order))
                    {
                        qRightAnswerHtml += itemQueAnswer.AnswerFlag == 1
                                                    ? (qRightAnswerHtml == ""
                                                           ? ((char)(itemQueAnswer.Order + 64)).ToString()
                                                           : (". " + ((char)(itemQueAnswer.Order + 64))))
                                                    : "";

                        qUserAnswerHtml += " <p><input disabled='disabled' type='" +
                                           (item.QType == 2 ? "radio" : "checkbox") + "'" +
                                           (("," + item.Answer + ",").IndexOf("," + itemQueAnswer.Order + ",") >= 0
                                                    ? "checked='checked'"
                                                    : "") + "name='answer_" + question._id + "' />" +
                                           ((char)(itemQueAnswer.Order + 64)) + ". " + itemQueAnswer.Answer + "</p>";
                    }
                    break;

                case 4:
                    qRightAnswerHtml = question.QuestionAnswer[0].Answer == "0" ? "A. 正确" : "B. 错误";
                    // 判断题
                    qUserAnswerHtml = "<p><input disabled='disabled' type='radio' name='answer_" + question._id +
                                      "'" + (item.Answer == "0" ? "checked='checked'" : "") +
                                      "/>A. 正确</p> <p><input disabled='disabled' type='radio' name='answer_" +
                                      question._id + "'" + (item.Answer == "1" ? "checked='checked'" : "") +
                                      " />B. 错误</p>";
                    break;

                case 5:
                    qRightAnswerHtml = question.QuestionAnswer[0].Answer.Replace("!!%%!!", " ");
                    // 填空题
                    qUserAnswerHtml = " <p>学员答案:" + (item.Answer.Replace("##**##", " ")) + "</p>";

                    break;

                case 6:
                    int type = question.QuestionAnswer[0].AnswerType;
                    if (type == 0)
                    {
                        qRightAnswerHtml = question.QuestionAnswer[0].Answer;
                        //  问答题
                        qUserAnswerHtml = "<p><textarea class='Boxarea all60' disabled='disabled'>" + (item.Answer) +
                                          "</textarea></p>";
                    }
                    else
                    {
                        //单选题
                        foreach (QuestionAnswer an in question.QuestionAnswer.OrderBy(p => p.Order))
                        {
                            qRightAnswerHtml += an.AnswerFlag == 1
                                                        ? (qRightAnswerHtml == ""
                                                               ? ((char)(an.Order + 64)).ToString()
                                                               : (". " + ((char)(an.Order + 64))))
                                                        : "";
                            qUserAnswerHtml += " <p><input disabled='disabled' type='" +
                                               (type == 1 ? "radio" : "checkbox") + "'" +
                                               (("," + item.Answer + ",").IndexOf("," + an.Order + ",") >= 0
                                                        ? "checked=checked"
                                                        : "") + " name='answer_" + question._id + "' />" +
                                               ((char)(an.Order + 64)) + ". " + (an.Answer) + "</p>";
                        }
                    }

                    break;

                default:
                    break;
                }
                var temp = new
                {
                    item.Qid,
                    QOrder          = item.Order,
                    QuestionContent = "<h5>" + question.QuestionContent + "</h5><div class='db'>" + multi_mediaHtml + "</div>",
                    UserAnswer      = qUserAnswerHtml,
                    QuestionAnswer  = qRightAnswerHtml,
                    UserGetScore    = reStuExamAnswer.GetScore,
                    QuestionScore   = item.Score
                };
                totalScore  += reStuExamAnswer.GetScore;
                itemArray[n] = temp;
                n++;
            }

            return
                (Json(
                     new
            {
                result = 1,
                dataList = itemArray.ToList(),
                questionTypeHtml,
                answerCaseHtml,
                examTitle = exam.ExamTitle,
                totalScore
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 12
0
        public override void Execute()
        {
            #line 3 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

            ViewBag.Title = NavigateMenuLanguage.ExamTestDetail;
            var questionList = ViewBag.QuestionList as List <tbQuestion>;
            var examUser     = ViewBag.ExanUser as tbExamSendStudent;
            var backurl      = Request.QueryString["backurl"] ?? "";



            #line default
            #line hidden
            WriteLiteral("<script src=\"");



            #line 9 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(Url.Content("~/Scripts/ckplayer5.8/ckplayer.js"));


            #line default
            #line hidden
            WriteLiteral("\" type=\"text/javascript\"> </script>\r\n<div class=\"main-c\">\r\n    ");



            #line 11 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(Html.Action("SiteMapLink", "Common", new
            {
                linkName = "ExamTestDetail"
            }));


            #line default
            #line hidden
            WriteLiteral("\r\n    <div class=\"TitClass_line\">\r\n");



            #line 16 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

            if (ViewBag.ExamScoreStatus == 1)
            {
            #line default
            #line hidden
                WriteLiteral("            <span>得分: <strong class=\"c_blue f16\">");



            #line 19 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                Write(ViewBag.PercentFlag == 0 ? (examUser.StudentAnswerList.Sum(p => p.GetScore) * 100 / examUser.StudentAnswerList.Sum(p => p.Score)) : (examUser.StudentAnswerList.Sum(p => p.GetScore)));


            #line default
            #line hidden
                WriteLiteral("</strong>\r\n                分</span>\r\n");



            #line 21 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            }



            #line default
            #line hidden
            WriteLiteral("        <h2>");



            #line 23 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(ViewBag.ExamName);


            #line default
            #line hidden
            WriteLiteral("</h2>\r\n    </div>\r\n    <div class=\"qView\">\r\n        <span class=\"ml10\">答错:");



            #line 26 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(examUser.StudentAnswerList.Count(p => p.GetScore == 0 && p.Answer != ""));


            #line default
            #line hidden
            WriteLiteral("</span>\r\n        <span class=\"ml10\">未答:");



            #line 27 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(examUser.StudentAnswerList.Count(p => p.Answer == ""));


            #line default
            #line hidden
            WriteLiteral("</span>\r\n        <span class=\"ml10\">正确:");



            #line 28 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(examUser.StudentAnswerList.Count(p => p.GetScore > 0));


            #line default
            #line hidden
            WriteLiteral("</span>\r\n    </div>\r\n    <div class=\"exam-list mt10\">\r\n");



            #line 31 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

            foreach (ReStudentExamAnswer q in examUser.StudentAnswerList.OrderBy(p => p.Order))
            {
                string     rightAnswer = "";
                tbQuestion qu          = questionList.FirstOrDefault(p => p._id == q.Qid);


            #line default
            #line hidden
                WriteLiteral("            <div class=\"QSingle\">\r\n                <div class=\"title\">\r\n         " +
                             "           <div class=\"info\">\r\n                        <span>");



            #line 39 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                Write(q.Order);


            #line default
            #line hidden
                WriteLiteral("</span> . [ <span class=\"fen\">");



            #line 39 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                Write(q.Score);


            #line default
            #line hidden
                WriteLiteral("</span>分 ]\r\n                    </div>\r\n                    <h5>\r\n               " +
                             "         ");



            #line 42 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                Write(Html.Raw(qu.QuestionContent));


            #line default
            #line hidden
                WriteLiteral("\r\n");



            #line 43 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

                if (qu.QuestionType == 6)
                {
                    string name = qu.FileUpload[0].FileName;
                    switch (qu.FileUpload[0].FileType)
                    {
                    case 0:
                    {
            #line default
            #line hidden
                        WriteLiteral(@"                            <center class=""mt10"">
                                <div id=""imageCollection"">
                                    <a id=""k-prev"" class=""pl"" onclick="" turnToNext(this, 'left'); ""></a>
                                    <input type=""hidden"" value=""1"" />
");



            #line 55 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

                        for (int i = 0; i < qu.FileUpload.Count; i++)
                        {
            #line default
            #line hidden
                            WriteLiteral("                                        <img src=\"../../ClientBin/UploadFile/");



            #line 58 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write(qu.FileUpload[i].FileName);


            #line default
            #line hidden
                            WriteLiteral("\" style=\"");



            #line 58 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write(i == 0 ? " display:block; " : " display:none; ");


            #line default
            #line hidden
                            WriteLiteral("\" />\r\n");



            #line 59 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        }



            #line default
            #line hidden
                        WriteLiteral("                                    <a id=\"k-next\" class=\"pr\" onclick=\" turnToNex" +
                                     "t(this, \'right\'); \"></a>\r\n                                </div>\r\n              " +
                                     "              </center>\r\n");



            #line 64 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    }
                    break;

                    case 1:


            #line default
            #line hidden
                        WriteLiteral("                            <div class=\"mt10\">\r\n                                <" +
                                     "embed type=\"application/x-mplayer2\" src=\"../../ClientBin/UploadFile/");



            #line 68 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(name);


            #line default
            #line hidden
                        WriteLiteral("\" name=\"mediaplayer\" width=\"500\" height=\"250\" showcontrols=\"1\" showstatusbar=\"0\" " +
                                     "showdisplay=\"0\" autostart=\"0\"></embed>\r\n                            </div>\r\n");



            #line 70 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        break;

                    case 2:
                    {
                        var id = name.Substring(0, name.Length - 4);


            #line default
            #line hidden
                        WriteLiteral("                            <input name=\"FlvName\" value=\"");



            #line 74 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(name);


            #line default
            #line hidden
                        WriteLiteral("\" type=\"hidden\" />\r\n");



                        WriteLiteral("                            <div class=\"mt10\">\r\n                                <" +
                                     "div id=\'");



            #line 76 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(id);


            #line default
            #line hidden
                        WriteLiteral("\'>\r\n                                </div>\r\n                            </div> \r\n" +
                                     "");



            #line 79 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    }
                    break;
                    }
                }



            #line default
            #line hidden
                WriteLiteral("                    </h5>\r\n                </div>\r\n                <div class=\"co" +
                             "ntent\">\r\n");



            #line 87 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

                if (qu.QuestionType == 1)
                {
                    rightAnswer = qu.QuestionAnswer[0].Answer;


            #line default
            #line hidden
                    WriteLiteral("                        <!-- 问答题 -->\r\n");



                    WriteLiteral("                        <div class=\"ans\">\r\n                            <div class" +
                                 "=\"ans-stu\">\r\n                                <span class=\"tit\"><i></i>学员答案</span" +
                                 ">\r\n                                <p>");



            #line 95 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(q.Answer);


            #line default
            #line hidden
                    WriteLiteral("</p>\r\n                            </div>\r\n                        </div>\r\n");



            #line 98 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                }
                else if (qu.QuestionType == 2 || qu.QuestionType == 3)
                {
            #line default
            #line hidden
                    WriteLiteral("                        <!-- 单选题 -->\r\n");



            #line 102 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    foreach (QuestionAnswer an in qu.QuestionAnswer.OrderBy(p => p.Order))
                    {
                        rightAnswer += an.AnswerFlag == 1 ? (rightAnswer == "" ? ((char)(an.Order + 64)).ToString() : ("、" + ((char)(an.Order + 64)))) : "";


            #line default
            #line hidden
                        WriteLiteral("                        <div>\r\n                            <input disabled=\"disab" +
                                     "led\" type=\"");



            #line 106 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(qu.QuestionType == 2 ? "radio" : "checkbox");


            #line default
            #line hidden
                        WriteLiteral("\" ");



            #line 106 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(("," + q.Answer + ",").IndexOf("," + an.Order + ",") >= 0 ? "checked=checked" : "");


            #line default
            #line hidden
                        WriteLiteral(" name=\"answer_");



            #line 106 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(qu._id);


            #line default
            #line hidden
                        WriteLiteral("\" />");



            #line 106 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write((char)(an.Order + 64));


            #line default
            #line hidden
                        WriteLiteral(".\r\n                            ");



            #line 107 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(an.Answer);


            #line default
            #line hidden
                        WriteLiteral("</div>\r\n");



            #line 108 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    }
                }
                else if (qu.QuestionType == 4)
                {
                    rightAnswer = qu.QuestionAnswer[0].Answer == "0" ? "A、正确" : "B、错误";


            #line default
            #line hidden
                    WriteLiteral("                        <!-- 判断题 -->\r\n");



                    WriteLiteral("                        <div class=\"jud\">\r\n                            <span>\r\n  " +
                                 "                              <input disabled=\"disabled\" type=\"radio\" name=\"answ" +
                                 "er_");



            #line 116 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(qu._id);


            #line default
            #line hidden
                    WriteLiteral("\" ");



            #line 116 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(q.Answer == "0" ? "checked=checked" : "");


            #line default
            #line hidden
                    WriteLiteral(" /><label>A.\r\n                                    正确</label></span> <span>\r\n     " +
                                 "                                   <input disabled=\"disabled\" type=\"radio\" name=" +
                                 "\"answer_");



            #line 118 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(qu._id);


            #line default
            #line hidden
                    WriteLiteral("\" ");



            #line 118 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(q.Answer == "1" ? "checked=checked" : "");


            #line default
            #line hidden
                    WriteLiteral(" /><label>B.\r\n                                            错误</label></span>\r\n    " +
                                 "                    </div>\r\n");



            #line 121 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                }
                else if (qu.QuestionType == 5)
                {
                    rightAnswer = qu.QuestionAnswer[0].Answer.Replace("!!%%!!", " ");


            #line default
            #line hidden
                    WriteLiteral("                        <!-- 填空题 -->\r\n");



                    WriteLiteral("                        <div class=\"ans\">\r\n                            <div class" +
                                 "=\"ans-stu\">\r\n                                <span class=\"tit\"><i></i>学员答案</span" +
                                 ">\r\n                                <p>");



            #line 129 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(q.Answer.Replace("##**##", " "));


            #line default
            #line hidden
                    WriteLiteral("</p>\r\n                            </div>\r\n                        </div>\r\n");



            #line 132 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                }
                else if (qu.QuestionType == 6)
                {
                    int type = qu.QuestionAnswer[0].AnswerType;
                    if (type == 0)
                    {
                        rightAnswer = qu.QuestionAnswer[0].Answer;


            #line default
            #line hidden
                        WriteLiteral("                        <!-- 问答题 -->\r\n");



                        WriteLiteral("                        <div class=\"ans\">\r\n                            <div class" +
                                     "=\"ans-stu\">\r\n                                <span class=\"tit\"><i></i>学员答案</span" +
                                     ">\r\n                                <p>");



            #line 143 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        Write(q.Answer);


            #line default
            #line hidden
                        WriteLiteral("</p>\r\n                            </div>\r\n                        </div>\r\n");



            #line 146 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    }
                    else
                    {
            #line default
            #line hidden
                        WriteLiteral("                        <!-- 单选题 -->\r\n");



            #line 150 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        foreach (QuestionAnswer an in qu.QuestionAnswer.OrderBy(p => p.Order))
                        {
                            rightAnswer += an.AnswerFlag == 1 ? (rightAnswer == "" ? ((char)(an.Order + 64)).ToString() : ("、" + ((char)(an.Order + 64)))) : "";


            #line default
            #line hidden
                            WriteLiteral("                        <div>\r\n                            <input disabled=\"disab" +
                                         "led\" type=\"");



            #line 154 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write(type == 1 ? "radio" : "checkbox");


            #line default
            #line hidden
                            WriteLiteral("\" ");



            #line 154 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write(("," + q.Answer + ",").IndexOf("," + an.Order + ",") >= 0 ? "checked=checked" : "");


            #line default
            #line hidden
                            WriteLiteral(" name=\"answer_");



            #line 154 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write(qu._id);


            #line default
            #line hidden
                            WriteLiteral("\" />");



            #line 154 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write((char)(an.Order + 64));


            #line default
            #line hidden
                            WriteLiteral("、\r\n                            ");



            #line 155 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                            Write(an.Answer);


            #line default
            #line hidden
                            WriteLiteral("</div>\r\n");



            #line 156 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                        }
                    }
                }



            #line default
            #line hidden
                WriteLiteral("                    <div class=\"ans\">\r\n                        <div class=\"ans-ok" +
                             "\">\r\n                            <span class=\"tit\"><i></i>正确答案</span>\r\n          " +
                             "                  <p>");



            #line 163 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                Write(rightAnswer);


            #line default
            #line hidden
                WriteLiteral("</p>\r\n                        </div>\r\n                    </div>\r\n");



            #line 166 "..\..\Views\ExamTest\ExamTestDetail.cshtml"

                if (qu.QuestionAnalysis == "")
                {
                }
                else
                {
            #line default
            #line hidden
                    WriteLiteral("                        <div class=\"ans\">\r\n                            <div class" +
                                 "=\"ans-res\">\r\n                                <span class=\"tit\"><i></i>试题解析</span" +
                                 ">\r\n                                <p>");



            #line 175 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                    Write(qu.QuestionAnalysis);


            #line default
            #line hidden
                    WriteLiteral("</p>\r\n                            </div>\r\n                        </div>\r\n");



            #line 178 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
                }



            #line default
            #line hidden
                WriteLiteral("                </div>\r\n            </div>\r\n");



            #line 182 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            }



            #line default
            #line hidden
            WriteLiteral(@"    </div>
    <center class=""mt10"">
        <input type=""button"" class=""btn btn-cancel"" value=""返回"" onclick=""backurl();"" /></center>
</div>
<script type=""text/javascript"">
    $(document).ready(function ()
    {
        $(""input[name='FlvName']"").each(function ()
        {
            ckplay($(this).val());
        });
        //ckplay();
    });

    function ckplay(name)
    {

        var url = '");



            #line 201 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(Url.Content("~/ClientBin/UploadFile/"));


            #line default
            #line hidden
            WriteLiteral("\' + name;\r\n        var id = name.substring(0, name.length - 4);\r\n        var s1 =" +
                         " new swfupload();\r\n        s1.ckplayer_url = \'");



            #line 204 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(Url.Content("~/Scripts/ckplayer5.8/ckplayer.swf"));


            #line default
            #line hidden
            WriteLiteral(@"'; //播放器文件名
        s1.ckplayer_flv = url; //视频地址,这里也可以填写一个网址或xml地址或flash文件,具体的设置请到网站了解
        s1.ckplayer_pat = '1'; //传递的参数,这里的具体参数设置方式到网站了解
        s1.ckplayer_style = 0; //传递的方式,0是普通方式,1是网址传送,2是xml传送,3是flash传送
        s1.ckplayer_default = 0; //读取文本配置,此参数具有非常强大的功能,(比如外站引用视频只需一个参数即可)说来话长,请到网站了解详情
        s1.ckplayer_xml = ''; //风格配置xml文件,如果为空的话将使用js文件配置
        s1.ckplayer_loadimg = ''; //初始图片地址
        s1.ckplayer_pauseflash = ''; //暂停时播放的广告,只支持flash和图片
        s1.ckplayer_pauseurl = ''; //暂停时播放图片时需要加一个链接
        s1.ckplayer_loadadv = ''; //视频开始前播放的广告,可以是flash,也可是视频格式
        s1.ckplayer_loadurl = ''; //视频开始前广告的链接地址,主要针对视频广告,如果是flash可以不填写
        s1.ckplayer_loadtime = 0; //视频开始前广告播放的秒数,只针对flash或图片有效
        s1.ckplayer_endstatus = 2; //视频结束后的动作,0停止播放并发送js,1是不发送js且重新循环播放,2停止播放
        s1.ckplayer_volume = 40; //视频默认音量0-100之间
        s1.ckplayer_play = 0; //视频默认播放还是暂停,0是暂停,1是播放
        s1.ckplayer_width = 300; //播放器宽度
        s1.ckplayer_height = 150; //播放器高度
        s1.ckplayer_bgcolor = '#000000'; //播放器背景颜色
        s1.ckplayer_allowFullScreen = true; //是否支持全屏,true支持,false不支持,默认支持
        s1.swfwrite(id); //div的id

    }


    function backurl()
    {
        if(""");



            #line 230 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(backurl);


            #line default
            #line hidden
            WriteLiteral("\"==\"\")\r\n        {\r\n           window.location.href = \"/ExamTest/MyExaminationList" +
                         "\"; \r\n        }\r\n        else\r\n        {\r\n           window.location.href=\"");



            #line 236 "..\..\Views\ExamTest\ExamTestDetail.cshtml"
            Write(backurl);


            #line default
            #line hidden
            WriteLiteral("\";\r\n        }\r\n    }\r\n</script>\r\n");
        }
Exemplo n.º 13
0
        /// <summary>
        ///     单题得分
        /// </summary>
        /// <param name="qu">试题信息</param>
        /// <param name="userAnswer">学员答案</param>
        /// <param name="score">本题分值</param>
        /// <returns></returns>
        public int GetScore(tbQuestion qu, string userAnswer, int score)
        {
            int getScore = 0; //是否得分(0:未得分;1:得分)

            switch (qu.QuestionType)
            {
            case 1:     //问答
            {
                //正确答案关键字
                string[] rightKeys = qu.QuestionAnswerKeys.Split(' ');
                int      count     = 0; //答对个数
                rightKeys.ToList().ForEach(p => { count += userAnswer.Contains(p) ? 1 : 0; });
                getScore = score * count / rightKeys.Count();
            }
            break;

            case 2:     //单选
            case 3:     //多选
            {
                string rightAnswer = "";
                qu.QuestionAnswer.ForEach(
                    p =>
                    {
                        rightAnswer += p.AnswerFlag == 1
                                                       ? (rightAnswer == "" ? (p.Order + "") : ("," + p.Order))
                                                       : "";
                    });
                getScore = userAnswer == rightAnswer ? score : 0;
            }
            break;

            case 4:     //判断
            {
                string rightAnswer = qu.QuestionAnswer[0].Answer;
                getScore = userAnswer == rightAnswer ? score : 0;
            }
            break;

            case 5:     //填空
            {
                //正确答案关键字
                string[] rightKeys = qu.QuestionAnswerKeys.Split(' ');
                //学员答案关键字
                string[] uanswer = userAnswer.Split(new[] { "##**##" }, StringSplitOptions.None);
                int      count   = 0;  //答对个数
                for (int i = 0; i < rightKeys.Count(); i++)
                {
                    if (uanswer.Count() > i && rightKeys[i] == uanswer[i])
                    {
                        count++;
                    }
                }
                getScore = score * count / rightKeys.Count();
            }
            break;

            case 6:     //情景
            {
                switch (qu.QuestionAnswer[0].AnswerType)
                {
                case 0:
                {
                    //正确答案关键字
                    string[] rightKeys = qu.QuestionAnswerKeys.Split(' ');
                    int      count     = 0;        //答对个数
                    rightKeys.ToList().ForEach(p => { count += userAnswer.Contains(p) ? 1 : 0; });
                    getScore = score * count / rightKeys.Count();
                }
                break;

                case 1:
                case 2:
                {
                    string rightAnswer = "";
                    qu.QuestionAnswer.ForEach(
                        p =>
                            {
                                rightAnswer += p.AnswerFlag == 1
                                                                   ? (rightAnswer == ""
                                                                          ? (p.Order + "")
                                                                          : ("," + p.Order))
                                                                   : "";
                            });
                    getScore = userAnswer == rightAnswer ? score : 0;
                }
                break;
                }
            }
            break;
            }
            return(getScore);
        }
Exemplo n.º 14
0
        public JsonResult SubmitQuestion()
        {
            string content = Request.Form["hiddenQuestionContent"].NoHtml();

            if (content.Replace("&nbsp;", "").Trim() == "")
            {
                return(Json(new
                {
                    result = 0,
                    content = "请输入试题题干",
                }, "text/html", JsonRequestBehavior.AllowGet));
            }

            //ID
            int id = Convert.ToInt32(Request.QueryString["id"]);
            //类型
            int  qType    = Convert.ToInt32(Request.Form["hiddenSelQuestionType"]);
            int  newid    = 0;
            bool flag     = true;
            int  fileType = Convert.ToInt32(Request.QueryString["type"]); //0:图片,1:音频,2:视频

            if (qType == 6)
            {
                HttpFileCollectionBase files = Request.Files;
                for (int i = 0; i < files.Count; i++)
                {
                    if (((fileType != 0 && files[i].ContentLength > 8388608) ||
                         (fileType == 0 && files[i].ContentLength > 512000)) && flag)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            int questionType = Convert.ToInt32(Request.Form["hiddenSelQuestionType"]);

            if (flag)
            {
                List <FileUpload> listfileUpload = qType == 6 ? FileUpload(fileType) : new List <FileUpload>();
                tbQuestion        question       = id > 0
                                          ? EQuestionBL.GetSingleByID(id)
                                          : new tbQuestion
                {
                    Status         = 0,
                    LastUpdateTime = DateTime.Now,
                    _id            = id,
                    UserID         = Session["userID"] == null ? 0 : CurrentUser.UserId,
                    FileUpload     = listfileUpload,
                    CreateTime     = DateTime.Now
                };
                question.QuestionAnswerKeys = Request.Form["txtQuestionAnswerKeys"] ?? "";
                question.QuestionLevel      = Convert.ToInt32(Request.Form["hiddenSelQuestionLevel"]);
                question.QuestionSortID     = Convert.ToInt32(Request.Form["hiddenSelQuestionSort"]);
                question.QuestionType       = questionType;
                question.QuestionAnalysis   = Request.Form["txtQuestionAnalysis"] ?? "";
                question.QuestionKey        = Request.Form["hiddenSelQuestionKey"].StringToInt32();
                question.QuestionAnswer     = new List <QuestionAnswer>();


                if (qType == 6 && listfileUpload.Count > 0)
                {
                    question = UpdateQuestionFiles(question, listfileUpload);
                }

                switch (qType)
                {
                case 1:     //主观题
                    newid = SubmitSubjectQuestion(id, question);
                    break;

                case 2:     //单选题
                    newid = SubmitSingleQuestion(id, question);
                    break;

                case 3:     //多选题
                    newid = SubmitMultipeQuestion(id, question);
                    break;

                case 4:     //判断题
                    newid = SubmitJudgeQuestion(id, question);
                    break;

                case 5:     //填空题
                    newid = SubmitFillblankQuestion(id, question);
                    break;

                case 6:     //情景题
                    newid = SubmitMultimediaQuestion(id, question);
                    break;
                }

                if (newid > 0)
                {
                    return(Json(new
                    {
                        result = 1,
                        questionID = newid,
                        content = CommonLanguage.Common_AddSuccess,
                    }, "text/html", JsonRequestBehavior.AllowGet));
                }
                return(Json(new
                {
                    result = 0,
                    content = CommonLanguage.Common_AddFailed,
                    url = ""
                }, "text/html", JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                result = -1,
                content = CommonLanguage.Common_Tip_UpLoadFileLimit,
            }, "text/html", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 15
0
 /// <summary>
 ///     插入问题
 /// </summary>
 /// <param name="question"></param>
 /// <returns></returns>
 public int Insert(tbQuestion question)
 {
     return(Qdb.Insert(question));
 }
Exemplo n.º 16
0
        /// <summary>
        ///     查看试卷呈现
        /// </summary>
        public ViewResult ExampaperDetail(int flag = 0)
        {
            int         id     = Convert.ToInt32(Request.QueryString["id"]);
            tbExampaper expape = EBL.GetExampaper(id);
            List <ReExampaperQuestion> questionList = expape.QuestionList;
            List <ReRuleQuestion>      ruleList     = expape.QuestionRule;

            var itemArray = new List <tbQuestion>();

            if (questionList.Count > 0)
            {
                //遍历试卷问题ID,获取题目
                foreach (ReExampaperQuestion Pquestion in questionList)
                {
                    tbQuestion baseInfor = qBL.GetSingleByID(Pquestion.Qid);
                    baseInfor.QuestionAnswer = baseInfor.QuestionAnswer.OrderByDescending(p => p.AnswerFlag).ToList();
                    itemArray.Add(baseInfor);
                }
            }

            var itemArray1 = new List <MExamRuleShow>();

            if (ruleList.Count > 0)
            {
                foreach (ReRuleQuestion qRule in ruleList)
                {
                    var eq = new MExamRuleShow();
                    eq.QuestingScore = qRule.QScore;
                    switch (qRule.Qtype)
                    {
                    case 1:     //问答题
                        eq.QuestionType = "问答题";
                        break;

                    case 2:     //单选题
                        eq.QuestionType = "单选题";
                        break;

                    case 3:     //多选题
                        eq.QuestionType = "多选题";
                        break;

                    case 4:     //判断题
                        eq.QuestionType = "判断题";
                        break;

                    case 5:     //填空题
                        eq.QuestionType = "填空题";
                        break;

                    case 6:     //情景题
                        eq.QuestionType = "情景题";
                        break;
                    }

                    tbQuestionSort qSort = qSortBL.GetSingleByID(qRule.QSort);
                    eq.QuestionSort = qSort.Title;
                    string[] questionLevel = qRule.QLevelStr.Split(';');
                    string[] Easy          = questionLevel[0].Split(':');
                    string[] Common        = questionLevel[1].Split(':');
                    string[] Hard          = questionLevel[2].Split(':');
                    eq.Leveleasy   = Convert.ToInt32(Easy[1]);
                    eq.Levelcommon = Convert.ToInt32(Common[1]);
                    eq.Levelhard   = Convert.ToInt32(Hard[1]);
                    string qit1 = qRule.Qtype + "|" + qRule.QSort;
                    string qit  = qRule.Qtype + "|" + qRule.QSort + "|" + qRule.QScore + "|" + Easy[1] + "|" + Common[1] +
                                  "|" + Hard[1];
                    eq.qita    = qit;
                    eq.qitaone = qit1;

                    itemArray1.Add(eq);
                }
            }

            if (Request.QueryString["sortID"] != null)
            {
                if (flag == 1)
                {
                    ViewData["fatherModel"] = eSortBL.GetAllExampaperSortDictionary().Keys.Contains(expape.ExamSortID)
                                                  ? eSortBL.GetAllExampaperSortDictionary()[expape.ExamSortID].Title
                                                  : "无";
                }
                else
                {
                    ViewData["fatherModel"] = Request.QueryString["SortID"] == "0"
                                                  ? Exampaper.NO
                                                  : eSortBL.GetAllExampaperSortDictionary()[
                        Convert.ToInt32(Request.QueryString["sortID"])].Title;
                }
            }
            else
            {
                ViewData["fatherModel"] = Exampaper.NO;
            }
            ViewData["expape"]         = expape;
            ViewData["expapeQuestion"] = itemArray;
            ViewData["expapeRule"]     = itemArray1;
            return(View());
        }
Exemplo n.º 17
0
 /// <summary>
 ///     修改试题
 /// </summary>
 /// <param name="question">修改内容的集合</param>
 /// <returns></returns>
 public int ModifyByID(tbQuestion question)
 {
     Qdb.Modify(question);
     return(question._id);
 }
Exemplo n.º 18
0
        /// <summary>
        ///     保存学员答案
        /// </summary>
        /// <param name="form">答案</param>
        /// <param name="euid">学员考试ID</param>
        /// <param name="submitType">1:暂存;2:提交</param>
        /// <param name="pecent">是否百分制(0:是;1:否)</param>
        /// <param name="passScore">及格线</param>
        /// 0为考试试卷1为课程下试卷
        /// <returns></returns>
        public JsonResult SubmitStudentAnswer(FormCollection form, int euid = 0, int submitType = 1, int pecent = 0,
                                              int passScore = 0, int courseType = 0)
        {
            string answer  = form["userAnswer"];    //答案
            string quScore = form["questionScore"]; //试题分值
            string quOrder = form["questionOrder"]; //试题题序

            if (answer == "" || quScore == "" || quOrder == "")
            {
                return(Json(new { result = 0 }, JsonRequestBehavior.AllowGet));
            }

            //tbExamSendStudent examUser = ExamTestBL.GetExamUser(euid);

            tbExamSendStudent examUser = null;
            tbExamSendStudent student  = null;

            if (courseType == 0)
            {
                examUser = ExamTestBL.GetExamUser(euid);
            }
            else
            {
                //var  student= ExamTestBL.GetExamUser(euid);
                student  = ExamTestBL.GetExamUser(euid);
                examUser = ExaminationBL.GetSingletbExamSendStudentByCourseIdAndUserId(student.RelationID, CurrentUser.UserId, student.SourceType);
                //if (student.SourceType == 1)
                //{
                //    examUser = ExaminationBL.GetSingletbExamSendStudentByCourseIdAndUserId(student.RelationID, CurrentUser.UserId,1);
                //}
                //else
                //{
                //    examUser = ExaminationBL.GetSingletbExamSendStudentByCourseIdAndUserId(student.RelationID, CurrentUser.UserId, 2);
                //}
            }

            var oldPaperScore = examUser.StudentAnswerList; //.Sum(p => p.GetScore);

            var pass         = 0;                           //0没通过,1通过
            var nopassnumber = 0;

            var dicAnswer = new Dictionary <int, string>();

            answer.Split(new[] { "**!!!**" }, StringSplitOptions.None).ToList().ForEach(p =>
            {
                string[] arr = p.Split(new[] { "!!***!!" }, StringSplitOptions.None);
                dicAnswer.Add(arr[0].StringToInt32(), arr[1]);
            });

            var dicScore = new Dictionary <int, int>();

            quScore.Split(';').ToList().ForEach(p =>
            {
                string[] arr = p.Split(',');
                dicScore.Add(arr[0].StringToInt32(), arr[1].StringToInt32());
            });

            var dicOrder = new Dictionary <int, int>();

            quOrder.Split(';').ToList().ForEach(p =>
            {
                string[] arr = p.Split(',');
                dicOrder.Add(arr[0].StringToInt32(), arr[1].StringToInt32());
            });

            List <tbQuestion> qulist = ExamTestBL.GetQuestionList(dicAnswer.Keys.ToList());

            examUser.StudentAnswerList = new List <ReStudentExamAnswer>();

            //int NowSum = 0;//记录当前分数

            //循环学员答案
            foreach (var o in dicAnswer)
            {
                tbQuestion qu = qulist.FirstOrDefault(p => p._id == o.Key); //试题
                if (qu != null)
                {
                    int score = submitType == 2 ? GetScore(qu, o.Value, dicScore[o.Key]) : 0;
                    examUser.StudentAnswerList.Add(new ReStudentExamAnswer
                    {
                        DoneFlag = o.Value == "" ? 0 : 1,
                        Evlution = "",
                        GetScore = score,
                        Answer   = o.Value,
                        Qid      = o.Key,
                        QType    = qu.QuestionType,
                        Order    = dicOrder[o.Key],
                        Score    = dicScore[o.Key]
                    });
                    // NowSum += score;
                }
            }
            if (submitType == 2)
            {
                examUser.DoExamStatus = 2;
                int totalScore = dicScore.Values.Sum();                                       //总分
                examUser.PaperScore = pecent == 1 ? passScore : totalScore * passScore / 100; //考试通过的基线
                int userScore = examUser.StudentAnswerList.Sum(p => p.GetScore);              //考生得分
                if (pecent == 0)
                {
                    examUser.IsPass = userScore * 100 / totalScore >= passScore ? 1 : 0;
                }
                else
                {
                    examUser.IsPass = userScore >= passScore ? 1 : 0;
                }
            }

            //当1的时候是课程下的考试
            if (examUser.SourceType == 1)
            //if(courseType==1)
            {
                //var student = ExamTestBL.GetExamUser(euid);
                //查找这门课程对应的通过线和考试次数
                var CoCoursePaper = ICoCoursePaperBL.GetCo_CourseMainPaper(student.RelationID);
                //查找课程信息 用于查找该课程的学时
                var course = ICourseBl.GetCo_Course(student.RelationID);
                //查找试卷总分
                var exampaper = ExampaperBL.GetExampaper(CoCoursePaper.PaperId);


                if (IAttendceBL.ExistAtts(course.Id, CurrentUser.UserId))
                {
                    //获取这个人预定信息 因为集中课程学时是走一步算一步 获取已经获得的学时
                    var courseorder = CourseOrderBL.GetCourseById(student.RelationID, CurrentUser.UserId);

                    //如果当前考试分数大于上一次考的分数则修改, 如果小则还是记录以前的分数
                    int fenshju = examUser.StudentAnswerList.Sum(p => p.GetScore);
                    //int olderfenshuju=
                    if (fenshju > oldPaperScore.Sum(p => p.GetScore))
                    {
                        //examUser.PaperScore = fenshju;
                        ExamTestBL.SaveExamUser(examUser);
                    }
                    else
                    {
                        if (oldPaperScore.Count != 0)  // 如果第一次没过就记录当前选项
                        {
                            examUser.StudentAnswerList = oldPaperScore;
                        }
                        ExamTestBL.SaveExamUser(examUser);
                    }

                    //var xueshi = AllSystemConfigs.Find(p => p.ConfigType == 24);
                    var xueshi     = course.CourseLengthDistribute;
                    var aa         = examUser.StudentAnswerList.Sum(p => p.GetScore);
                    var tongguofen = (exampaper.ExampaperScore * CoCoursePaper.LevelScore) / 100;
                    //var aa = ((double)examUser.StudentAnswerList.Sum(p => p.GetScore) / (double)exampaper.ExampaperScore)*100;

                    //考试没有超过通线 记录课后评估
                    //if ((int)aa < CoCoursePaper.LevelScore)
                    nopassnumber = Convert.ToInt32(CoCoursePaper.TestTimes) - student.TestTimes;
                    if ((int)aa < (int)tongguofen)
                    {
                        pass = 0;
                        //考试不过则不做任何操作
                        if (examUser.Number == 0)
                        {
                            //double afterlenght = (double) Convert.ToInt32(xueshi.ConfigValue.Split(';')[0])/100 +
                            //                        (double) Convert.ToInt32(xueshi.ConfigValue.Split(';')[2])/100;

                            ////获取考试不过的百分比
                            //decimal forlenght = course.CourseLength*Convert.ToDecimal(afterlenght);

                            ////加上已得分数
                            //decimal tt = courseorder.GetScore  + forlenght;
                            ////PassStatus;1:通过;2:不通过;LearnStatus: 1:进行中;2:已完成
                            //CourseOrderBL.UpdateGetScore(course.Id, CurrentUser.UserId, tt, 2, 1);
                        }
                    }
                    else //考试通过
                    {
                        pass = 1;
                        //当Number为1的时候 则不在记录学时
                        if (examUser.Number == 0)
                        {
                            //只有考勤和考试 没有评估 考试通过后则把考试和评估的部分都加上去
                            if (course.IsPing == 0 && course.IsTest == 1)
                            {
                                double afterlenght = (double)Convert.ToInt32(xueshi.Split(';')[1]) / 100 +
                                                     (double)Convert.ToInt32(xueshi.Split(';')[2]) / 100;
                                decimal fortestlenght = (Convert.ToDecimal(afterlenght) * course.CourseLength) + courseorder.GetScore;


                                #region 折算CPA学时
                                if (course.IsCPA == 1)
                                {
                                    Cl_CpaLearnStatus cls = ICpaLearnStatusBL.GetCl_CpaLearnStatusByCourseId(course.Id, CurrentUser.UserId);
                                    if (cls == null)
                                    {
                                        cls            = new Cl_CpaLearnStatus();
                                        cls.CourseID   = course.Id;
                                        cls.UserID     = CurrentUser.UserId;
                                        cls.IsAttFlag  = 0;
                                        cls.Progress   = 0;
                                        cls.LearnTimes = 0;
                                        if (course.IsMust == 1)
                                        {
                                            cls.GetLength = fortestlenght * Convert.ToDecimal(0.5);
                                        }
                                        if (course.IsMust == 0)
                                        {
                                            cls.GetLength = fortestlenght;
                                        }

                                        cls.CpaFlag     = 2;
                                        cls.GradeStatus = 1;
                                        ICpaLearnStatusBL.SubscribeCPALearnStatus(cls);
                                    }
                                    else
                                    {
                                        cls.IsAttFlag  = 0;
                                        cls.IsPass     = 1;
                                        cls.Progress   = 0;
                                        cls.LearnTimes = 0;
                                        //cls.GetLength = fortestlenght;
                                        if (course.IsMust == 1)
                                        {
                                            cls.GetLength = fortestlenght * Convert.ToDecimal(0.5);
                                        }
                                        if (course.IsMust == 0)
                                        {
                                            cls.GetLength = fortestlenght;
                                        }
                                        cls.CpaFlag     = 2;
                                        cls.GradeStatus = 1;
                                        ICpaLearnStatusBL.UpdateCPALearnStatusByModel(cls);
                                    }
                                }
                                #endregion



                                CourseOrderBL.UpdateGetScore(course.Id, CurrentUser.UserId, fortestlenght, 1, 2);

                                //考试通过后就把Number标志位改成1 以后在考试则不记学时
                                ExaminationBL.UpdateNumber(student._id, 1);
                            }
                            else //有考勤 评估 考试。考试通过则把考试那部分加上去
                            {
                                //考过后 已得到的分数+考试所占的比例
                                decimal fortestlenght = (course.CourseLength * Convert.ToDecimal((double)Convert.ToInt32(xueshi.Split(';')[1]) / 100)) + courseorder.GetScore;
                                CourseOrderBL.UpdateGetScore(course.Id, CurrentUser.UserId, fortestlenght, 1, 2);

                                //考试通过后就把Number标志位改成1 以后在考试则不记学时
                                ExaminationBL.UpdateNumber(student._id, 1);

                                #region 折算CPA学时
                                if (course.IsCPA == 1)
                                {
                                    Cl_CpaLearnStatus cls = ICpaLearnStatusBL.GetCl_CpaLearnStatusByCourseId(course.Id, CurrentUser.UserId);
                                    if (cls == null)
                                    {
                                        cls            = new Cl_CpaLearnStatus();
                                        cls.CourseID   = course.Id;
                                        cls.UserID     = CurrentUser.UserId;
                                        cls.IsAttFlag  = 0;
                                        cls.Progress   = 0;
                                        cls.LearnTimes = 0;
                                        if (course.IsMust == 1)
                                        {
                                            cls.GetLength = fortestlenght * Convert.ToDecimal(0.5);
                                        }
                                        if (course.IsMust == 0)
                                        {
                                            cls.GetLength = fortestlenght;
                                        }

                                        cls.CpaFlag     = 2;
                                        cls.GradeStatus = 1;
                                        ICpaLearnStatusBL.SubscribeCPALearnStatus(cls);
                                    }
                                    else
                                    {
                                        cls.IsAttFlag  = 0;
                                        cls.IsPass     = 1;
                                        cls.Progress   = 0;
                                        cls.LearnTimes = 0;
                                        //cls.GetLength = fortestlenght;
                                        if (course.IsMust == 1)
                                        {
                                            cls.GetLength = fortestlenght * Convert.ToDecimal(0.5);
                                        }
                                        if (course.IsMust == 0)
                                        {
                                            cls.GetLength = fortestlenght;
                                        }
                                        cls.CpaFlag     = 2;
                                        cls.GradeStatus = 1;
                                        ICpaLearnStatusBL.UpdateCPALearnStatusByModel(cls);
                                    }
                                }
                                #endregion
                            }
                        }
                    }

                    //如果当前考试次数等于考试总次数后 改变考试通过LearnStatus
                    if (CoCoursePaper.TestTimes == examUser.TestTimes)
                    {
                        CourseOrderBL.UpdateLearnStatus(course.Id, CurrentUser.UserId, 2);
                    }
                }
            }
            else if (examUser.SourceType == 2)//2为视频下的考试
            {
                //var student = ExamTestBL.GetExamUser(euid);
                var CoCoursePaper = ICoCoursePaperBL.GetCo_CourseMainPaper(student.RelationID);
                var course        = ICourseBl.GetCo_Course(student.RelationID);
                var exampaper     = ExampaperBL.GetExampaper(CoCoursePaper.PaperId);

                //var courseorder = CourseOrderBL.GetCourseById(student.RelationID);

                //如果当前考试分数大于上一次考的分数则修改, 如果小则还是记录以前的分数
                if (examUser.StudentAnswerList.Sum(p => p.GetScore) > oldPaperScore.Sum(p => p.GetScore))
                {
                    ExamTestBL.SaveExamUser(examUser);
                }
                else
                {
                    if (oldPaperScore.Count != 0)
                    {
                        examUser.StudentAnswerList = oldPaperScore;
                    }
                    ExamTestBL.SaveExamUser(examUser);
                }

                var aa         = examUser.StudentAnswerList.Sum(p => p.GetScore);
                var tongguofen = (exampaper.ExampaperScore * CoCoursePaper.LevelScore) / 100;
                //var aa = ((double)examUser.StudentAnswerList.Sum(p => p.GetScore) / (double)exampaper.ExampaperScore) * 100;

                nopassnumber = Convert.ToInt32(CoCoursePaper.TestTimes) - student.TestTimes;
                //考试没有超过通线 记录课后评估
                if (aa < tongguofen)
                {
                    pass = 0;
                    //考试没过的话
                    if (student.TestTimes == 1)
                    {
                        ICpaLearnStatusBL.UpdateGetCl_CpaLearnStatusByCourseId(course.Id, CurrentUser.UserId, 0, 0);
                    }
                    //关键 如果考试次数达到考试次数还没过 则清空他学习记录 重新在读
                }
                else
                {
                    pass = 1;
                    if (examUser.Number == 0)
                    {
                        ICpaLearnStatusBL.UpdateGetCl_CpaLearnStatusByCourseId(course.Id, CurrentUser.UserId,
                                                                               course.CourseLength, 1);
                        ExaminationBL.UpdateNumber(student._id, 1);

                        #region 折算cpa学时

                        if (course.IsCPA == 1)
                        {
                            Cl_CpaLearnStatus cls = new Cl_CpaLearnStatus();
                            cls.CourseID   = course.Id;
                            cls.UserID     = CurrentUser.UserId;
                            cls.IsAttFlag  = 0;
                            cls.Progress   = 0;
                            cls.LearnTimes = 0;
                            if (course.IsMust == 1)
                            {
                                cls.GetLength = course.CourseLength * (Convert.ToDecimal(0.5));
                            }
                            if (course.IsMust == 0)
                            {
                                cls.GetLength = course.CourseLength;
                            }

                            cls.CpaFlag     = 2;
                            cls.GradeStatus = 1;
                            cls.IsPass      = 1;

                            ICpaLearnStatusBL.SubscribeCPALearnStatus(cls);
                        }
                        #endregion
                    }
                }

                //通过了之后 达到考试次数就不在清数据..如果达到次数都没过就清次数
                if (examUser.Number == 0 && examUser.TestTimes == CoCoursePaper.TestTimes)
                {
                    var examUserSecond = ExaminationBL.GetSingletbExamSendStudentByCourseIdAndUserId(student.RelationID, CurrentUser.UserId, 2);
                    if (examUser.TestTimes == CoCoursePaper.TestTimes && aa < CoCoursePaper.LevelScore)
                    {
                        var cpa = ICpaLearnStatusBL.GetCl_CpaLearnStatusByCourseId(examUserSecond.RelationID,
                                                                                   CurrentUser.UserId);
                        ICpaLearnStatusBL.DeleteLearn(cpa.Id);
                        ExaminationBL.DeleteExamSendStudentWithByCourseIdAndUserId(course.Id, CurrentUser.UserId, 2);
                    }
                }
            }
            else
            {
                ExamTestBL.SaveExamUser(examUser);
                return(Json(new { result = 1 }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { result = 0, courseid = examUser.RelationID, way = examUser.SourceType, pass = pass, nopassnumber = nopassnumber }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 获取试卷的试题
        /// </summary>
        /// <param name="exampaper">试卷信息</param>
        /// <param name="exam">试卷信息</param>
        /// <param name="examuser">学员答案</param>
        public void GetExampaper(ExampaperShow exampaper, tbExampaper exam, tbExamSendStudent examuser)
        {
            if (exampaper.ExampaperType == 0)
            {
                #region 正常

                IMongoQuery       query  = Query.In("_id", new BsonArray(exam.QuestionList.Select(p => p.Qid)));
                List <tbQuestion> quList = Etdb.GetAllList <tbQuestion>(query); //获取试题
                exam.QuestionList.ForEach(p =>
                {
                    tbQuestion qu = quList.FirstOrDefault(q => q._id == p.Qid);
                    if (qu != null)
                    {
                        ReStudentExamAnswer an = examuser == null
                                                     ? null
                                                     : examuser.StudentAnswerList.FirstOrDefault(
                            pa => pa.Qid == p.Qid);
                        var newqu = new MQuestion
                        {
                            QAnswerType     = qu.QuestionAnswer[0].AnswerType,
                            QType           = qu.QuestionType,
                            QuestionContent = qu.QuestionContent,
                            QuestionID      = qu._id,
                            QuestionLevel   = ((QuestionLevel)qu.QuestionLevel).ToString(),
                            QuestionOrder   = p.QOrder,
                            Score           = p.QScore,
                            UserAnswer      = an == null ? "" : (an.Answer),
                            FillBlankCount  =
                                qu.QuestionContent.Split(new[] { "()" }, StringSplitOptions.None).Count() - 1
                        };
                        qu.QuestionAnswer.OrderBy(o => o.Order)
                        .ToList()
                        .ForEach(pa => newqu.QuestionAnswer.Add(new MQuestionAnswer
                        {
                            AnswerContent = pa.Answer,
                            AnswerFlag    = pa.AnswerFlag,
                            AnswerType    = pa.AnswerType,
                            Order         = pa.Order,
                            QuID          = newqu.QuestionID,
                            QType         = newqu.QType
                        }));
                        qu.FileUpload.ForEach(pa => newqu.FileUpload.Add(new QuestionFile
                        {
                            _fileName = pa.FileName,
                            _fileType = pa.FileType,
                            _realName = pa.RealName
                        }));
                        exampaper.QuestionList.Add(newqu);
                    }
                });

                #endregion
            }
            else
            {
                #region 随机

                List <tbQuestion> questionList = Etdb.GetAllList <tbQuestion>(Query.EQ("Status", 0));
                exam.QuestionRule.ForEach(p =>
                {
                    var newqulist = new List <tbQuestion>();
                    foreach (string s in p.QLevelStr.Split(';'))
                    {
                        newqulist.AddRange(
                            questionList.Where(
                                qu =>
                                p.QSort == qu.QuestionSortID && p.Qtype == qu.QuestionType &&
                                s.Split(':')[0].StringToInt32() == qu.QuestionLevel)
                            .ToList()
                            .RandomGetSome(s.Split(':')[1].StringToInt32()));
                    }
                    newqulist.ForEach(qu =>
                    {
                        var newqu = new MQuestion
                        {
                            QAnswerType     = qu.QuestionAnswer[0].AnswerType,
                            QType           = qu.QuestionType,
                            QuestionContent = qu.QuestionContent,
                            QuestionID      = qu._id,
                            QuestionLevel   = ((QuestionLevel)qu.QuestionLevel).ToString(),
                            QuestionOrder   = 0,
                            Score           = p.QScore,
                            UserAnswer      = "",
                            FillBlankCount  = qu.QuestionContent.Split(new[] { "()" }, StringSplitOptions.None).Count() - 1
                        };
                        qu.QuestionAnswer.OrderBy(o => o.Order)
                        .ToList()
                        .ForEach(pa => newqu.QuestionAnswer.Add(new MQuestionAnswer
                        {
                            AnswerContent = pa.Answer,
                            AnswerFlag    = pa.AnswerFlag,
                            AnswerType    = pa.AnswerType,
                            Order         = pa.Order,
                            QuID          = newqu.QuestionID,
                            QType         = newqu.QType
                        }));
                        qu.FileUpload.ForEach(pa => newqu.FileUpload.Add(new QuestionFile
                        {
                            _fileName = pa.FileName,
                            _fileType = pa.FileType,
                            _realName = pa.RealName
                        }));
                        exampaper.QuestionList.Add(newqu);
                    });
                });

                #endregion
            }
            //if (exampaper.ExampaperType == 1 || (examination._id > 0 && examination.RadomOrderFlag == 1))
            if (exampaper.ExampaperType == 1)
            {
                //排序
                int order = 1;
                foreach (string s in exam.QuestionTypeOrder.Split(','))
                {
                    exampaper.QuestionList.Where(p => p.QType == s.StringToInt32())
                    .ToList()
                    .RandomListOrder()
                    .ForEach(p =>
                    {
                        p.QuestionOrder = order;
                        order++;
                    });
                }
            }
            exampaper.QuestionList = exampaper.QuestionList.OrderBy(p => p.QuestionOrder).ToList();
        }