//Bind data for role interest dropdowns protected void RolesRepeater_BindRepeater() { List <Role> roles = GrouperMethods.GetRoles(); RolesRepeater.DataSource = roles; RolesRepeater.DataBind(); }
protected void CoursesGridView_BindGridView() { List <Course> courses = GrouperMethods.GetCourses(); CoursesGridView.DataSource = courses; CoursesGridView.DataBind(); }
//Bind data for personal skill dropdowns protected void SkillsRepeater_BindRepeater() { List <Skill> skills = GrouperMethods.GetSkills(); SkillsRepeater.DataSource = skills; SkillsRepeater.DataBind(); }
//Bind data for Language skill dropdowns protected void LanguagesRepeater_BindRepeater() { List <ProgrammingLanguage> languages = GrouperMethods.GetLanguages(); LanguagesRepeater.DataSource = languages; LanguagesRepeater.DataBind(); }
protected void InstructorsGridView_BindGridView() { List <Instructor> instructors = GrouperMethods.GetInstructors(); InstructorsGridView.DataSource = instructors; InstructorsGridView.DataBind(); }
//Function triggered when student selects different concurrent class from dropdown protected void CurrentCoursesDropDownList_SelectedIndexChanged(object sender, EventArgs e) { if (CurrentCoursesDropDownList.SelectedIndex > 0) { //Figure out which course int courseID = int.Parse(CurrentCoursesDropDownList.SelectedValue); Course course = GrouperMethods.GetCourse(courseID); if (ViewState["CurrentCourses"] == null) { ViewState["CurrentCourses"] = new List <Course>(); } else //Check if the use is trying to select a course they've already selected { foreach (Course curCourse in ((List <Course>)ViewState["CurrentCourses"])) { if (curCourse.CourseID == courseID) //They've already selected this course, so don't re-add it { return; } } } //Add selected course to gridview ((List <Course>)ViewState["CurrentCourses"]).Add(course); //Rebind CurrentCoursesGridView.DataSource = (List <Course>)ViewState["CurrentCourses"]; CurrentCoursesGridView.DataBind(); } }
protected void StudentsGridView_BindGridView() { InstructorCourse course = GrouperMethods.GetInstructorCourse(InstructorCourseID); StudentsGridView.DataSource = course.Students; StudentsGridView.DataBind(); }
protected void AddStudentLinkButton_Click(object sender, EventArgs e) { StudentListPanel.Visible = false; AddStudentPanel.Visible = true; DuckIDTextBox.Text = ""; FirstNameTextBox.Text = ""; LastNameTextBox.Text = ""; AddStudentLinkButton.Visible = false; SendWelcomeToAllStudentsLinkButton.Visible = false; DeleteAllStudentsLinkButton.Visible = false; ProgrammingLanguagesDropDownList.DataSource = GrouperMethods.GetLanguages(); ProgrammingLanguagesDropDownList.DataBind(); RolesDropDownList.DataSource = GrouperMethods.GetRoles(); RolesDropDownList.DataBind(); SkillsDropDownList.DataSource = GrouperMethods.GetSkills(); SkillsDropDownList.DataBind(); RolesGridView.DataSource = null; RolesGridView.DataBind(); ProgrammingLanguagesGridView.DataSource = null; ProgrammingLanguagesGridView.DataBind(); SkillsGridView.DataSource = null; SkillsGridView.DataBind(); ProgrammingLanguagesDropDownList.DataSource = GrouperMethods.GetLanguages(); ProgrammingLanguagesDropDownList.DataBind(); }
protected void SendWelcomeToAllStudentsLinkButton_Click(object sender, EventArgs e) { InstructorCourse course = GrouperMethods.GetInstructorCourse(InstructorCourseID); if (course.Students.Where(x => x.InitialNotificationSentDate == null).Count() == 0) { MessageBox("No Students to Notify", "All students have already been sent a welcome email. To resend, select <b>Send Welcome</b> for the individual student row.", "Okay"); } else { foreach (Student student in course.Students) { if (student.InitialNotificationSentDate == null) { SendSurveyLinkMessage(student); student.InitialNotificationSentDate = DateTime.Now; GrouperMethods.UpdateStudent(student); } } StudentsGridView_BindGridView(); MessageBox("Welcome Messages Sent", "Welcome messages have been sent to all previously unnotified students.", "Okay"); } }
protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 //string code = manager.GenerateEmailConfirmationToken(user.Id); //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request); //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>."); Instructor instructor = new GroupBuilder.Instructor(); instructor.FirstName = FirstNameTextBox.Text.Trim(); instructor.LastName = LastNameTextBox.Text.Trim(); instructor.DuckID = DuckIDTextBox.Text.Trim(); instructor.IdentityUserID = user.Email; int instructorID = GrouperMethods.InsertInstructor(instructor); Session["InstructorID"] = instructorID; signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
//Bind data for previous classes dropdowns protected void ClassesRepeater_BindRepeater() { List <Course> courses = GrouperMethods.GetCourses().Where(x => x.CoreCourseFlag == true).ToList(); ClassesRepeater.DataSource = courses; ClassesRepeater.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = Request.QueryString["id"].Trim().ToLower(); Student thisStudent = GrouperMethods.GetStudent(int.Parse(id)); //NameLabel.Text = " " + thisStudent.PreferredName; } }
protected void DeleteAllGroupsLinkButton_Click(object sender, EventArgs e) { InstructorCourse course = GrouperMethods.GetInstructorCourse(InstructorCourseID); foreach (Group group in course.Groups) { GrouperMethods.DeleteGroup(group.GroupID); } StudentsGridView_BindGridView(); GroupsRepeater_BindRepeater(); }
protected void StudentsGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int studentID = Convert.ToInt32(StudentsGridView.DataKeys[e.Row.RowIndex].Values[0]); Student student = GrouperMethods.GetStudent(studentID); Label languagesLabel = (Label)e.Row.FindControl("LanguagesLabel"); string languages = ""; foreach (ProgrammingLanguage language in student.Languages.OrderBy(x => x.ProficiencyLevel)) { switch (language.Name) { case "Java": languages += "<span class='fa fa-coffee'></span>"; break; case "Python": languages += "<span class='fa fa-python'></span>"; break; case "Android": languages += "<span class='fa fa-android'></span>"; break; case "Web Programming (PHP)": languages += "<span class='fa fa-php'></span>"; break; case "Web Design (HTML/XML)": languages += "<span class='fa fa-html5'></span>"; break; case "C++": languages += "<span style='font-size: small; font-weight: bold; margin-left: 3px; margin-right: 3px;'>C++</span>"; //languages += @"<span class='fa-layers fa-fw'> // <i class='fas fa-circle-o'></i> // <span class='fa-layers-text fa-inverse' data-fa-transform='shrink-8 down-3' style='font-weight:900'>C++</span> // </span>"; break; case "C": languages += "<span style='font-size: small; font-weight: bold; margin-left: 3px; margin-right: 3px;'>C</span>"; break; } } languagesLabel.Text = languages; } }
protected void StudentsGridView_BindGridView() { InstructorCourse course = GrouperMethods.GetInstructorCourse(InstructorCourseID); if (course.Groups.Count > 0) { NumberOfGroupsDropDownList.SelectedValue = course.Groups.Count.ToString(); } StudentsGridView.DataSource = course.Students; StudentsGridView.DataBind(); }
protected void BindDropDownLists() { List <Course> courses = GrouperMethods.GetCourses(); CoursesDropDownList.DataSource = courses; CoursesDropDownList.DataBind(); List <ListItem> years = new List <ListItem>(); for (int i = DateTime.Now.Year; i < DateTime.Now.Year + 10; i++) { ListItem year = new ListItem { Text = i.ToString(), Value = i.ToString() }; years.Add(year); } YearsDropDownList.DataSource = years; YearsDropDownList.DataBind(); List <ListItem> times = new List <ListItem>(); for (int i = 8; i < 19; i++) { for (int j = 0; j < 2; j++) { int hour = i; if (i > 12) { hour = i - 12; } string minutes = (j * 30).ToString(); if (minutes.Length == 1) { minutes += "0"; } string time = hour.ToString() + ":" + minutes; ListItem item = new ListItem { Text = time, Value = time }; times.Add(item); } } TimesDropDownList.DataSource = times; TimesDropDownList.DataBind(); }
protected void GroupsRepeater_BindRepeater() { InstructorCourse course = GrouperMethods.GetInstructorCourse(InstructorCourseID); if (course.Groups.Count > 0) { NoGroupsPanel.Visible = false; } else { NoGroupsPanel.Visible = true; } GroupsRepeater.DataSource = course.Groups; GroupsRepeater.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] != "" && Request.QueryString["ID"] != null) { int instructorCourseID = int.Parse(Request.QueryString["ID"]); InstructorCourseID = instructorCourseID; InstructorCourse course = GrouperMethods.GetInstructorCourse(instructorCourseID); CourseNameLabel.Text = course.Course.FullName; StudentsGridView_BindGridView(); } }
protected void BuildGroupsLinkButton_Click(object sender, EventArgs e) { int numberOfGroups = int.Parse(NumberOfGroupsDropDownList.SelectedValue); for (int i = 0; i < numberOfGroups; i++) { Group group = new GroupBuilder.Group(); group.InstructorCourseID = InstructorCourseID; group.GroupNumber = i + 1; group.Name = "Group " + (i + 1).ToString() + " (untitled)"; GrouperMethods.InsertGroup(group); } GroupsRepeater_BindRepeater(); }
protected void CoursesGridView_RowCommand(object sender, GridViewCommandEventArgs e) { int instructorCourseID = int.Parse(e.CommandArgument.ToString()); if (e.CommandName == "delete_instructor_course") { GrouperMethods.DeleteInstructorCourse(instructorCourseID); BindGridView(); } if (e.CommandName == "edit_instructor_course") { Response.Redirect("students.aspx?ID=" + instructorCourseID); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] != "" && Request.QueryString["ID"] != null) { int instructorCourseID = int.Parse(Request.QueryString["ID"]); InstructorCourseID = instructorCourseID; InstructorCourse course = GrouperMethods.GetInstructorCourse(instructorCourseID); GroupsRepeater_BindRepeater(); } if (!IsPostBack) { StudentsGridView_BindGridView(); } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signinManager = Context.GetOwinContext().GetUserManager <ApplicationSignInManager>(); // This doen't count login failures towards account lockout // To enable password failures to trigger lockout, change to shouldLockout: true var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: false); switch (result) { case SignInStatus.Success: Instructor instructor = GrouperMethods.GetInstructor(Email.Text.ToLower().Trim()); if (instructor != null) { Session["InstructorID"] = instructor.InstructorID; } IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); break; case SignInStatus.LockedOut: Response.Redirect("/Account/Lockout"); break; case SignInStatus.RequiresVerification: Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}", Request.QueryString["ReturnUrl"], RememberMe.Checked), true); break; case SignInStatus.Failure: default: FailureText.Text = "Invalid login attempt"; ErrorMessage.Visible = true; break; } } }
protected void ProcessStudentsFileLinkButton_Click(object sender, EventArgs e) { List <Student> students = new List <Student>(); HttpPostedFile file = StudentsFileUpload.PostedFile; string fileName = ""; if (file.ContentLength > 0) { fileName = SaveFile(file); } string path = Server.MapPath(LOCAL_PATH + fileName); if (File.Exists(path)) { StreamReader reader = File.OpenText(path); students = ParseFileForStudents(reader); int importedCount = 0; foreach (Student student in students) { int studentID = GrouperMethods.InsertStudent(student); if (studentID > 0) { importedCount++; } } if (importedCount > 0) { StudentsGridView_BindGridView(); ImportStudentsLinkButton.Visible = true; ImportStudentsPanel.Visible = false; StudentListPanel.Visible = true; AddStudentLinkButton.Visible = true; MessageBox("Student Records Imported", importedCount.ToString() + " student records were found and imported.", "Okay"); } } }
//This executes whenever the page is loaded (or re-loaded) protected void Page_Load(object sender, EventArgs e) { //instantiate the student object if (ThisStudent == null) { ThisStudent = new Student(); } if (!TEST_FLAG) { //If the GUID does not idicate a valid student, redirect if ((ThisStudent.SurveySubmittedDate != null) || (GUID == "") || (GUID == null)) { Response.Redirect("Oops.aspx"); } } //Only do these things the firsrt time the page loads (not on post-backs) if (!IsPostBack) { //Fill out name information FirstNameLabel.Text = ThisStudent.FirstName; LastNameLabel.Text = ThisStudent.LastName; PreferedNameTextBox.Text = ThisStudent.FirstName; //Bind data for drop-down repeaters ClassesRepeater_BindRepeater(); RolesRepeater_BindRepeater(); LanguagesRepeater_BindRepeater(); SkillsRepeater_BindRepeater(); //Bind data for current courses section CurrentCoursesDropDownList.DataSource = GrouperMethods.GetCourses(); CurrentCoursesDropDownList.DataBind(); CurrentCoursesGridView.DataSource = null; CurrentCoursesGridView.DataBind(); } }
protected void BindGridView() { string userName = Context.User.Identity.GetUserName(); List <InstructorCourse> courses = new List <InstructorCourse>(); if (!string.IsNullOrEmpty(userName)) { Instructor instructor = GrouperMethods.GetInstructor(userName); if (instructor != null) { InstructorNameLabel.Text = instructor.FirstName + " " + instructor.LastName; } courses = GrouperMethods.GetInstructorCourses(instructor.InstructorID); if (courses.Count > 0) { CoursesPanel.Visible = true; NoCoursesPanel.Visible = false; AddCourseSectionPanel.Visible = false; } else { AddCourseSectionPanel.Visible = false; NoCoursesPanel.Visible = true; CoursesPanel.Visible = false; } } //else //{ // courses = GrouperMethods.GetInstructorCourses(); //} CoursesGridView.DataSource = courses; CoursesGridView.DataBind(); }
protected void SaveCourseLinkButton_Click(object sender, EventArgs e) { string userName = Context.User.Identity.GetUserName(); Instructor instructor = GrouperMethods.GetInstructor(userName); if (instructor != null) { InstructorCourse course = new InstructorCourse(); course.InstructorID = instructor.InstructorID; course.CourseID = int.Parse(CoursesDropDownList.SelectedValue); course.TermNumber = int.Parse(TermsDropDownList.SelectedValue); course.Year = int.Parse(YearsDropDownList.SelectedValue); switch (course.TermNumber) { case 1: course.TermName = "Fall " + course.Year.ToString(); break; case 2: course.TermName = "Winter " + course.Year.ToString(); break; case 3: course.TermName = "Spring " + course.Year.ToString(); break; case 4: course.TermName = "Summer " + course.Year.ToString(); break; } int instructorCourseID = GrouperMethods.InsertInstructorCourse(course); BindGridView(); } }
protected void MessageBoxCreateLinkButton_Click(object sender, EventArgs e) { int studentID = int.Parse(SelectedStudentIDHiddenField.Value); if (studentID == 0) { InstructorCourse course = GrouperMethods.GetInstructorCourse(InstructorCourseID); foreach (Student student in course.Students) { GrouperMethods.DeleteStudent(student.StudentID); } StudentsGridView_BindGridView(); MessageBox("Students Deleted", "All students have been deleted.", "Okay"); } else { GrouperMethods.DeleteStudent(studentID); MessageBox("Student Deleted", "The student record has been deleted.", "Okay"); StudentsGridView_BindGridView(); } }
protected void StudentsGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int studentID = Convert.ToInt32(StudentsGridView.DataKeys[e.Row.RowIndex].Values[0]); Student student = GrouperMethods.GetStudent(studentID); string languages = ""; if (student.Languages != null) { if (student.Languages.Count > 0) { languages += "<ul>"; foreach (ProgrammingLanguage language in student.Languages) { languages += "<li>" + language.Name + " - " + language.ProficiencyLevel.ToString() + "</li>"; } languages += "</ul>"; } } Label programmingLanguagesLabel = (Label)e.Row.FindControl("LanguagesLabel"); programmingLanguagesLabel.Text = languages; string roles = ""; if (student.InterestedRoles != null) { if (student.InterestedRoles.Count > 0) { roles += "<ul>"; foreach (Role role in student.InterestedRoles) { roles += "<li>" + role.Name + " - " + role.InterestLevel.ToString() + "</li>"; } roles += "</ul>"; } } Label rolesLabel = (Label)e.Row.FindControl("RolesLabel"); rolesLabel.Text = roles; string skills = ""; if (student.Skills != null) { if (student.Skills.Count > 0) { skills += "<ul>"; foreach (Skill skill in student.Skills) { skills += "<li>" + skill.Name + " - " + skill.ProficiencyLevel.ToString() + "</li>"; } skills += "</ul>"; } } Label skillsLabel = (Label)e.Row.FindControl("SkillsLabel"); skillsLabel.Text = skills; } }
protected void SendSurveyLinkMessage(Student student) { InstructorCourse course = GrouperMethods.GetInstructorCourse(student.InstructorCourseID); string header = @" <html> <head> <style> body { font-size:15px; font-family:'Calibri',sans-serif; } p, ul, li { font-size:15px; font-family:'Calibri',sans-serif; } </style> </head> <body>"; string footer = @"</body> </html>"; string messageBody = header; messageBody += @"<table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' id='bodyTable'> <tr> <td> <table border='0' cellpadding='20' cellspacing='0' width='600' id='emailContainer'> <tr> <td valign='top'>"; messageBody += "<h3>" + course.Course.FullName + " - Welcome</h3>"; string link = ""; link = "https://groupbuilder.azurewebsites.net?id=" + (student.FirstName + student.LastName); messageBody += @"</td> </tr> <tr> <td> <p>Welcome to " + course.Course.FullName + @". This course requires you to complete a short survey to best match you to a group.</p> <p> At your earliest convenience, please visit <a href='" + link + "'>" + link + @"</a> and complete the survey. </p> </td> </tr>"; messageBody += @" <tr> <td> <p>Please contact <a href='mailto:[email protected]'>Chris Friedrich</a> with general questions.</p> </td> </tr> </table> </td> </tr> </table> "; messageBody += footer; SmtpClient client = new SmtpClient(); MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("*****@*****.**", course.Course.FullName); mailMessage.To.Add(student.DuckID + "@uoregon.edu"); mailMessage.Subject = "Welcome to " + course.Course.Code; mailMessage.Body = messageBody; mailMessage.IsBodyHtml = true; if (client.Host != null) { if (mailMessage.To.Count > 0) { try { client.Send(mailMessage); } catch (SmtpFailedRecipientException ex) { SmtpStatusCode statusCode = ex.StatusCode; if (statusCode == SmtpStatusCode.MailboxBusy || statusCode == SmtpStatusCode.MailboxUnavailable || statusCode == SmtpStatusCode.TransactionFailed) { Thread.Sleep(2000); client.Send(mailMessage); } else { throw; } } finally { mailMessage.Dispose(); } } } }
protected void SaveAddStudentLinkButton_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(SelectedStudentIDHiddenField.Value)) { Student student = new Student(); student.InstructorCourseID = InstructorCourseID; student.FirstName = FirstNameTextBox.Text.Trim(); student.LastName = LastNameTextBox.Text.Trim(); student.DuckID = DuckIDTextBox.Text.Trim(); int studentID = GrouperMethods.InsertStudent(student); if (studentID > 0) { if (ViewState["Languages"] != null) { if (((List <ProgrammingLanguage>)ViewState["Languages"]).Count() > 0) { foreach (ProgrammingLanguage language in ((List <ProgrammingLanguage>)ViewState["Languages"])) { GrouperMethods.InsertStudentLanguage(studentID, language.LanguageID, (int)language.ProficiencyLevel); } } } if (ViewState["Roles"] != null) { if (((List <Role>)ViewState["Roles"]).Count() > 0) { foreach (Role role in ((List <Role>)ViewState["Roles"])) { GrouperMethods.InsertStudentRoleInterest(studentID, role.RoleID, (int)role.InterestLevel); } } } if (ViewState["Skills"] != null) { if (((List <Skill>)ViewState["Skills"]).Count() > 0) { foreach (Skill skill in ((List <Skill>)ViewState["Skills"])) { GrouperMethods.InsertStudentSkill(studentID, skill.SkillID, (int)skill.ProficiencyLevel); } } } } } else { int studentID = int.Parse(SelectedStudentIDHiddenField.Value); Student student = GrouperMethods.GetStudent(studentID); student.FirstName = FirstNameTextBox.Text.Trim(); student.LastName = LastNameTextBox.Text.Trim(); student.DuckID = DuckIDTextBox.Text.Trim(); if (ViewState["Languages"] != null) { student.Languages = (List <ProgrammingLanguage>)ViewState["Languages"]; } if (ViewState["Roles"] != null) { student.InterestedRoles = (List <Role>)ViewState["Roles"]; } if (ViewState["Skills"] != null) { student.Skills = (List <Skill>)ViewState["Skills"]; } GrouperMethods.UpdateStudent(student); } StudentsGridView_BindGridView(); SelectedStudentIDHiddenField.Value = null; RolesGridView.DataSource = null; RolesGridView.DataBind(); ProgrammingLanguagesGridView.DataSource = null; ProgrammingLanguagesGridView.DataBind(); SkillsGridView.DataSource = null; SkillsGridView.DataBind(); AddStudentPanel.Visible = false; DuckIDTextBox.Text = ""; FirstNameTextBox.Text = ""; LastNameTextBox.Text = ""; AddStudentLinkButton.Visible = true; SendWelcomeToAllStudentsLinkButton.Visible = true; DeleteAllStudentsLinkButton.Visible = true; StudentListPanel.Visible = true; }