Exemplo n.º 1
0
        private double calculateTotalGrade(String StudentEGN, String programmeName)
        {
            //Boolean useMatExam = false; //should the matricularity exam be used instead of the diploma grade
            Double value;
            //TODO: return formulas applicable for this student

            List <List <String> > formulas = queryManager.getFormulasComponents(programmeName);
            double totalGrade = 0;
            double maxGrade   = 0;

            List <String> matricularityExams = getMatricularityExams(formulas);

            for (int formulaInd = 0; formulaInd < formulas.Count; formulaInd++)
            {
                for (int componentInd = 1; componentInd < formulas[formulaInd].Count; componentInd += 2)
                {
                    if (formulas[formulaInd][componentInd].ToLower().Contains(DIPLOMA) &&
                        hasMatricularityGrade(formulas[formulaInd][componentInd], matricularityExams))
                    {
                        //we shouldn't allow diploma grading if matricularity grade is available
                        totalGrade = 0;
                        break;
                    }

                    if (!grades.TryGetValue(formulas[formulaInd][componentInd], out value))
                    {
                        totalGrade = 0;
                        break;
                    }

                    int    weight = Int32.Parse(formulas[formulaInd][componentInd - 1]);
                    double grade  = grades[formulas[formulaInd][componentInd]];

                    if (grade < MINIMAL_ALLOWED_GRADE)
                    {
                        totalGrade = 0;
                        break;
                    }

                    totalGrade += weight * grade;
                }

                if (totalGrade > maxGrade)
                {
                    maxGrade = totalGrade;
                }

                totalGrade = 0;
            }

            return(maxGrade);
        }