Exemple #1
0
        protected void gvwGrade_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int index = e.NewSelectedIndex;
            List <GradeItem> items = (List <GradeItem>) this.odsStudents.Select();

            HttpContext.Current.Session["CurrentGradedItem"] = items[index];
            HttpContext.Current.Session["SelectedStudent"]   = items[index].Student;
            CourseDAL courseDal     = new CourseDAL();
            int       crn           = int.Parse(this.ddlCourses.SelectedValue);
            Course    currentCourse = courseDal.GetCourseByCRN(crn);

            HttpContext.Current.Session["CurrentCourse"] = currentCourse;
            HttpContext.Current.Response.Redirect("TeacherGradeGradeItemPage.aspx");
        }
Exemple #2
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            List <GradeItem> items   = (List <GradeItem>) this.odsStudents.Select();
            GradeItem        current = items[0];

            HttpContext.Current.Session["CurrentGradedItem"] = current;
            HttpContext.Current.Session["editing"]           = true;
            CourseDAL courseDal     = new CourseDAL();
            int       crn           = int.Parse(this.ddlCourses.SelectedValue);
            Course    currentCourse = courseDal.GetCourseByCRN(crn);

            HttpContext.Current.Session["CurrentCourse"] = currentCourse;
            HttpContext.Current.Response.Redirect("ManageCreateGradeItem.aspx");
        }
        public bool CheckIfStudentCanSignUpForCourseBasedOnPreReqs(int crn, string studentID)
        {
            CourseDAL courses = new CourseDAL();
            var       preReqs = courses.GetPrerequisiteCoursesForGivenCRN(crn);

            if (preReqs.Count == 0)
            {
                return(true);
            }
            List <string> namesToCheck  = new List <string>();
            List <char>   gradesToCheck = new List <char>();

            foreach (var curr in preReqs)
            {
                namesToCheck.Add(curr.Key);
                gradesToCheck.Add(curr.Value);
            }
            Course currentcourse = courses.GetCourseByCRN(crn);
            int    counter       = 0;

            bool[] canAdd = new bool[preReqs.Count];
            foreach (var courseToCheck in namesToCheck)
            {
                var grades = courses.GetGradesEarnedForCompletedCourse(courseToCheck, studentID);
                if (grades.Count < 1)
                {
                    return(false);
                }

                foreach (var currentGrade in grades)
                {
                    if (this.getGradeValueFromChar(gradesToCheck[counter]) <=
                        this.getGradeValueFromChar(currentGrade))
                    {
                        canAdd[counter] = true;
                    }
                }

                counter++;
            }
            foreach (var currentCanAddValue in canAdd)
            {
                if (!currentCanAddValue)
                {
                    return(false);
                }
            }
            return(true);
        }
        public bool CheckIfCourseContributesToMajor(int crn, string studentID)
        {
            DegreeProgramDAL degreeChecker  = new DegreeProgramDAL();
            string           degree         = degreeChecker.GetDegreeProgramByStudentID(studentID);
            List <string>    degreeCourses  = degreeChecker.GetCourseNamesByDegreeProgram(degree);
            CourseDAL        courseChecker  = new CourseDAL();
            Course           currentCourse  = courseChecker.GetCourseByCRN(crn);
            bool             isContributing = false;

            foreach (var names in degreeCourses)
            {
                if (names.Equals(currentCourse.Name))
                {
                    isContributing = true;
                }
            }

            return(isContributing);
        }
        protected void AvailableCourses_SelectedIndexChanged(object sender, EventArgs e)
        {
            int crn = (int)this.AvailableCoursesGrid.SelectedValue;

            HttpContext.Current.Session["chosenCRN"] = crn;
            CourseDAL  courseGetter = new CourseDAL();
            Course     courseToAdd  = courseGetter.GetCourseByCRN(crn);
            TeacherDAL dal          = new TeacherDAL();

            Models.Teacher instructor     = dal.GetTeacherByCRN(crn);
            string         instructorName = instructor != null ? instructor.Name : "TBA";

            this.lblCourseToAdd.Text = "Course to Add: " + courseToAdd.CRN + " " + courseToAdd.Name + " " +
                                       courseToAdd.SectionNumber + " Instructor: " + instructorName;
            CourseSignUpHelper degreeChecker = new CourseSignUpHelper();
            var current = HttpContext.Current.Session["User"] as User;

            if (!degreeChecker.CheckIfCourseContributesToMajor(crn, current.UserId))
            {
                this.lblCourseToAdd.Text +=
                    Environment.NewLine + "This course does not contribute to your degree program.";
            }
        }