/// <summary> /// Create a new section /// </summary> public bool Create(string name, string owner, int courseID) { string actor = Identity.Name; //Check Permission Authorize(courseID, Permission.COURSE, "createsect", courseID, null); //Send email to the owner if the owner did not make the change if (actor != owner) new EmailWizard(m_ident).SendByUsername(owner, "FrontDesk Section Notification", String.Format(Globals.GetMessage("SectionCreate"), actor, name, System.DateTime.Now)); Section sec = new Section(); sec.CourseID = courseID; sec.Name = name; sec.Owner = owner; //Make sure the section does not exist CheckSectionExists(sec); //Create section m_dp.CreateSection(sec); //Create default permissions CreatePermissions(sec.ID, courseID, Permission.SECTION); //Log Log("User created section: " + name, courseID); return true; }
private void BindSectionItem(Section sec, Label lblName, Label lblProgress, System.Web.UI.WebControls.Image imgStatus, System.Web.UI.WebControls.Image imgType, CheckBox chkSelect) { imgType.ImageUrl = "../../attributes/group.gif"; lblName.Text = sec.Name; chkSelect.Checked = false; int prg = GetSectionProgress(sec); lblProgress.Text = prg.ToString() + "%"; if (prg == 100) imgStatus.ImageUrl = "../../attributes/subgrade.gif"; else imgStatus.Visible = false; }
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))); }
private void BindSectionItem(Section sec, Label lblName, LinkButton lnkGraded, LinkButton lnkUnGraded, Label lblStudents, Label lblSubmissions, System.Web.UI.WebControls.Image imgStatus, System.Web.UI.WebControls.Image imgType, CheckBox chkSelect) { imgType.ImageUrl = "../../attributes/group.gif"; lblName.Text = sec.Name; chkSelect.Checked = false; Section.SectionProgress progress = new Sections(Globals.CurrentIdentity).GetGradingProgress(sec.ID, GetAsstID()); int gradedperc = Math.Min(100, Math.Max(0, (int)(((double)progress.TotalGraded / ((double)(progress.TotalSubmissions)))*100.0))); lnkGraded.Text = progress.TotalGraded.ToString() + " (" + gradedperc + "%)"; lnkUnGraded.Text = (progress.TotalSubmissions - progress.TotalGraded).ToString() + " (" + (100-gradedperc).ToString() + "%)"; lblStudents.Text = progress.TotalStudents.ToString(); lblSubmissions.Text = progress.TotalSubmissions.ToString(); if (progress.TotalGraded == progress.TotalSubmissions) imgStatus.ImageUrl = "../../attributes/subgrade.gif"; else imgStatus.Visible = false; }
protected void CheckSectionExists(Section sec) { //Check to see if a section with identical attributes exists Section.SectionList secs = (new Courses(Globals.CurrentIdentity)).GetSections(sec.CourseID); if (secs.Contains(sec)) throw new DataAccessException("Identical section already exists"); }
/// <summary> /// Update section information /// </summary> public bool Update(Section sec) { //Check permission Authorize(sec.CourseID, Permission.SECTION, "update", sec.ID, null); //Check for the section already existing CheckSectionExists(sec); return m_dp.UpdateSection(sec); }
private TreeNode AddSectionNode(TreeNodeCollection par, Section sect) { return AddNode(par, sect.Name, "attributes/group.gif", "attributes/group.gif", "Section " + sect.ID, true); }