Ejemplo n.º 1
0
        /// <summary>
        /// Parses the specified criteria catalog at the given path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static List<Category> Parse(string path)
        {

            List<Category> categories = new List<Category>();
            Dictionary<String, Category> catDict = new Dictionary<string, Category>();

            if (!System.IO.File.Exists(path)) return categories;

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(path);

                XmlNodeList nodes = xDoc.DocumentElement.SelectNodes("category");


                foreach (XmlNode node in nodes)
                {
                    if (node == null) continue;
                    Category ca = new Category();
                    List<Criterion> crlist = new List<Criterion>();
                    XmlNodeList criterions = node.SelectNodes("criterion");

                    foreach (XmlNode node2 in criterions)
                    {
                        if (node2 == null) continue;

                        Recommendation rec = new Recommendation();

                        var helpNode7 = node2.SelectSingleNode("recommendation");
                        if (helpNode7 != null)
                        {
                            var helpNode8 = helpNode7.Attributes["type"];
                            CriterionType type = CriterionType.unknown;
                            if (helpNode8 != null)
                            {
                                try
                                {
                                    if (Enum.IsDefined(typeof(CriterionType), helpNode8.Value))
                                    {
                                        type = (CriterionType)Enum.Parse(typeof(CriterionType), helpNode8.Value);

                                    }
                                }
                                catch { }
                                rec.Type = type;
                            }
                        }
                        Criterion cr = new Criterion(rec);

                        var helpNode = node2.SelectSingleNode("help");
                        if (helpNode != null)
                        {
                            cr.Help = helpNode.InnerText;
                        }

                        var helpNode2 = node2.Attributes["name"];
                        if (helpNode2 != null)
                        {
                            cr.Name = helpNode2.Value;
                        }

                        var helpNode3 = node2.Attributes["id"];
                        if (helpNode3 != null)
                        {
                            cr.Id = helpNode3.Value;
                        }

                        var helpNode4 = node2.Attributes["mode"];
                        if (helpNode4 != null)
                        {
                            cr.Mode = helpNode4.Value;
                        }

                        var helpNode5 = node2.Attributes["priority"];
                        if (helpNode5 != null)
                        {
                            cr.Priority = Convert.ToInt32(helpNode5.Value);
                        }
                        var helpNode6 = node2.Attributes["relation"];
                        if (helpNode6 != null)
                        {
                            cr.Relation = helpNode6.Value;
                        }


                        var helpNode0 = node2.SelectSingleNode("desc");
                        if (helpNode0 != null)
                        {
                            cr.Desc = helpNode0.InnerText;

                        }

                        XmlNodeList items = node2.SelectSingleNode("recommendation").SelectNodes("item");
                        foreach (XmlNode node3 in items)
                        {

                            if (node3 == null) continue;

                            Item i = new Item();
                            var helpNode30 = node3.Attributes["role"];
                            if (helpNode30 != null)
                            {
                                i.Role = helpNode30.Value;
                                if (helpNode30.Value == "rating")
                                {
                                    cr.Rec.Type = CriterionType.rating;

                                }

                            }

                            var helpNode9 = node3.SelectSingleNode("desc");
                            if (helpNode9 != null)
                            {
                                i.Desc = helpNode9.InnerText;
                            }

                            XmlNodeList vars = node3.SelectNodes("var");
                            if (vars.Count == 0)
                            {
                                cr.Rec.Items.Add(i);

                            }
                            else
                            {
                                foreach (XmlNode var in vars)
                                {
                                    Variable v = new Variable();


                                    var helpNode10 = var.Attributes["name"];
                                    if (helpNode10 != null)
                                    {
                                        v.Name = helpNode10.Value;
                                    }

                                    var helpNode11 = var.Attributes["max"];
                                    if (helpNode11 != null)
                                    {
                                        v.Max = helpNode11.Value;
                                    }

                                    var helpNode12 = var.Attributes["min"];
                                    if (helpNode12 != null)
                                    {
                                        v.Min = helpNode12.Value;
                                    }

                                    var helpNode13 = var.Attributes["value"];
                                    if (helpNode13 != null)
                                    {
                                        v.Value = helpNode13.Value;
                                    }

                                    var helpNode14 = var.Attributes["media"];
                                    if (helpNode14 != null)
                                    {
                                        if (helpNode14.Value.Equals("all")) v.MediaType = MediaType.All;
                                        if (helpNode14.Value.Equals("Tiger")) v.MediaType = MediaType.Tiger;
                                        if (helpNode14.Value.Equals("Schwellpapier")) v.MediaType = MediaType.Schwellpapier;
                                    }
                                    //System.Console.WriteLine(v.Value + v.Max + v.Min);
                                    i.Var.Add(v);
                                    //TODO: IS not the best solution because when a item has more then one variable, it will repeatedly added
                                    

                                }
                                cr.Rec.Items.Add(i);
                            }
                        }
                        
                        //System.Console.WriteLine(cr.Id);
                        //System.Console.WriteLine(cr.Priority);
                        cr.CA = ca;
                        cr.setResult();
                        crlist.Add(cr);
                    }

                    var helpNode33 = node.Attributes["name"];
                    if (helpNode33 != null)
                    {
                        ca.Name = helpNode33.Value;
                    }

                    var helpNode15 = node.Attributes["id"];
                    if (helpNode15 != null)
                    {
                        ca.Id = helpNode15.Value;
                    }

                    var helpNode16 = node.SelectSingleNode("desc");
                    if (helpNode16 != null)
                    {
                        ca.Desc = helpNode16.InnerText;
                    }

                    var helpNode17 = node.SelectSingleNode("help");
                    if (helpNode17 != null)
                    {
                        ca.Help = helpNode17.InnerText;
                    }

                    ca.Criteria = crlist;
                    categories.Add(ca);
                    catDict.Add(ca.Id, ca);

                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception in criteria parsing:\r\n" + ex);
            }

            AllCategories = categories;
            AllCategoriesDict = catDict;
            return categories;
        }
