public static string TakeScore(ResStudentBlank test, KeyBlank key)
        {
            var score = 0;

            Dictionary <int, string> ResBlank = new Dictionary <int, string>();

            foreach (var x in key.Keys)
            {
                ResBlank.Add(x.Id, x.Answer);
            }

            foreach (var x in test.Ress)
            {
                if (ResBlank.ContainsKey(x.Id))
                {
                    var k = ResBlank[x.Id];

                    if (x.Answer == k && x.Option == "Sure")
                    {
                        score += 5;
                    }

                    else if (x.Answer == k && x.Option == "notSure")
                    {
                        score += 3;
                    }

                    else if (x.Answer != k && x.Option == "notSure")
                    {
                        score += 0;
                    }

                    else if (x.Answer != k && x.Option == "Sure")
                    {
                        score -= 3;
                    }
                }
            }
            ///ТУТ БУДЕТ ОЦЕНКА
            return(score.ToString());
        }
Exemple #2
0
        public static KeyBlank LoadFromXml(XElement Ques)
        {
            if (Ques != null)
            {
                var res = new KeyBlank();
                foreach (var ques in Ques.Elements())
                {
                    foreach (var que in ques.Elements())
                    {
                        res.Keys.Add(KeyStudent.LoadFromXml(que));
                    }
                }

                res.User = "******" + (string)Ques.Element("User").Attribute("f") + " "
                           + (string)Ques.Element("User").Attribute("i") + " "
                           + (string)Ques.Element("User").Attribute("o");

                return(res);
            }
            return(null);
        }
        public static ListModel Zzz(string[] f)
        {
            List <XElement> res = new List <XElement>();

            foreach (var item in f)
            {
                res.Add(XElement.Load(item));
            }
            Dictionary <String, Tuple <XElement, XElement> > TestKey = new Dictionary <string, Tuple <XElement, XElement> >();

            foreach (var x in res)
            {
                var rootName = x.Name.LocalName;
                var guid     = (string)x.Element("Guid");
                if (TestKey.ContainsKey(guid))
                {
                    var k = TestKey[guid];
                    if (k.Item1 != null && k.Item1.Name.LocalName == "Test")
                    {
                        TestKey[guid] = new Tuple <XElement, XElement>(k.Item1, x);
                    }
                    else
                    {
                        TestKey[guid] = new Tuple <XElement, XElement>(x, k.Item2);
                    }
                }
                else
                {
                    if (rootName == "Test")
                    {
                        TestKey.Add(guid, new Tuple <XElement, XElement>(x, null));
                    }
                    else
                    {
                        TestKey.Add(guid, new Tuple <XElement, XElement>(null, x));
                    }
                }
            }
            var ListModel = new ListModel();

            foreach (var resof in TestKey.Values)
            {
                var key  = KeyBlank.LoadFromXml(resof.Item2);
                var test = ResStudentBlank.LoadFromXml(resof.Item1);
                if (test == null)
                {
                    ListModel.Add(new ListItemModel()
                    {
                        KeyStudent = key.User
                    });
                }
                else if (key == null)
                {
                    ListModel.Add(new ListItemModel()
                    {
                        CheckStudent = test.User
                    });
                }
                else
                {
                    ListModel.Add(new ListItemModel()
                    {
                        CheckStudent = test.User,
                        KeyStudent   = key.User,
                        Score        = ListItemModel.TakeScore(test, key)
                    });
                }
            }

            return(ListModel);
        }