コード例 #1
0
        /// <summary>
        /// Synchronize local zone with remote store
        /// </summary>
        public Zone Synchronize(object oeval)
        {
            bool           success;
            Zone           zone = new Zone();
            AutoEvaluation eval = oeval as AutoEvaluation;

            //Check for the existence of the zone
            zone.LocalPath = Path.Combine(TestConfig.LocalZonePath, eval.ZoneID.ToString());
            zone.ZoneID    = eval.ZoneID;

            if (Directory.Exists(zone.LocalPath))
            {
                success = UpdateZone(eval);
            }
            else
            {
                success = CreateZone(eval);
            }

            if (success)
            {
                m_logger.Log("Zone synchro complete");
                return(zone);
            }
            else
            {
                m_logger.Log("Zone synchro FAILED", TestLogger.LogType.ERROR);
                return(null);
            }
        }
コード例 #2
0
        public void BindData(AutoEvaluation eval)
        {
            int asstID = eval.AsstID;

            Assignments assts = new Assignments(Globals.CurrentIdentity);
            Evaluations evals = new Evaluations(Globals.CurrentIdentity);

            Evaluation.EvaluationList allevals = assts.GetAutoEvals(asstID);
            Evaluation.EvaluationList deps     = evals.GetDependencies(eval.ID);

            chkDeps.Items.Clear();
            foreach (Evaluation e in allevals)
            {
                if (e.ID == eval.ID)
                {
                    continue;
                }
                ListItem eitem = new ListItem(e.Name, e.ID.ToString());
                foreach (Evaluation d in deps)
                {
                    if (d.ID == e.ID)
                    {
                        eitem.Selected = true;
                        break;
                    }
                }
                chkDeps.Items.Add(eitem);
            }
        }
コード例 #3
0
        protected bool UpdateZone(AutoEvaluation eval)
        {
            DataSet zonedesc = new DataSet();

            string dpath   = Path.Combine(TestConfig.LocalZonePath, eval.ZoneID.ToString());
            string xmlpath = Path.Combine(dpath, "__zone.xml");

            if (!File.Exists(xmlpath))
            {
                Directory.Delete(dpath, true);
                return(CreateZone(eval));
            }
            else
            {
                m_logger.Log("Checking for update on zone: " + eval.ZoneID);
                zonedesc.ReadXml(xmlpath);
                DateTime localmod = Convert.ToDateTime(zonedesc.Tables["Export"].Rows[0]["Mod"]);
                DateTime zonemod  = eval.ZoneModified;

                //If zone is modified, blow it away and get it again
                if (zonemod > localmod)
                {
                    m_logger.Log("Update needed for zone: " + eval.ZoneID);
                    Directory.Delete(dpath, true);
                    return(CreateZone(eval));
                }
            }

            return(true);
        }
コード例 #4
0
        private int CommitTestSource(AutoEvaluation eval, IExternalSource zone)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Make sure toplevel zone directory exists
            CFile zonedir = fs.GetFile(@"c:\zones");

            if (null == zonedir)
            {
                zonedir = fs.CreateDirectory(@"c:\zones", true, null);
            }

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            CourseRole.CourseRoleList          staff = new Courses(m_ident).GetTypedRoles(eval.CourseID, true, null);
            foreach (CourseRole role in staff)
            {
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            }

            //Create zone directory
            string zpath = @"c:\zones\" + eval.ID;
            CFile  ezonedir;

            if (null == (ezonedir = fs.GetFile(zpath)))
            {
                ezonedir       = fs.CreateDirectory(zpath, false, perms);
                ezonedir.Alias = eval.Name; ezonedir.SpecType = CFile.SpecialType.TEST;
                fs.UpdateFileInfo(ezonedir, false);
            }
            fs.ImportData(zpath, zone, false, true);             //Import the data

            return(ezonedir.ID);
        }
コード例 #5
0
        private string ExportToTemp(AutoEvaluation eval)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            string tpath = Path.Combine(Globals.TempDirectory, Globals.CurrentUserName);

            try { Directory.Delete(tpath); } catch (Exception) { }
            Directory.CreateDirectory(tpath);

            IExternalSink tsink = new OSFileSystemSink();

            tsink.CreateSink("");

            //Export eval files (JUnit test suite)
            try {
                fs.ExportData(tpath, fs.GetFile(eval.ZoneID), tsink, false);
            } catch (Exception er) {
                string mike = er.Message;
            }

            //Export jdisco program
            try {
                fs.ExportData(tpath, fs.GetFile(@"c:\system\junit"), tsink, false);
            } catch (Exception er) {
                string mike = er.Message;
            }

            return(tpath);
        }
