private void BindData()
        {
            if (ddlCompete.Items.Count == 0) return;

            m_subs = new Hashtable();
            //Get results
            Result.ResultList ress =
                new Evaluations(Globals.CurrentIdentity).GetCompetitionResults(Convert.ToInt32(ddlCompete.SelectedValue),
                                                                               out m_subs);
            dgCompete.DataSource = ress;
            dgCompete.DataBind();
        }
Exemple #2
0
        /// <summary>
        /// Create a test for a job
        /// </summary>
        public bool CreateTest(int jobID, int subID, int evalID, bool onsubmit)
        {
            Components.Submission sub = new Submissions(m_ident).GetInfo(subID);
            Assignment asst = new Assignments(m_ident).GetInfo(sub.AsstID);
            Evaluation eval = new Evaluations(m_ident).GetInfo(evalID);
            //		Authorize(asst.CourseID, "createjob", asst.ID, null);

            //Log that the student is being auto run
            new Activities(m_ident).Create(m_ident.Name, Activity.SUBMISSION, subID,
                "Started auto-evaluation: " + eval.Name);

            return m_dp.CreateAutoJobTest(jobID, evalID, subID, onsubmit);
        }
Exemple #3
0
        /// <summary>
        /// Create a test for a job
        /// </summary>
        public bool CreateTest(int jobID, int subID, int evalID, bool onsubmit)
        {
            Components.Submission sub  = new Submissions(m_ident).GetInfo(subID);
            Assignment            asst = new Assignments(m_ident).GetInfo(sub.AsstID);
            Evaluation            eval = new Evaluations(m_ident).GetInfo(evalID);

            //		Authorize(asst.CourseID, "createjob", asst.ID, null);

            //Log that the student is being auto run
            new Activities(m_ident).Create(m_ident.Name, Activity.SUBMISSION, subID,
                                           "Started auto-evaluation: " + eval.Name);

            return(m_dp.CreateAutoJobTest(jobID, evalID, subID, onsubmit));
        }
        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);
            }
        }
