private ArrayList Setup(User.UserList users) { ArrayList groups = new ArrayList(); int i; for (i = 0; i < alphabet.Length; i++) { string bound = alphabet[i]; UserGroup group = new UserGroup(); group.UpperBound = alphabet[i]; if (i == alphabet.Length - 1) { group.LowerBound = bound; } else { group.LowerBound = alphabet[i + 1]; } foreach (User user in users) { if (group.InGroup(user.LastName)) { group.Users.Add(user); } } groups.Add(group); } return(groups); }
private void cmdExport_Click(object sender, System.EventArgs e) { CFile export; ExportRow.ExportRowList rows = new ExportRow.ExportRowList(); int courseID = GetCourseID(); Users userda = new Users(Globals.CurrentIdentity); User.UserList users = GetUserSet(GetSectionID(), GetCourseID()); //Add rows rows.Add(userda.GetCourseExportHeading(courseID)); foreach (User user in users) { rows.Add(userda.GetCourseExport(user.UserName, courseID)); } //Do export try { IExporter exporter = (IExporter)ExporterFactory.GetInstance().CreateItem(ddlExportFormat.SelectedItem.Value); export = exporter.Export(new FileSystem(Globals.CurrentIdentity), rows); } catch (CustomException er) { PageExportError(er.Message); return; } //Setup d/l link lnkExport.Attributes.Clear(); lnkExport.Attributes.Add("onClick", @"window.open('Controls/Filesys/dlfile.aspx?FileID=" + export.ID + @"', '" + export.ID + @"', 'width=770, height=580')"); lnkExport.Visible = true; }
private void BindData() { Sections sectda = new Sections(Globals.CurrentIdentity); Section sect = sectda.GetInfo(GetSectionID()); User.UserList secs = sectda.GetMembers(sect.ID); lstSectionUsers.Items.Clear(); foreach (User user in secs) { lstSectionUsers.Items.Add( new ListItem(user.FullName + " (" + user.UserName + ")", user.UserName)); } User.UserList mems = new Courses(Globals.CurrentIdentity).GetMembers(sect.CourseID, null); lstAllUsers.Items.Clear(); foreach (User user in mems) { lstAllUsers.Items.Add( new ListItem(user.FullName + " (" + user.UserName + ")", user.UserName)); } lnkSecExpl.Attributes.Add("onClick", @"window.open('sectionexpl.aspx?CourseID=" + sect.CourseID + @"', '" + sect.CourseID + @"', 'width=430, height=530')"); }
private string HarvestSelectedUsers() { string userstr = ""; Label lblType, lblID; Sections sectda = new Sections(Globals.CurrentIdentity); Users userda = new Users(Globals.CurrentIdentity); foreach (DataGridItem row in dgUsers.Items) { if ((row.FindControl("chkSelect") as CheckBox).Checked) { lblType = (Label)row.FindControl("lblType"); lblID = (Label)row.FindControl("lblID"); string sid = lblID.Text; if (lblType.Text == "S") { int id = Convert.ToInt32(sid); User.UserList users = sectda.GetMembers(id); foreach (User user in users) { userstr += user.UserName + "|"; } } else { userstr += sid + "|"; } } } return(userstr); }
private void BindAllUsers() { User.UserList users = (new Users(Globals.CurrentIdentity)).GetAll(); dgAllUsers.DataSource = users; dgAllUsers.DataBind(); }
private void BindData() { int i; int courseID = GetCourseID(); Courses courseda = new Courses(Globals.CurrentIdentity); User.UserList users = courseda.GetStaff(courseID, null); CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null); Principal.PrincipalList prins = new Principal.PrincipalList(); prins.AddRange(roles); prins.AddRange(users); dgRoles.DataSource = prins; dgRoles.DataBind(); for (i = 0; i < roles.Count; i++) { if (roles[i].Staff) { dgRoles.SelectedIndex = i; BindPermissions(); break; } } }
/// <summary> /// Add a user to a section /// switchuser indicates that the user should be dropped /// from all other sections /// Email owner of the group if actor != username /// </summary> public bool AddUser(int sectionID, string username, bool switchuser) { Section section = GetInfo(sectionID); //Check permission Authorize(section.CourseID, Permission.SECTION, "update", sectionID, null); //Check to see if the user is in this group already string actor = Identity.Name; User.UserList users = GetMembers(sectionID); User user = new User(); user.UserName = username; if (users.Contains(user)) { throw new DataAccessException("User already exists in the section"); } //Send email to the owner if the owner did not make the change if (actor != section.Owner) { new EmailWizard(m_ident).SendByUsername(section.Owner, "FrontDesk Section Notification", String.Format(Globals.GetMessage("SectionAdd"), actor, username, System.DateTime.Now)); } //TODO: Enforce policy of section membership //Create the membership m_dp.CreateSectionMember(sectionID, username, switchuser); return(true); }
private void BindFileLink() { string roots = ""; //Check to see if we already did this, if not then calculate sub root string for FB if (!GetFileRoots(out roots)) { Users userda = new Users(Globals.CurrentIdentity); User.UserList users = CourseMatrixControl.GetFeedbackUsers(GetUserList()); foreach (User user in users) { Components.Submission.SubmissionList subs = userda.GetAsstSubmissions(user.UserName, GetAsstID()); foreach (Components.Submission sub in subs) { roots += sub.LocationID.ToString() + "|"; } } ViewState["fileroots"] = roots; } lnkLoadAll.Attributes.Add("onClick", @"window.open('filebrowser.aspx?Roots=" + roots + @"', '" + 8 + @"', 'width=730, height=630')"); }
private void BindData() { User.UserList users = GetUserSet(GetSectionID(), GetCourseID()); dgCourse.DataSource = users; dgCourse.DataBind(); BindExporters(); }
private void BindData() { string userstr = GetUserList(); User.UserList users = CourseMatrixControl.GetFeedbackUsers(userstr); DataTable userset = TabulateUsers(users); dgAggregate.DataSource = new DataView(userset); dgAggregate.DataBind(); }
public void BindData() { int courseID = new Assignments(Globals.CurrentIdentity).GetInfo(GetAsstID()).CourseID; int sectionID = GetSectionID(); //Load the groups into viewstate User.UserList users = GetUserSet(sectionID, courseID); string[] bounds = GetGroups().Split( "\n".ToCharArray())[dgReport.CurrentPageIndex].Split(" ".ToCharArray()); new UserGrouper().Regroup(bounds[1], bounds[0], users); dgReport.DataSource = users; dgReport.DataBind(); }
/// <summary> /// Add users to the course from an XML stream /// </summary> public void BatchAddUsers(Stream xmlStream, int courseID, bool sync) { //TODO: Error checking User mem = new User(); Users usersDB = new Users(m_ident); DataSet xmldata = new DataSet(); xmldata.ReadXml(xmlStream); DataRowCollection users = xmldata.Tables["User"].Rows; IProviderTransaction tran = m_dp.BeginTransaction(); foreach (DataRow row in users) { mem.UserName = (string)row["UserName"]; string role = (string)row["Role"]; //Make sure the user is in the system if (null == usersDB.GetInfo(mem.UserName, tran)) { m_dp.RollbackTransaction(tran); throw new DataAccessException("User: "******" is not in the FrontDesk database"); } User.UserList cmems = GetMembers(courseID, tran); //The user already exists in the course if (cmems.Contains(mem)) { if (sync) { UpdateRole(mem.UserName, courseID, role, tran); } else { m_dp.RollbackTransaction(tran); throw new DataAccessException("User: "******" already exists in the course. " + "Do a merge if you want to change the roles"); } } else { m_dp.CreateCourseMember(mem.UserName, courseID, role, tran); } } m_dp.CommitTransaction(tran); }
/// <summary> /// Group users into binsize groups /// </summary> public bool Group(User.UserList users, ArrayList groups, int binsize) { groups.Clear(); groups.AddRange(Setup(users)); while (Divide(groups, binsize) || Combine(groups, binsize)) { ; } if (groups.Count == 1) { return(false); } return(true); }
public void BindSearchData(User.UserList users) { int courseID = new Assignments(Globals.CurrentIdentity).GetInfo(GetAsstID()).CourseID; //Load the groups into viewstate if (users.Count > 0) { string[] bounds = GetGroups().Split( "\n".ToCharArray())[dgUserSearch.CurrentPageIndex].Split(" ".ToCharArray()); new UserGrouper().Regroup(bounds[1], bounds[0], users); } dgUserSearch.DataSource = users; dgUserSearch.DataBind(); }
/// <summary> /// Get all staff from a course /// </summary> public User.UserList GetStaff(int courseID, IProviderTransaction tran) { User.UserList staff = new User.UserList(); User.UserList all = GetMembers(courseID, tran); //Filter out students foreach (User cm in all) { if (GetRole(cm.UserName, courseID, tran).Staff) { staff.Add(cm); } } return(staff); }
/// <summary> /// Regroup /// </summary> public void Regroup(string ubound, string lbound, User.UserList users) { int i; UserGroup group = new UserGroup(); group.UpperBound = ubound; group.LowerBound = lbound; for (i = 0; i < users.Count; i++) { User user = users[i] as User; if (!group.InGroup(user.LastName)) { users.Remove(user); i--; } } }
/// <summary> /// Leave the group /// </summary> public bool Leave(string username, int groupID) { Group group = GetInfo(groupID); //Take the member m_dp.DeleteGroupMember(username, group); //Delete the group if no one is in it User.UserList mems = GetMembership(groupID); if (mems.Count == 0) { Delete(groupID, group.AsstID); } return(true); }
private void AddSectionMembers(TreeNode node) { string[] tokens = node.NodeData.Split(" ".ToCharArray()); int sectionID = Convert.ToInt32(tokens[1]); User.UserList mems = (new Sections(Globals.CurrentIdentity)).GetMembers(sectionID); foreach (User user in mems) { TreeNode root = AddNode(node.Nodes, true, user.FullName + " (Username: "******")", "attributes/user.jpg", "Uname " + user.UserName); AddNode(root.Nodes, false, "Sections", "attributes/folder.gif", "attributes/folderopen.gif", "USects " + user.UserName); AddNode(root.Nodes, false, "Submission Groups", "attributes/folder.gif", "attributes/folderopen.gif", "UGrous " + user.UserName); } }
private void BindGroups(User.UserList users) { //Load the groups into viewstate ArrayList groups = new ArrayList(); new UserGrouper().Group(users, groups, 9); string vsrecord = ""; foreach (UserGrouper.UserGroup group in groups) { vsrecord += group.LowerBound + " " + group.UpperBound + "\n"; } ViewState["Groups"] = vsrecord; dgUserSearch.VirtualItemCount = 9 * groups.Count; // dgUserSearch.CurrentPageIndex = 0; }
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); }
private void cmdSearch_Click(object sender, EventArgs e) { User.UserList foundUsers = null; //to get the course id, you can use the current assignment Assignment asst = new Assignments(Globals.CurrentIdentity).GetInfo(GetAsstID()); if (drpSearchMethod.SelectedValue == "username") { foundUsers = new Courses(Globals.CurrentIdentity).GetMembersByUsername(txtSearch.Text, asst.CourseID); } else if (drpSearchMethod.SelectedValue == "lastname") { foundUsers = new Courses(Globals.CurrentIdentity).GetMembersByLastname(txtSearch.Text, asst.CourseID); } //clear the text box and then fill the dialog box txtSearch.Text = ""; BindGroups(foundUsers); BindSearchData(foundUsers); }
/// <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> /// Add a user into a course /// </summary> public bool AddUser(string username, string role, int courseID, IProviderTransaction tran) { //Check permission if (m_ident.Name != username) { Authorize(courseID, Permission.COURSE, "adduser", courseID, tran); } User.UserList cmems = GetMembers(courseID, null); //Check an make sure the user isn't already in the course foreach (User user in cmems) { if (user.UserName == username) { throw new DataAccessException("User already enrolled in course"); } } return(m_dp.CreateCourseMember(username, courseID, role, tran)); }
private void BindGroups() { int courseID = new Assignments(Globals.CurrentIdentity).GetInfo(GetAsstID()).CourseID; int sectionID = GetSectionID(); //Load the groups into viewstate User.UserList users = GetUserSet(sectionID, courseID); ArrayList groups = new ArrayList(); new UserGrouper().Group(users, groups, 8); string vsrecord = ""; foreach (UserGrouper.UserGroup group in groups) { vsrecord += group.LowerBound + " " + group.UpperBound + "\n"; } ViewState["Groups"] = vsrecord; dgReport.VirtualItemCount = groups.Count * 8; dgReport.CurrentPageIndex = 0; }
private void BindPrincipals() { int courseID = Convert.ToInt32(Request.Params["CourseID"]); Courses courseda = new Courses(Globals.CurrentIdentity); User.UserList users = courseda.GetMembers(courseID, null); CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null); ddlPrins.Items.Clear(); //Add roles foreach (CourseRole role in roles) { ListItem item = new ListItem("Role: " + role.Name, role.PrincipalID.ToString()); ddlPrins.Items.Add(item); } //Add users foreach (User user in users) { ListItem item = new ListItem(user.FullName + " (" + user.UserName + ")", user.PrincipalID.ToString()); ddlPrins.Items.Add(item); } }
private void dgSections_ItemCommand(object sender, DataGridCommandEventArgs e) { string refreshString = ""; string prinstr = ""; int status = Components.Submission.UNGRADED;; User.UserList users = null; Label lblID = (Label)e.Item.FindControl("lblID"); if (e.CommandName == "UnGraded") { status = Components.Submission.UNGRADED; } else if (e.CommandName == "Graded") { status = Components.Submission.GRADED; } users = new Sections(Globals.CurrentIdentity).GetStudentsBySubStatus( Convert.ToInt32(lblID.Text), GetAsstID(), status); if (users != null) { if (users.Count != 0) { foreach (User user in users) { refreshString += user.UserName + "|"; prinstr += user.PrincipalID.ToString() + " "; } mpViews.SelectedIndex = 2; Refresh(this, new RefreshEventArgs(refreshString, false, false)); lblPrinStr.Text = prinstr; BindAutoData(); } } }
private string[] HarvestSelectedUsers(System.Web.UI.WebControls.DataGrid sgrid) { string userstr = "", prinstr = ""; Label lblType, lblID; Sections sectda = new Sections(Globals.CurrentIdentity); Users userda = new Users(Globals.CurrentIdentity); foreach (DataGridItem row in sgrid.Items) { if ((row.FindControl("chkSelect") as CheckBox).Checked) { lblType = (Label)row.FindControl("lblType"); lblID = (Label)row.FindControl("lblID"); string sid = lblID.Text; if (lblType.Text == "S") { int id = Convert.ToInt32(sid); User.UserList users = sectda.GetMembers(id); foreach (User user in users) { userstr += user.UserName + "|"; prinstr += user.PrincipalID.ToString() + " "; } } else { userstr += sid + "|"; User user = userda.GetInfo(sid, null); prinstr += user.PrincipalID.ToString() + " "; } } } string[] retarr = new string[2]; retarr[0] = userstr; retarr[1] = prinstr; return(retarr); }
public string Backup(int courseID) { string zfile, wzfile; Authorize(courseID, Permission.COURSE, "createback", courseID, null); //Create our external sink file IExternalSink extsink = ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink; Course course = GetInfo(courseID); zfile = course.Name + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".zip"; wzfile = Globals.BackupDirectoryName + "/" + zfile; zfile = Path.Combine(Globals.BackupDirectory, zfile); extsink.CreateSink(zfile); //Backup Info //Backup Results //Back up submissions Users users = new Users(m_ident); User.UserList mems = GetMembers(courseID, null); foreach (User mem in mems) { users.Backup(mem.UserName, courseID, extsink); } extsink.CloseSink(); //Log in database new Backups(m_ident).Create(GetInfo(courseID).Name, wzfile, courseID); return(zfile); }
/// <summary> /// Group users into binsize groups /// </summary> public bool Group(User.UserList users, ArrayList groups) { return(Group(users, groups, BINSIZE)); }
private void tvSection_Check(object sender, TreeViewClickEventArgs e) { TreeNode node = tvSection.GetNodeFromIndex(e.Node); Users users = new Users(Globals.CurrentIdentity); int courseID = Convert.ToInt32(HttpContext.Current.Request.Params["CourseID"]); string[] tokens; if (node.NodeData.IndexOf("Uname") == 0) { tokens = node.NodeData.Split(" ".ToCharArray()); int pid = users.GetInfo(tokens[1], null).PrincipalID; ArrayList prins = Principals; if (node.Checked) { prins.Add(pid); } else { prins.Remove(pid); } Principals = prins; } else if (node.NodeData.IndexOf("Group") == 0) { tokens = node.NodeData.Split(" ".ToCharArray()); int pid = Convert.ToInt32(tokens[1]); ArrayList prins = Principals; if (node.Checked) { prins.Add(pid); } else { prins.Remove(pid); } Principals = prins; } else if (node.NodeData.IndexOf("Uallusers") == 0) { User.UserList mems = new Courses(Globals.CurrentIdentity).GetMembers(courseID, null); ArrayList prins = Principals; foreach (TreeNode cnode in node.Nodes) { cnode.Checked = node.Checked; } foreach (User mem in mems) { if (node.Checked) { prins.Add(mem.PrincipalID); } else { prins.Remove(mem.PrincipalID); } } node.Expanded = true; Principals = prins; } else if (node.NodeData.IndexOf("Section") == 0) { tokens = node.NodeData.Split(" ".ToCharArray()); User.UserList susers = (new Sections(Globals.CurrentIdentity)).GetMembers( Convert.ToInt32(tokens[1])); if (node.Nodes.Count == 0) { AddSectionMembers(node); } foreach (TreeNode cnode in node.Nodes) { cnode.Checked = node.Checked; } ArrayList prins = Principals; foreach (User user in susers) { if (node.Checked) { prins.Add(user.PrincipalID); } else { prins.Remove(user.PrincipalID); } } node.Expanded = true; Principals = prins; } }