Ejemplo n.º 1
0
        /// <summary>
        /// Adds a success objective to the given SuccessCategory and Semester.
        /// </summary>
        /// <param name="successCategory">Success category the objective is in.</param>
        /// <param name="semester">School semester the objective is in.</param>
        /// <param name="successObjective">The success objective to add.</param>
        public void addSuccessObjective(SuccessCategory successCategory, Semester semester,
                                        SuccessObjective successObjective)
        {
            if (successCategory != null && semester != null && successObjective != null)
            {
                //Category not already in the success map, add it
                if (!successCategories.Contains(successCategory))
                {
                    successCategories.Add(successCategory);
                }

                //Semester SchoolYear not already in the success map, add it
                if (!schoolYears.Contains(semester.SchoolYear))
                {
                    schoolYears.Add(semester.SchoolYear);
                }

                var key = new Tuple <SuccessCategory, Semester>(successCategory, semester);

                //Key does not exist, create it and instantiate objectives list
                if (!successObjectives.ContainsKey(key))
                {
                    successObjectives.Add(key, new List <SuccessObjective>());
                }

                //Store success objective in collections
                successObjectives[key].Add(successObjective);
                allSuccessObjectives.Add(successObjective);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a success objective from the given SuccessCategory and Semester.
        /// </summary>
        /// <param name="successCategory">Success category the objective is in.</param>
        /// <param name="semester">School semester the objective is in.</param>
        /// <param name="successObjective">The success objective to remove.</param>
        public bool removeSuccessObjective(SuccessCategory successCategory, Semester semester,
                                           SuccessObjective successObjective)
        {
            var key = new Tuple <SuccessCategory, Semester>(successCategory, semester);

            //Key does not exist
            if (!successObjectives.ContainsKey(key))
            {
                return(false);
            }

            //Remove the successObjective from collections
            allSuccessObjectives.Remove(successObjective);
            return(successObjectives[key].Remove(successObjective));
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Determines if the given success objective has been compelted.
 /// </summary>
 public bool isCompleted(SuccessObjective objective)
 {
     return(completedObjectives.Contains(objective.ID));
 }