Example #1
0
        private void BindAuto(Rubric rub)
        {
            Rubrics rubda = new Rubrics(Globals.CurrentIdentity);

            Result.ResultList ress = rubda.GetResults(rub.ID, GetSubID());

            lblEvalID.Text = rub.EvalID.ToString();
            if (ress.Count == 0)
            {
                if (!IsStudent())
                {
                    mpViews.SelectedIndex = 2;
                }
                else
                {
                    mpViews.SelectedIndex = 5;
                }
            }
            else
            {
                AutoResult res = ress[0] as AutoResult;

                XmlWizard xmlwiz = new XmlWizard();
                xmlwiz.DisplayDivXslt(res.XmlResult, Path.Combine(Globals.WWWDirectory, "Xml/reshtml.xslt"), divAuto);

                mpViews.SelectedIndex = 3;
            }
        }
Example #2
0
        public string Discover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            //Get Perl
            IExternalTool perl = ExternalToolFactory.GetInstance().CreateExternalTool("Perl",
                                                                                      "5.0", ExternalToolFactory.VersionCompare.ATLEAST);

            if (perl == null)
            {
                throw new JUnitToolException(
                          "Unable to find Perl v5.0 or later. Please check the installation or contact the administrator");
            }

            //Get all files on the disk
            string tpath = ExportToTemp(eval);

            //Run disco program
            perl.Arguments = "jdisco.pl i";
            perl.Execute(tpath);
            Directory.Delete(tpath, true);

            //Validate XML
            string    xmltests = perl.Output;
            XmlWizard xmlwiz   = new XmlWizard();

            if (!xmlwiz.ValidateXml(xmltests, Path.Combine(Globals.WWWDirectory, "Xml/testsuite.xsd")))
            {
                throw new JUnitToolException("Invalid JUnit Test Suite. Check to make sure the test suite conforms to FrontDesk standards");
            }

            //Write XML
            FileSystem fs      = new FileSystem(Globals.CurrentIdentity);
            CFile      zone    = fs.GetFile(eval.ZoneID);
            string     tspath  = Path.Combine(zone.FullPath, "__testsuite.xml");
            CFile      xmldesc = fs.GetFile(tspath);

            if (xmldesc == null)
            {
                xmldesc = fs.CreateFile(tspath, false, null);
            }
            xmldesc.Data = xmltests.ToCharArray();
            fs.Edit(xmldesc);
            fs.Save(xmldesc);

            //Copy disco program over
            CFile.FileList dfiles = new CFile.FileList();
            dfiles.Add(fs.GetFile(@"c:\system\junit\jdisco.pl"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover.class"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover$ClassFileFilter.class"));
            fs.CopyFiles(zone, dfiles, true);

            //Get suite metadata
            GetSuiteInfo(xmltests, out points, out time, out count);

            //Punt all previous results
            RemoveResults(eval);

            return(xmltests);
        }
Example #3
0
        private void GetSuiteInfo(string xmltests, out double points, out int time, out int count)
        {
            ArrayList tests = new XmlWizard().GetXSDTests(xmltests);

            points = 0; time = 5; count = tests.Count;
            foreach (XmlWizard.XSDTest test in tests)
            {
                points += test.Points; time += test.Time;
            }
        }
Example #4
0
        protected SubjResult.SubjResultList ParseSubjXmlResults(string xmlresults, Submission sub)
        {
            SubjResult.SubjResultList ress = new SubjResult.SubjResultList();
            XPathNavigator            xnav = new XmlWizard().GetXPathNavigator(xmlresults);
            FileSystem fs   = new FileSystem(m_ident);
            CFile      zone = fs.GetFile(sub.LocationID);

            xnav.MoveToFirstChild(); xnav.MoveToFirstChild();
            XPathNavigator comments = xnav.Clone();

            while (comments.MoveToNext())
            {
                SubjResult     res     = new SubjResult();
                XPathNavigator comment = comments.Clone();
                comment.MoveToFirstChild();

                string subjtype = comment.Value; comment.MoveToNext();
                switch (subjtype)
                {
                case "Warning":
                    res.SubjType = Rubric.WARNING;
                    break;

                case "Error":
                    res.SubjType = Rubric.ERROR;
                    break;

                case "Good":
                    res.SubjType = Rubric.GOOD;
                    break;
                }
                ;

                res.Points  = Convert.ToDouble(comment.Value); comment.MoveToNext();
                res.Comment = comment.Value; comment.MoveToNext();

                string filename = comment.Value; comment.MoveToNext();
                if (filename.StartsWith(@".\"))
                {
                    filename = filename.Substring(2, filename.Length - 2);
                }
                CFile file = fs.GetFile(Path.Combine(zone.FullPath, filename));
                if (file != null)
                {
                    res.FileID = file.ID;
                    res.Line   = Convert.ToInt32(comment.Value);
                    ress.Add(res);
                }
            }

            return(ress);
        }
Example #5
0
        protected string ValidateResult(string result)
        {
            XmlWizard xmlwiz = new XmlWizard();

            if (xmlwiz.ValidateXml(result, "result.xsd") ||
                xmlwiz.ValidateXml(result, "subjresult.xsd"))
            {
                return(result);
            }
            else
            {
                throw new ResultFormatException("Xml result description does not conform to the FrontDesk XSD specification.\n" +
                                                " Please use a FrontDesk toolkit when designing tests, or debug the current test " +
                                                "to conform with FrontDesk specifications. \nError: " + xmlwiz.GetLastError() +
                                                "\n\n<![CDATA[ XML: " + result + "]]>");
            }
        }
Example #6
0
        private void BindJUnitView(AutoEvaluation eval)
        {
            string xmltests = null;
            double points = 0;
            int    time = 0, count = 0;

            //Attempt to load suite info
            try {
                xmltests = new JUnitTool().ReDiscover(eval, out points, out time, out count);
            } catch (JUnitToolException) {
                points = 0; time = 0; count = 0; xmltests = null;
            } catch (CustomException er) {
                PageJUnitError(er.Message);
            }

            //Display test info
            XmlWizard xmlwiz = new XmlWizard();

            lblJUnitTime.Text  = "Total Time Limit: <b>" + time + "s</b>";
            lblJUnitCount.Text = "Total Test Count: <b>" + count + "</b>";
            if (xmltests != null)
            {
                xmlwiz.DisplayDivXslt(xmltests,
                                      Path.Combine(Globals.WWWDirectory, "Xml/testhtml.xslt"), divJUnitTest);
            }
            else
            {
                divJUnitTest.InnerHtml = "<br><i>No JUnit Test Suite Present</i>";
            }

            ucJUnitDeps.BindData(eval);
            ucJUnitDeps.ShowUpdate = true;
            ucJUnitDeps.EvalID     = eval.ID;

            AddBrowserAttr(lnkJUnitView, eval);
            lblEvalID.Text          = eval.ID.ToString();
            chkJUnitPreTest.Checked = eval.RunOnSubmit;
            chkJUnitCompete.Checked = eval.Competitive;
        }