Example #1
0
        public ActionResult Index()
        {
            /*List<Student> students = db.students.ToList();
             *
             * // eager load information needed for view
             * foreach (Student s in students)
             * {
             *      s.assessments.ToList ();
             *      foreach(Assessment sa in s.assessments)
             *      {
             *              int i = sa.scene.id;
             *      }
             * }
             *
             * return View (students);*/

            List <Student> students = db.students.ToList();

            List <studentVM> studentVMs = new List <studentVM> ();

            foreach (Student s in students)
            {
                // foreach scene...
                foreach (Scene n in db.scenes.ToList())
                {
                    if (s.assessments.Where(v => v.scene == n).Count() < 1)
                    {
                        continue;
                    }
                    studentVM vm = new studentVM();
                    vm.student = s;
                    //vm.firstScore = s.assessments.Where (v => v.scene == n).OrderBy (v => v.date).First ().score;

                    int totalScore = 0;
                    int count      = 0;
                    foreach (Assessment f in s.assessments.Where(v => v.scene == n))
                    {
                        count++;
                        totalScore += f.score;
                    }

                    vm.averageScore = totalScore / count;

                    studentVMs.Add(vm);
                }
            }

            return(View(studentVMs));
        }
Example #2
0
        public ActionResult StudentList(int classRoomId, string gradeName)
        {
            ViewBag.gradeName   = gradeName;
            ViewBag.classRoomId = classRoomId;
            var students    = db.StudentClassRooms.Where(c => c.ClassRoomID == classRoomId).ToList();
            var studentList = new List <studentVM>();
            var termList    = db.Terms.ToList();

            foreach (var student in students)
            {
                var studentProfile = db.students.Where(h => h.StID == student.StID).FirstOrDefault();
                var student1       = new studentVM();
                student1.StID           = student.StID;
                student1.StudentName    = studentProfile.StudentName;
                student1.StudentSurname = studentProfile.StudentSurname;
                student1.termLists      = termList;
                studentList.Add(student1);
            }
            return(View(studentList));
        }