コード例 #6
0
        protected string RunBuildTest(Zone zone, AutoEvaluation job, out bool suc)
        {
            int retval = -1;
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);

            exttool.Arguments = job.RunToolArgs;

            DateTime begin = DateTime.Now;

            try {
                retval = exttool.Execute(zone.LocalPath, job.TimeLimit * 1000);
            } catch (ToolExecutionException er) {
                suc = false;
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (Exception) {
                suc = false;
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points));
            }

            DateTime end = DateTime.Now;

            int time = Convert.ToInt32(end.Subtract(begin).TotalSeconds);

            suc = (retval == 0);
            return(FormBuildXml(suc, time,
                                String.Format("{0}\n\n{1}", exttool.Output, exttool.ErrorOutput),
                                job.Points));
        }
コード例 #7
0
        protected string RunTest(Zone zone, AutoEvaluation job)
        {
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            //Get interface to external running tool
            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);

            exttool.Arguments = job.RunToolArgs;

            //Execute the test with the tool
            try {
                if (exttool.Execute(zone.LocalPath, job.TimeLimit * 1000) != 0)
                {
                    return(FormErrorXml(AutoResult.CRITICALLYFLAWED,
                                        exttool.ErrorOutput, job.Points));
                }
                else
                {
                    return(ValidateResult(exttool.Output));
                }
            } catch (ToolExecutionException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (ResultFormatException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (Exception) {
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points));
            }
        }
コード例 #8
0
        /// <summary>
        /// Create the evaluation
        /// Inserts the test files into the file system
        /// Create the record for the auto evaluation
        /// </summary>
        public bool CreateAuto(AutoEvaluation eval, IExternalSource zone)
        {
            //Create the record for the val
            m_dp.CreateAutoEvaluation(eval);
            eval.CourseID = new Assignments(m_ident).GetInfo(eval.AsstID).CourseID;

            return(UpdateAuto(eval, zone));
        }
コード例 #9
0
ファイル: evaluations.cs プロジェクト: padilhalino/FrontDesk
        /// <summary>
        /// Create the evaluation
        /// Inserts the test files into the file system
        /// Create the record for the auto evaluation
        /// </summary>
        public bool CreateAuto(AutoEvaluation eval, IExternalSource zone)
        {
            //Create the record for the val
            m_dp.CreateAutoEvaluation(eval);
            eval.CourseID = new Assignments(m_ident).GetInfo(eval.AsstID).CourseID;

            return UpdateAuto(eval, zone);
        }
コード例 #10
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);
        }
コード例 #11
0
        private void BindCSView(AutoEvaluation eval)
        {
            ucCSDeps.BindData(eval);
            ucCSDeps.ShowUpdate = true;
            ucCSDeps.EvalID     = eval.ID;

            AddBrowserAttr(lnkCSEval, eval);
            lblEvalID.Text = eval.ID.ToString();
        }
コード例 #12
0
        /// <summary>
        /// Update an automatic evaluation
        /// </summary>
        public bool UpdateAuto(AutoEvaluation eval, IExternalSource esrc)
        {
            //Check version
            if (!ValidateVersion(eval.ToolVersion))
            {
                throw new DataAccessException("Illegal version number");
            }

            eval.ZoneID = CommitTestSource(eval, esrc);

            return(m_dp.UpdateAutoEvaluation(eval));
        }
コード例 #13
0
        private void RemoveResults(AutoEvaluation eval)
        {
            Rubric rub = new Evaluations(Globals.CurrentIdentity).GetRubric(eval.ID);

            Result.ResultList ress  = new Rubrics(Globals.CurrentIdentity).GetResults(rub.ID);
            Results           resda = new Results(Globals.CurrentIdentity);

            foreach (Result res in ress)
            {
                resda.Delete(res.ID);
            }
        }
