/* * Pre: * Post: Get teachers based on selected district */ private void updateTeacherDropdown() { ddlTeacher.DataSource = null; ddlTeacher.DataBind(); if (ddlDistrictSearch.SelectedIndex > 0 && !HighestPermissionTeacher()) { int districtId = Convert.ToInt32(ddlDistrictSearch.SelectedValue); DataTable table = DbInterfaceContact.GetTeachersFromDistrict(districtId); if (table != null) { ddlTeacher.DataSource = null; ddlTeacher.DataBind(); ddlTeacher.Items.Clear(); //add empty item ddlTeacher.Items.Add(new ListItem("", "")); //add teachers from district ddlTeacher.DataSource = table; ddlTeacher.DataTextField = "ComboName"; ddlTeacher.DataValueField = "ContactId"; ddlTeacher.DataBind(); } else { showErrorMessage("Error: The teachers for the selected district could not be retrieved."); } } }
/* * Pre: * Post: If the current user is a teacher they can only add/edit their own students. * If the current user is a district administrator they can only add/edit students * in their district */ private void filterDistrictsAndTeachers() { //filter available districts and teachers based on user role User user = (User)Session[Utility.userRole]; //if the user is a teacher, only allow students to be added to their district and assigned to themselves if (user.permissionLevel.Contains('T') && !(user.permissionLevel.Contains('A') || user.permissionLevel.Contains('S') || user.permissionLevel.Contains('D'))) { //only show current teacher's district cboDistrict.DataBind(); ListItem item = cboDistrict.Items.FindByValue(user.districtId.ToString()); cboDistrict.Items.Clear(); cboDistrict.Items.Add(item); //only show current teacher in teacher dropdown cboCurrTeacher.DataBind(); item = cboCurrTeacher.Items.FindByValue(user.contactId.ToString()); cboCurrTeacher.Items.Clear(); cboCurrTeacher.Items.Add(item); } //if the user is a district admin, allow them to add students to their district to and assign them to a teacher in their district else if (user.permissionLevel.Contains('D') && !(user.permissionLevel.Contains('A') || user.permissionLevel.Contains('S'))) { //only show current user's district cboDistrict.DataBind(); ListItem item = cboDistrict.Items.FindByValue(user.districtId.ToString()); cboDistrict.Items.Clear(); cboDistrict.Items.Add(item); //only show teachers in the current user's district DataTable table = DbInterfaceContact.GetTeachersFromDistrict(user.districtId); cboCurrTeacher.DataSourceID = null; cboCurrTeacher.DataSource = table; cboCurrTeacher.DataBind(); } }