示例#1
0
        public async Task <IActionResult> SetAnswerScore()
        {
            int           id         = Request.Form["id"].TryToInt(0);
            double        score      = Request.Form["score"].TryToDouble();
            UserAnswerBll bll        = new UserAnswerBll();
            var           userAnswer = await bll.GetByIdAsync(id);

            if (userAnswer != null)
            {
                userAnswer.Score = score;
                bool flag = await bll.UpdateAsync(userAnswer);

                UserAnswerLogBll userAnswerLogBll = new UserAnswerLogBll();
                var log = await userAnswerLogBll.GetById(userAnswer.LogId);

                if (log != null)
                {
                    log.TotalScore = log.TotalScore + score;
                    await userAnswerLogBll.UpdateAsync(log);
                }

                if (flag)
                {
                    return(Json(new { code = 1, msg = "OK" }));
                }
            }

            return(Json(new { code = 0, msg = "更新失败" }));
        }
示例#2
0
        private void frmStartExam_FormClosing(object sender, FormClosingEventArgs e)
        {
            string date = DateTime.Now.Date.ToString();

            foreach (KeyValuePair <string, UserAnswer> a in ua)
            {
                a.Value.ExamTime = date;
            }
            UserAnswerBll.AddUserAnswer(ua);
        }
示例#3
0
 private void frmUserPaper_Load(object sender, EventArgs e)
 {
     answer                   = UserAnswerBll.GetUserAnswer(UserID, Date, PaperID);
     lblPaper.Text            = answer.PaperName;
     lblTime.Text             = answer.ExamTime;
     txtSingleProblem.Text    = answer.SingleProblem.ToString();
     txtMultiProblem.Text     = answer.MultiProblem.ToString();
     txtJudgeProblem.Text     = answer.JudgeProblem.ToString();
     txtFillBlankProblem.Text = answer.FillBlankProblem.ToString();
     dataGridView1.DataSource = UserAnswerBll.QuestionFillDs(UserID, Date, PaperID).Tables[0];
     getcolumn();
 }
示例#4
0
        /// <summary>
        /// 用户答题详情
        /// </summary>
        /// <param name="logId"></param>
        /// <returns></returns>
        public async Task <IActionResult> UserAnswerLogInfo(int logId)
        {
            UserQuestionsBll bll = new UserQuestionsBll();
            var userQuestionses  = await bll.GetList(logId);

            UserAnswerBll userAnswerBll = new UserAnswerBll();
            var           userAnswers   = await userAnswerBll.GetList(logId);

            List <Questions> questionses  = new List <Questions>();
            List <Option>    options      = new List <Option>();
            OptionBll        optionBll    = new OptionBll();
            QuestionsBll     questionsBll = new QuestionsBll();

            if (userQuestionses != null)
            {
                foreach (UserQuestions userQuestionse in userQuestionses)
                {
                    var info = await questionsBll.GetByIdAsync(userQuestionse.QuestionsId);

                    if (info != null)
                    {
                        questionses.Add(info);
                    }

                    var optionlist = await optionBll.GetList(userQuestionse.QuestionsId);

                    if (optionlist != null)
                    {
                        options.AddRange(optionlist);
                    }
                }
            }

            userQuestionses = userQuestionses.OrderBy(x => x.QIndex).ToList();

            ViewBag.questionses = questionses;
            ViewBag.options     = options;
            ViewBag.userAnswers = userAnswers;

            ViewBag.isadmin = User.RoleID == 1;
            return(View(userQuestionses));
        }
示例#5
0
 private void tsbtnDel_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentCell != null)
     {
         if (MessageBox.Show("是否删除记录", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             try
             {
                 UserAnswerBll.UserAnswerDelete(dataGridView1.CurrentRow.Cells[1].Value.ToString(), dataGridView1.CurrentRow.Cells[2].ToString());
                 dataGridView1.DataSource = UserAnswerBll.UserAnswerFillDs().Tables[0];
                 getcolumn();
                 MessageBox.Show("删除成功!");
             }
             catch (Exception ee)
             {
                 MessageBox.Show("删除失败!" + ee);
                 throw;
             }
         }
     }
 }