コード例 #14
0
ファイル: cstool.cs プロジェクト: lokygb/FrontDesk
        //Copy CS helper code into autoevaluation zone
        public void CopySupportFiles(AutoEvaluation eval)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            //Get zone
            CFile zone = fs.GetFile(eval.ZoneID);

            //Copy CS program over
            CFile.FileList dfiles = new CFile.FileList();
            dfiles.Add(fs.GetFile(@"c:\system\checkstyle\CheckStyle.class"));
            dfiles.Add(fs.GetFile(@"c:\system\checkstyle\checksubj.xslt"));
            fs.CopyFiles(zone, dfiles, true);
        }
コード例 #15
0
ファイル: cstool.cs プロジェクト: padilhalino/FrontDesk
        //Copy CS helper code into autoevaluation zone
        public void CopySupportFiles(AutoEvaluation eval)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            //Get zone
            CFile zone = fs.GetFile(eval.ZoneID);

            //Copy CS program over
            CFile.FileList dfiles = new CFile.FileList();
            dfiles.Add(fs.GetFile(@"c:\system\checkstyle\CheckStyle.class"));
            dfiles.Add(fs.GetFile(@"c:\system\checkstyle\checksubj.xslt"));
            fs.CopyFiles(zone, dfiles, true);
        }
コード例 #16
0
ファイル: junittool.cs プロジェクト: padilhalino/FrontDesk
        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;
        }
コード例 #17
0
        private void cmdJUnitUpdate_Click(object sender, System.EventArgs e)
        {
            int            evalID = Convert.ToInt32(lblEvalID.Text);
            Evaluations    evalda = new Evaluations(Globals.CurrentIdentity);
            AutoEvaluation eval   = (AutoEvaluation)evalda.GetInfo(evalID);

            try {
                eval.RunOnSubmit = chkJUnitPreTest.Checked;
                eval.Competitive = chkJUnitCompete.Checked;
                evalda.UpdateAuto(eval, new EmptySource());
            } catch (CustomException er) {
                PageJUnitError(er.Message);
            }

            UpdateRightSide();
        }
コード例 #18
0
ファイル: junittool.cs プロジェクト: padilhalino/FrontDesk
        public string ReDiscover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            string xmltests;
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            CFile zone = fs.GetFile(eval.ZoneID);
            CFile xmldesc = fs.GetFile(Path.Combine(zone.FullPath, "__testsuite.xml"));
            if (xmldesc == null)
                throw new JUnitToolException("No proper JUnit Test Suite uploaded");

            fs.LoadFileData(xmldesc);
            xmltests = new string(xmldesc.Data);

            GetSuiteInfo(xmltests, out points, out time, out count);

            return xmltests;
        }
