Example #1
0
        /// <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));
        }
Example #2
0
        /// <summary>
        /// The get scores method returns a list of select list items of Placement Scores for the given test type.
        /// </summary>
        /// <param name="placementTest">
        /// The placement Test.
        /// </param>
        /// <returns>
        /// Placement Score drop down items.
        /// </returns>
        private List <SelectListItem> GetScores(PlacementTests placementTest)
        {
            Dictionary <string, string> dict = this.GetScoreData(placementTest);

            return(dict.Select(item => new SelectListItem {
                Value = item.Key, Text = item.Value
            }).ToList());
        }
Example #3
0
        /// <summary>
        /// The get score dictionary creates a dictionary used into create the score drop down list.
        /// </summary>
        /// <param name="placementTest">
        /// The placement test.
        /// </param>
        /// <returns>
        /// A dictionary of placement scores and placement levels.
        /// </returns>
        private Dictionary <string, string> GetScoreData(PlacementTests placementTest)
        {
            switch (placementTest)
            {
            case PlacementTests.AccuplacerNextGen:
            {
                return(this.majorChange.Placements.Where(p => p.Accuplacer != null)
                       .OrderBy(p => p.PlacementLevel).ToDictionary(
                           p => p.PlacementLevel.ToString(),
                           p => p.Accuplacer));
            }

            case PlacementTests.ACT:
            {
                return(this.majorChange.Placements.Where(p => p.Act != null).OrderBy(p => p.PlacementLevel)
                       .ToDictionary(p => p.PlacementLevel.ToString(), p => p.Act));
            }

            case PlacementTests.Aleks:
            {
                return(this.majorChange.Placements.Where(p => p.Aleks != null).OrderBy(p => p.PlacementLevel)
                       .ToDictionary(p => p.PlacementLevel.ToString(), p => p.Aleks));
            }

            case PlacementTests.SAT:
            {
                return(this.majorChange.Placements.Where(p => p.Sat != null).OrderBy(p => p.PlacementLevel)
                       .ToDictionary(p => p.PlacementLevel.ToString(), p => p.Sat));
            }

            default:
            {
                return(new Dictionary <string, string>());
            }
            }
        }