private void lnkDefunct_Click(object sender, EventArgs e) { Submissions subda = new Submissions(Globals.CurrentIdentity); Components.Submission sub = subda.GetInfo(GetSubID()); //Change status if (sub.Status != Components.Submission.DEFUNCT) { sub.Status = Components.Submission.DEFUNCT; } else { sub.Status = Components.Submission.UNGRADED; } try { subda.Update(sub, new EmptySource()); } catch (DataAccessException er) { PageError(er.Message); } catch (FileOperationException er) { PageError(er.Message); } BindData(); Refresh(this, new RefreshEventArgs("", true, false)); }
public ExportRow GetAsstExport(Components.Submission sub, int asstID, out double totpoints) { Rubrics rubda = new Rubrics(m_ident); ExportRow row = new ExportRow(); //Get all rubric entries for the assignment Rubric rub = new Assignments(m_ident).GetRubric(asstID); Rubric.RubricList rublist = rubda.Flatten(rub); //Tally //Cats double points = 0; foreach (Rubric rubent in rublist) { if (sub == null) { row.Fields.Add("0"); } else { double catpoints = rubda.GetPoints(rubent.ID, sub.ID); points += catpoints; row.Fields.Add(catpoints.ToString()); } } //Total row.Fields.Insert(0, points.ToString()); totpoints = points; return(row); }
/// <summary> /// Create a new submission /// </summary> public Components.Submission Create(int asstid, int principalID, IExternalSource files) { //TODO: Verify parameters Components.Submission sub = new Components.Submission(); sub.AsstID = asstid; sub.PrincipalID = principalID; sub.Status = Submission.UNGRADED; //Check for locked for evaluation if (!new Assignments(m_ident).IsSubmissionAvailable(asstid)) throw new DataAccessException("Submission is locked. No more submissions are being accepted. Please contact course staff to proceed"); //Create submission m_dp.CreateSubmission(sub); //Update to commit files sub = GetInfo(sub.ID); try { Update(sub, files); } catch (DataAccessException er) { UnsafeDelete(sub.ID); throw er; } //Queue autosubmit tests QueueSubmitTests(sub); //Log submission Assignment asst = new Assignments(m_ident).GetInfo(asstid); Log("User submitted " + asst.Description + " successfully", sub.ID); return sub; }
private void cmdSubmit_Click(object sender, EventArgs e) { ArrayList prins = ucSectionExpl.Principals; ArrayList tests = GetTests(); string warnings=""; int asstID = Convert.ToInt32(HttpContext.Current.Request.Params["AsstID"]); AutoJobs jobs = new AutoJobs(Globals.CurrentIdentity); Principals aprins = new Principals(Globals.CurrentIdentity); foreach (int prin in prins) { foreach (int evalid in tests) { try { Components.Submission sub = aprins.GetLatestSubmission(prin, asstID); if (sub == null) { warnings += aprins.GetInfo(prin).Name + " "; break; } else jobs.Create(txtName.Text, evalid, sub.ID); } catch (DataAccessException er) { PageError(er.Message); return; } } } PageError("Job: " + txtName.Text + " created successfully. Refer to the " + "job status page to monitor its progress through the testing centers. Users/Groups: " + warnings + " do not have any submissions and tests will not be run on them."); }
/// <summary> /// Get the results of a competitive evaluation /// </summary> public Result.ResultList GetCompetitionResults(int evalID, out Hashtable subhash) { subhash = new Hashtable(); Evaluation eval = GetInfo(evalID); int rubID = GetRubric(evalID).ID; //Get all results for the evaluation Result.ResultList ress = new Rubrics(m_ident).GetResults(rubID); //Get all subs for the assignment Components.Submission.SubmissionList subs = new Assignments(m_ident).GetSubmissions(eval.AsstID); //Load unique subs into hash table Principals prinda = new Principals(m_ident); foreach (Components.Submission sub in subs) { if (!subhash.Contains(sub.PrincipalID) && prinda.GetLatestSubmission(sub.PrincipalID, eval.AsstID).ID == sub.ID) { subhash[sub.PrincipalID] = sub; } } Components.Submission[] usubs = new Components.Submission[subhash.Count]; subhash.Values.CopyTo(usubs, 0); subhash.Clear(); foreach (Components.Submission sub in usubs) { subhash[sub.ID] = sub; } //Run through results and delete any repetitive ones Result.ResultList fress = new Result.ResultList(); foreach (Result res in ress) { if (((AutoResult)res).Success != AutoResult.CRITICALLYFLAWED && ((AutoResult)res).Success != AutoResult.DEPFAIL && subhash.Contains(res.SubmissionID)) { fress.Add(res); } } //Sort by competitive score fress.Sort(new CompResultComparer()); return(fress); }
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); } }
private void BindUserItem(User user, Label lblName, Label numSubmissions, LinkButton lnkProgress, System.Web.UI.WebControls.Image imgStatus, System.Web.UI.WebControls.Image imgType, CheckBox chkSelect) { imgType.ImageUrl = "../../attributes/user.gif"; lblName.Text = user.FullName + "(" + user.UserName + ")"; if (lnkProgress == null) { lnkProgress = new LinkButton(); } Principals prinda = new Principals(Globals.CurrentIdentity); Components.Submission sub = prinda.GetLatestSubmission(user.PrincipalID, GetAsstID()); int numsubs = prinda.GetSubmissions(user.PrincipalID, GetAsstID()).Count; numSubmissions.Text = numsubs.ToString(); if (sub == null) { imgStatus.ImageUrl = "../../attributes/nosub.gif"; lnkProgress.Text = "N/A"; chkSelect.Enabled = false; } else { switch (sub.Status) { case Components.Submission.GRADED: imgStatus.ImageUrl = "../../attributes/subgrade.gif"; lnkProgress.Text = "100%"; break; case Components.Submission.INPROGRESS: imgStatus.ImageUrl = "../../attributes/clock.gif"; lnkProgress.Text = "??%"; break; case Components.Submission.UNGRADED: imgStatus.ImageUrl = "../../attributes/sub.gif"; lnkProgress.Text = "0%"; break; } } }
private void dgReport_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Details") { int pid = (int)dgReport.DataKeys[e.Item.ItemIndex]; Rubric rub = new Assignments(Globals.CurrentIdentity).GetRubric(GetAsstID()); Components.Submission sub = GetLatestSub(pid); if (sub != null) { ucRubric.Visible = true; spnNothing.Visible = false; lblDetailsName.Text = "for " + new Users(Globals.CurrentIdentity).GetInfo( new Principals(Globals.CurrentIdentity).GetInfo(pid).Name, null).FullName; ucRubric.InitRubric(rub, sub.ID, ""); } } }
private DataTable TabulateUsers(User.UserList users) { DataTable resulttab = new DataTable(); int asstID = GetAsstID(); Rubrics rubda = new Rubrics(Globals.CurrentIdentity); Principals prinda = new Principals(Globals.CurrentIdentity); Rubric asstrub = new Assignments(Globals.CurrentIdentity).GetRubric(asstID); //Add rubric columns to data grid Rubric.RubricList flatrub = rubda.Flatten(asstrub); resulttab.Columns.Add("UserName"); resulttab.Columns.Add("Status"); resulttab.Columns.Add("Total"); foreach (Rubric rub in flatrub) { AddRubricColumn(rub.Name, rub.Name); resulttab.Columns.Add(rub.Name); } //Add user data to the datatable foreach (User user in users) { Components.Submission sub = prinda.GetLatestSubmission(user.PrincipalID, asstID); DataRow row = resulttab.NewRow(); if (sub == null) { continue; } row["UserName"] = user.UserName; row["Status"] = sub.Status; row["Total"] = rubda.GetPoints(asstrub.ID, sub.ID).ToString() + "/" + asstrub.Points.ToString(); foreach (Rubric rub in flatrub) { row[rub.Name] = GetRubricPoints(rub, sub.ID) + "/" + rub.Points.ToString(); } resulttab.Rows.Add(row); } return(resulttab); }
/// <summary> /// Returns the users in this section who are already graded /// </summary> public User.UserList GetStudentsBySubStatus(int sectionID, int asstID, int status) { Principals prinda = new Principals(Globals.CurrentIdentity); User.UserList users = m_dp.GetSectionMembers(sectionID); User.UserList retList = new User.UserList(); foreach (User user in users) { Components.Submission sub = prinda.GetLatestSubmission(user.PrincipalID, asstID); if (sub != null) { if (sub.Status == status) { retList.Add(user); } } } return(retList); }
private void BindUserItem(CourseMember mem, Label lblName, Label lblProgress, System.Web.UI.WebControls.Image imgStatus, System.Web.UI.WebControls.Image imgType, CheckBox chkSelect) { User user = mem.User; imgType.ImageUrl = "../../attributes/user.gif"; lblName.Text = user.FullName + "(" + user.UserName + ")"; Users userda = new Users(Globals.CurrentIdentity); Components.Submission sub = userda.GetLatestAsstSubmission(user.UserName, GetAsstID()); if (sub == null) { imgStatus.ImageUrl = "../../attributes/nosub.gif"; lblProgress.Text = "N/A"; chkSelect.Enabled = false; } else { switch (sub.Status) { case Components.Submission.GRADED: imgStatus.ImageUrl = "../../attributes/subgrade.gif"; lblProgress.Text = "100%"; break; case Components.Submission.INPROGRESS: imgStatus.ImageUrl = "../../attributes/clock.gif"; lblProgress.Text = "??%"; break; case Components.Submission.UNGRADED: imgStatus.ImageUrl = "../../attributes/sub.gif"; lblProgress.Text = "0%"; break; } } }
public void Execute() { IExternalSource extsource; ICommandEventArgs args = new ICommandEventArgs(); //Unpack archive Components.Submission sub = null; try { extsource = CreateSource(m_upfile); //Create submission sub = m_subda.Create(m_asstID, m_prinID, extsource); } catch (Exception er) { args.Exception = er; } args.ReturnValue = sub; if (Finished != null) { Finished(this, args); } }
private int GetSectionProgress(Section sec) { Users userda = new Users(Globals.CurrentIdentity); User.UserList users = new Sections(Globals.CurrentIdentity).GetMembers(sec.ID); int done = 0, count = 0; foreach (User user in users) { Components.Submission sub = userda.GetLatestAsstSubmission(user.UserName, GetAsstID()); if (sub != null) { count++; if (sub.Status == Components.Submission.GRADED) { done++; } } } return(Math.Min(100, Math.Max(0, (int)(((double)done) / ((double)count) * 100.0)))); }
/// <summary> /// Create a auto result. /// </summary> public bool CreateAuto(int evalID, string grader, int subID, string result) { //Check permission Submissions subac = new Submissions(m_ident); Components.Submission sub = subac.GetInfo(subID); Assignment asst = new Assignments(m_ident).GetInfo(sub.AsstID); Authorize(asst.CourseID, "createauto", asst.ID, null); AutoResult res = new AutoResult(); res.EvalID = evalID; res.Grader = grader; res.SubmissionID = subID; res.XmlResult = result; //Clear out all results for this evaluation Submission.SubmissionList subs = new Principals(m_ident).GetSubmissions(sub.PrincipalID, sub.AsstID); //Delete all old results foreach (Submission s in subs) { Result.ResultList ress = subac.GetResults(s.ID); foreach (Result r in ress) { if (r.Type == Result.AUTO_TYPE) { AutoResult ar = r as AutoResult; if (ar.EvalID == evalID) { Delete(ar.ID); } } } } return(m_dp.CreateAutoResult(res)); }
public void Execute() { IExternalSource extsrc; ICommandEventArgs args = new ICommandEventArgs(); //Run CVS to get the files CVSTool cvs = new CVSTool(); try { extsrc = cvs.Checkout(m_cvsroot, m_module, m_password, out m_target); } catch (Exception er) { args.Exception = er; Finish(args); return; } //Sanity check on CVS if (extsrc == null) { args.Exception = new ToolExecutionException("Failure during execution of CVS"); Finish(args); return; } //Create the submission Submissions subda = new Submissions(Globals.CurrentIdentity); Components.Submission sub = null; try { sub = m_subda.Create(m_asstID, m_prinID, extsrc); } catch (Exception er) { args.Exception = er; Finish(args); return; } //Finish up args.ReturnValue = sub; Finish(args); }
private void cmdSubmit_Click(object sender, EventArgs e) { ArrayList prins = GetPrincipals(); ArrayList tests = GetTests(); AutoJobs jobs = new AutoJobs(Globals.CurrentIdentity); Principals aprins = new Principals(Globals.CurrentIdentity); //Check for nothing if (tests.Count == 0 || prins.Count == 0) { PageAutoError("Must select at least one user and one test to create an auto job"); return; } AutoJob job = jobs.Create(txtName.Text, GetAsstID()); foreach (int prin in prins) { foreach (int evalid in tests) { try { Components.Submission sub = aprins.GetLatestSubmission(prin, GetAsstID()); if (sub != null) { jobs.CreateTest(job.ID, sub.ID, evalid, false); } } catch (DataAccessException er) { PageAutoError(er.Message); return; } } } mpViews.SelectedIndex = 1; }
private void dgSubmissions_ItemDataBound(object sender, DataGridItemEventArgs e) { Label lblLate, lblDueDate; System.Web.UI.WebControls.Image imgSubber; if (null != (lblLate = e.Item.FindControl("lblLate") as Label)) { Components.Submission sub = e.Item.DataItem as Components.Submission; Assignment asst = (new Assignments(Globals.CurrentIdentity)).GetInfo(sub.AsstID); if (asst.DueDate < sub.Creation) { lblLate.Text = "<b><font color=\"#ff0000\">LATE</font></b>"; } else { lblLate.Text = "<b><font color=\"#4768A3\">ON TIME</font></b>"; } lblDueDate = (Label)e.Item.FindControl("lblDueDate"); lblDueDate.Text = asst.DueDate.ToString(); imgSubber = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgSubber"); int pid = Convert.ToInt32(dgSubmissions.DataKeys[e.Item.ItemIndex]); Principal prin = (new Principals(Globals.CurrentIdentity)).GetInfo(pid); if (prin.Type == Principal.USER) { imgSubber.ImageUrl = "../../attributes/user.jpg"; } else { imgSubber.ImageUrl = "../../attributes/group.jpg"; } } }
/// <summary> /// Create a new submission /// </summary> public Components.Submission Create(int asstid, int principalID, IExternalSource files) { //TODO: Verify parameters Components.Submission sub = new Components.Submission(); sub.AsstID = asstid; sub.PrincipalID = principalID; sub.Status = Submission.UNGRADED; //Check for locked for evaluation if (!new Assignments(m_ident).IsSubmissionAvailable(asstid)) { throw new DataAccessException("Submission is locked. No more submissions are being accepted. Please contact course staff to proceed"); } //Create submission m_dp.CreateSubmission(sub); //Update to commit files sub = GetInfo(sub.ID); try { Update(sub, files); } catch (DataAccessException er) { UnsafeDelete(sub.ID); throw er; } //Queue autosubmit tests QueueSubmitTests(sub); //Log submission Assignment asst = new Assignments(m_ident).GetInfo(asstid); Log("User submitted " + asst.Description + " successfully", sub.ID); return(sub); }
private void QueueSubmitTests(Components.Submission sub) { int asstID = sub.AsstID; string strlog = ""; Evaluation.EvaluationList tests = new Assignments(m_ident).GetSubmitAutoEvals(asstID); if (tests.Count == 0) { return; } //Queue up pretests AutoJobs jobda = new AutoJobs(m_ident); AutoJob job = jobda.Create(m_ident.Name + " submission", asstID); foreach (Evaluation eval in tests) { jobda.CreateTest(job.ID, sub.ID, eval.ID, true); strlog += eval.Name + " "; } //Log queueing Log("Pretests queued: " + strlog, sub.ID); }
/// <summary> /// Get the results of a competitive evaluation /// </summary> public Result.ResultList GetCompetitionResults(int evalID, out Hashtable subhash) { subhash = new Hashtable(); Evaluation eval = GetInfo(evalID); int rubID = GetRubric(evalID).ID; //Get all results for the evaluation Result.ResultList ress = new Rubrics(m_ident).GetResults(rubID); //Get all subs for the assignment Components.Submission.SubmissionList subs = new Assignments(m_ident).GetSubmissions(eval.AsstID); //Load unique subs into hash table Principals prinda = new Principals(m_ident); foreach (Components.Submission sub in subs) if (!subhash.Contains(sub.PrincipalID) && prinda.GetLatestSubmission(sub.PrincipalID, eval.AsstID).ID == sub.ID) { subhash[sub.PrincipalID] = sub; } Components.Submission[] usubs = new Components.Submission[subhash.Count]; subhash.Values.CopyTo(usubs, 0); subhash.Clear(); foreach (Components.Submission sub in usubs) subhash[sub.ID] = sub; //Run through results and delete any repetitive ones Result.ResultList fress = new Result.ResultList(); foreach (Result res in ress) if (((AutoResult)res).Success != AutoResult.CRITICALLYFLAWED && ((AutoResult)res).Success != AutoResult.DEPFAIL && subhash.Contains(res.SubmissionID)) fress.Add(res); //Sort by competitive score fress.Sort(new CompResultComparer()); return fress; }
/// <summary> /// Load submission directory with new files, updates time /// </summary> public bool Update(Submission sub, IExternalSource files) { FileSystem fs = new FileSystem(m_ident); bool markcmp, unmarkcmp, defunct; //Get old sub Components.Submission oldsub = GetInfo(sub.ID); markcmp = (oldsub.Status == Components.Submission.UNGRADED && sub.Status == Components.Submission.GRADED); unmarkcmp = (oldsub.Status == Components.Submission.GRADED && sub.Status == Components.Submission.UNGRADED); defunct = (oldsub.Status != Components.Submission.DEFUNCT && sub.Status == Components.Submission.DEFUNCT); //Make sure toplevel zone directory exists CFile subdir = fs.GetFile(@"c:\subs"); if (null == subdir) { subdir = fs.CreateDirectory(@"c:\subs", true, null, false); } //Build file perms CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList(); int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID; CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null); foreach (CourseRole role in staff) { perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID)); } perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID)); //Create zone directory CFile esubdir; string zpath = @"c:\subs\" + sub.ID; if (null == (esubdir = fs.GetFile(zpath))) { esubdir = fs.CreateDirectory(zpath, false, perms, false); esubdir.SpecType = CFile.SpecialType.SUBMISSION; string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name; esubdir.Alias = String.Format("{0}: {1}", name, GetNextSubmission(sub.AsstID, sub.PrincipalID)); fs.UpdateFileInfo(esubdir, false); } //Update sub entry sub.LocationID = esubdir.ID; m_dp.UpdateSubmission(sub); //Load files try { fs.ImportData(zpath, files, false, false); //Import the data } catch (Exception) { throw new DataAccessException("Invalid external file source. This means the system does " + "not understand how to extract files from the source. Please create a valid source"); } //Verify submission structure VerifyFormat(sub.AsstID, zpath); //Log if (markcmp) { Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID); } else if (unmarkcmp) { Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID); } else if (defunct) { Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID); } return(true); }
public SubmissionEventArgs(Components.Submission sub) { m_sub = sub; }