Exemple #5
0
            private Node BuildGraph(Evaluations evals, Evaluation eval, Hashtable adjlists)
            {
                //Create node in graph if not there
                Node enode = new Node(eval, false);

                if (!adjlists.ContainsKey(enode))
                {
                    adjlists.Add(enode, new ArrayList());
                }

                //Create edges
                Evaluation.EvaluationList deps = evals.GetDependencies(eval.ID);
                foreach (Evaluation dep in deps)
                {
                    //Get node in graph
                    Node dnode = BuildGraph(evals, dep, adjlists);

                    //Create edge
                    ((ArrayList)adjlists[enode]).Add(dnode);
                }

                return(enode);
            }
        public void Update(int editEval, int asstID)
        {
            Assignments assts = new Assignments(Globals.CurrentIdentity);
            Evaluations evals = new Evaluations(Globals.CurrentIdentity);

            Evaluation.EvaluationList allevals = assts.GetAutoEvals(asstID);
            foreach (ListItem item in Items) {
                int iid = Convert.ToInt32(item.Value);
                foreach (Evaluation eval in allevals) {
                    if (iid == eval.ID) {
                        bool dependence = evals.DependsOn(editEval, iid);
                        if (dependence && !item.Selected)
                            evals.DeleteDependency(editEval, iid);
                        else if (!dependence && item.Selected) {
                            if (!evals.CreateDependency(editEval, iid)) {
                                item.Selected = false;
                                throw new DataAccessException("Cannot create a circular dependency: " +
                                    eval.Name);
                            }
                        }
                    }
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Main worker thread for the testing center
        /// </summary>
        public void TestWorker()
        {
            AutoJobTest job;
            bool bsuc;
            Evaluations evals = new Evaluations(m_ident);
            AutoJobs jobs = new AutoJobs(m_ident);
            ZoneService testsvc = new ZoneService("auto", m_ident, m_logger);
            ZoneService stusvc = new ZoneService("stu", m_ident, m_logger);
            Submissions subs = new Submissions(m_ident);

            while (!m_shutdown) {

                //Get job
                try {
                    job = jobs.Claim(m_ipaddress, m_desc);
                    if (job != null) {

                        m_status = Status.RUNNING;

                        Submission sub = subs.GetInfo(job.SubmissionID);
                        m_logger.Log(String.Format("Claimed job: JOB: {0} EVAL: {1} SUB: {2}",
                            job.JobName, job.AutoEval.Name, new Principals(m_ident).GetInfo(sub.PrincipalID).Name));

                        m_logger.Log("Synchronizing eval and student zones");
                        //Sync test zone
                        Zone tzone = testsvc.Synchronize(job.AutoEval);

                        //Sync stu zone
                        Zone szone = stusvc.Synchronize(sub);

                        //Copy stu zone into test zone
                        testsvc.CopyZone(tzone, szone);

                        //Create dep graph and run deps
                        m_logger.Log("Beginning dependency running");
                        Evaluations.DependencyGraph dg =
                            new Evaluations.DependencyGraph(job.AutoEval, m_ident);
                        string faildep, xmloutput="";
                        if (null != (faildep = RunDependencies(tzone, testsvc, dg))) {
                            xmloutput = FormErrorXml(AutoResult.DEPFAIL,
                                "Test unable to run, dependency: " +
                                faildep + " failed to complete successfully!",
                                job.AutoEval.Points);
                            m_logger.Log("Dependency fail (" + faildep + "), not running main test",
                                TestLogger.LogType.WARNING);
                        } else {
                            //Run test and gather result
                            m_logger.Log("Starting run of test");
                            if (job.AutoEval.IsBuild)
                                xmloutput = RunBuildTest(tzone, job.AutoEval, out bsuc);
                            else
                                xmloutput = RunTest(tzone, job.AutoEval);
                        }

                        //Post result
                        xmloutput = Globals.PurifyZeroes(xmloutput);
                        if (!PostResult(job, xmloutput))
                            m_logger.Log("Error logging result", TestLogger.LogType.ERROR);
                        else
                            m_logger.Log("Test completed, result stored");

                        //Clear the job out
                        jobs.FinishTest(job);
                    }
                } catch (Exception er) {
                    m_logger.Log("Unexpected and fatal error during testing: MESSAGE: " + er.Message, TestLogger.LogType.ERROR);
                }

                m_status = Status.QUEUED;
                Thread.Sleep(TimeSpan.FromSeconds(5));
            }
        }
        private void lstTests_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            ArrayList evals = GetTests();
            Evaluations aevals = new Evaluations(Globals.CurrentIdentity);

            lstOrder.Items.Clear();
            foreach (int evalID in evals) {
                Evaluation eval = aevals.GetInfo(evalID);
                Evaluations.DependencyGraph dg =
                    new Evaluations.DependencyGraph(eval, Globals.CurrentIdentity);

                Evaluation.EvaluationList order = dg.GetBuildOrder();
                foreach (Evaluation oeval in order)
                    lstOrder.Items.Add(oeval.Name);

                lstOrder.Items.Add(eval.Name);
            }
        }
        private void lnkUpdate_Click(object sender, EventArgs e)
        {
            Evaluation eval = new Evaluations(Globals.CurrentIdentity).GetInfo(EvalID);

            try {
                Update(eval.ID, eval.AsstID);
            } catch (DataAccessException er) {
                PageError(er.Message);
            }

            BindData((AutoEvaluation)eval);
        }
Exemple #10
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);
 }
Exemple #11
0
            private Node BuildGraph(Evaluations evals, Evaluation eval, Hashtable adjlists)
            {
                //Create node in graph if not there
                Node enode = new Node(eval, false);
                if (!adjlists.ContainsKey(enode))
                    adjlists.Add(enode, new ArrayList());

                //Create edges
                Evaluation.EvaluationList deps = evals.GetDependencies(eval.ID);
                foreach (Evaluation dep in deps) {

                    //Get node in graph
                    Node dnode = BuildGraph(evals, dep, adjlists);

                    //Create edge
                    ((ArrayList)adjlists[enode]).Add(dnode);
                }

                return enode;
            }