コード例 #19
0
        private void PercolateModified(CFile file, DateTime mod)
        {
            if (file != null && file.FullPath != @"c:\")
            {
                file.FileModified = mod;
                m_dp.SyncFile(file);

                //Check special directories
                if (file.SpecType == CFile.SpecialType.SUBMISSION)
                {
                    Submissions           subda = new Submissions(Globals.CurrentIdentity);
                    Components.Submission sub   = subda.GetInfoByDirectoryID(file.ID);
                    if (sub != null)
                    {
                        //Check to see if a staff member modded
                        CourseRole role = new Courses(Globals.CurrentIdentity).GetRole(
                            m_ident.Name, new Assignments(Globals.CurrentIdentity).GetInfo(sub.AsstID).CourseID, null);

                        //Student mods update the submission time, staff mods don't...
                        if (!role.Staff)
                        {
                            sub.Creation = mod;
                            sub.Status   = Components.Submission.UNGRADED;
                            subda.Update(sub, new EmptySource());

                            //Log this in sub log
                            new Activities(m_ident).Create(m_ident.Name, Activity.SUBMISSION, sub.ID,
                                                           "Updated submission time due to student modification of files");
                        }
                    }
                }
                else if (file.SpecType == CFile.SpecialType.TEST)
                {
                    Evaluations    evalda = new Evaluations(Globals.CurrentIdentity);
                    AutoEvaluation eval   = evalda.GetAutoInfoByZone(file.ID);
                    if (eval != null)
                    {
                        eval.ZoneModified = mod;
                        evalda.UpdateAuto(eval, new EmptySource());
                    }
                }

                CFile par = GetFile(file.Path);
                PercolateModified(par, mod);
            }
        }
コード例 #20
0
        private void cmdUpdate_Click(object source, EventArgs e)
        {
            AutoEvaluation eval = new AutoEvaluation();

            eval.ID          = Convert.ToInt32(lblEvalID.Text);
            eval             = (AutoEvaluation) new Evaluations(Globals.CurrentIdentity).GetInfo(eval.ID);
            eval.TimeLimit   = Convert.ToInt32(txtTimeLimit.Text);
            eval.RunToolArgs = txtRunArguments.Text;
            eval.RunTool     = ddlRunTool.SelectedItem.Text;

            eval.IsBuild        = chkBuild.Checked;
            eval.RunOnSubmit    = chkPretest.Checked;
            eval.Competitive    = chkCompete.Checked;
            eval.ToolVersion    = txtVersion.Text;
            eval.ToolVersioning = Convert.ToInt32(ddlVersioning.SelectedItem.Value);

            //Create deps if possible
            try {
                ucEvalDeps.Update(eval.ID, eval.AsstID);
            } catch (CustomException er) {
                PageJUnitError(er.Message);
                return;
            }

            //Create xtern source
            IExternalSource esrc;

            if (fuTester.PostedFile.ContentLength == 0)
            {
                esrc = new EmptySource();
            }
            else
            {
                esrc = CreateSource(fuTester.PostedFile);
            }

            //Upload files
            try {
                new Evaluations(Globals.CurrentIdentity).UpdateAuto(eval, esrc);
            } catch (CustomException er) {
                PageAutoError(er.Message);
            }

            BindAutoView(eval);
        }
コード例 #21
0
        public string ReDiscover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            string     xmltests;
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            CFile zone    = fs.GetFile(eval.ZoneID);
            CFile xmldesc = fs.GetFile(Path.Combine(zone.FullPath, "__testsuite.xml"));

            if (xmldesc == null)
            {
                throw new JUnitToolException("No proper JUnit Test Suite uploaded");
            }

            fs.LoadFileData(xmldesc);
            xmltests = new string(xmldesc.Data);

            GetSuiteInfo(xmltests, out points, out time, out count);

            return(xmltests);
        }
コード例 #22
0
        /// <summary>
        /// Remove an auto evaluation (takes results with it)
        /// </summary>
        public bool Delete(int evalID)
        {
            Evaluation eval = GetInfo(evalID);

            //take evaluation
            m_dp.DeleteEval(evalID);

            //Delete zone files
            if (eval.Type == Evaluation.AUTO_TYPE)
            {
                FileSystem     fs    = new FileSystem(m_ident);
                AutoEvaluation aeval = eval as AutoEvaluation;
                CFile          zdir  = fs.GetFile(aeval.ZoneID);
                if (null != zdir)
                {
                    fs.DeleteFile(zdir);
                }
            }

            return(true);
        }
コード例 #23
0
        private void AddBrowserAttr(LinkButton link, AutoEvaluation eval)
        {
            Evaluation.EvaluationList evals =
                (new Assignments(Globals.CurrentIdentity)).GetAutoEvals(eval.AsstID);

            int    i;
            string roots = "";

            for (i = 0; i < evals.Count; i++)
            {
                AutoEvaluation aeval = evals[i] as AutoEvaluation;
                if (aeval.ZoneID > 0)
                {
                    roots += aeval.ZoneID + "|";
                }
            }

            link.Attributes.Add("onClick",
                                @"window.open('filebrowser.aspx?Roots=" + roots +
                                @"', '" + 8 + @"', 'width=730, height=630')");
        }
