示例#1
0
        public ActionResult SummaryReportById(int teacherId, bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(viewMeetExceedSummary);
                ViewBag.SummaryLink   = "SummaryReportById";
                ViewBag.TeacherFilter = teacherId;
                bool           unAuthorizedRequest = false;
                SiteUser       su              = ((SiteUser)Session["SiteUser"]);
                ModelServices  modelServices   = new ModelServices();
                StudentService studentService  = new StudentService(su, entities);
                int            defaultDistrict = su.Districts[0].Id;
                int            schoolYearId    = modelServices.SchoolYearId();
                int[]          userSchools     = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();

                var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict);
                unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == teacherId).Count() == 0 ? true : false;

                if (unAuthorizedRequest)
                {
                    return(RedirectToAction("AccessDenied", "Error"));
                }

                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear    = modelServices.SchoolYearDescription();
                data.DropDown      = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear       = schoolYearId;
                data.DropDown.District                = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.Teacher                 = new TeacherDropDown(dropdownTeachers);
                data.DropDown.Teacher.SelectedTeacher = teacherId;
                data.DropDown.Race        = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Gender      = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { teacherId }));

                var filterParameter = new FilterParameter
                {
                    ClassId    = classDefaultValue,
                    Teacher    = teacherId,
                    School     = userSchools.First(),
                    Year       = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList     = modelServices.GetSummaryReport(filterParameter);
                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return(View("SummaryReport", data));
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
        }
示例#2
0
        public ActionResult SummaryReport(bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                ViewBag.SummaryLink = "SummaryReport";

                SetViewBag(viewMeetExceedSummary);
                SiteUser       su             = ((SiteUser)Session["SiteUser"]);
                ModelServices  modelServices  = new ModelServices();
                StudentService studentService = new StudentService(su, entities);

                int   defaultDistrict = su.Districts[0].Id;
                int   schoolYearId    = modelServices.SchoolYearId();
                int[] userSchools     = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();



                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear    = modelServices.SchoolYearDescription();
                data.DropDown      = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = schoolYearId;
                data.DropDown.District          = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));

                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Race.SelectedRace     = -1;
                data.DropDown.Gender                = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.Gender.SelectedGender = -1;

                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                if (su.isTeacher)
                {
                    data.DropDown.Teacher = new TeacherDropDown(
                        new List <DropDownIdName>()
                    {
                        new DropDownIdName()
                        {
                            Id = su.EdsUserId, Name = su.UserFullName
                        }
                    });
                    data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { su.EdsUserId }));
                }
                else // data administrator and eds administrator
                {
                    int[] schoolsTeacher = modelServices.getTeachersBySchoolsId(userSchools).ToArray();
                    data.DropDown.Teacher     = new TeacherDropDown(modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict));
                    data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, schoolsTeacher));
                }

                var filterParameter = new FilterParameter
                {
                    ClassId    = classDefaultValue,
                    Teacher    = su.EdsUserId,
                    School     = userSchools.First(),
                    Year       = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return(View(data));
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
        }
        private void InitializeReportMetadata(HeirarchicalTIRDetailModel model, TIRDetailReportParameter detailReportParameter)
        {
            base.SetNavigationLinksUrl();

            int decimalPlace = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SiteDecimalPlace"].ToString());

            SiteUser      su      = ((SiteUser)Session["SiteUser"]);
            ModelServices service = new ModelServices();

            model.SchoolYear = service.SchoolYearDescriptionByYearId(detailReportParameter.Year);

            SetDetailReportUrlData(detailReportParameter);
            UpdateReportTemplateConfigurations(service, detailReportParameter.ReportTemplateId);
            ViewBag.SchoolTermList = service.GetSchoolTerms(detailReportParameter);

            var details = service.GetHeirarchicalDetailReport(su.Districts.First().Id, detailReportParameter);

            model.details          = details;
            model.Subject          = service.GetSubjectDescriptionById(detailReportParameter.Subject);
            model.SubjectId        = detailReportParameter.Subject;
            model.SchoolYearId     = detailReportParameter.Year;
            model.AssessmentTypeId = detailReportParameter.AssessmentTypeId;
            model.CameFromTitle    = detailReportParameter.CameFromTitle;
            if (details.Count > 0)
            {
                model.AssessmentList = new List <AssessmentMEPerc>();
                var firstTirDetail = details[0];
                var schoolTermId   = firstTirDetail.SchoolTermId;
                detailReportParameter.InputTermId = schoolTermId;
                foreach (var score in firstTirDetail.ScoreDataCollection)
                {
                    AssignMePercentForAssessment(score, service, su, detailReportParameter, ref model.AssessmentList);
                }

                service.IsChildAssessmentsExists(model.AssessmentList);

                List <int>     studentCounts       = studentCounts = new List <int>();
                List <decimal> impactSums          = new List <decimal>();
                List <decimal> avgImpacts          = new List <decimal>();
                List <int>     countOfMeetOrExceed = new List <int>();

                for (int i = 0; i < model.details[0].ScoreDataCollection.Count; i++)
                {
                    studentCounts.Add(model.details.Count(d => d.ScoreDataCollection[i].Impact != null));
                    impactSums.Add(model.details.Sum(d => d.ScoreDataCollection[i].Impact.GetValueOrDefault()));
                    countOfMeetOrExceed.Add(model.details.Where(d => d.ScoreDataCollection[i].Impact >= -2).Count());
                    if (studentCounts[i] > 0)
                    {
                        avgImpacts.Add(Math.Round(impactSums[i] / studentCounts[i], decimalPlace));
                    }
                    else
                    {
                        avgImpacts.Add(0);
                    }
                }
                ViewBag.avgImpacts = avgImpacts;
            }
            var filterParameter = new FilterParameter
            {
                ClassId      = detailReportParameter.ClassId,
                Teacher      = detailReportParameter.Teacher,
                Year         = detailReportParameter.Year,
                Race         = detailReportParameter.Race,
                Gender       = detailReportParameter.Gender,
                FrlIndicator = detailReportParameter.FrlIndicator,
                IEPIndicator = detailReportParameter.IEPIndicator,
                LEPIndicator = detailReportParameter.LEPIndicator,
                Hispanic     = detailReportParameter.Hispanic,
                SchoolYear   = model.SchoolYear
            };

            var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, service, su);

            ViewBag.ReportFilters = reportFilterViewModel;
        }
