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> /// 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); }
protected int GetNextSubmission(int asstID, int pid) { Components.Submission.SubmissionList subdata = new Principals(m_ident).GetSubmissions(pid, asstID); return(subdata.Count); }
private void BindPermissions() { Permission.PermissionList perms = new Permissions(Globals.CurrentIdentity).GetTypePermissions(GetObjectType()); int prinID = (int) dgRoles.DataKeys[dgRoles.SelectedIndex]; Principal prin = new Principals(Globals.CurrentIdentity).GetInfo(prinID); lblPrin.Text = "Selection: " + prin.Name; dgPerms.DataSource = perms; dgPerms.DataBind(); }
protected string GetAsstPoints(User user, int asstID) { Components.Submission latsub = new Principals(Globals.CurrentIdentity).GetLatestGradedSubmission(user.PrincipalID, asstID); double total = new Assignments(Globals.CurrentIdentity).GetRubric(asstID).Points; if (latsub != null) { double userp = new Users(Globals.CurrentIdentity).GetAsstPoints(user.UserName, asstID); return String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp/total)*100.0, 2)); } else return String.Format("?? / {0}", total); }
public bool SendByPrincipal(int principalID, string subj, string body) { Principal prin = new Principals(m_ident).GetInfo(principalID); if (prin.Type == Principal.USER) { User user = new Users(m_ident).GetInfo(prin.Name, null); return SendByEmail(user.Email, subj, body); } else { User.UserList users = new Groups(m_ident).GetMembership(principalID); foreach (User user in users) SendByEmail(user.Email, subj, body); } return true; }
/// <summary> /// Get earned points by a user for an assignment /// </summary> public double GetAsstPoints(string username, int asstID) { Submission sub = new Principals(m_ident).GetLatestGradedSubmission( GetInfo(username, null).PrincipalID, asstID); if (sub != null) { return(new Submissions(m_ident).GetPoints(sub.ID)); } else { return(0); } }
/// <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> /// Delete a group ID /// </summary> public bool Delete(int groupID, int asstID) { //Get subs Submissions subda = new Submissions(m_ident); Components.Submission.SubmissionList subs = new Principals(m_ident).GetSubmissions(groupID, asstID); //Take the subs foreach (Components.Submission sub in subs) { subda.Delete(sub.ID); } //Take the group return(m_dp.DeleteGroup(groupID)); }
/// <summary> /// Check to see if principal ID has permission /// </summary> public Permission.GrantType CheckPermission(int principalID, int courseID, string etype, string perm, int entityID) { //Check ID directly if (m_dp.CheckPermission(principalID, courseID, perm, entityID, etype, null)) return Permission.GrantType.DIRECT; Principal prin = new Principals(m_ident).GetInfo(principalID); if (prin.Type == Principal.USER) { CourseRole role = new Courses(m_ident).GetRole( prin.Name, courseID, null); if (m_dp.CheckPermission(role.PrincipalID, courseID, perm, entityID, etype, null)) return Permission.GrantType.INHERIT; } return Permission.GrantType.DENY; }
/// <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); }
/// <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)); }
/// <summary> /// Check to see if principal ID has permission /// </summary> public Permission.GrantType CheckPermission(int principalID, int courseID, string etype, string perm, int entityID) { //Check ID directly if (m_dp.CheckPermission(principalID, courseID, perm, entityID, etype, null)) { return(Permission.GrantType.DIRECT); } Principal prin = new Principals(m_ident).GetInfo(principalID); if (prin.Type == Principal.USER) { CourseRole role = new Courses(m_ident).GetRole( prin.Name, courseID, null); if (m_dp.CheckPermission(role.PrincipalID, courseID, perm, entityID, etype, null)) { return(Permission.GrantType.INHERIT); } } return(Permission.GrantType.DENY); }
/// <summary> /// Delete a group ID /// </summary> public bool Delete(int groupID, int asstID) { //Get subs Submissions subda = new Submissions(m_ident); Components.Submission.SubmissionList subs = new Principals(m_ident).GetSubmissions(groupID, asstID); //Take the subs foreach (Components.Submission sub in subs) subda.Delete(sub.ID); //Take the group return m_dp.DeleteGroup(groupID); }
/// <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> /// 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 LoadEvaluationNode(TreeNode par, int asstID) { string[] tokens = par.NodeData.Split(" ".ToCharArray()); par.Nodes.Clear(); if (tokens.Length > 2 && tokens[2].Length > 0) { User.UserList users = GetFeedbackUsers(tokens[2]); Principals prinda = new Principals(Globals.CurrentIdentity); AddAggregateNode(par.Nodes, asstID, tokens[2]); // Aggregate node foreach (User user in users) { Components.Submission sub = prinda.GetLatestSubmission(user.PrincipalID, asstID); if (sub != null) AddSubjUserNode(par.Nodes, user, asstID, sub, true); } par.Expandable = ExpandableValue.Always; par.Expanded = true; } else { par.Expandable = ExpandableValue.Auto; par.Expanded = false; } }
private void dgReport_ItemDataBound(object sender, DataGridItemEventArgs e) { Label lblPoints; if (null != (lblPoints = (Label) e.Item.FindControl("lblPoints"))) { int asstID = Convert.ToInt32(dgReport.DataKeys[e.Item.ItemIndex]); User user = new Users(Globals.CurrentIdentity).GetInfo(GetUsername(), null); Components.Submission latsub = new Principals(Globals.CurrentIdentity).GetLatestGradedSubmission(user.PrincipalID, asstID); double total = new Assignments(Globals.CurrentIdentity).GetRubric(asstID).Points; if (latsub != null) { double userp = new Users(Globals.CurrentIdentity).GetAsstPoints(user.UserName, asstID); lblPoints.Text = String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp/total)*100.0, 2)); } else { lblPoints.Text = String.Format("?? / {0}", total); } } }
protected int GetNextSubmission(int asstID, int pid) { Components.Submission.SubmissionList subdata = new Principals(m_ident).GetSubmissions(pid, asstID); return subdata.Count; }
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> /// 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); }
/// <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; }
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 BindSubs() { int asstID = Convert.ToInt32(Request.Params["AsstID"]); Components.Submission.SubmissionList subs = new Users(Globals.CurrentIdentity).GetAsstSubmissions(Globals.CurrentUserName, asstID); ddlSubs.Items.Clear(); foreach (Components.Submission sub in subs) { string name = new Principals(Globals.CurrentIdentity).GetInfo(sub.PrincipalID).Name + " (" + sub.Creation.ToString() + ")"; ddlSubs.Items.Add(new ListItem(name, sub.ID.ToString())); } }
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; }
/// <summary> /// Get earned points by a user for an assignment /// </summary> public double GetAsstPoints(string username, int asstID) { Submission sub = new Principals(m_ident).GetLatestGradedSubmission( GetInfo(username, null).PrincipalID, asstID); if (sub != null) return new Submissions(m_ident).GetPoints(sub.ID); else return 0; }
private void LoadResFolderNode(TreeNode par, int asstID) { User user = new Users(Globals.CurrentIdentity).GetInfo(Globals.CurrentUserName, null); Components.Submission.SubmissionList subs = new Principals(Globals.CurrentIdentity).GetGradedSubmissions(user.PrincipalID, asstID); par.Nodes.Clear(); foreach (Components.Submission sub in subs) AddResSubNode(par.Nodes, sub); }