private void BindData() { Users userda = new Users(Globals.CurrentIdentity); Courses courseda = new Courses(Globals.CurrentIdentity); int courseID = GetCourseID(); User user = userda.GetInfo(GetUsername(), null); txtFirst.Text = user.FirstName; txtLast.Text = user.LastName; txtEmail.Text = user.Email; double total = courseda.GetTotalPoints(courseID); double userp = userda.GetCoursePoints(user.UserName, courseID); lblTotal.Text = String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp / total) * 100.0, 2)); dgReport.DataSource = courseda.GetAssignments(courseID); dgReport.DataBind(); CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null); CourseRole urole = courseda.GetRole(user.UserName, courseID, null); ddlRoles.Items.Clear(); foreach (CourseRole role in roles) { ListItem item = new ListItem(role.Name, role.PrincipalID.ToString()); if (role.PrincipalID == urole.PrincipalID) { item.Selected = true; } ddlRoles.Items.Add(item); } }
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> /// Get staff roles from a course /// </summary> public CourseRole.CourseRoleList GetTypedRoles(int courseID, bool staff, IProviderTransaction tran) { CourseRole.CourseRoleList roles = GetRoles(courseID, tran); CourseRole.CourseRoleList sroles = new CourseRole.CourseRoleList(); foreach (CourseRole role in roles) { if ((staff && role.Staff) || (!staff && !role.Staff)) { sroles.Add(role); } } return(sroles); }
/// <summary> /// Create an assignment /// </summary> public int Create(int courseID, string creator, string desc, DateTime duedate) { //Check perm Authorize(courseID, Permission.COURSE, "createasst", courseID, null); Assignment asst = new Assignment(); asst.CourseID = courseID; asst.Creator = creator; asst.Description = desc; asst.DueDate = duedate; asst.Format = Assignment.DEFAULT_FORMAT; //Create m_dp.CreateAssignment(asst); //Setup default permissions CreatePermissions(asst.ID, courseID, Permission.ASSIGNMENT); //Setup default file permissions Courses courseda = new Courses(m_ident); CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList(); CourseRole.CourseRoleList staff = courseda.GetTypedRoles(courseID, true, null); CourseRole.CourseRoleList stu = courseda.GetTypedRoles(courseID, false, null); foreach (CourseRole role in staff) { perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID)); } foreach (CourseRole role in stu) { perms.Add(new CFilePermission(role.PrincipalID, FileAction.READ, true)); } //Create content area FileSystem fs = new FileSystem(m_ident); CFile cdir = fs.CreateDirectory(@"c:\acontent\" + asst.ID, false, perms, false); asst.ContentID = cdir.ID; Update(asst); //Log Log("Created assignment: " + desc, asst.ID); return(asst.ID); }
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); } }
/// <summary> /// Recreate the file permissions table /// </summary> public void RecoverBaseFilePermissions() { //Get all submissions Components.Submission.SubmissionList subs = new Submissions(m_ident).GetAll(); Assignments asstda = new Assignments(m_ident); Courses courseda = new Courses(m_ident); CFilePermission.FilePermissionList full; foreach (Components.Submission sub in subs) { CFile subdir = GetFile(sub.LocationID); int courseID = asstda.GetInfo(sub.AsstID).CourseID; //Give staff access CourseRole.CourseRoleList staff = courseda.GetTypedRoles(courseID, true, null); foreach (CourseRole role in staff) { full = CFilePermission.CreateFullAccess(role.PrincipalID); SetPermissionsInt(subdir, full); } //Give sub principal access full = CFilePermission.CreateOprFullAccess(sub.PrincipalID); SetPermissionsInt(subdir, full); } //Do content Course.CourseList courses = courseda.GetAll(); foreach (Course course in courses) { CFile cont = GetFile(course.ContentID); //Give staff access CourseRole.CourseRoleList staff = courseda.GetTypedRoles(course.ID, true, null); foreach (CourseRole role in staff) { full = CFilePermission.CreateFullAccess(role.PrincipalID); SetPermissionsInt(cont, full); } //Give students read access CourseRole.CourseRoleList stu = courseda.GetTypedRoles(course.ID, false, null); foreach (CourseRole role in stu) { full = new CFilePermission.FilePermissionList(); full.Add(new CFilePermission(role.PrincipalID, FileAction.READ, true)); SetPermissionsInt(cont, full); } //Give staff and stuaccess to asst content Assignment.AssignmentList assts = courseda.GetAssignments(course.ID); foreach (Assignment asst in assts) { CFile acont = GetFile(asst.ContentID); foreach (CourseRole role in staff) { full = CFilePermission.CreateFullAccess(role.PrincipalID); SetPermissionsInt(acont, full); } foreach (CourseRole role in stu) { full = new CFilePermission.FilePermissionList(); full.Add(new CFilePermission(role.PrincipalID, FileAction.READ, true)); SetPermissionsInt(acont, full); } } } }