示例#1
0
        public void InsertRecoredData(ExamPageModel model, string name, string examguid)
        {
            var usercode  = "";
            int examid    = 0;
            var usersheet = Data.ExamUsersFromehr.Get_ExamUsersFromehr(new { EamilUsername = name });

            if (usersheet != null)
            {
                usercode = usersheet.UserCode;
            }
            var ee = Data.ExamScore.Get_All_ExamScore(new { CreateUser = usercode, ExamGuid = examguid });

            if (ee.Count() > 0)
            {
                examid = ee.FirstOrDefault().ExamID;
            }

            foreach (var item in model.VExamUserInfo.LExamViews)
            {
                var        RightMeno = string.Empty;
                var        IsRight   = false;
                ExamRecord record    = new ExamRecord();

                record.ExamID     = examid.ToString();
                record.TopicTitle = item.proName;
                if (item.TopicTitlePic != null)
                {
                    record.TopicTitlePicNum = item.TopicTitlePic;
                }
                record.TopicNum = Convert.ToInt32(item.TopicScore);
                record.Type     = item.type;
                record.Remark   = item.Remark;
                if (item.selectItem != null)
                {
                    foreach (var ss in item.selectItem)
                    {
                        var sr = "";
                        if (ss == "0")
                        {
                            sr = "A";
                        }
                        if (ss == "1")
                        {
                            sr = "B";
                        }
                        if (ss == "2")
                        {
                            sr = "C";
                        }
                        if (ss == "3")
                        {
                            sr = "D";
                        }
                        if (ss == "4")
                        {
                            sr = "E";
                        }

                        //选择的答案
                        record.WriteAnsower += sr + ';';
                    }
                }

                if (item.RightKey.Count() > 0)
                {
                    foreach (var sr in item.RightKey)
                    {
                        //选择的答案
                        record.CorrectAnsower += sr + ';';
                    }
                }
                var sss = item.RightKey.OrderBy(x => x).ToArray();
                if (item.LselectItem != null)
                {
                    var sl = item.LselectItem.OrderBy(x => x).ToArray();
                    //答错的情况把正确答案捞出
                    if (!Enumerable.SequenceEqual(sss, sl))
                    {
                        foreach (var ii in item.RightKey)
                        {
                            if (item.ansowerList.Where(x => x.ansowerflag == ii).Count() != 0)
                            {
                                RightMeno += item.ansowerList.Where(x => x.ansowerflag == ii).FirstOrDefault().ansower;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(RightMeno))
                    {
                        IsRight = true;
                    }
                }
                if (item.ansowerList != null && item.ansowerList.Count() > 0)
                {
                    for (int i = 0; i < item.ansowerList.Count();)
                    {
                        if (item.ansowerList[0] != null)
                        {
                            record.OptionA       = item.ansowerList[0].ansower;
                            record.OptionAPicNum = item.ansowerList[0].ansowerpic;
                        }

                        if (item.ansowerList[1] != null)
                        {
                            record.OptionB       = item.ansowerList[1].ansower;
                            record.OptionBPicNum = item.ansowerList[1].ansowerpic;
                        }
                        if (item.ansowerList.Count() >= 3)
                        {
                            if (item.ansowerList[2] != null)
                            {
                                record.OptionC       = item.ansowerList[2].ansower;
                                record.OptionCPicNum = item.ansowerList[2].ansowerpic;
                            }
                        }
                        if (item.ansowerList.Count() >= 4)
                        {
                            if (item.ansowerList[3] != null)
                            {
                                record.OptionD       = item.ansowerList[3].ansower;
                                record.OptionDPicNum = item.ansowerList[3].ansowerpic;
                            }
                        }
                        if (item.ansowerList.Count() >= 5)
                        {
                            if (item.ansowerList[4] != null)
                            {
                                record.OptionE       = item.ansowerList[4].ansower;
                                record.OptionEPicNum = item.ansowerList[4].ansowerpic;
                            }
                        }

                        i++;
                    }
                }

                record.IsRight    = IsRight;
                record.DaRemark   = RightMeno;
                record.CreateUser = model.VExamUserInfo.UserName;
                record.CreateDate = DateTime.Now;
                Data.ExamRecord.Insert_ExamRecord(record, null, new string[] { "ID" });
            }
        }
示例#2
0
        public string InsertScoreData(ExamPageModel model)
        {
            var id = "";

            if (model.VExamUserInfo.LExamViews.Count() > 0)
            {
                ExamScore sc = new ExamScore();
                sc.ExamType = model.VExamUserInfo.ExamType;

                sc.CreateDate    = DateTime.Now;
                sc.CreateUser    = model.VExamUserInfo.UserName;
                sc.IsTest        = model.VExamUserInfo.IsTest;
                sc.TatalTopicNum = model.VExamUserInfo.LExamViews.Count();
                sc.PassScore     = model.VExamUserInfo.PassScore;
                //+科目
                sc.ExamSubject = model.VExamUserInfo.ExamSubject;
                sc.IsQuestion  = model.VExamUserInfo.IsQuestion;

                int sd    = 0;
                int score = 0;

                if (sc.IsQuestion == true)
                {
                    sc.CorrectScore = 0;
                }
                else
                {
                    sc.TotalScore = model.VExamUserInfo.TotalScore;
                    foreach (var item in model.VExamUserInfo.LExamViews)
                    {
                        var ss = item.RightKey.OrderBy(x => x).ToArray();
                        if (item.LselectItem != null)
                        {
                            var sl = item.LselectItem.OrderBy(x => x).ToArray();
                            //答对题数CorrectNum

                            if (Enumerable.SequenceEqual(ss, sl))
                            {
                                sd++;
                                sc.CorrectNum = sd;
                                //答对分数CorrectScore
                                score += item.TopicScore;
                            }
                            else
                            {
                                foreach (var ii in item.RightKey)
                                {
                                    if (item.ansowerList.Where(x => x.ansowerflag == ii).Count() != 0)
                                    {
                                        Remark += item.ansowerList.Where(x => x.ansowerflag == ii).FirstOrDefault().ansower;
                                    }
                                }
                            }
                        }
                    }

                    if (sc.CorrectNum == null)
                    {
                        sc.CorrectNum = 0;
                    }
                    sc.CorrectScore = score;
                }

                var guid = Guid.NewGuid();
                sc.ExamGuid = guid.ToString();
                id          = sc.ExamGuid;


                Data.ExamScore.Insert_ExamScore(sc, null, new string[] { "ExamID" });


                if (model.VExamUserInfo.IsTest == false)
                {
                    //根据人员,科目,ExamStatus更新分数,时间,isexam
                    ListExamUserDetailInfo = Data.ExamUserDetailInfo.Get_All_ExamUserDetailInfo(new { UserCode = model.VExamUserInfo.UserName, SubjectName = model.VExamUserInfo.ExamSubject, ExamStatus = "HrCheck" });
                    if (ListExamUserDetailInfo.Count() > 0 && ListExamUserDetailInfo != null)
                    {
                        foreach (var item in ListExamUserDetailInfo)
                        {
                            item.ExamScore    = score;
                            item.UserExamDate = DateTime.Now;
                            if (model.VExamUserInfo.IsTest == true)
                            {
                                item.IsExam = "false";
                            }
                            else
                            {
                                item.IsExam = "true";
                            }
                            Data.ExamUserDetailInfo.Update_ExamUserDetailInfo(item, null, new string[] { "ID" });
                        }
                    }
                }
            }

            return(id);
        }