Exemplo n.º 1
0
        private void UpdateAvgGrade(CollegeModule moduleData, bool shouldAddGrade)
        {
            if (_finishedModules == null)
            {
                _finishedModules = new List <CollegeModule>();
            }

            if (shouldAddGrade)
            {
                _finishedModules.Add(moduleData);
            }
            else
            {
                var moduleToRemove = _finishedModules.First(e => e.Title == moduleData.Title);
                _finishedModules.Remove(moduleToRemove);
            }

            List <double> gradesList = new List <double>();

            foreach (var module in _finishedModules)
            {
                var amountOfEntries = module.Credits == 15 ? 3 : 1;

                for (int i = 0; i < amountOfEntries; i++)
                {
                    gradesList.Add(module.Grade);
                }
            }

            var avgGrade = gradesList.Sum(x => Convert.ToDouble(x)) / gradesList.Count;

            MainWindow.AppWindow.avgGradeLabel.Content = Math.Round(avgGrade, 1);
        }
Exemplo n.º 2
0
        public CollegeModule GetCollegeModuleByTitle(string moduleTitle)
        {
            List <CollegeModule> modules       = GetAllModules();
            CollegeModule        currentModule = modules.First(m => m.Title == moduleTitle);

            return(currentModule);
        }
Exemplo n.º 3
0
 private static void ShowGradePopupIfNecessary(CollegeModule selectedModule, bool moduleAddedToList)
 {
     if (moduleAddedToList)
     {
         var popUp = new GradePopUp();
         popUp.SetupAndShow(selectedModule);
     }
     else
     {
         MainWindow.AppWindow.UpdateGradeForModule(selectedModule, 0, false);
     }
 }
        internal void UpdateGradeForModule(CollegeModule currentModule, double chosenGrade, bool shouldAddGrade)
        {
            var listIndexToUpdate = finishedModules.Items.IndexOf(currentModule.Title);

            if (shouldAddGrade)
            {
                finishedModulesGrades.Items.Add(chosenGrade);
            }
            else
            {
                finishedModulesGrades.Items.RemoveAt(listIndexToUpdate);
            }
        }
Exemplo n.º 5
0
        private void CheckModuleForDependencies(CollegeModule movedModuleData, object movedModuleElement, ListBox ToList)
        {
            if (movedModuleData.DependandModules == null)
            {
                return;
            }

            var finishedModules = MainWindow.AppWindow.finishedModules.Items;

            if (ToList == MainWindow.AppWindow.plannedModules)
            {
                if (!finishedModules.Contains(movedModuleElement))
                {
                    foreach (var finishedModule in finishedModules)
                    {
                        var finishedModuleData = GetCollegeModuleByTitle(finishedModule.ToString());

                        foreach (var dependandID in movedModuleData.DependandModules)
                        {
                            if (finishedModuleData.ID == dependandID)
                            {
                                return;
                            }
                        }
                    }

                    MainWindow.AppWindow.SetAlertLabelForModule(movedModuleElement.ToString(), true);
                }
            }

            else if (ToList == MainWindow.AppWindow.openModules ||
                     ToList == MainWindow.AppWindow.finishedModules)
            {
                MainWindow.AppWindow.SetAlertLabelForModule(movedModuleElement.ToString(), false);
            }
        }
Exemplo n.º 6
0
 internal void UpdateModuleGrade(CollegeModule currentModule, double chosenGrade)
 {
     currentModule.Grade = chosenGrade;
     UpdateAvgGrade(currentModule, true);
     MainWindow.AppWindow.UpdateGradeForModule(currentModule, chosenGrade, true);
 }