コード例 #24
0
        protected bool CreateZone(AutoEvaluation eval)
        {
            FileSystem fs   = FileSystem.GetInstance();
            DataSet    desc = new DataSet();

            //Create initial zone directory
            string zpath = Path.Combine(TestConfig.LocalZonePath, eval.ZoneID.ToString());

            Directory.CreateDirectory(zpath);

            //Export the zone files into local store
            IExternalSink zdir = new OSFileSystemSink();

            m_logger.Log("Retrieving zone files for zone: " + eval.ZoneID);

            zdir.CreateSink("");
            try {
                desc = fs.ExportData(zpath, fs.GetFile(eval.ZoneID), zdir, false);

                //Write XML descriptor
                desc.Tables["Export"].Rows[0]["Mod"] = eval.ZoneModified.ToString();
                desc.WriteXml(Path.Combine(zpath, "__zone.xml"));
                m_logger.Log("Zone retrieved successfully");
            } catch (FileOperationException e) {
                m_logger.Log("File error: " + e.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return(false);
            } catch (DataAccessException er) {
                m_logger.Log("Data error: " + er.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return(false);
            } catch (Exception e) {
                m_logger.Log("Unexpected error: " + e.Message, TestLogger.LogType.ERROR);
                m_logger.Log("Trace: " + e.StackTrace, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return(false);
            }

            return(true);
        }
コード例 #25
0
ファイル: testzonesvc.cs プロジェクト: padilhalino/FrontDesk
        protected bool CreateZone(AutoEvaluation eval)
        {
            FileSystem fs = FileSystem.GetInstance();
            DataSet desc = new DataSet();

            //Create initial zone directory
            string zpath = Path.Combine(TestConfig.LocalZonePath, eval.ZoneID.ToString());
            Directory.CreateDirectory(zpath);

            //Export the zone files into local store
            IExternalSink zdir = new OSFileSystemSink();

            m_logger.Log("Retrieving zone files for zone: " + eval.ZoneID);

            zdir.CreateSink("");
            try {
                desc = fs.ExportData(zpath, fs.GetFile(eval.ZoneID), zdir, false);

                //Write XML descriptor
                desc.Tables["Export"].Rows[0]["Mod"] = eval.ZoneModified.ToString();
                desc.WriteXml(Path.Combine(zpath, "__zone.xml"));
                m_logger.Log("Zone retrieved successfully");

            } catch (FileOperationException e) {
                m_logger.Log("File error: " + e.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            } catch (DataAccessException er) {
                m_logger.Log("Data error: " + er.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            } catch (Exception e) {
                m_logger.Log("Unexpected error: " + e.Message, TestLogger.LogType.ERROR);
                m_logger.Log("Trace: " + e.StackTrace, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            }

            return true;
        }
コード例 #26
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;
        }
コード例 #27
0
        public void BindData(AutoEvaluation eval)
        {
            int asstID = eval.AsstID;

            Assignments assts = new Assignments(Globals.CurrentIdentity);
            Evaluations evals = new Evaluations(Globals.CurrentIdentity);

            Evaluation.EvaluationList allevals = assts.GetAutoEvals(asstID);
            Evaluation.EvaluationList deps = evals.GetDependencies(eval.ID);

            chkDeps.Items.Clear();
            foreach (Evaluation e in allevals) {
                if (e.ID == eval.ID) continue;
                ListItem eitem = new ListItem(e.Name, e.ID.ToString());
                foreach (Evaluation d in deps) {
                    if (d.ID == e.ID) {
                        eitem.Selected = true;
                        break;
                    }
                }
                chkDeps.Items.Add(eitem);
            }
        }
コード例 #28
0
        private void BindAutoView(AutoEvaluation eval)
        {
            //Add file browser link
            AddBrowserAttr(lnkFiles, eval);

            lblEvalID.Text     = eval.ID.ToString();
            chkBuild.Checked   = eval.IsBuild;
            chkPretest.Checked = eval.RunOnSubmit;
            chkCompete.Checked = eval.Competitive;
            txtVersion.Text    = eval.ToolVersion;

            //Set up versioning
            ddlVersioning.Items.Clear();
            ddlVersioning.Items.Add(new ListItem("At Least", ((int)ExternalToolFactory.VersionCompare.ATLEAST).ToString()));
            ddlVersioning.Items.Add(new ListItem("Exact Match", ((int)ExternalToolFactory.VersionCompare.EQUAL).ToString()));
            ddlVersioning.Items.Add(new ListItem("No Versioning", ((int)ExternalToolFactory.VersionCompare.NONE).ToString()));
            ddlVersioning.SelectedIndex = eval.ToolVersioning;

            BindAutoTools(eval.RunTool);
            txtRunArguments.Text = eval.RunToolArgs;
            txtTimeLimit.Text    = eval.TimeLimit.ToString();

            ucEvalDeps.BindData(eval);
        }
コード例 #29
0
        private void AddBrowserAttr(LinkButton link, AutoEvaluation eval)
        {
            Evaluation.EvaluationList evals =
                (new Assignments(Globals.CurrentIdentity)).GetAutoEvals(eval.AsstID);

            int i;
            string roots="";
            for (i = 0; i < evals.Count; i++) {
                AutoEvaluation aeval = evals[i] as AutoEvaluation;
                if (aeval.ZoneID > 0)
                    roots += aeval.ZoneID+"|";
            }

            link.Attributes.Add("onClick",
                @"window.open('filebrowser.aspx?Roots=" + roots +
                @"', '"+8+@"', 'width=730, height=630')");
        }
コード例 #30
0
ファイル: testcenter.cs プロジェクト: padilhalino/FrontDesk
        protected string RunTest(Zone zone, AutoEvaluation job)
        {
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            //Get interface to external running tool
            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);
            exttool.Arguments = job.RunToolArgs;

            //Execute the test with the tool
            try {
                if (exttool.Execute(zone.LocalPath, job.TimeLimit*1000) != 0)
                    return FormErrorXml(AutoResult.CRITICALLYFLAWED,
                        exttool.ErrorOutput, job.Points);
                else
                    return ValidateResult(exttool.Output);
            } catch (ToolExecutionException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points);
            } catch (ResultFormatException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points);
            } catch (Exception) {
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points);
            }
        }
コード例 #31
0
ファイル: junittool.cs プロジェクト: padilhalino/FrontDesk
 private void RemoveResults(AutoEvaluation eval)
 {
     Rubric rub = new Evaluations(Globals.CurrentIdentity).GetRubric(eval.ID);
     Result.ResultList ress = new Rubrics(Globals.CurrentIdentity).GetResults(rub.ID);
     Results resda = new Results(Globals.CurrentIdentity);
     foreach (Result res in ress)
         resda.Delete(res.ID);
 }
コード例 #32
0
ファイル: testzonesvc.cs プロジェクト: padilhalino/FrontDesk
        protected bool UpdateZone(AutoEvaluation eval)
        {
            DataSet zonedesc = new DataSet();

            string dpath = Path.Combine(TestConfig.LocalZonePath, eval.ZoneID.ToString());
            string xmlpath = Path.Combine(dpath, "__zone.xml");

            if (!File.Exists(xmlpath)) {
                Directory.Delete(dpath, true);
                return CreateZone(eval);
            }
            else {
                m_logger.Log("Checking for update on zone: " + eval.ZoneID);
                zonedesc.ReadXml(xmlpath);
                DateTime localmod = Convert.ToDateTime(zonedesc.Tables["Export"].Rows[0]["Mod"]);
                DateTime zonemod = eval.ZoneModified;

                //If zone is modified, blow it away and get it again
                if (zonemod > localmod) {
                    m_logger.Log("Update needed for zone: " + eval.ZoneID);
                    Directory.Delete(dpath, true);
                    return CreateZone(eval);
                }
            }

            return true;
        }
コード例 #33
0
ファイル: evaluations.cs プロジェクト: padilhalino/FrontDesk
        /// <summary>
        /// Update an automatic evaluation
        /// </summary>
        public bool UpdateAuto(AutoEvaluation eval, IExternalSource esrc)
        {
            //Check version
            if (!ValidateVersion(eval.ToolVersion))
                throw new DataAccessException("Illegal version number");

            eval.ZoneID = CommitTestSource(eval, esrc);

            return m_dp.UpdateAutoEvaluation(eval);
        }
コード例 #34
0
ファイル: evaluations.cs プロジェクト: padilhalino/FrontDesk
        private int CommitTestSource(AutoEvaluation eval, IExternalSource zone)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Make sure toplevel zone directory exists
            CFile zonedir = fs.GetFile(@"c:\zones");
            if (null == zonedir)
                zonedir = fs.CreateDirectory(@"c:\zones", true, null);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(eval.CourseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));

            //Create zone directory
            string zpath = @"c:\zones\" + eval.ID;
            CFile ezonedir;
            if (null == (ezonedir = fs.GetFile(zpath))) {
                ezonedir = fs.CreateDirectory(zpath, false, perms);
                ezonedir.Alias = eval.Name; ezonedir.SpecType = CFile.SpecialType.TEST;
                fs.UpdateFileInfo(ezonedir, false);
            }
            fs.ImportData(zpath, zone, false, true); //Import the data

            return ezonedir.ID;
        }