Ejemplo n.º 2
0
        void setCriterionRating(Criterion cr)
        {
            //TODO

        }
        protected override void SetCellTextList(ref XTextTable table, string cellName, Criterion cr)
        {
            String items;
            var a1 = table.getCellByName(cellName);
            if (a1 != null && a1 is XText)
            {
                // set the style of the cell
                // set style for the TextRange before inserting text content!
                var start = ((XTextRange)a1).getStart();
                if (start != null && start is XTextRange)
                {
                    OoUtils.SetStringProperty(start, "NumberingStyleName", WriterDocument.ParaStyleName.LIST_1);
                    OoUtils.SetStringProperty(start, "CharFontName", "Verdana");
                    OoUtils.SetProperty(start, "CharWeight", (float)100.000000);

                    items = CreateStringFailedItems(cr);
                    ((XText)a1).setString(items);
                }
            }
        }
        public void ShowCommentarForRating(Criterion cr, int count){
            count--;
            var lastVisibleElement = GetControlByName("RatingBox" + Convert.ToString(count) );
            var commentLabel = GetControlByName("commentLabel");
            var commentField = GetControlByName("commentField");
            var yPos = GetProperty(lastVisibleElement, "PositionY");
           
            SetProperty(commentLabel, "EnableVisible", true);
            SetProperty(commentLabel, "PositionY", (int)yPos + 32);
            SetProperty(commentField, "PositionY", (int)yPos + 40);

            SetProperty(commentField, "Text", cr.Comment);
            SetProperty(commentField, "EnableVisible", true);
        }
        public void setRating(Criterion cr, List<float> resultList)
        {
            XmlNode node = earl.SelectSingleNode("//earl:TestResult[@rdf:ID='" + "result_" + cr.Id + "']", nsmgr);

            if (node != null) 
            {
                String rating = node.InnerText;
                Regex regex = new Regex("\\d+([,]{1}\\d+)?");
                Match ma = regex.Match(rating);
                float erg = float.Parse(ma.ToString());
                int index = Convert.ToInt16((erg * (cr.Res.Rating.Count - 1)));
                //noch nicht die perfekte Lösung aber zur Sicherheit erstmal alle Werte in der RatingListe auf 0 setzen
                for (int i = 0; i < cr.Res.Rating.Count; i++)
                {
                    cr.Res.Rating[i] = 0;

                }
                cr.Res.Rating[index] = 1;
            }
            }
 private String createStringFailedItems(Criterion cr)
 {
     String items = "";
     if (cr.Rec.Type == CriterionType.one && cr.Res.resultType == ResultType.pass)
     {
         return "";
     }
     if (cr.Res.Type == CriterionType.rating && cr.Res.resultType == ResultType.fail)
     {
         items += cr.Rec.Items[0].Desc + "(Ratingergebnis " + cr.Res.ratingerg * 100 + "%)";
     }
     else if (cr.Res.Type == CriterionType.rating)
     {
         return "";
     }
     else
     {
         for (int i = 0; i < cr.Rec.Items.Count; i++)
         {
             if (cr.Res.Rating[i] == 0)
             {
                 items += cr.Rec.Items[i].Desc + cr.Rec.Items[i].VarText + "\r";
                 //if (i == cr.Rec.Items.Count - 1)
                 //{
                 //   items += cr.Rec.Items[i].Desc + cr.Rec.Items[i].VarText;
                 //}
                 //else
                 //{
                 //    items += cr.Rec.Items[i].Desc + cr.Rec.Items[i].VarText+"\r";
                 //}
             }
         }
         if (items.EndsWith("\r"))
         {
             items = items.Remove(items.Length - 1);
         }
     }
     return items;
 }
        private void addFailTestPoints(ScrollableContainer SC, Criterion cr)
        {
            if (cr.Rec.Type == CriterionType.all || cr.Rec.Type == CriterionType.count||cr.Rec.Type==CriterionType.one)
            {
                for (int i = 0; i < cr.Res.Rating.Count; i++)
                {
                    if (cr.Res.Rating[i] == 0)
                    {
                        var testPoint = CreateFixedLabel("-" + cr.Rec.Items[i].Desc + cr.Rec.Items[i].VarText, 0, 0, 0, 0, 10, null, "item" + i);
                        SetProperty(testPoint, "MultiLine", true);
                        var l = SC.AddElementToTheEndAndAdoptTheSize(testPoint as XControl, "item" + i, 5, 5);

                        testPointsMap.Add("item" + i, l);
                    }

                }
            }
            if (cr.Rec.Type == CriterionType.rating)
            {
                
                        var testPoint = CreateFixedLabel("-" + cr.Rec.Items[0].Desc + cr.Rec.Items[0].VarText+" (Ratingergebnis "+cr.Res.ratingerg* 100+"%)", 0, 0, 0, 0, 10, null, "item" + 0);
                        SetProperty(testPoint, "MultiLine", true);
                        var l = SC.AddElementToTheEndAndAdoptTheSize(testPoint as XControl, "item" + 0, 5, 5);

                        testPointsMap.Add("item" + 0, l);
                    

                }
            
            }
