Ejemplo n.º 1
0
        /// <summary>
        /// Gets a StudentSuccessMap for the student with the given star ID and Program.
        /// </summary>
        /// /// <param name="starID">The Star ID of the student to retrieve a StudentSuccessMap for.</param>
        /// <param name="program">The Program to retrieve a SuccessMap for.</param>
        public Task <StudentSuccessMap> getStudentSuccessMapAsync(string starID, Program program)
        {
            //Can't retrieve success map without knowing the program to retrieve from (eventually)
            if (program == null)
            {
                return(null);
            }

            //Return program success map if already retrieved
            //Don't refresh due to low frequency of change
            if (program.successMap != null && program.successMap is StudentSuccessMap)
            {
                return(Task.FromResult((StudentSuccessMap)program.successMap));
            }

            DatabaseSelect dbSelect = new DatabaseSelect();
            DataTable      studentSuccessMapTable = dbSelect.SelectStudentSuccessMap(starID, program.ID);

            //Make sure a student success map was retrieved
            if (studentSuccessMapTable != null && studentSuccessMapTable.Rows.Count > 0)
            {
                StudentSuccessMap successMap = DataInterpreter.getStudentSuccessMap(studentSuccessMapTable.Rows[0]);
                program.successMap = successMap;
                return(Task.FromResult(successMap));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an array of Programs in the specified Department asynchronously.
        /// </summary>
        /// <param name="department">The Department to retrieve Programs for.</param>
        public Task <Program[]> getProgramsAsync(Department department)
        {
            //Can't retrieve departments without knowing the college to retrieve from (eventually)
            if (department == null)
            {
                return(null);
            }

            //Return department programs if already retrieved
            //Don't refresh due to low frequency of change
            if (department.programs != null)
            {
                return(Task.FromResult(department.programs));
            }

            //Get programs from database
            DatabaseSelect dbSelect      = new DatabaseSelect();
            DataTable      programsTable = dbSelect.SelectPrograms(department.ID);

            //Convert data to Program objects
            List <Program> programs = new List <Program>();

            foreach (DataRow row in programsTable.Rows)
            {
                programs.Add(DataInterpreter.getProgram(row));
            }

            return(Task.FromResult(programs.ToArray()));
        }
        /// <summary>
        /// Gets an array of Departments in the specified College asynchronously.
        /// </summary>
        /// <param name="college">The College to retrieve Departments for.</param>
        public Task <Department[]> getDepartmentsAsync(College college)
        {
            //Can't retrieve departments without knowing the college to retrieve from (eventually)
            if (college == null)
            {
                return(null);
            }

            //Return college departments if already retrieved
            //Don't refresh due to low frequency of change
            if (college.departments != null)
            {
                return(Task.FromResult(college.departments));
            }

            //Get departments from database
            DatabaseSelect dbSelect         = new DatabaseSelect();
            DataTable      departmentsTable = dbSelect.SelectDepartments(college.ID);

            //Convert data to Department objects
            List <Department> departments = new List <Department>();

            foreach (DataRow row in departmentsTable.Rows)
            {
                departments.Add(DataInterpreter.getDepartment(row));
            }

            return(Task.FromResult(departments.ToArray()));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets an array of Colleges in the university asynchronously.
        /// </summary>
        public Task <College[]> getCollegesAsync()
        {
            //Get colleges from database
            DatabaseSelect dbSelect     = new DatabaseSelect();
            DataTable      collegeTable = dbSelect.SelectColleges();

            //Convert data to College objects
            List <College> colleges = new List <College>();

            foreach (DataRow row in collegeTable.Rows)
            {
                colleges.Add(DataInterpreter.getCollege(row));
            }

            return(Task.FromResult(colleges.ToArray()));
        }
Ejemplo n.º 5
0
        public static StudentSuccessMap getStudentSuccessMap(DataRow studentSuccessPlanData)
        {
            string starID    = studentSuccessPlanData["StarID"].ToString();
            int    programID = (int)studentSuccessPlanData["PrgmID"];

            DatabaseSelect dbSelect        = new DatabaseSelect();
            DataTable      successMapTable = dbSelect.SelectSuccessMap(programID);

            //Make sure a success map was retrieved
            if (successMapTable != null && successMapTable.Rows.Count > 0)
            {
                DataRow successMapData = successMapTable.Rows[0];

                int    ID   = (int)successMapData["SMID"];
                string name = successMapData["SMName"].ToString();

                //Create student success map
                SuccessMap successMap = new StudentSuccessMap(ID, name, starID, programID);

                //Populate success map base data
                populateSuccessMap(ref successMap); //ref does not support polymorphism
                StudentSuccessMap studentSuccessMap = (StudentSuccessMap)successMap;

                //Populate Student Success Map specific data
                DataTable completedObjsTable = dbSelect.SelectCompletedObjectives(starID);
                if (completedObjsTable != null)
                {
                    //Add completed objectives to success map
                    foreach (DataRow completedObjData in completedObjsTable.Rows)
                    {
                        string objectiveID = completedObjData["ObjID"].ToString();
                        studentSuccessMap.addCompletedObjective(objectiveID);
                    }
                }

                return(studentSuccessMap);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        //Populates the given success map with the required data.
        private static void populateSuccessMap(ref SuccessMap successMap)
        {
            DatabaseSelect dbSelect = new DatabaseSelect();

            DataTable objectiveMappingsTable = dbSelect.SelectSuccessObjMapSuccessMap(successMap.ID);

            //The success map has success objectives
            if (objectiveMappingsTable != null && objectiveMappingsTable.Rows.Count > 0)
            {
                Dictionary <int, SuccessCategory>            categories  = new Dictionary <int, SuccessCategory>();
                Dictionary <int, SuccessObjectiveClassifier> classifiers = new Dictionary <int, SuccessObjectiveClassifier>();
                Dictionary <int, Semester>   semesters   = new Dictionary <int, Semester>();
                Dictionary <int, SchoolYear> schoolYears = new Dictionary <int, SchoolYear>();

                foreach (DataRow mappingData in objectiveMappingsTable.Rows)
                {
                    string objectiveID = mappingData["ObjID"].ToString();
                    int    semesterID  = (int)mappingData["SemesterID"];
                    int    categoryID  = (int)mappingData["CategoryID"];
                    int    weight      = (int)mappingData["Weight"];

                    //Classifier optional
                    int classifierID;
                    try
                    {
                        classifierID = (int)mappingData["ClassificationID"];

                        //Get success objective classifier if it doesn't already exist
                        if (!classifiers.ContainsKey(classifierID))
                        {
                            DataTable classifierTable = dbSelect.SelectClassifier(classifierID);
                            if (classifierTable != null && classifierTable.Rows.Count > 0) //Classifier exists
                            {
                                classifiers.Add(classifierID, getSuccessObjectiveClassifier(classifierTable.Rows[0]));
                            }
                        }
                    }
                    catch
                    {
                        classifierID = default;
                        Console.WriteLine("Classifier ID not provided for objective: " + objectiveID);
                    }

                    SuccessObjective successObjective = null;

                    //Get success objective
                    DataTable objectiveTable = dbSelect.SelectObjective(objectiveID);
                    if (objectiveTable != null && objectiveTable.Rows.Count > 0) //Objective exists
                    {
                        //Check if objective has a classifier
                        SuccessObjectiveClassifier classifier = classifierID != default ? classifiers[classifierID] : null;
                        successObjective = getSuccessObjective(objectiveTable.Rows[0], weight, classifier);
                    }
                    else
                    {
                        Console.WriteLine("Could not retrieve success objective with ID: " + objectiveID);
                    }

                    //Get success category if it doesn't already exist
                    if (!categories.ContainsKey(categoryID))
                    {
                        DataTable categoryTable = dbSelect.SelectCategory(categoryID);
                        if (categoryTable != null && categoryTable.Rows.Count > 0) //Category exists
                        {
                            categories.Add(categoryID, getSuccessCategory(categoryTable.Rows[0]));
                        }
                        else
                        {
                            Console.WriteLine("Could not retrieve success category with ID: " + categoryID);
                        }
                    }

                    //Get semester if it doesn't already exist
                    if (!semesters.ContainsKey(semesterID))
                    {
                        DataTable semesterTable = dbSelect.SelectSemester(semesterID);
                        if (semesterTable != null && semesterTable.Rows.Count > 0) //Semester exists
                        {
                            int year;
                            semesters.Add(semesterID, getSemester(semesterTable.Rows[0], out year));

                            //Get year if it doesn't already exist
                            if (!schoolYears.ContainsKey(year))
                            {
                                DataTable yearTable = dbSelect.SelectYear(year);
                                if (yearTable != null && yearTable.Rows.Count > 0) //Year exists
                                {
                                    schoolYears.Add(year, getSchoolYear(yearTable.Rows[0]));
                                }
                                else
                                {
                                    Console.WriteLine("Could not retrieve school year with ID: " + year);
                                }
                            }

                            //Add semester to year
                            Semester   semester   = semesters[semesterID];
                            SchoolYear schoolYear = schoolYears[year];
                            semester.SchoolYear = schoolYear;

                            //Associate semester with school year
                            string lowerCaseName = semester.Name.ToLower();
                            if (lowerCaseName.Contains("fall"))
                            {
                                schoolYear.Fall = semester;
                            }
                            else if (lowerCaseName.Contains("spring"))
                            {
                                schoolYear.Spring = semester;
                            }
                            else if (lowerCaseName.Contains("summer"))
                            {
                                schoolYear.Summer = semester;
                            }
                        }
                    }

                    SuccessCategory category          = categories[categoryID];
                    Semester        objectiveSemester = semesters[semesterID];

                    //Add success objective to the success map if all the required data is present
                    if (successObjective != null && category != null && objectiveSemester != null)
                    {
                        successMap.addSuccessObjective(category, objectiveSemester, successObjective);
                    }
                    else
                    {
                        Console.WriteLine("Could not add success objective to success map, missing required data.");
                    }
                }

                //Add classifiers to success map
                successMap.addSuccessObjectiveClassifiers(classifiers.Values);
            }
        }