Beispiel #1
0
        // TODO IMPLEMENT WITH TASK GROUP GRADES
        public GradedCourse GetCourseGrade(int userId, int courseId)
        {
            List <TaskGroup>       taskGroups       = sqlManager.GetTaskGroups(courseId);
            GradedCourse           gradedCourse     = new GradedCourse(sqlManager.getCourse(courseId));
            List <GradedTaskGroup> gradedTaskGroups = new List <GradedTaskGroup>();

            gradedCourse.GradedTaskGroups = gradedTaskGroups;
            float grade = 0, bonus = 0;


            bool allTaskGroupsGraded = true;
            bool allTaskGroupsPassed = true;

            foreach (TaskGroup tg in taskGroups)
            {
                GradedTaskGroup gtg = GetTaskGroupGrade(userId, tg);

                if (!gtg.AllTasksGraded)
                {
                    allTaskGroupsGraded = false;
                }

                if (gtg.AllTasksPassed == false)
                {
                    allTaskGroupsPassed = false;
                }

                gradedTaskGroups.Add(gtg);
            }
            if (allTaskGroupsGraded && allTaskGroupsPassed)
            {
                foreach (GradedTaskGroup gtg in gradedTaskGroups)
                {
                    compiler.Interpretate(gtg.GradeExpression);
                    grade += compiler.GetVarAsFloat("g");
                    bonus += compiler.GetVarAsFloat("b");
                }
                List <CourseGrade> courseGrades = sqlManager.GetCourseGrades(courseId);
                String             expressionParsed, tmp;
                float meetsGradeReq = 0, parsed;
                foreach (CourseGrade cg in courseGrades)
                {
                    expressionParsed = "g = " + grade + Environment.NewLine + "b = " + bonus + Environment.NewLine + "parsed = " + cg.Expression + Environment.NewLine;
                    compiler.Interpretate(expressionParsed);
                    parsed = compiler.GetVarAsFloat("parsed");
                    tmp    = "meetsGradeReq = IfElse(Max(" + parsed + "," + cg.Limit + "), " + cg.Limit + ", 0, 1)" + Environment.NewLine;
                    compiler.Interpretate(tmp);
                    meetsGradeReq = compiler.GetVarAsFloat("meetsGradeReq");

                    if (meetsGradeReq == 1)
                    {
                        gradedCourse.GradeName = cg.GradeName;
                        break;
                    }
                }
            }

            return(gradedCourse);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            GradedCourse gradedcourse = db.GradedCourses.Find(id);

            db.Courses.Remove(gradedcourse);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //
        // GET: /GradedCourse/Details/5

        public ActionResult Details(int id = 0)
        {
            GradedCourse gradedcourse = db.GradedCourses.Find(id);

            if (gradedcourse == null)
            {
                return(HttpNotFound());
            }
            return(View(gradedcourse));
        }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "CourseId,ProgramId,CourseNumber,Title,CreditHours,TuitionAmount,Notes,AssignmentWeight,MidtermWeight,FinalWeight")] GradedCourse gradedCourse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gradedCourse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProgramId = new SelectList(db.Programs, "ProgramId", "Description", gradedCourse.ProgramId);
     return(View(gradedCourse));
 }
 public ActionResult Edit(GradedCourse gradedcourse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gradedcourse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProgramId = new SelectList(db.Programs, "ProgramId", "Description", gradedcourse.ProgramId);
     return(View(gradedcourse));
 }
        //
        // GET: /GradedCourse/Edit/5

        public ActionResult Edit(int id = 0)
        {
            GradedCourse gradedcourse = db.GradedCourses.Find(id);

            if (gradedcourse == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProgramId = new SelectList(db.Programs, "ProgramId", "Description", gradedcourse.ProgramId);
            return(View(gradedcourse));
        }
Beispiel #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            GradedCourse gradedCourse = db.GradedCourses.Find(id);

            if (gradedCourse.registration != null)
            {
                gradedCourse.registration.Clear();
            }
            db.GradedCourses.Remove(gradedCourse);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(GradedCourse gradedcourse)
        {
            if (ModelState.IsValid)
            {
                gradedcourse.setNextCourseNumber();
                db.Courses.Add(gradedcourse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProgramId = new SelectList(db.Programs, "ProgramId", "Description", gradedcourse.ProgramId);
            return(View(gradedcourse));
        }
Beispiel #9
0
        public ActionResult Create([Bind(Include = "CourseId,AcademicProgramId,CourseNumber,Title,CreditHours,TuitionAmount,Notes,AssignmentWeight,MidtermWeight,FinalWeight")] GradedCourse gradedCourse)
        {
            gradedCourse.SetNextCourseNumber();
            if (ModelState.IsValid)
            {
                db.GradedCourses.Add(gradedCourse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AcademicProgramId = new SelectList(db.AcademicPrograms, "AcademicProgramId", "ProgramAcronym", gradedCourse.AcademicProgramId);
            return(View(gradedCourse));
        }
Beispiel #10
0
        // GET: GradedCourses/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GradedCourse gradedCourse = db.GradedCourses.Find(id);

            if (gradedCourse == null)
            {
                return(HttpNotFound());
            }
            return(View(gradedCourse));
        }
Beispiel #11
0
        public ActionResult Create([Bind(Include = "CourseId,ProgramId,Title,CreditHours,TuitionAmount,Notes,AssignmentWeight,MidtermWeight,FinalWeight")] GradedCourse gradedCourse)
        //public ActionResult Create([Bind(Include = "CourseId,ProgramId,CourseNumber,Title,CreditHours,TuitionAmount,Notes,AssignmentWeight,MidtermWeight,FinalWeight")] GradedCourse gradedCourse)
        {
            if (ModelState.IsValid)
            {
                gradedCourse.setNextCourseNumber(); //is this right
                db.Courses.Add(gradedCourse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProgramId = new SelectList(db.Programs, "ProgramId", "Description", gradedCourse.ProgramId);
            return(View(gradedCourse));
        }
Beispiel #12
0
        // GET: GradedCourses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GradedCourse gradedCourse = db.GradedCourses.Find(id);

            if (gradedCourse == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProgramId = new SelectList(db.Programs, "ProgramId", "Description", gradedCourse.ProgramId);
            return(View(gradedCourse));
        }