Ejemplo n.º 8
0
        //creates RESULT classes for criterions type "Count"
        public void createCountItemResult(Criterion cr, int index, int erg)
        {

            XmlElement result = earl.CreateElement("earl", "TestResult", nsmgr.LookupNamespace("earl"));
            result.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            result.SetAttribute("ID", "result_" + cr.Id + "_item" + index);
            root.AppendChild(result);


            XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            title.AppendChild(earl.CreateTextNode(cr.Rec.Items[index].Desc.Normalize()));
            result.AppendChild(title);

            String varText = createVarText(cr.Rec.Items[index]).Normalize();
            //XmlElement desc = earl.CreateElement("dct","description", nsmgr.LookupNamespace("dct"));
            //desc.AppendChild(earl.CreateTextNode(cr.Rec.Items[index].Desc.Normalize()));
            //result.AppendChild(desc);

            switch (erg)
            {
                case 1:
                    XmlElement pass = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    pass.AppendChild(earl.CreateTextNode("Der Prüfpunkt : " + cr.Rec.Items[index].Desc.Normalize() + varText+ " wurde erfüllt"));
                    result.AppendChild(pass);

                    XmlElement earlOutcomePass = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomePass.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomePass.SetAttribute("resource", "http://www.w3.org/ns/earl#passed");
                    result.AppendChild(earlOutcomePass);
                    break;
                case 0:
                    XmlElement fail = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    fail.AppendChild(earl.CreateTextNode("Der Prüfpunkt : " + cr.Rec.Items[index].Desc.Normalize() + varText + " wurde nicht erfüllt"));
                    result.AppendChild(fail);

                     XmlElement earlOutcomeFail = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomeFail.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomeFail.SetAttribute("resource", "http://www.w3.org/ns/earl#failed");
                    result.AppendChild(earlOutcomeFail);
                    break;


            }
            this.createSubAssertion(cr, result);

            //INode result = earlGraph.CreateUriNode(":" + cr.CA.Id + "/" + cr.Id + "/result/item" + index);


            //earlGraph.Assert(result, rdfType, earlGraph.CreateUriNode("earl:TestResult"));
            //earlGraph.Assert(result, earlGraph.CreateUriNode("dct:title"), earlGraph.CreateLiteralNode(cr.Rec.Items[index].Desc.Normalize()));
            //switch (erg)
            //{

            //    case 1:
            //        earlGraph.Assert(result, earlGraph.CreateUriNode("earl:info"), earlGraph.CreateLiteralNode("Die Empfehlung : " + cr.Rec.Items[index].Desc.Normalize() + " wurde erfüllt"));
            //        earlGraph.Assert(result, earlGraph.CreateUriNode("earl:outcome"), earlGraph.CreateUriNode("earl:pass"));
            //        break;
            //    case 0:
            //        earlGraph.Assert(result, earlGraph.CreateUriNode("earl:info"), earlGraph.CreateLiteralNode("Die Empfehlung : " + cr.Rec.Items[index].Desc.Normalize() + " wurde nicht erfüllt"));
            //        earlGraph.Assert(result, earlGraph.CreateUriNode("earl:outcome"), earlGraph.CreateUriNode("earl:fail"));
            //        break;
            //}
            //this.createSubAssertion(cr, result);
        }
Ejemplo n.º 9
0
        //creates RESULT classes for criterions type "Rating" which fail
        public void createRatingResultFail(Criterion cr, float erg, int index)
        {
            XmlElement result = earl.CreateElement("earl", "TestResult", nsmgr.LookupNamespace("earl"));
            result.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            result.SetAttribute("ID", "result_" + cr.Id + "_item" + index);
            root.AppendChild(result);


            XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            title.AppendChild(earl.CreateTextNode(cr.Rec.Items[index].Desc));
            result.AppendChild(title);

            //XmlElement desc = earl.CreateElement("dct","description", nsmgr.LookupNamespace("dct"));
            //desc.AppendChild(earl.CreateTextNode(cr.Rec.Items[index].Desc.Normalize()));
            //result.AppendChild(desc);


            XmlElement fail = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            fail.AppendChild(earl.CreateTextNode("Das Rating wurde mit dem Wert " + erg + " nicht bestanden"));
            result.AppendChild(fail);


            XmlElement earlOutcomeFail = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
            earlOutcomeFail.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            earlOutcomeFail.SetAttribute("resource", "http://www.w3.org/ns/earl#failed");
            result.AppendChild(earlOutcomeFail);

            this.createSubAssertion(cr, result);

            //INode result = earlGraph.CreateUriNode(":" + cr.CA.Id + "/" + cr.Id + "/result/itemrating");

            //earlGraph.Assert(result, rdfType, earlGraph.CreateUriNode("earl:TestResult"));
            //earlGraph.Assert(result, earlGraph.CreateUriNode("earl:info"), earlGraph.CreateLiteralNode("Das Rating wurde mit dem Wert " + erg + " nicht bestanden"));
            //earlGraph.Assert(result, earlGraph.CreateUriNode("earl:outcome"), earlGraph.CreateUriNode("earl:fail"));

        }