コード例 #35
0
ファイル: junittool.cs プロジェクト: padilhalino/FrontDesk
        private string ExportToTemp(AutoEvaluation eval)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            string tpath = Path.Combine(Globals.TempDirectory, Globals.CurrentUserName);
            try { Directory.Delete(tpath); } catch (Exception) { }
            Directory.CreateDirectory(tpath);

            IExternalSink tsink = new OSFileSystemSink();
            tsink.CreateSink("");

            //Export eval files (JUnit test suite)
            try {
                fs.ExportData(tpath, fs.GetFile(eval.ZoneID), tsink, false);
            } catch (Exception er) {
                string mike = er.Message;
            }

            //Export jdisco program
            try {
                fs.ExportData(tpath, fs.GetFile(@"c:\system\junit"), tsink, false);
            } catch (Exception er) {
                string mike = er.Message;
            }

            return tpath;
        }
コード例 #36
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;
        }
コード例 #37
0
ファイル: testcenter.cs プロジェクト: padilhalino/FrontDesk
        protected string RunBuildTest(Zone zone, AutoEvaluation job, out bool suc)
        {
            int retval=-1;
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);
            exttool.Arguments = job.RunToolArgs;

            DateTime begin = DateTime.Now;
            try {
                retval = exttool.Execute(zone.LocalPath, job.TimeLimit*1000);
            } catch (ToolExecutionException er) {
                suc = false;
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points);
            } catch (Exception) {
                suc = false;
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points);
            }

            DateTime end = DateTime.Now;

            int time = Convert.ToInt32(end.Subtract(begin).TotalSeconds);

            suc = (retval == 0);
            return FormBuildXml(suc, time,
                String.Format("{0}\n\n{1}", exttool.Output, exttool.ErrorOutput),
                job.Points);
        }