示例#6
0
 private void frmUserPaperList_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource         = UserAnswerBll.UserAnswerFillDs().Tables[0];
     dataGridView1.Columns[3].Visible = false;
     getcolumn();
 }
示例#7
0
 private void frmUserPaper_FormClosing(object sender, FormClosingEventArgs e)
 {
     UserAnswerBll.QuestionDrop();
 }
示例#8
0
 /// <summary>
 /// 统计简答题总分
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnQuestionSum_Click(object sender, EventArgs e)
 {
     txtQuestion.Text = UserAnswerBll.QuestionSum().ToString();
     txtSum.Text      = (Convert.ToInt32(txtSingleProblem.Text) + Convert.ToInt32(txtMultiProblem.Text) + Convert.ToInt32(txtJudgeProblem.Text) + Convert.ToInt32(txtFillBlankProblem.Text) + Convert.ToInt32(txtQuestion.Text)).ToString();
 }
示例#9
0
        public async Task <IActionResult> SaveUserAnswer()
        {
            UserAnswer userAnswer = new UserAnswer()
            {
                LogId      = Request.Form["LogId"].TryToInt(0),
                QuestionId = Request.Form["QuestionId"].TryToInt(0),
            };
            UserAnswerBll bll      = new UserAnswerBll();
            string        qtype    = Request.Form["qtype"].TryToString();
            string        OptionId = Request.Form["OptionIds"].TryToString();
            string        Content  = Request.Form["Content"].TryToString();
            int           isend    = Request.Form["isend"].TryToInt(0);

            OptionBll optionBll = new OptionBll();
            var       options   = await optionBll.GetList(userAnswer.QuestionId);

            int uid = 0;

            switch (qtype)
            {
            case "ChoiceMore":
                double oklength = 1;
                var    oklist   = options.Where(x => x.IsOk);
                if (oklist != null && oklist.Count() > 0)
                {
                    oklength = oklist.Count();
                }
                double scoreRat = 1 / oklength;
                var    ids      = OptionId.Split('|', StringSplitOptions.RemoveEmptyEntries);
                if (ids != null && ids.Length > 0)
                {
                    foreach (string id in ids)
                    {
                        userAnswer.OptionId = id.TryToInt();
                        userAnswer.Score    = 0;
                        if (options != null)
                        {
                            var option = options.FirstOrDefault(x => x.Id == userAnswer.OptionId);
                            if (option != null)
                            {
                                userAnswer.IsOk = option.IsOk;
                                if (option.IsOk)
                                {
                                    userAnswer.Score = scoreRat;
                                }
                            }
                        }

                        userAnswer.Id = 0;
                        uid           = await bll.AddAsync(userAnswer);
                    }
                }
                break;

            case "ChoiceOne":
                userAnswer.OptionId = OptionId.TryToInt();
                userAnswer.Score    = 0;
                var opti = options?.FirstOrDefault(x => x.Id == userAnswer.OptionId);
                if (opti != null)
                {
                    userAnswer.IsOk = opti.IsOk;
                    if (opti.IsOk)
                    {
                        userAnswer.Score = 1;
                    }
                }
                uid = await bll.AddAsync(userAnswer);

                break;

            case "FillInTheBlanks":
                userAnswer.Content = Content;
                uid = await bll.AddAsync(userAnswer);

                break;
            }

            if (isend == 1)
            {
                var ualist = await bll.GetList(userAnswer.LogId);

                var scores             = ualist.Select(x => x.Score);
                UserAnswerLogBll ulbll = new UserAnswerLogBll();
                var log = await ulbll.GetById(userAnswer.LogId);

                if (log != null)
                {
                    log.TotalScore = scores.Sum();
                    log.Duration   = (DateTime.Now - log.CreateTime).TotalMinutes;
                    await ulbll.UpdateAsync(log);
                }
            }
            return(uid > 0 ? Json(new { code = 1, msg = "Ok" }) : Json(new { code = 0, msg = "保存失败" }));
        }