Ejemplo n.º 10
0
        //public void createTestRequirement(Category ca)
        //{
        //    XmlElement category1 = earl.CreateElement("earl","TestRequirement", nsmgr.LookupNamespace("earl"));
        //    category1.SetAttributeNode("about", nsmgr.LookupNamespace("rdf"));
        //    category1.SetAttribute("about", baseUri + "#" + ca.Id);
        //    root.AppendChild(category1);

        //    XmlElement desc = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
        //    desc.AppendChild(earl.CreateTextNode(ca.Desc.Normalize()));
        //    category1.AppendChild(desc);

        //    XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
        //    title.AppendChild(earl.CreateTextNode(ca.Name.Normalize()));
        //    category1.AppendChild(title);
            
            

        //}


        //public void createTestCase(Criterion cr)
        //{
        //    XmlElement criterion1 = earl.CreateElement("earl", "TestCase", nsmgr.LookupNamespace("earl"));
        //    criterion1.SetAttributeNode("about", nsmgr.LookupNamespace("rdf"));
        //    criterion1.SetAttribute("about", baseUri + "#" + cr.Id);
        //    root.AppendChild(criterion1);

        //    XmlElement desc = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
        //    desc.AppendChild(earl.CreateTextNode(cr.Desc.Normalize()));
        //    criterion1.AppendChild(desc);

        //    XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
        //    title.AppendChild(earl.CreateTextNode(cr.Name.Normalize()));
        //    criterion1.AppendChild(title);

        //    XmlElement isPart = earl.CreateElement("dct", "isPartOf", nsmgr.LookupNamespace("dct"));
        //    isPart.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
        //    isPart.SetAttribute("resource", baseUri + "#" + cr.CA.Id);
        //    criterion1.AppendChild(isPart);

        //    XmlElement hasPart = earl.CreateElement("dct", "hasPart", nsmgr.LookupNamespace("dct"));
        //    hasPart.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
        //    hasPart.SetAttribute("resource", baseUri + "#" + cr.Id);
        //    //System.Console.WriteLine("@about = \"" + baseUri + "#" + cr.CA.Id + "\"");
        //    earl.SelectSingleNode("//earl:TestRequirement[@rdf:about='"+baseUri +"#" + cr.CA.Id + "']", nsmgr).AppendChild(hasPart);



        //    createItemTestCases(cr, cr.Rec.Items);
            

            
        //}
        
        private void createItemTestCases(Criterion cr, List<Item> list)
        {
            //int z = 0;
            //foreach (Item i in list) { 

            //XmlElement item = earl.CreateElement("earl", "TestCase", nsmgr.LookupNamespace("earl"));
            //item.SetAttributeNode("about", nsmgr.LookupNamespace("rdf"));
            //item.SetAttribute("about", baseUri + "#" + cr.Id +"_item"+z);
            //root.AppendChild(item);

            //XmlElement desc = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            //desc.AppendChild(earl.CreateTextNode(i.Desc.Normalize()));
            //item.AppendChild(desc);

            //XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            //title.AppendChild(earl.CreateTextNode(z.ToString().Normalize()));
            //item.AppendChild(title);

            //XmlElement isPart = earl.CreateElement("dct", "isPartOf", nsmgr.LookupNamespace("dct"));
            //isPart.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //isPart.SetAttribute("resource", baseUri + "#" + cr.Id);
            //item.AppendChild(isPart);

            //XmlElement hasPart = earl.CreateElement("dct", "hasPart", nsmgr.LookupNamespace("dct"));
            //hasPart.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //hasPart.SetAttribute("resource", baseUri + "#" + cr.Id +"_item" +z);
            ////System.Console.WriteLine("@about = \"" + baseUri + "#" + cr.CA.Id + "\"");
            //earl.SelectSingleNode("//earl:TestCase[@rdf:about='" + baseUri + "#" + cr.Id + "']", nsmgr).AppendChild(hasPart);
            
                
            //z++;
            //}
        }