Exemple #12
0
        /// <summary>
        /// Delete the assignment
        /// </summary>
        public bool Delete(int asstID)
        {
            FileSystem fs = new FileSystem(m_ident);
            Submissions subda = new Submissions(m_ident);
            Evaluations evalda = new Evaluations(m_ident);
            Results resultda = new Results(m_ident);
            Groups groupda = new Groups(m_ident);
            AutoJobs jobda = new AutoJobs(m_ident);

            Assignment asst = GetInfo(asstID);

            //Check permission
            Authorize(asst.CourseID, "delete", asstID, null);

            //Take auto jobs
            IProviderTransaction tran = m_dp.BeginTransaction();
            AutoJob.AutoJobList jobs = GetAutoJobs(asstID, tran);
            foreach (AutoJob job in jobs)
                jobda.Finish(job.ID, tran);
            m_dp.CommitTransaction(tran);

            //Take submissions and results
            Components.Submission.SubmissionList allsubs = GetSubmissions(asstID);
            foreach (Components.Submission sub in allsubs)
                subda.Delete(sub.ID);

            //Take rubric
            Rubric rub = GetRubric(asstID);
            new Rubrics(m_ident).Delete(rub.ID);

            //Take evaluations
            Evaluation.EvaluationList allevals = GetEvals(asstID);
            foreach (Evaluation eval in allevals)
                evalda.Delete(eval.ID);

            //Take groups
            Group.GroupList groups = GetGroups(asstID);
            foreach (Group group in groups)
                groupda.Delete(group.PrincipalID, asstID);

            //Take assignment
            m_dp.DeleteAssignment(asstID);

            //Take content
            CFile content = fs.GetFile(asst.ContentID);
            fs.DeleteFile(content);

            //Log
            Log("Deleted assignment: " + asst.Description, asst.ID);

            return true;
        }
        private void lnkRunTest_Click(object sender, EventArgs e)
        {
            AutoJobs ajobda = new AutoJobs(Globals.CurrentIdentity);

            Components.Submission sub =
                new Submissions(Globals.CurrentIdentity).GetInfo(GetSubID());

            Evaluation eval =
                new Evaluations(Globals.CurrentIdentity).GetInfo(Convert.ToInt32(lblEvalID.Text));
            string name = new FileSystem(Globals.CurrentIdentity).GetFile(sub.LocationID).Alias +
                " (" + eval.Name + ")";
            try {
                AutoJob job =
                    ajobda.Create(name, sub.AsstID);
                ajobda.CreateTest(job.ID, sub.ID, eval.ID, false);
            } catch (DataAccessException er) {
                PageRunError(er.Message);
                return;
            }

            PageRunError("Automatic job created successfully!");
        }
        private void UpdateRightSide()
        {
            int rubID = GetCurrentID();
            Rubric rub = new Rubrics(Globals.CurrentIdentity).GetInfo(rubID);

            txtDescription.Text = rub.Description;
            txtName.Text = rub.Name;
            txtPoints.Enabled = true;
            chkAllowNeg.Checked = rub.AllowNegativePoints;
            if (!IsHeading(rub)) {
                txtPoints.Visible = true;
                txtPoints.Text = rub.Points.ToString();
                if (rub.EvalID >= 0) {
                    Evaluation eval = new Evaluations(Globals.CurrentIdentity).GetInfo(rub.EvalID);
                    if (eval.Manager == Evaluation.JUNIT_MANAGER) {
                        BindJUnitView((AutoEvaluation)eval);
                    //	txtPoints.Enabled = false;
                        mpViews.SelectedIndex = JUNITVIEW;
                    } else if (eval.Manager == Evaluation.CHECKSTYLE_MANAGER) {
                        BindCSView((AutoEvaluation)eval);
                        mpViews.SelectedIndex = CHECKSTYLEVIEW;
                    } else {
                        BindAutoView((AutoEvaluation)eval);
                        mpViews.SelectedIndex = AUTOVIEW;
                    }
                }
                else {
                    BindCannedResponses(rubID);
                    mpViews.SelectedIndex = SUBJVIEW;
                }
            }
            else {
                txtPoints.Visible = false;
                mpViews.SelectedIndex = NOVIEW;
            }
        }
        private void cmdJUnitUpload_Click(object sender, System.EventArgs e)
        {
            //Import tester data
            AutoEvaluation eval;
            Evaluations evalda = new Evaluations(Globals.CurrentIdentity);
            Rubrics rubda = new Rubrics(Globals.CurrentIdentity);
            IExternalSource esrc;

            if (fiJUnit.PostedFile.ContentLength == 0) {
                PageJUnitError("You must specify a tester suite to upload");
                return;
            }
            else {
                esrc = CreateSource(fiJUnit.PostedFile);
                eval = (AutoEvaluation) new Evaluations(Globals.CurrentIdentity).GetInfo(
                    Convert.ToInt32(lblEvalID.Text));
            }

            //Load files
            try {
                evalda.UpdateAuto(eval, esrc);
            } catch (CustomException er) {
                PageJUnitError(er.Message);
                return;
            }

            //Discover JUnit test
            double points=0;
            int time=0, count=0;
            try {
                new JUnitTool().Discover(eval, out points, out time, out count);
            } catch (CustomException er) {
                PageJUnitError(er.Message);
            }

            //Update points and time
            Rubric rub = rubda.GetInfo(GetCurrentID());
            eval.TimeLimit = time;
            rub.Points = points;
            try {
                evalda.UpdateAuto(eval, new EmptySource());
                rubda.Update(rub);
                PageJUnitError("Upload successful!");
            } catch (CustomException er) {
                PageJUnitError(er.Message);
            }

            UpdateRightSide();
        }
        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();
        }
        private void cmdCSUpload_Click(object sender, System.EventArgs e)
        {
            //Import tester data
            AutoEvaluation eval;
            Evaluations evalda = new Evaluations(Globals.CurrentIdentity);
            IExternalSource esrc;

            //Get all necessary info
            if (fuCS.PostedFile.ContentLength == 0) {
                PageCSError("You must specify a tester suite to upload");
                return;
            }
            else {
                esrc = CreateSource(fuCS.PostedFile);
                eval = (AutoEvaluation) new Evaluations(Globals.CurrentIdentity).GetInfo(
                    Convert.ToInt32(lblEvalID.Text));
            }

            //Load files
            try {
                evalda.UpdateAuto(eval, esrc);
                new CheckStyleTool().CopySupportFiles(eval);
                PageCSError("Upload successful!");
            } catch (CustomException er) {
                PageCSError(er.Message);
            }

            UpdateRightSide();
        }
