Exemple #1
0
        private void AnswerSet(int productID, int styleID, int questionID, string userAnswer)
        {
            XmlHelper   xmldoc   = new XmlHelper(TestPaperBLL.ReadTestPaperPath(base.UserID, productID));
            XmlNodeList NodeList = xmldoc.ReadChildNodes(TestPaperBLL.GetTestPaperStyleNodeName(styleID));

            if (NodeList != null)
            {
                foreach (XmlNode node in NodeList)
                {
                    if (node.Attributes["id"].Value == questionID.ToString())
                    {
                        node.ChildNodes[6].InnerText = userAnswer;
                    }
                }
            }
            xmldoc.Save();
        }
Exemple #2
0
        /// <summary>
        /// 在线试卷总信息,每次从Xml取出后重构。
        /// <para value=CateId></para>
        /// </summary>
        private Dictionary <string, object> GetQuestionsList()
        {
            int       productID = RequestHelper.GetForm <int>("CateID");
            string    filePath  = TestPaperBLL.ReadTestPaperPath(base.UserID, productID);
            XmlHelper XmlDoc    = new XmlHelper(filePath);
            Dictionary <string, object> testPaper = new Dictionary <string, object>();

            testPaper.Add("CateId", XmlDoc.ReadAttribute("TestPaper", "CateId"));
            testPaper.Add("QuestionNum", XmlDoc.ReadAttribute("TestPaper", "QuestionNum"));
            testPaper.Add("QuestionsStyle", "[{\"StyleName\":\"单项选择题\",\"StyleId\":1,\"QuestionsNum\":" + XmlDoc.ReadAttribute("TestPaper", "SingleNum") + "},{\"StyleName\":\"多项选择题\",\"StyleId\":2,\"QuestionsNum\":" + XmlDoc.ReadAttribute("TestPaper", "MultiNum") + "},{\"StyleName\":\"判断题\",\"StyleId\":3,\"QuestionsNum\":" + XmlDoc.ReadAttribute("TestPaper", "PanDunNum") + "}]");

            List <QuestionJsonInfo> questionList = new List <QuestionJsonInfo>();

            for (int styleID = 1; styleID <= 3; styleID++)
            {
                string NodeName = TestPaperBLL.GetTestPaperStyleNodeName(styleID);
                //判断题型库里是否有考题
                XmlNode Node = XmlDoc.ReadNode(NodeName);
                if (Node != null && Node.HasChildNodes)
                {
                    XmlNodeList NodeList = XmlDoc.ReadChildNodes(NodeName);

                    int id = 0;
                    //遍历节点
                    foreach (XmlNode node in NodeList)
                    {
                        id++;
                        questionList.Add(this.GetQuestions(node.ChildNodes, id));
                    }
                }
            }

            testPaper.Add("QuestionsList", questionList);

            return(testPaper);
        }