Ejemplo n.º 11
0
        //creates RESULT classes for criterions type "all"
        public void createAllItemResult(Criterion cr, int index, int erg)
        {
            XmlElement result = earl.CreateElement("earl", "TestResult", nsmgr.LookupNamespace("earl"));
            result.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            result.SetAttribute("ID", "result_" + cr.Id + "_item" + index);
            root.AppendChild(result);


            XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            title.AppendChild(earl.CreateTextNode(cr.Rec.Items[index].Desc.Normalize()));
            result.AppendChild(title);

            String varText = createVarText(cr.Rec.Items[index]).Normalize();
            //XmlElement desc = earl.CreateElement("dct","description", nsmgr.LookupNamespace("dct"));
            //desc.AppendChild(earl.CreateTextNode(cr.Rec.Items[index].Desc.Normalize()));
            //result.AppendChild(desc);

            switch (erg)
            {
                case 1:
                    XmlElement pass = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    pass.AppendChild(earl.CreateTextNode("Der Prüfpunkt : " + cr.Rec.Items[index].Desc.Normalize() + varText+ " wurde erfüllt"));
                    result.AppendChild(pass);

                    XmlElement earlOutcomePass = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomePass.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomePass.SetAttribute("resource", "http://www.w3.org/ns/earl#passed");
                    result.AppendChild(earlOutcomePass);
                    break;
                case 0:
                    XmlElement fail = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    fail.AppendChild(earl.CreateTextNode("Prüfpunkt: " + cr.Rec.Items[index].Desc.Normalize() + varText + " wurde nicht erfüllt"));
                    result.AppendChild(fail);

                    XmlElement earlOutcomeFail = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomeFail.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomeFail.SetAttribute("resource", "http://www.w3.org/ns/earl#failed");
                    result.AppendChild(earlOutcomeFail);
                    break;


            }
            this.createSubAssertion(cr, result);
            //this.createSubAssertion(cr, result);
            




        }
 protected virtual void SetCellTextList(ref XTextTable table, string cellName, Criterion cr)
 {
     throw new NotImplementedException();
 }
 protected virtual void FillColWithText(ref XTextTable table, int colCount, Criterion cr, int crNumber, int caNumber)
 {
     WriterDocument.SetCellTextValue(ref table, "A" + colCount, caNumber + "." + crNumber + " " + cr.Name);
     SetCellTextList(ref table, "B" + colCount, cr);
     //SetCellTextValue(ref table, "B" + colCount, caNumber + "." + crNumber + " " + cr.Name);
     WriterDocument.SetCellTextValue(ref table, "C" + colCount, cr.Comment);
     WriterDocument.SetCellTextValue(ref table, "D" + colCount, cr.Priority.ToString(), "Verdana", 150, 1, 13);
 }
Ejemplo n.º 14
0
        public int getItemResult(Criterion cr, int index)
        {
            String value ="";
            XmlNode node = earl.SelectSingleNode("//earl:TestResult[@rdf:ID='" + "result_" + cr.Id +"_item"+index+ "']", nsmgr);
            if (node != null)
            {
                value = node.LastChild.Attributes.GetNamedItem("rdf:resource").Value;
            }
            
            switch (value)
            {
                case "http://www.w3.org/ns/earl#failed":
                    return 0;
                case "http://www.w3.org/ns/earl#passed":
                    return 1;

            }
            //System.Console.WriteLine(value);
            return 0;
        }
        protected override void SetCellTextList(ref XTextTable table, string cellName, Criterion cr)
        {
            //base.SetCellTextList(ref table, cellName, cr);

            String itemsFail;
            String itemsPass;
            var a1 = table.getCellByName(cellName);
            if (a1 != null && a1 is XText)
            {
                // set the style of the cell
                // set style for the TextRange before inserting text content!
                var start = ((XTextRange)a1).getStart();
                if (start != null && start is XTextRange)
                {
                    itemsFail = createStringFailedItems(cr);
                    itemsPass = CreateStringPassedItems(cr);
                    XTextCursor xTextCurser = ((XText)a1).createTextCursor();
                    xTextCurser.gotoEnd(false);
                    if (itemsFail != String.Empty)
                    {
                        OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.NONE);
                        OoUtils.SetProperty(xTextCurser, "CharWeight", 150);
                        OoUtils.SetProperty(xTextCurser, "CharHeight", 12);
                        ((XText)a1).insertString(xTextCurser, "Nicht erfüllt: \r", false);

                        xTextCurser.gotoEnd(false);
                        OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.LIST_1);
                        OoUtils.SetStringProperty(xTextCurser, "CharFontName", "Verdana");
                        OoUtils.SetProperty(xTextCurser, "CharWeight", (float)100.000000);
                        OoUtils.SetProperty(xTextCurser, "CharHeight", 12);
                        ((XText)a1).insertString(xTextCurser, itemsFail, false);
                        xTextCurser.gotoEnd(false);
                        //OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.NONE);


                    }
                    if (itemsPass != String.Empty && itemsFail != String.Empty)
                    {
                        ((XText)a1).insertString(xTextCurser, "\r", false);
                        //XTextCursor xTextCurser2 = ((XText)a1).createTextCursor();
                        xTextCurser.gotoEnd(false);

                        OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.NONE);
                        OoUtils.SetProperty(xTextCurser, "CharWeight", 150);
                        OoUtils.SetProperty(xTextCurser, "CharHeight", 12);
                        ((XText)a1).insertString(xTextCurser, "\rErfüllt: \r", false);
                        xTextCurser.gotoEnd(false);
                        OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.LIST_1);
                        OoUtils.SetStringProperty(xTextCurser, "CharFontName", "Verdana");
                        OoUtils.SetProperty(xTextCurser, "CharWeight", (float)100.000000);
                        OoUtils.SetProperty(xTextCurser, "CharHeight", 12);
                        ((XText)a1).insertString(xTextCurser, itemsPass, false);
                        xTextCurser.gotoEnd(false);
                        return;

                    }
                    if (itemsPass != String.Empty)
                    {
                        OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.NONE);
                        OoUtils.SetProperty(xTextCurser, "CharWeight", 150);
                        OoUtils.SetProperty(xTextCurser, "CharHeight", 12);
                        ((XText)a1).insertString(xTextCurser, "Erfüllt: \r", false);
                        xTextCurser.gotoEnd(false);
                        OoUtils.SetStringProperty(xTextCurser, "NumberingStyleName", WriterDocument.ParaStyleName.LIST_1);
                        OoUtils.SetStringProperty(xTextCurser, "CharFontName", "Verdana");
                        OoUtils.SetProperty(xTextCurser, "CharWeight", (float)100.000000);
                        OoUtils.SetProperty(xTextCurser, "CharHeight", 12);
                        ((XText)a1).insertString(xTextCurser, itemsPass, false);
                        xTextCurser.gotoEnd(false);
                    }

                }
            }
        }
