Ejemplo n.º 1
0
        /// <summary>
        /// 查询当前点击的完型填空信息
        /// </summary>
        /// <param name="item">AssessmentItemID</param>
        /// <returns>当前点击的完型填空信息</returns>
        ClozePart ICedts_AssignRepository.SelectCloze(Guid item)
        {
            var Assigns = (from As in db.CEDTS_Assign where As.AssessmentItemID == item orderby As.Time descending select As.QuestionID).FirstOrDefault();

            if (Assigns == null)
            {
                return(null);
            }
            else
            {
                string[]    Assign    = Assigns.Split(',');
                var         question1 = (from m in db.CEDTS_Question where m.AssessmentItemID == item orderby m.Order ascending select m).ToList();
                var         question  = (from m in db.CEDTS_Question where m.AssessmentItemID == item orderby m.Order ascending select m).ToList();
                var         assess    = (from m in db.CEDTS_AssessmentItem where m.AssessmentItemID == item select m).First();
                List <Guid> QID       = new List <Guid>();
                int         Count     = 0;
                for (int s = 0; s < Assign.Length; s++)
                {
                    QID.Add(Guid.Parse(Assign[s]));
                }

                foreach (var q in question1)
                {
                    if (!QID.Contains(q.QuestionID))
                    {
                        question.Remove(q);
                        if (Count == 0)
                        {
                            Count = assess.QuestionCount.Value - 1;
                        }
                        else
                        {
                            Count = Count - 1;
                        }
                    }
                }
                if (Count == 0)
                {
                    Count = assess.QuestionCount.Value;
                }
                var Itemtype = (from m in db.CEDTS_ItemType where m.ItemTypeID == assess.ItemTypeID select m).First();
                var PartType = (from m in db.CEDTS_PartType where m.PartTypeID == Itemtype.PartTypeID select m).First();

                ItemBassInfo info  = new ItemBassInfo();
                ClozePart    Cloze = new ClozePart();
                info.AnswerValue       = new List <string>();
                info.Tip               = new List <string>();
                info.QuestionID        = new List <Guid>();
                info.DifficultQuestion = new List <double>();
                info.ScoreQuestion     = new List <double>();

                info.Knowledge     = new List <string>();
                info.KnowledgeID   = new List <string>();
                Cloze.Choices      = new List <string>();
                info.TimeQuestion  = new List <double>();
                info.ItemID        = item;
                info.Count         = Convert.ToInt32(assess.Count);
                info.ItemType      = Itemtype.TypeName;
                info.ItemType_CN   = Itemtype.TypeName_CN;
                info.PartType      = PartType.TypeName;
                info.QuestionCount = Convert.ToInt32(question.Count);
                info.ReplyTime     = Convert.ToInt32(assess.Duration);
                info.Diffcult      = Convert.ToDouble(assess.Difficult);
                info.Score         = Convert.ToInt32(assess.Score);

                Cloze.Content = assess.Original;

                string QkID = null;
                foreach (var qu in question)
                {
                    var QkList = (from m in db.CEDTS_QuestionKnowledge where m.QuestionID == qu.QuestionID orderby m.Weight ascending select m.QuestionKnowledgeID).ToList();
                    foreach (var q in QkList)
                    {
                        QkID += q + ",";
                    }
                }
                QkID = QkID.Substring(0, QkID.LastIndexOf(","));
                info.QuestionKnowledgeID = QkID;

                foreach (var list in question)
                {
                    info.QuestionID.Add(list.QuestionID);
                    info.ScoreQuestion.Add(list.Score.Value);
                    info.TimeQuestion.Add(list.Duration.Value);
                    info.DifficultQuestion.Add(list.Difficult.Value);
                    Cloze.Choices.Add(list.ChooseA);
                    Cloze.Choices.Add(list.ChooseB);
                    Cloze.Choices.Add(list.ChooseC);
                    Cloze.Choices.Add(list.ChooseD);
                    info.AnswerValue.Add(list.Answer);
                    info.Tip.Add(list.Analyze);
                    string name = string.Empty;
                    string id   = string.Empty;


                    var KnowledgeList = (from m in db.CEDTS_QuestionKnowledge where m.QuestionID == list.QuestionID orderby m.Weight ascending select m.KnowledgePointID).ToList();
                    foreach (var Knowledge in KnowledgeList)
                    {
                        var KnowledgeName = (from m in db.CEDTS_KnowledgePoints where m.KnowledgePointID == Knowledge select m).FirstOrDefault();
                        id   += KnowledgeName.KnowledgePointID + ",";
                        name += KnowledgeName.Title + ",";
                    }
                    name = name.Substring(0, name.LastIndexOf(","));
                    id   = id.Substring(0, id.LastIndexOf(','));
                    info.KnowledgeID.Add(id);
                    info.Knowledge.Add(name);
                }
                Cloze.Info = info;
                return(Cloze);
            }
        }
        ClozePart ICedts_ItemXMLRepository.GetCp(string text, string type)
        {
            ClozePart    cp   = new ClozePart();
            ItemBassInfo info = new ItemBassInfo();

            doc = new XmlDocument();
            doc.LoadXml(text);
            node        = doc.SelectSingleNode("assessmentItem");//查找<assessmentItem>节点
            elem        = (XmlElement)node;
            info.ItemID = Guid.Parse(elem.GetAttribute("identifier"));
            info.Course = elem.GetAttribute("course");
            info.Unit   = elem.GetAttribute("unit");
            XmlNodeList nodeList = node.ChildNodes;//<assessmentItem>下的所有子节点

            info.QuestionCount     = nodeList.Count - 1;
            info.ItemType          = type;
            info.ItemType_CN       = "完型填空";
            info.PartType          = "4";
            info.AnswerResposn     = "_";
            info.QustionInterval   = "";
            info.QuestionID        = new List <Guid>();
            info.AnswerValue       = new List <string>();
            info.Tip               = new List <string>();
            info.Problem           = new List <string>();
            info.DifficultQuestion = new List <double>();
            info.ScoreQuestion     = new List <double>();
            info.TimeQuestion      = new List <double>();

            cp.Choices = new List <string>();

            info.Score     = 0.0;
            info.ReplyTime = 0.0;
            info.Diffcult  = 0.0;

            for (int i = 0; i < nodeList.Count; i++)
            {
                if (i == 0)
                {
                    XmlElement pElem = (XmlElement)nodeList[i];//prompt节点
                    int        a     = 0;
                    while (pElem.InnerXml.IndexOf("<tag type=\"choice\" />") > 0)
                    {
                        a++;
                        int index  = pElem.InnerXml.IndexOf("<tag type=\"choice\" />");
                        int length = "<tag type=\"choice\" />".Length;
                        pElem.InnerXml = pElem.InnerXml.Substring(0, index) + "(_" + a + "_)" + pElem.InnerXml.Substring(index + length);
                    }
                    cp.Content = pElem.InnerXml;
                    continue;
                }

                XmlNodeList qList = nodeList[i].ChildNodes;//question下的所有子节点

                for (int j = 0; j < qList.Count; j++)
                {
                    XmlElement pElem = (XmlElement)qList[j];

                    if (pElem.Name == "choice")
                    {
                        XmlNodeList optionList = qList[j].ChildNodes;
                        for (int k = 0; k < optionList.Count; k++)
                        {
                            XmlElement oElem = (XmlElement)optionList[k];
                            if (oElem.Name == "option")
                            {
                                cp.Choices.Add(oElem.InnerXml);
                            }
                        }
                    }

                    if (pElem.Name == "key")
                    {
                        string[] answers = { "A", "B", "C", "D" };
                        int      temp    = int.Parse(pElem.InnerXml) - 1;
                        info.AnswerValue.Add(answers[temp]);
                    }
                }

                info.Tip.Add("");
                info.Problem.Add("");
                info.ScoreQuestion.Add(0.5);
                info.Score += 0.5;
                info.TimeQuestion.Add(0.75);
                info.ReplyTime += 0.75;
                info.DifficultQuestion.Add(0.4);
                info.Diffcult += 0.4;
            }

            info.Diffcult = info.Diffcult / info.QuestionCount;
            cp.Info       = info;

            return(cp);
        }