Exemple #18
0
        /// <summary>
        /// Delete the assignment
        /// </summary>
        public bool Delete(int asstID)
        {
            FileSystem  fs       = new FileSystem(m_ident);
            Submissions subda    = new Submissions(m_ident);
            Evaluations evalda   = new Evaluations(m_ident);
            Results     resultda = new Results(m_ident);
            Groups      groupda  = new Groups(m_ident);
            AutoJobs    jobda    = new AutoJobs(m_ident);

            Assignment asst = GetInfo(asstID);

            //Check permission
            Authorize(asst.CourseID, "delete", asstID, null);

            //Take auto jobs
            IProviderTransaction tran = m_dp.BeginTransaction();

            AutoJob.AutoJobList jobs = GetAutoJobs(asstID, tran);
            foreach (AutoJob job in jobs)
            {
                jobda.Finish(job.ID, tran);
            }
            m_dp.CommitTransaction(tran);

            //Take submissions and results
            Components.Submission.SubmissionList allsubs = GetSubmissions(asstID);
            foreach (Components.Submission sub in allsubs)
            {
                subda.Delete(sub.ID);
            }

            //Take rubric
            Rubric rub = GetRubric(asstID);

            new Rubrics(m_ident).Delete(rub.ID);

            //Take evaluations
            Evaluation.EvaluationList allevals = GetEvals(asstID);
            foreach (Evaluation eval in allevals)
            {
                evalda.Delete(eval.ID);
            }

            //Take groups
            Group.GroupList groups = GetGroups(asstID);
            foreach (Group group in groups)
            {
                groupda.Delete(group.PrincipalID, asstID);
            }

            //Take assignment
            m_dp.DeleteAssignment(asstID);

            //Take content
            CFile content = fs.GetFile(asst.ContentID);

            fs.DeleteFile(content);

            //Log
            Log("Deleted assignment: " + asst.Description, asst.ID);

            return(true);
        }
 private void ucRubric_RubricSelect(object sender, RubricViewSelectEventArgs e)
 {
     Rubric rub = e.SelectedRubric;
     if (rub.EvalID >= 0) {
         Evaluation eval = new Evaluations(Globals.CurrentIdentity).GetInfo(rub.EvalID);
         if (eval.ResultType == Result.AUTO_TYPE)
             BindAuto(rub);
         else if (eval.ResultType == Result.SUBJ_TYPE)
             BindSubj(rub);
     }
     else if (!new Rubrics(Globals.CurrentIdentity).IsHeading(rub))
         BindSubj(rub);
     else {
         if (!IsStudent())
             mpViews.SelectedIndex = 4;
         else
             mpViews.SelectedIndex = 1;
     }
 }