Ejemplo n.º 16
0
        //final Result ob Criterion bestanden oder nicht 
        public void createCriterionResult(Criterion cr, bool pass , float evaluationValue)
        {
            
            XmlElement result = earl.CreateElement("earl", "TestResult", nsmgr.LookupNamespace("earl"));
            result.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            result.SetAttribute("ID", "result_" + cr.Id);
            root.AppendChild(result);
            

            if (cr.Comment != String.Empty)
            {
                XmlElement title = earl.CreateElement("earl", "info", nsmgr.LookupNamespace("earl"));
                title.AppendChild(earl.CreateTextNode(cr.Comment));
                result.AppendChild(title);
            }
            
            
            switch (pass)
            {
                case true:
                    XmlElement passed = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    passed.AppendChild(earl.CreateTextNode(("Das Kriterium: " + cr.Name + " wurde erfüllt." + createErgPassString(cr, evaluationValue)).Normalize()));
                    result.AppendChild(passed);

                    XmlElement earlOutcomePass = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomePass.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomePass.SetAttribute("resource", "http://www.w3.org/ns/earl#passed");
                    result.AppendChild(earlOutcomePass);
                    break;
                case false:
                    XmlElement warning = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
                    warning.AppendChild(earl.CreateTextNode(("Das Kriterium: " + cr.Name.Normalize() + " wurde nicht erfüllt. "+ createErgFailString(cr, evaluationValue)).Normalize()));
                    result.AppendChild(warning);

                    XmlElement earlOutcomeWarning = earl.CreateElement("earl", "outcome", nsmgr.LookupNamespace("earl"));
                    earlOutcomeWarning.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    earlOutcomeWarning.SetAttribute("resource", "http://www.w3.org/ns/earl#failed");
                    result.AppendChild(earlOutcomeWarning);
                    break;
               
            }
            createAssertionCriterion(cr, result);
            
        }
        private string CreateStringPassedItems(Criterion cr)
        {
            String items = "";
            if (cr.Res.Type == CriterionType.rating && (cr.Res.resultType == ResultType.pass || cr.Res.resultType == ResultType.passwithwarning))
            {
                items += cr.Rec.Items[0].Desc + "(Ratingergebnis " + cr.Res.ratingerg * 100 + "%)";
            }
            else
            {
                for (int i = 0; i < cr.Rec.Items.Count; i++)
                {
                    if (cr.Res.Rating[i] == 1)
                    {
                        items += cr.Rec.Items[i].Desc + cr.Rec.Items[i].VarText + "\r";

                    }
                }
                if (items.EndsWith("\r"))
                {
                    items = items.Remove(items.Length - 1);
                }
            }
            return items;
        }
