예제 #1
0
 public GradedTaskGroup(TaskGroup taskGroup)
 {
     tasks = new List<GradedTask>();
     allTasksGraded = false;
     gradeExpression = String.Empty;
     this.taskGroup = taskGroup;
     gradeName = String.Empty;
     allTasksPassed = true;
 }
예제 #2
0
 public GradedTaskGroup(TaskGroup taskGroup)
 {
     tasks           = new List <GradedTask>();
     allTasksGraded  = false;
     gradeExpression = String.Empty;
     this.taskGroup  = taskGroup;
     gradeName       = String.Empty;
     allTasksPassed  = true;
 }
예제 #3
0
        private GradedTaskGroup GetTaskGroupGrade(int userId, TaskGroup taskGroup)
        {
            String exp = "";
            List<Common.Task> tasks = sqlManager.GetTasks(taskGroup.Id);
            List<GradedTask> gradedTasks = new List<GradedTask>();
            GradedTaskGroup gtg = new GradedTaskGroup(taskGroup);
            bool allTasksGraded = true;
            UserTask userTask;
            foreach (Common.Task task in tasks)
            {
                if ((userTask = sqlManager.GetUserTask(userId, task.Id)) != null)
                {

                    gradedTasks.Add(new GradedTask(task.Id, task.Name, task.Weight, task.GradeType, userTask.Grade));

                }
                else
                {
                    gradedTasks.Add(new GradedTask(task.Id, task.Name, task.Weight, task.GradeType)); ;
                    allTasksGraded = false;
                }
            }
            // All tasks graded, calc task group grade
            if (allTasksGraded)
            {
                int grade = 0, bonus = 0, pass = 1;
                foreach (GradedTask gtask in gradedTasks)
                {
                    // P/F, GRADED OR BONUS ON EXAM
                    if (gtask.GradeType == Common.Task.GRADED_GRADE_TYPE)
                    {
                        grade += gtask.Grade * gtask.Weight;

                    }
                    else if (gtask.GradeType == Common.Task.PASS_FAIL_GRADE_TYPE)
                    {
                        pass *= gtask.Grade;
                    }
                    else if (gtask.GradeType == Common.Task.BONUS_ON_EXAM_GRADE_TYPE)
                    {
                        bonus += gtask.Grade;
                    }

                }

                // Failed some pass/fail moment, can't pass course
                if (pass == 0)
                    grade = 0;

                List<TaskGroupGrade> grades = sqlManager.GetTaskGroupGrades(taskGroup.Id);
                exp = "g = 0" + Environment.NewLine + "b = 0" + Environment.NewLine;

                foreach (TaskGroupGrade tgg in grades)
                {
                    String expressionParsed = "g = " + grade + Environment.NewLine + "b = " + bonus + Environment.NewLine + "parsed = " + tgg.Expression + Environment.NewLine;
                    compiler.Interpretate(expressionParsed);
                    float parsed = compiler.GetVarAsFloat("parsed");
                    String tmp = "meetsGradeReq = IfElse(Max(" + parsed + "," + tgg.Limit + "), " + tgg.Limit + ", 0, 1)" + Environment.NewLine;
                    compiler.Interpretate(tmp);
                    float meetsGradeReq = compiler.GetVarAsFloat("meetsGradeReq");

                    // Meets grade requirements, do point calculations
                    if (meetsGradeReq == 1)
                    {
                        exp = "g = " + tgg.Value + Environment.NewLine + "b = " + bonus + Environment.NewLine;
                        gtg.GradeName = tgg.GradeName;

                         // FAILED TASK GROUP, set status bool
                        if (tgg.Value == 0)
                            gtg.AllTasksPassed = false;

                        break;
                    }

                }
            }

            gtg.Tasks = gradedTasks;
            gtg.AllTasksGraded = allTasksGraded;
            gtg.GradeExpression = exp;

            return gtg;
        }