Exemple #20
0
        protected bool PostResult(AutoJobTest job, string xmloutput)
        {
            Results resda = new Results(m_ident);
            if (job.AutoEval.ResultType == Result.AUTO_TYPE) {
                new Activities(m_ident).Create(job.JobCreator, Activity.SUBMISSION, job.SubmissionID,
                    "Result posted for evaluation: " + job.AutoEval.Name);
                if (!job.OnSubmit) {
                    return resda.CreateAuto(
                        job.AutoEval.ID, job.JobCreator, job.SubmissionID, xmloutput);
                }
                else {
                    Components.Submission sub = new Submissions(m_ident).GetInfo(job.SubmissionID);
                    new EmailWizard(m_ident).SendByPrincipal(sub.PrincipalID,
                        "FrontDesk Submission Results: " + job.AutoEval.Name,
                        ConvertXmlToText(xmloutput, job.AutoEval.CourseID, job.AutoEval.AsstID));
                    m_logger.Log("Result emailed to submitter");
                    if (job.AutoEval.Competitive) {
                        m_logger.Log("Competitive pre-test result stored");
                        return resda.CreateAuto(
                            job.AutoEval.ID, job.JobCreator, job.SubmissionID, xmloutput);
                    }
                    else
                        return true;
                }
            } else {
                SubjResult.SubjResultList ress =
                    ParseSubjXmlResults(xmloutput, new Submissions(m_ident).GetInfo(job.SubmissionID));
                Rubric rub = new Evaluations(m_ident).GetRubric(job.AutoEval.ID);
                new Rubrics(m_ident).ClearResults(rub.ID, job.SubmissionID);
                foreach (SubjResult res in ress)
                    resda.CreateSubj(job.SubmissionID, rub.ID, res.Comment,
                        res.FileID, res.Line, res.Points, new ArrayList(), res.SubjType);

                return true;
            }
        }
Exemple #21
0
        protected string RunDependencies(Zone tzone, ZoneService testsvc, 
            Evaluations.DependencyGraph dg)
        {
            Evaluation.EvaluationList border = dg.GetBuildOrder();
            bool suc;

            //Copy zones first
            foreach (AutoEvaluation eval in border) {
                Zone ezone = testsvc.Synchronize(eval);
                testsvc.CopyZone(tzone, ezone);
            }

            //Run the deps
            foreach (AutoEvaluation eval in border) {

                m_logger.Log("Running Dep: " + eval.Name);
                if (eval.IsBuild)
                    RunBuildTest(tzone, eval, out suc);
                else {
                    string xmlout = RunTest(tzone, eval);
                    if (eval.ResultType == Result.AUTO_TYPE) {
                        AutoResult res = new AutoResult();
                        res.XmlResult = xmlout;

                        suc = (res.Success != AutoResult.CRITICALLYFLAWED);
                    } else
                        suc = true;
                }

                if (!suc)
                    return eval.Name;
            }

            return null;
        }
        private TreeNode AddRubricNode(TreeNodeCollection par, Rubric rub)
        {
            string img, expimage, text;
            bool expand;

            if (new Rubrics(Globals.CurrentIdentity).IsHeading(rub)) {
                if (rub.ParentID < 0)
                    text = String.Format("Rubric - {0} Points", rub.Points);
                else
                    text = rub.Name;
                img = "attributes/folder.gif";
                expimage = "attributes/folderopen.gif";
                expand = true;
            }
            else {
                text = String.Format("{0} ({1} points)", rub.Name, rub.Points);

                if (rub.EvalID < 0) {
                    img = "attributes/book.gif";
                    expimage = "attributes/book.gif";
                }
                else {
                    Evaluation eval = new Evaluations(Globals.CurrentIdentity).GetInfo(rub.EvalID);
                    if (eval.Manager == Evaluation.JUNIT_MANAGER) {
                        img = "attributes/cylj.gif";
                        expimage = "attributes/cylj.gif";
                    }
                    else if (eval.Manager == Evaluation.CHECKSTYLE_MANAGER) {
                        img = "attributes/bookcs.gif";
                        expimage = "attributes/bookcs.gif";
                    } else {
                        img = "attributes/cyl.gif";
                        expimage = "attributes/cyl.gif";
                    }
                }
                expand = false;
            }

            return AddNode(par, text, img, expimage, "Rubric " + rub.ID.ToString(), expand);
        }