Ejemplo n.º 1
0
        /// <summary>
        /// 核对岗位是否通过
        /// </summary>
        /// <param name="productID"></param>
        /// <returns></returns>
        public static void CheckPostPass(int userID, int productID)
        {
            string      companyPostID = CookiesHelper.ReadCookieValue("UserCompanyPostSetting");
            ProductInfo product       = ProductBLL.ReadProduct(productID);

            //如果本次通过的是综合考试,就更新通过岗位的记录状态
            if (StringHelper.CompareSingleString(product.ClassID, "4387", '|'))
            {
                PostPassInfo PostPassModel = new PostPassInfo();
                PostPassModel.UserId = userID;
                PostPassModel.PostId = RenZhengCateBLL.ReadTestCateByID(productID, companyPostID).PostId;
                PostPassModel.IsRZ   = 1;
                PostPassBLL.UpdateIsRZ(PostPassModel);
            }
            else
            {
                //读取和本课程关联的岗位
                List <PostInfo> RelatedPostList = PostBLL.FilterPostListByCourseID(productID);
                if (RelatedPostList != null)
                {
                    //统计通过的课程ID
                    string PassCateId     = TestPaperBLL.ReadCourseIDStr(TestPaperBLL.ReadList(userID, DateTime.Now.AddDays(1), 1));
                    string companyBrandID = CookiesHelper.ReadCookieValue("UserCompanyBrandID");
                    foreach (PostInfo Item in RelatedPostList)
                    {
                        //去除非公司设定的岗位
                        if (StringHelper.CompareSingleString(companyPostID, Item.PostId.ToString()))
                        {
                            string postCourseID = PostBLL.ReadPostCourseID(Item.PostId, companyBrandID);
                            if (string.IsNullOrEmpty(StringHelper.SubString(postCourseID, PassCateId)))
                            {
                                PostPassInfo PostPassModel = PostPassBLL.ReadPostPassInfo(userID, Item.PostId);
                                if (PostPassModel.Id <= 0)
                                {
                                    PostPassModel.UserId   = userID;
                                    PostPassModel.PostId   = Item.PostId;
                                    PostPassModel.PostName = Item.PostName;
                                    if (Item.PostId == 220) //钣金喷漆岗位直接发证书
                                    {
                                        PostPassModel.IsRZ = 1;
                                    }
                                    else
                                    {
                                        PostPassModel.IsRZ = 0;
                                    }
                                    PostPassBLL.AddPostPassInfo(PostPassModel);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 计算考试成绩
        /// </summary>
        /// <returns></returns>
        public static TestPaperInfo CalcTestResult(int companyID, int userID, int productID)
        {
            TestPaperInfo       PaperModel  = new TestPaperInfo();
            string              filePath    = ReadTestPaperPath(userID, productID);
            TestPaperReportInfo testPaper   = ReadTheLatestPaper(userID, productID);
            TestSettingInfo     testSetting = TestSettingBLL.ReadTestSetting(companyID, productID);

            if (File.Exists(filePath) && (testPaper.TestDate == DateTime.MinValue || (DateTime.Now - testPaper.TestDate).TotalHours >= testSetting.TestInterval))
            {
                XmlHelper XmlDoc = new XmlHelper(filePath);

                int QuestionNum = int.Parse(XmlDoc.ReadAttribute("TestPaper", "QuestionNum"));

                decimal Scorse   = 0; //试卷得分
                int     RightNum = 0; //正确的题目数量

                //从xml里读取答案,进行校卷
                string QuestionList   = string.Empty;
                string UserAnswerList = string.Empty;
                for (int StyleId = 1; StyleId <= 3; StyleId++)
                {
                    string NodeName = GetTestPaperStyleNodeName(StyleId);
                    //判断题型库里是否有考题
                    XmlNode Node = XmlDoc.ReadNode(NodeName);
                    if (Node != null && Node.HasChildNodes)
                    {
                        XmlNodeList NodeList = XmlDoc.ReadChildNodes(NodeName);
                        //遍历节点
                        foreach (XmlNode node in NodeList)
                        {
                            QuestionList   = QuestionList + "," + node.ChildNodes[9].InnerText;
                            UserAnswerList = UserAnswerList + "," + node.ChildNodes[6].InnerText;
                            if (node.ChildNodes[6].InnerText.ToLower() == node.ChildNodes[5].InnerText.ToLower())
                            {
                                RightNum = RightNum + 1;
                            }
                        }
                    }
                }

                //UserInfo user = UserBLL.ReadUser(userID);
                //TestSettingInfo testSetting = TestSettingBLL.ReadTestSetting(companyID, productID);
                if (QuestionNum == 0)
                {
                    Scorse = 0;
                }
                else
                {
                    Scorse = Convert.ToDecimal(Math.Round((decimal.Parse(testSetting.PaperScore.ToString()) * RightNum / QuestionNum), 1));//这样计算的总分更准备
                }
                if (QuestionList != string.Empty && QuestionList.StartsWith(","))
                {
                    QuestionList   = QuestionList.Substring(1);
                    UserAnswerList = UserAnswerList.Substring(1);
                }

                PaperModel.CateId     = productID;
                PaperModel.PaperName  = ProductBLL.ReadProduct(productID).Name;
                PaperModel.CompanyId  = companyID;
                PaperModel.UserId     = userID;
                PaperModel.QuestionId = QuestionList;
                PaperModel.Answer     = UserAnswerList;
                PaperModel.Scorse     = Scorse;
                if (Scorse >= testSetting.LowScore)
                {
                    PaperModel.Point  = 2;
                    PaperModel.IsPass = 1;
                }
                else
                {
                    PaperModel.IsPass = 0;
                }

                UserLogBLL.AddUserLog(ShopLanguage.ReadLanguage("ApplyTest"), ShopLanguage.ReadLanguage("TestPaper"), ProductBLL.ReadProduct(productID).Name);
                TestPaperBLL.AddPaper(PaperModel);
                File.SetLastWriteTime(filePath, DateTime.Now);
            }
            if ((testPaper.TestDate > DateTime.MinValue && (DateTime.Now - testPaper.TestDate).TotalHours < testSetting.TestInterval))
            {
                PaperModel.Scorse = testPaper.Score;
            }

            //解除本课程的考试限制
            //TestSettingBLL.TestEnd(userID, productID);

            return(PaperModel);
        }