示例#1
0
        private void submit()
        {
            int index = uc_question_bottom.CurrentIndex;
            var b     = uc_question.JudgeAnswer();

            if (b != null)
            {
                var           arr = uc_question.Answer;
                string        str = string.Join(",", arr);
                question_data qd  = _questions[index];
                Answer_Data   ad  = new Answer_Data
                {
                    qid    = qd.qid,
                    select = str,
                    type   = qd.type,
                };
                if (!_answer_List.ContainsKey(index))
                {
                    _answer_List.Add(index, ad);
                }
                else
                {
                    _answer_List[index] = ad;
                }
                uc_question_bottom.SetColor(index, (bool)b);
                if (index > _max_index)
                {
                    _max_index = index;
                }
            }
            List <Answer_Data> adlist = new List <Answer_Data>();

            foreach (var kv in _answer_List)
            {
                adlist.Add(kv.Value);
            }
            var json  = JsonConvert.SerializeObject(adlist);
            var param = new
            {
                token  = Config.Token,
                phone  = Config.Phone,
                cid    = _gid,//_cate_id,
                answer = json,
                sign   = _max_index,
            };
            var re = HttpHelper.Post(Config.Server + "/record/mark", param);

            b = HttpHelper.IsOk(re);
            if (b == true)
            {
                var data = re["data"];
                //string msg = string.Format("总分:{0}\r\n总得分:{1}\r\n答对题数:{2}\r\n答错题数:{3}\r\n已做题总数:{4}\r\n试卷总题数:{5}\r\n未做题数:{6}\r\n正确率:{7}\r\n", data["max"], data["mark"], data["success"], data["error"], data["all"], data["num"], data["done"], data["CorrectRate"]);
                //MessageBox.Show(msg);
                frmMain.ShowResult(data, _questions, _gid);
            }
            else if (b == null)
            {
                frmMain.ShowLogin(callBack_submit);
            }
        }
示例#2
0
        private void uc_question_bottom_Select_Event(int index, int next)
        {
            var b = uc_question.JudgeAnswer();

            if (b != null)
            {
                var           arr = uc_question.Answer;
                string        str = string.Join(",", arr);
                question_data qd  = _questions[index];
                Answer_Data   ad  = new Answer_Data
                {
                    qid    = qd.qid,
                    select = str,
                    type   = qd.type,
                };
                if (!_answer_List.ContainsKey(index))
                {
                    _answer_List.Add(index, ad);
                }
                else
                {
                    _answer_List[index] = ad;
                }
                uc_question_bottom.SetColor(index, (bool)b);
                uc_question_bottom.SetText(_answer_List.Count, _questions.Count - _answer_List.Count);
                if (index > _max_index)
                {
                    _max_index = index;
                }
            }
            showQuestion(next);
        }