Пример #1
0
        public ActionResult Answer(int notificationReadId)
        {
            var opera = _notificationQASystemContract.GetQuestion(notificationReadId, AuthorityHelper.OperatorId ?? 0);

            var    questionList = new List <NotificationQuestion>();
            string Ids          = "";
            string htmlStr      = "";

            if (opera.ResultType == OperationResultType.Success)
            {
                questionList = opera.Data as List <NotificationQuestion>;

                #region 初始化消息对应问题html代码
                int i = 0;

                questionList.Each(q =>
                {
                    htmlStr += "<div id=\"" + q.GuidId + "\"><div class=\"form-group\" ><label class=\"control-label col-md-3\">问题" + (i + 1) + " :</label><div class=\"col-md-7\"><label id=\"" + q.GuidId + "_QContent\">" + q.Content + "</label>";

                    htmlStr += "</div></div>";

                    int j = 0;
                    switch (q.QuestionType)
                    {
                    case (int)QuestionTypeFlag.Choice:
                        q.AnsweringsList.Each(a =>
                        {
                            htmlStr += "<div class=\"form-group\" ><label class=\"control-label col-md-3\">" + a.Number + "、 </label><div class=\"col-md-7\">" + a.Content + "&nbsp:&nbsp:&nbsp:&nbsp:<input type=\"checkbox\" onclick=\"Answer('" + q.GuidId + "','" + a.GuidId + "')\" class=\"form-control\" /></div></div>";
                        });
                        break;

                    case (int)QuestionTypeFlag.FillIn:
                        q.AnsweringsList.Each(a =>
                        {
                            htmlStr += "<div class=\"form-group\" ><label class=\"control-label col-md-3\">答: </label><div class=\"col-md-7\"><input type='text' value='' onblur=\"Answer('" + q.GuidId + "',$(this).val())\" /></div></div>";
                        });
                        break;

                    case (int)QuestionTypeFlag.Judgment:
                        q.AnsweringsList.Each(a =>
                        {
                            htmlStr += "<div class=\"form-group\" ><label class=\"control-label col-md-3\">答: </label><div class=\"col-md-7\"><input type=\"radio\" value='1' name='" + q.GuidId + "_Judge' onclick=\"Answer('" + q.GuidId + "','1')\"  />对 <input type=\"radio\" value='1' name='" + q.GuidId + "_Judge' onclick=\"Answer('" + q.GuidId + "','0')\"  />错 </div></div>";
                        });
                        break;
                    }

                    htmlStr += "</div>";

                    Ids += q.GuidId + ",";
                    i++;
                });
            }
            Ids                        = Ids.TrimEnd(',');
            ViewBag.htmlStr            = htmlStr;
            ViewBag.Ids                = Ids;
            ViewBag.NotificationReadId = notificationReadId;
            #endregion

            return(PartialView());
        }
Пример #2
0
        /// <summary>
        /// 获取要回答的题目
        /// </summary>
        /// <param name="notificationReadId"></param>
        /// <param name="adminId"></param>
        /// <returns></returns>
        public JsonResult GetQuestion(int notificationReadId, int adminId)
        {
            var opera = _notificationQASystemContract.GetQuestion(notificationReadId, adminId <= 0 ? AuthorityHelper.OperatorId ?? 0 : adminId);

            if (opera.Data != null)
            {
                opera.Data = (opera.Data as List <NotificationQuestion>).Select(q => new
                {
                    q.Id,
                    q.GuidId,
                    q.QuestionType,
                    q.Content,
                    q.NotificationId,
                    AnsweringList = q.AnsweringsList == null ? new List <Answering>() : q.AnsweringsList.Select(a => new Answering
                    {
                        Id      = a.Id,
                        GuidId  = a.GuidId,
                        QGuidId = a.GuidId,
                        Number  = a.Number,
                        Content = q.QuestionType == (int)QuestionTypeFlag.Choice ? a.Content : ""
                    })
                });
            }
            return(Json(opera, JsonRequestBehavior.AllowGet));
        }