コード例 #38
0
        private void BindAutoView(AutoEvaluation eval)
        {
            //Add file browser link
            AddBrowserAttr(lnkFiles, eval);

            lblEvalID.Text = eval.ID.ToString();
            chkBuild.Checked = eval.IsBuild;
            chkPretest.Checked = eval.RunOnSubmit;
            chkCompete.Checked = eval.Competitive;
            txtVersion.Text = eval.ToolVersion;

            //Set up versioning
            ddlVersioning.Items.Clear();
            ddlVersioning.Items.Add(new ListItem("At Least", ((int)ExternalToolFactory.VersionCompare.ATLEAST).ToString()));
            ddlVersioning.Items.Add(new ListItem("Exact Match", ((int)ExternalToolFactory.VersionCompare.EQUAL).ToString()));
            ddlVersioning.Items.Add(new ListItem("No Versioning", ((int)ExternalToolFactory.VersionCompare.NONE).ToString()));
            ddlVersioning.SelectedIndex = eval.ToolVersioning;

            BindAutoTools(eval.RunTool);
            txtRunArguments.Text = eval.RunToolArgs;
            txtTimeLimit.Text = eval.TimeLimit.ToString();

            ucEvalDeps.BindData(eval);
        }
コード例 #39
0
        private void BindCSView(AutoEvaluation eval)
        {
            ucCSDeps.BindData(eval);
            ucCSDeps.ShowUpdate = true;
            ucCSDeps.EvalID = eval.ID;

            AddBrowserAttr(lnkCSEval, eval);
            lblEvalID.Text = eval.ID.ToString();
        }