示例#4
0
        public ActionResult UpdateGrid(FilterParameter filterParameter)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(filterParameter.ViewMeetExceedSummary);
                ViewBag.SummaryLink = "UpdateGrid";
                bool            unAuthorizedRequest = false;
                SiteUser        su            = ((SiteUser)Session["SiteUser"]);
                ModelServices   modelServices = new ModelServices();
                TIRSummaryModel data          = new TIRSummaryModel();

                int defaultDistrict = su.Districts[0].Id;
                data.DropDown           = new DropDownData();
                ViewBag.FilterParameter = filterParameter;

                #region Initializations
                var dropdownSchools = modelServices.GetSchoolDropDownData(su.EdsUserId, filterParameter.Year);
                var schoolCount     = dropdownSchools.Where(x => x.Id == filterParameter.School).Count();
                unAuthorizedRequest = schoolCount == 0 ? true : false;
                if (unAuthorizedRequest)
                {
                    return(RedirectToAction("AccessDenied", "Error"));
                }

                if (!unAuthorizedRequest)
                {
                    if (su.isTeacher)
                    {
                        unAuthorizedRequest = (su.EdsUserId != filterParameter.Teacher) ? true : false;
                        if (!unAuthorizedRequest)
                        {
                            data.DropDown.Teacher = new TeacherDropDown(new List <DropDownIdName>()
                            {
                                new DropDownIdName()
                                {
                                    Id = su.EdsUserId, Name = su.UserFullName
                                }
                            });
                        }
                    }
                    else
                    {
                        var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(new int[] { filterParameter.School }, filterParameter.Year, defaultDistrict);
                        unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == filterParameter.Teacher).Count() == 0 ? true : false;

                        if (!unAuthorizedRequest)
                        {
                            data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers);
                            data.DropDown.Teacher.SelectedTeacher = filterParameter.Teacher;
                        }
                    }
                }
                #endregion

                //TODO: need to refactor below code if possible.
                ViewBag.TeacherFilter = filterParameter.Teacher;
                ViewBag.SchoolFilter  = filterParameter.School;
                ViewBag.YearFilter    = filterParameter.Year;
                ViewBag.ClassFilter   = filterParameter.ClassId;
                ViewBag.Race          = filterParameter.Race;
                ViewBag.Gender        = filterParameter.Gender;
                ViewBag.FrlIndicator  = filterParameter.FrlIndicator;
                ViewBag.IEPIndicator  = filterParameter.IEPIndicator;
                ViewBag.LEPIndicator  = filterParameter.LEPIndicator;
                ViewBag.Hispanic      = filterParameter.Hispanic;


                #region Init Filter Parameters
                data.SchoolYear    = modelServices.SchoolYearDescriptionByYearId(filterParameter.Year);
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear     = filterParameter.Year;
                data.DropDown.District              = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.School                = new SchoolDropDown(dropdownSchools);
                data.DropDown.School.SelectedSchool = filterParameter.School;
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);

                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(filterParameter.Year, new[] { filterParameter.Teacher }));

                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Race.SelectedRace     = filterParameter.Race;
                data.DropDown.Gender                = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.Gender.SelectedGender = filterParameter.Gender;
                data.Hispanic     = filterParameter.Hispanic;
                data.IepIndicator = filterParameter.IEPIndicator;
                data.LepIndicator = filterParameter.LEPIndicator;
                data.FrlIndicator = filterParameter.FrlIndicator;

                data.DropDown.SchoolClass.SelectedClass = filterParameter.ClassId;
                #endregion

                filterParameter.SchoolYear = data.SchoolYear;
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return(View("SummaryReport", data));
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
        }
        private void InitializeReportMetadata(TIRDetailModel model, TIRDetailReportParameter detailReportParameter)
        {
            base.SetNavigationLinksUrl();
            int decimalPlace = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SiteDecimalPlace"].ToString());

            SiteUser      su      = ((SiteUser)Session["SiteUser"]);
            ModelServices service = new ModelServices();

            model.SchoolYear = service.SchoolYearDescriptionByYearId(detailReportParameter.Year);

            SetDetailReportUrlData(detailReportParameter);
            UpdateReportTemplateConfigurations(service, detailReportParameter.ReportTemplateId);

            model.AssessmentList = service.GetDetailReportAssessmentList(su.Districts.First().Id, detailReportParameter);
            var list = (model.AssessmentList).Select(x => x.AssessmentDesc).ToList();

            var details = service.GetDetailReport(list, su.Districts.First().Id, detailReportParameter);

            model.details = details;
            model.Subject = service.GetSubjectDescriptionById(detailReportParameter.Subject);

            int[]     studentCounts       = new int[5];
            decimal[] impactSums          = new decimal[5];
            decimal[] avgImpacts          = new decimal[5];
            int[]     countOfMeetOrExceed = new int[5];
            decimal[] percOfMeetOrExceed  = new decimal[5];

            //TODO: Need to handle null check here if no data found in model.details list it will give object refrence not found error.
            studentCounts[0] = model.details.Count(d => d.ScoreData1.Impact != null);
            studentCounts[1] = model.details.Count(d => d.ScoreData2.Impact != null);
            studentCounts[2] = model.details.Count(d => d.ScoreData3.Impact != null);
            studentCounts[3] = model.details.Count(d => d.ScoreData4.Impact != null);
            studentCounts[4] = model.details.Count(d => d.ScoreData5.Impact != null);

            impactSums[0] = model.details.Sum(d => d.ScoreData1.Impact.GetValueOrDefault());
            impactSums[1] = model.details.Sum(d => d.ScoreData2.Impact.GetValueOrDefault());
            impactSums[2] = model.details.Sum(d => d.ScoreData3.Impact.GetValueOrDefault());
            impactSums[3] = model.details.Sum(d => d.ScoreData4.Impact.GetValueOrDefault());
            impactSums[4] = model.details.Sum(d => d.ScoreData5.Impact.GetValueOrDefault());

            for (int i = 0; i < studentCounts.Length; i++)
            {
                if (studentCounts[i] > 0)
                {
                    avgImpacts[i] = Math.Round(impactSums[i] / studentCounts[i], decimalPlace);
                }
            }
            countOfMeetOrExceed[0] = model.details.Where(tirDetail => tirDetail.ScoreData1.Impact >= -2).Count();
            countOfMeetOrExceed[1] = model.details.Where(tirDetail => tirDetail.ScoreData2.Impact >= -2).Count();
            countOfMeetOrExceed[2] = model.details.Where(tirDetail => tirDetail.ScoreData3.Impact >= -2).Count();
            countOfMeetOrExceed[3] = model.details.Where(tirDetail => tirDetail.ScoreData4.Impact >= -2).Count();
            countOfMeetOrExceed[4] = model.details.Where(tirDetail => tirDetail.ScoreData5.Impact >= -2).Count();

            service.IsChildAssessmentsExists(model.AssessmentList);

            for (int i = 0; i < model.AssessmentList.Count; i++)
            {
                if (studentCounts[i] > 0)
                {
                    percOfMeetOrExceed[i] = GetPerOfMeetValue(countOfMeetOrExceed[i], studentCounts[i], true);
                }
            }
            ViewBag.percOfMeetOrExceed = percOfMeetOrExceed;
            ViewBag.studentCounts      = studentCounts;
            ViewBag.impactSums         = impactSums;
            ViewBag.avgImpacts         = avgImpacts;


            var filterParameter = new FilterParameter
            {
                ClassId      = detailReportParameter.ClassId,
                Teacher      = detailReportParameter.Teacher,
                Year         = detailReportParameter.Year,
                Race         = detailReportParameter.Race,
                Gender       = detailReportParameter.Gender,
                FrlIndicator = detailReportParameter.FrlIndicator,
                IEPIndicator = detailReportParameter.IEPIndicator,
                LEPIndicator = detailReportParameter.LEPIndicator,
                Hispanic     = detailReportParameter.Hispanic,
                SchoolYear   = model.SchoolYear
            };

            var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, service, su);

            ViewBag.ReportFilters = reportFilterViewModel;
        }