/// <summary> /// The Get Paths gets a list of potential paths for the given program, placement test and placement index. /// </summary> /// <param name="programPaths"> /// The program Paths. /// </param> /// <param name="placementScore"> /// The placement Score. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private List <PathModel> GetPaths(List <ProgramPath> programPaths, PlacementScores placementScore) { List <PathModel> list = new List <PathModel>(); programPaths = programPaths.OrderBy(pp => pp.Path.Code).ToList(); foreach (ProgramPath pp in programPaths) { Path path = pp.Path; List <Course> courses = this.GetCourseList(path.Courses); PathModel pathModel = new PathModel { ProgramPathName = pp.Name, PathName = path.Name, Code = path.Code, RequiredCourse = pp.RequiredCourse, CourseList = courses }; int placementCourseId = this.SetPlacementCourse(path, courses, placementScore); if (placementCourseId < 0) { continue; // skip this path } pathModel.PlacementCourseId = placementCourseId; pathModel.TestedOut = pathModel.PlacementCourseId == 0; list.Add(pathModel); } return(list); }
/// <summary> /// The index method restores session variables if they exist, gets data for the view model and returns the index view. /// </summary> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public ActionResult Index() { string major = this.HttpContext.Session["Major"] != null ? (string)this.HttpContext.Session["Major"] : string.Empty; PlacementTests placementTest = new PlacementTests(); PlacementScores placementScore = new PlacementScores(); if (this.HttpContext.Session["PlacementTest"] != null) { placementTest = (PlacementTests)this.HttpContext.Session["PlacementTest"]; } if (this.HttpContext.Session["PlacementScore"] != null) { placementScore = (PlacementScores)this.HttpContext.Session["PlacementScore"]; } List <SelectListItem> placementScoreList = placementTest != 0 ? this.GetScores(placementTest) : new List <SelectListItem>(); DataViewModel form = new DataViewModel { MajorList = this.GetMajors(), SelectedMajor = major, SelectedPlacementTest = placementTest.ToString(), PlacementScoreList = placementScoreList, SelectedPlacementScore = ((int)placementScore).ToString() }; return(this.View(form)); }
/// <summary> /// The set placement course method determines the course placement for a given path. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="courses"> /// The courses. /// </param> /// <param name="placementScore"> /// The placement score. /// </param> /// <returns> /// zero means fulfilled, less than zero means no placement, greater than zero is the course id to be placed in. /// </returns> private int SetPlacementCourse(Path path, List <Course> courses, PlacementScores placementScore) { string code = path.Code; bool allowTestOut = path.AllowTestOut; int selectedPlacementLevel = (int)placementScore; int lastCourseId = -1; foreach (var course in courses) { if (course.PlacementLevel == selectedPlacementLevel) { return(course.CourseId); } if (course.PlacementLevel > selectedPlacementLevel) { return(lastCourseId); } lastCourseId = course.CourseId; } return(allowTestOut ? 0 : lastCourseId); }