コード例 #40
0
        private void CreateRubricEntry(int type)
        {
            TreeNode par = tvRubric.GetNodeFromIndex(tvRubric.SelectedNodeIndex);
            int parentID = Convert.ToInt32(par.NodeData.Split(" ".ToCharArray())[1]);
            int evalID=-1;
            double points=0;
            string ename="New Entry";

            Rubric rubpar = new Rubrics(Globals.CurrentIdentity).GetInfo(parentID);
            AutoEvaluation eval = new AutoEvaluation();
            string[] tools;
            try {
                switch (type) {
                case AUTOMATIC:
                    eval.Name = "New Automatic Entry";
                    eval.AsstID = rubpar.AsstID;
                    eval.Competitive = false;
                    eval.Creator = Globals.CurrentUserName;
                    eval.RunOnSubmit = false;
                    eval.Manager = Evaluation.NO_MANAGER;

                    tools = ExternalToolFactory.GetInstance().ListKeys();
                    if (tools.Length > 0)
                        eval.RunTool = tools[0];
                    else
                        eval.RunTool = "No tools installed";

                    eval.ToolVersioning = (int) ExternalToolFactory.VersionCompare.NONE;
                    eval.ToolVersion = "";
                    eval.RunToolArgs = "";
                    eval.TimeLimit = 60;
                    eval.IsBuild = false;
                    eval.ResultType = Result.AUTO_TYPE;

                    new Evaluations(Globals.CurrentIdentity).CreateAuto(eval, new EmptySource());
                    evalID = eval.ID;
                    ename = eval.Name;
                    break;

                case CHECKSTYLE:
                    eval = new AutoEvaluation();
                    eval.Name = "New CheckStyle Entry";
                    eval.AsstID = rubpar.AsstID;
                    eval.Competitive = false;
                    eval.Creator = Globals.CurrentUserName;
                    eval.RunOnSubmit = false;
                    eval.Manager = Evaluation.CHECKSTYLE_MANAGER;
                    eval.RunTool = "Java";
                    eval.ToolVersion = "1.4";
                    eval.ToolVersioning = (int) ExternalToolFactory.VersionCompare.ATLEAST;
                    eval.RunToolArgs = "CheckStyle";
                    eval.TimeLimit = 280;
                    eval.IsBuild = false;
                    eval.ResultType = Result.SUBJ_TYPE;

                    new Evaluations(Globals.CurrentIdentity).CreateAuto(eval, new EmptySource());

                    evalID = eval.ID;
                    ename = eval.Name;
                    break;

                case JUNIT:
                    eval = new AutoEvaluation();
                    eval.Name = "New JUnit Entry";
                    eval.AsstID = rubpar.AsstID;
                    eval.Competitive = false;
                    eval.Creator = Globals.CurrentUserName;
                    eval.RunOnSubmit = false;
                    eval.Manager = Evaluation.JUNIT_MANAGER;
                    eval.RunTool = "Perl";
                    eval.ToolVersion = "5.0";
                    eval.ToolVersioning = (int) ExternalToolFactory.VersionCompare.ATLEAST;
                    eval.RunToolArgs = "jdisco.pl r 0";
                    eval.TimeLimit = 0;
                    eval.IsBuild = false;
                    eval.ResultType = Result.AUTO_TYPE;

                    new Evaluations(Globals.CurrentIdentity).CreateAuto(
                        eval, new EmptySource());

                    evalID = eval.ID;
                    ename = eval.Name;
                    break;

                case CANNED:
                    evalID=-1;
                    ename = "New Human/Subjective Entry";
                    break;
                case HEADING:
                    points=-1;
                    ename = "New Folder Heading";
                    break;
                }

                new Rubrics(Globals.CurrentIdentity).CreateItem(parentID,
                    ename, "Hit modify and enter a description", points, evalID);

            } catch (CustomException er) {
                PageError(er.Message);
            }

            LoadRubricNode(par, parentID);
            par.Expanded = true;
        }
コード例 #41
0
        private void cmdUpdate_Click(object source, EventArgs e)
        {
            AutoEvaluation eval = new AutoEvaluation();

            eval.ID = Convert.ToInt32(lblEvalID.Text);
            eval = (AutoEvaluation) new Evaluations(Globals.CurrentIdentity).GetInfo(eval.ID);
            eval.TimeLimit = Convert.ToInt32(txtTimeLimit.Text);
            eval.RunToolArgs = txtRunArguments.Text;
            eval.RunTool = ddlRunTool.SelectedItem.Text;

            eval.IsBuild = chkBuild.Checked;
            eval.RunOnSubmit = chkPretest.Checked;
            eval.Competitive = chkCompete.Checked;
            eval.ToolVersion = txtVersion.Text;
            eval.ToolVersioning = Convert.ToInt32(ddlVersioning.SelectedItem.Value);

            //Create deps if possible
            try {
                ucEvalDeps.Update(eval.ID, eval.AsstID);
            } catch (CustomException er) {
                PageJUnitError(er.Message);
                return;
            }

            //Create xtern source
            IExternalSource esrc;
            if (fuTester.PostedFile.ContentLength == 0)
                esrc = new EmptySource();
            else
                esrc = CreateSource(fuTester.PostedFile);

            //Upload files
            try {
                new Evaluations(Globals.CurrentIdentity).UpdateAuto(eval, esrc);
            } catch (CustomException er) {
                PageAutoError(er.Message);
            }

            BindAutoView(eval);
        }