public ActionResult viewSubmission(HomeworkViewModel HVM, int HWV_id) { HVM.groupSelectList = (IEnumerable <SelectListItem>)Session["groupSelectList"]; HVM.typeSelectList = (IEnumerable <SelectListItem>)Session["typeSelectList"]; HVM.groupFilList = (IEnumerable <SelectListItem>)Session["groupFilList"]; HVM.typeFilList = (IEnumerable <SelectListItem>)Session["typeFilList"]; HVM.termFilList = (IEnumerable <SelectListItem>)Session["termFilList"]; HVM.submission_list = new List <Submission_view>(); HomeworkView view = HVM.viewList.Where(v => v.ID == HWV_id).First(); List <HOMEWORK_SUBMISSION_LIST> submissions = HWV_id > 0? DBS.findRecordsBySingleParm <HOMEWORK_SUBMISSION_LIST>("HOMEWORK", HWV_id): new List <HOMEWORK_SUBMISSION_LIST>(); List <STUDENT> students = StudentService.getStudentByGroup(view.group_id); if (students != null && students.Any()) { for (int s = 0; s < students.Count; s++) { Submission_view SV = new Submission_view(); SV.homework_id = (int)HWV_id; SV.student_id = students[s].ID; SV.group_id = view.group_id; SV.work_name = view.name; SV.group_name = view.group_name; SV.student_name = students[s].STUDENT_NAME; if (submissions != null && submissions.Exists(sub => sub.STUDENT == SV.student_id)) { HOMEWORK_SUBMISSION_LIST HSL = submissions.Where(sub => sub.STUDENT == SV.student_id).FirstOrDefault(); SV.QE_class = HSL.QE_CLASS; SV.QE_class_name = HSL.QE_CLASS_NAME; SV.class_num = HSL.CLASS_NUM; SV.mark = HSL.MARK; SV.remark = HSL.REMARK; SV.submit_date = HSL.ADD_DATE; SV.submission_id = HSL.ID; SV.contain = true; } else { ClassStudentMap map = ClassService.getClassStudentMapByStudent(students[s].ID); SV.QE_class = map.ID; SV.QE_class_name = map.FORM.ToString() + map.NAME; SV.class_num = map.CLASS_NUM; SV.contain = false; } HVM.submission_list.Add(SV); } } ModelState.Clear(); TempData["showForm2"] = true; TempData["showForm"] = false; return(View("Homework", HVM)); }
public ActionResult Homework(int SelectedTerm, int SelectedGroup, int SelectedType, HomeworkViewModel HVM) { checkLogin(); HVM.groupSelectList = SelectedTerm == CP.currentTerm.ID ? (IEnumerable <SelectListItem>)Session["groupSelectList"] : StudentGroupService.getGroupSelectList(HVM.SelectedTerm); Session["groupSelectList"] = HVM.groupSelectList; HVM.typeSelectList = (IEnumerable <SelectListItem>)Session["typeSelectList"]; HVM.SelectedTerm = SelectedTerm; HVM.SelectedGroup = SelectedGroup; HVM.SelectedType = SelectedType; HVM.termFilList = genSelectList(CP.termSelectList, HVM.SelectedTerm); HVM.groupFilList = genSelectList(HVM.groupSelectList, HVM.SelectedGroup); HVM.typeFilList = genSelectList(HVM.typeSelectList, HVM.SelectedType); Session["termFilList"] = HVM.termFilList; Session["groupFilList"] = HVM.groupFilList; Session["typeFilList"] = HVM.typeFilList; List <HOMEWORK> works = HomeworkService.GetFilteredWorks(HVM.SelectedTerm, HVM.SelectedGroup, HVM.SelectedType); //homeworks List <HomeworkView> viewList = new List <HomeworkView>(); //homework in display format if (works != null && works.Any()) { for (int h = 0; h < works.Count; h++) //put homeworks into display format { HomeworkView view = new HomeworkView(); view.ID = works[h].ID; view.name = works[h].NAME; view.date_assign = works[h].ADD_DATE; view.date_due = works[h].DUE_DATE; view.full_mark = works[h].FULL_MARK; view.group_id = works[h].STUDENT_GROUP; view.type_id = works[h].HOMEWORK_TYPE; view.submission_ratio = works[h].SUBMISSION_RATIO; view.late_ratio = works[h].LATE_RATIO; view.group_name = view.group_id > 0 ? DBS.findRecordByID <STUDENT_GROUP>(works[h].STUDENT_GROUP).NAME : string.Empty; view.type_name = view.type_id > 0 ? DBS.findRecordByID <HOMEWORK_TYPE>(works[h].HOMEWORK_TYPE).NAME : string.Empty; viewList.Add(view); } } HVM.viewList = viewList; ModelState.Clear(); TempData["showForm2"] = false; TempData["showForm"] = false; return(View("Homework", HVM)); }