Ejemplo n.º 18
0
        private void createAssertionCriterion(Criterion cr, XmlElement result)
        {
            XmlElement test = earl.CreateElement("earl", "Assertion", nsmgr.LookupNamespace("earl"));
            test.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            test.SetAttribute("ID", "finalassertion_"+cr.Id);
            root.AppendChild(test);

            XmlElement tester = earl.CreateElement("earl", "assertedBy", nsmgr.LookupNamespace("earl"));
            tester.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            tester.SetAttribute("resource","#"+ group.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
            test.AppendChild(tester);

            XmlElement subject = earl.CreateElement("earl", "subject", nsmgr.LookupNamespace("earl"));
            subject.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            subject.SetAttribute("resource","#"+ testsubject.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
            test.AppendChild(subject);

            XmlElement test1 = earl.CreateElement("earl", "test", nsmgr.LookupNamespace("earl"));
            test1.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            test1.SetAttribute("resource", baseUri + "#" + cr.Id);
            test.AppendChild(test1);

            XmlElement res = earl.CreateElement("earl", "result", nsmgr.LookupNamespace("earl"));
            res.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
            res.SetAttribute("resource","#"+ result.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
            test.AppendChild(res);
            
        }
        private void setTestPoints(ScrollableContainer testPointsContainer, Criterion cr)
        {
            foreach (XControl entry in testPointsMap.Values) 
            {
                entry.dispose();
            }
            

                testPointsMap.Clear();
              
            
                addFailTestPoints(testPointsContainer,cr);
            
           
        }
Ejemplo n.º 20
0
        private void createSubAssertion(Criterion cr, XmlElement result)
        {
            
            int i = 0;
            //sucht nach freiem platz für tesKnoten
            while (i < 20)
            {
                //var a = earl.SelectSingleNode("//earl:Assertion[@rdf:about='" + baseUri + "#" + cr.Id + "_test_item" + i + "']", nsmgr);
                if (earl.SelectSingleNode("//earl:Assertion[@rdf:ID='"+ "assertion" + i+ "_"  + cr.Id + "']", nsmgr) == null)
                {
                    XmlElement test = earl.CreateElement("earl", "Assertion", nsmgr.LookupNamespace("earl"));
                    test.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
                    test.SetAttribute("ID", "assertion" + i+ "_"  + cr.Id);
                    root.AppendChild(test);

                    XmlElement tester = earl.CreateElement("earl", "assertedBy", nsmgr.LookupNamespace("earl"));
                    tester.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
                    tester.SetAttribute("resource", "#" + group.GetAttribute("ID",nsmgr.LookupNamespace("rdf")));
                    test.AppendChild(tester);

                    XmlElement subject = earl.CreateElement("earl", "subject", nsmgr.LookupNamespace("earl"));
                    subject.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
                    subject.SetAttribute("resource","#"+ testsubject.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
                    test.AppendChild(subject);

                    XmlElement test1 = earl.CreateElement("earl", "test", nsmgr.LookupNamespace("earl"));
                    test1.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
                    test1.SetAttribute("resource", baseUri + "#" + cr.Id);
                    test.AppendChild(test1);

                    XmlElement res  = earl.CreateElement("earl", "result", nsmgr.LookupNamespace("earl"));
                    res.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
                    //var a = testPerson.GetAttribute("about", nsmgr.LookupNamespace("rdf"));
                    res.SetAttribute("resource","#"+ result.GetAttribute("ID", nsmgr.LookupNamespace("rdf")));
                    test.AppendChild(res);

                    break;
                }
                i++;
            }

      
        }
        public void ShowCommentar(Criterion cr, int count)
        {
            

            var lastVisibleCheckBox = GetControlByName("CheckBox" + Convert.ToString(count));
            var commentLabel = GetControlByName("commentLabel");
            var commentField = GetControlByName("commentField");
            var yPos = GetProperty(lastVisibleCheckBox, "PositionY");
          
            SetProperty(commentLabel, "EnableVisible", true);
            SetProperty(commentLabel, "PositionY", (int)yPos + 8);
            SetProperty(commentField, "PositionY", (int)yPos + 16);

            SetProperty(commentField, "Text", cr.Comment);
            SetProperty(commentField, "EnableVisible", true);
        }
Ejemplo n.º 22
0
 private string createErgFailString(Criterion cr, float evaluationValue)
 {
     String erg = "";
     switch(cr.Rec.Type){
         case CriterionType.all:
             if (cr.Res.Rating.Count == 1)
             {
                 erg = " Es wurde " + evaluationValue + " von " + cr.Rec.Items.Count + " Prüfpunkt erfüllt.";
             }
             else{
                 erg = " Es wurden " + evaluationValue*cr.Rec.Items.Count + " von " + cr.Rec.Items.Count + " Prüfpunkte erfüllt. Es hätten alle bestanden werden müssen."; 
                 }
             break;
         case CriterionType.count:
             String pruef = " Prüfpunkte";
             if (new Parameters().PassCount * cr.Rec.Items.Count == 1) pruef = " Prüfpunkt";
             erg = " Es wurden " + evaluationValue * cr.Rec.Items.Count + " von " + cr.Rec.Items.Count + " Prüfpunkte erfüllt. Zum bestehen dieses Kriteriums benötigte es " + new Parameters().PassCount * cr.Rec.Items.Count + pruef +".";
             break;
         case CriterionType.rating:
             erg = ("(Bewertung: " + evaluationValue +"%)");
             break;
     }
     return erg;
 }
 public void showResults(Criterion cr,int step)
 {
     if (cr != null)
     {
         SetProperty(GetControlByName(introductionLabelName), "EnableVisible", false);
         changeActiveResultLabel(cr.Id.ToString());
         SetProperty(GetControlByName(toCriterionButtonName), "EnableVisible", true);
         SetProperty(GetControlByName(toCriterionButtonName), "HelpURL", cr.Id);
         util.Debug.GetAllProperties(GetControlByName(toCriterionButtonName));
         SetProperty(GetControlByName(toCriterionButtonName), "FocusOnClick", false);
         SetProperty(GetControlByName(testPointsSkalaName), "EnableVisible", true);
         SetProperty(GetControlByName(testPointLabelName), "EnableVisible", true);
         SetProperty(GetControlByName(criterionHeaderResultName), "EnableVisible", true);
         SetProperty(GetControlByName(testPointHeaderName), "EnableVisible", true);
         SetProperty(GetControlByName(commentarResultLabelName), "EnableVisible", true);
         commentarResultContainer.SetVisible(true);
         testPointsContainer.SetVisible(true);
         testPointsContainer.InnerPosY = 0;
         testPointsContainer.VerticalScrlBar.setValue(0);
         setTestPoints(testPointsContainer,cr);
         commentarResultContainer.InnerPosY = 0;
         commentarResultContainer.VerticalScrlBar.setValue(0);
         addCommentarLabel(commentarResultContainer, cr.Comment);
         
        
         if(cr.Res.resultType == ResultType.fail)
         {
             SetProperty(GetControlByName(criterionHeaderResultName), "Label", "Das Kriterium '" + cr.Name + "' wurde nicht bestanden.");
             SetProperty(GetControlByName(testPointHeaderName), "Label", "Nicht erfüllte Prüfpunkte:");
         }
         if (cr.Res.resultType == ResultType.fail && cr.Rec.Type == CriterionType.one)
         {
             SetProperty(GetControlByName(criterionHeaderResultName), "Label", "Das Kriterium '" + cr.Name + "' wurde nicht bestanden. Es muss einer der beiden Prüfpunkte bestehen.");
             SetProperty(GetControlByName(testPointHeaderName), "Label", "Nicht erfüllte Prüfpunkte:");
         }
         
         if (cr.Res.resultType == ResultType.passwithwarning&&cr.Rec.Type==CriterionType.rating)
         {
             SetProperty(GetControlByName(testPointHeaderName), "Label", "Verbesserungswürdige Prüfpunkte");
             SetProperty(GetControlByName(criterionHeaderResultName), "Label", "Das Kriterium '" + cr.Name + "' wurde bestanden, kann aber verbessert werden.");
         }
         if (cr.Res.resultType == ResultType.passwithwarning && cr.Rec.Type == CriterionType.count)
         {
             SetProperty(GetControlByName(testPointHeaderName), "Label", "Nicht erfüllte Prüfpunkte:");
             SetProperty(GetControlByName(criterionHeaderResultName), "Label", "Das Kriterium '" + cr.Name + "' wurde bestanden, kann aber verbessert werden.");
         }
         
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="par"></param>
        /// <param name="element"></param>
        /// <param name="evaluationValue"></param>
        /// <returns></returns>
        private bool evaluateCriterion(Parameters par, Criterion element, out float evaluationValue)
        {
            evaluationValue = 0;
            if (element != null && element.Rec != null && element.Rec.Type != CriterionType.unknown)
            {
                switch (element.Rec.Type)
                {
                    case CriterionType.all:
                        {
                            if (element.Rec.Items != null && element.Rec.Items.Count > 0)
                            {
                                int passed = 0;

                                for (int i = 0; i < element.Rec.Items.Count; i++)
                                {
                                    //hier wird test Result für einzelnes Item erstellt
                                    earl.createAllItemResult(element, i, (int)(element.Res.GetItemRating(i)));
                                    if (element.Res.GetItemRating(i) == 1)
                                    {
                                        element.EvaluationValue++;
                                        passed++;

                                    }
                                }
                                evaluationValue = (float)passed / (float)element.Rec.Items.Count;
                                if (evaluationValue != 1)
                                {
                                    element.Res.resultType = ResultType.fail;
                                    return false;
                                }
                                else
                                {
                                    element.Res.resultType = ResultType.pass;
                                    element.Res.Passed = true;
                                    return true;
                                }
                            }
                            else
                            {
                                return false;
                            }
                        }
                    case CriterionType.one:
                        {
                            bool ergBool = false;
                            element.Res.resultType = ResultType.fail;
                            for (int i = 0; i < element.getCountOfItems(); i++)
                            {
                                earl.createOneItemResult(element, i, (int)element.Res.Rating[i]);
                                if (element.Res.GetItemRating(i) == 1)
                                {
                                    element.EvaluationValue++;
                                    evaluationValue = 1;
                                    ergBool = true;
                                    element.Res.Passed = true;
                                    element.Res.resultType = ResultType.pass;
                                }

                            }
                            return ergBool;
                            //if (element.Res.GetItemRating(0) == 0)
                            //{
                            //    return false;
                            //}
                            //evaluationValue = 1;
                            //return true;
                        }
                    case CriterionType.count:
                        {
                            int passed = 0;

                            for (int i = 0; i < element.Rec.Items.Count; i++)
                            {
                                earl.createCountItemResult(element, i, (int)element.Res.GetItemRating(i));
                                if (element.Res.GetItemRating(i) == 1)
                                {
                                    element.EvaluationValue++;
                                    passed++;
                                }
                            }
                            evaluationValue = (float)passed / (float)element.Rec.Items.Count;
                            if (evaluationValue < par.PassCount)
                            {
                                element.Res.resultType = ResultType.fail;
                                return false;
                            }
                            else if (evaluationValue == 1)
                            {
                                element.Res.resultType = ResultType.pass;
                                element.Res.Passed = true;
                                return true;
                            }
                            else
                            {
                                element.Res.resultType = ResultType.passwithwarning;
                                element.Res.Passed = true;
                                return true;
                            }
                        }
                    case CriterionType.rating:
                        {
                            int index = 0;
                            float sum = 0;
                            for (int i = 0; i < 5; i++)
                            {
                                if (element.Res.GetItemRating(i) == 1)
                                {
                                    sum = i;
                                }
                            }
                            if (element.Rec.Items.Count > 0)
                            {
                                evaluationValue = (float)sum / ((float)element.Res.Rating.Count - 1);
                                if (evaluationValue < par.PassRating)
                                {
                                    element.Res.resultType = ResultType.fail;
                                    earl.createRatingResultFail(element, evaluationValue, index);
                                    element.Res.ratingerg = evaluationValue;
                                    return false;
                                }
                                else if (evaluationValue == 1)
                                {
                                    element.Res.resultType = ResultType.pass;
                                    earl.createRatingResultPass(element, evaluationValue, index);
                                    element.Res.Passed = true;
                                    element.Res.ratingerg = evaluationValue;
                                    return true;
                                }
                                else
                                {
                                    element.Res.resultType = ResultType.passwithwarning;
                                    earl.createRatingResultPass(element, evaluationValue, index);
                                    element.Res.Passed = true;
                                    element.Res.ratingerg = evaluationValue;
                                    return true;
                                }
                            }
                            else
                            {
                                return false;
                            }
                        }
                    default:
                        break;
                }
            }
            return false;
        }