Esempio n. 1
0
            protected override ActionResult DoTask(string data)
            {
                QuestionLinkTypeEnum linkType = (QuestionLinkTypeEnum)int.Parse(Request.QueryString["style"]);
                int linkId = 0;
                string[] blocks = StringUtility.Split(data, "%22");
                for (int i = 0; i < blocks.Length; i++)
                {
                    string block = blocks[i];
                    string[] param = StringUtility.Split(block, "%27");
                    if (i == 0)
                    {
                        string shortDesc = Escape.JsUnEscape(param[0]);
                        int diff = int.Parse(Escape.JsUnEscape(param[2]));
                        string content = Escape.JsUnEscape(param[3]);
                        string attached = Escape.JsUnEscape(param[4]);

                        QuestionEntity linkEntity = new QuestionEntity();
                        linkEntity.QuestionLinkType = linkType;
                        linkEntity.QuestionLinkContent = content;
                        linkEntity.QuestionLinkDifficulty = diff;
                        linkEntity.QuestionLinkShortDescription = shortDesc;
                        linkEntity.QuestionLinkAttachedInfo = attached;
                        linkEntity.Save();
                        linkId = linkEntity.QuestionLinkId;
                    }
                    else
                    {
                        string shortDesc = Escape.JsUnEscape(param[0]);
                        int score = int.Parse(Escape.JsUnEscape(param[1]));
                        int diff = int.Parse(Escape.JsUnEscape(param[2]));
                        string content = Escape.JsUnEscape(param[3]);
                        string item = Escape.JsUnEscape(param[4]);
                        string answer = Escape.JsUnEscape(param[5]);
                        DefaultTypeEnum defaultType = (DefaultTypeEnum)int.Parse(Escape.JsUnEscape(param[6]));
                        if (score == 0)
                        {
                            DefaultEntity defaultEntity = new DefaultEntity();
                            defaultEntity.DefaultType = defaultType;
                            defaultEntity.Fill();
                            score = defaultEntity.DefaultScore;
                            if (score == 0)
                            {
                                switch (defaultType)
                                {
                                    case DefaultTypeEnum.SingleSelect:
                                        score = 2;
                                        break;
                                    case DefaultTypeEnum.MultiSelect:
                                        score = 4;
                                        break;
                                    case DefaultTypeEnum.JudgeSelect:
                                        score = 1;
                                        break;
                                }
                            }
                        }
                        QuestionEntity entity = new QuestionEntity();
                        entity.QuestionType = QuestionEntity.ConvertDefaultTypeToQuestionType(defaultType);
                        entity.QuestionLinkId = linkId;
                        entity.QuestionContent = content;
                        entity.QuestionDifficulty = diff;
                        entity.QuestionAnswer = answer;
                        entity.QuestionScore = score;
                        entity.QuestionShortDescription = shortDesc;
                        entity.QuestionItem = item;
                        entity.QuestionLinkType = QuestionLinkTypeEnum.Nothing;
                        entity.Save();
                    }
                }
                QuestionCollection collection = new QuestionCollection();
                collection.PageSize = 8;
                collection.AbsolutePage = 1;
                collection.IsReturnDataTable = true;
                collection.Fill();
                ActionResult result = new ActionResult();
                result.IsSuccess = true;
                StringBuilder response = new StringBuilder();
                response.Append(ActionTaskUtility.ReturnClientDataArray(collection.GetFillDataTable()));
                response.Append(string.Format("TmpStr={0};", collection.PageCount));
                result.ResponseData = response.ToString();
                return result;
            }
Esempio n. 2
0
            protected override ActionResult DoTask(string data)
            {
                string[] param = StringUtility.Split(data, "%27");
                int historyId = Convert.ToInt32(Request.QueryString["history"]);
                int score = 0;
                int singscore = 0;
                int multiscore = 0;
                int julgscore = 0;

                DefaultEntity defaultEntity = new DefaultEntity();
                defaultEntity.DefaultType = DefaultTypeEnum.SingleSelect;
                defaultEntity.Fill();
                singscore = defaultEntity.DefaultScore;

                defaultEntity.DefaultType = DefaultTypeEnum.MultiSelect;
                defaultEntity.Fill();
                multiscore = defaultEntity.DefaultScore;

                defaultEntity.DefaultType = DefaultTypeEnum.JudgeSelect;
                defaultEntity.Fill();
                julgscore = defaultEntity.DefaultScore;

                foreach (string val in param)
                {
                    string txt = (val ?? string.Empty).Trim();
                    if (string.IsNullOrEmpty(txt))
                        continue;
                    string[] idandanswer = StringUtility.Split(txt, "%22");
                    QuestionEntity entity = new QuestionEntity();
                    entity.QuestionId = Convert.ToInt32(Escape.JsUnEscape(idandanswer[0]));
                    entity.Fill();
                    int itemScore = 0;
                    if (entity.QuestionAnswer.Equals(Escape.JsUnEscape(idandanswer[1])))
                        itemScore = entity.QuestionScore;
                    if (itemScore == 0)
                    {
                        switch (entity.QuestionType)
                        {
                            case QuestionTypeEnum.SingleSelect:
                                itemScore = singscore;
                                break;
                            case QuestionTypeEnum.JudgeSelect:
                                itemScore = julgscore;
                                break;
                            case QuestionTypeEnum.MultiSelect:
                                itemScore = multiscore;
                                break;
                        }
                    }
                    score = score + itemScore;
                }
                HistoryEntity history = new HistoryEntity();
                history.HistoryId = historyId;
                history.Fill();
                history.HistoryEndTime = DateTime.Now;
                history.HistoryScore = score;
                history.Save();

                ActionResult result = new ActionResult();
                result.IsSuccess = true;
                StringBuilder response = new StringBuilder();
                response.Append(string.Format("TmpStr='{0}';", score));
                result.ResponseData = response.ToString();
                return result;
            }