Пример #1
0
        public SchoolViewModel(EdubaseDataObject contextDataModel)
        {
            this.ContextData = contextDataModel;
            var underReviewSchools = ConfigurationManager.AppSettings["UnderReviewSchools"]?.Split(',').ToList() ?? new List <string>();

            this.IsUnderReview = underReviewSchools.Contains(this.Id.ToString());
        }
        public void BuildShouldApplyPercentageMarginForNumberOfPupils()
        {
            dynamic model = new EdubaseDataObject();

            model.NumberOfPupils = 100;

            var financeObj = new SchoolTrustFinancialDataObject();

            financeObj.NoPupils             = 100;
            financeObj.OverallPhase         = "Secondary";
            financeObj.UrbanRural           = "Urban and city";
            financeObj.PercentageFSM        = 100;
            financeObj.PercentagePupilsWSEN = 100;
            financeObj.PercentagePupilsWEAL = 100;
            financeObj.LA = 831;

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalFinancialDataModels = new List <FinancialDataModel>();
            benchmarkSchool.HistoricalFinancialDataModels.Add(new FinancialDataModel("123", "2014-2015", financeObj, EstablishmentType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalFinancialDataModels.Last(), true, true, true, true, 5);

            Assert.AreEqual((financeObj.NoPupils - CriteriaSearchConfig.QC_DEFAULT_CONSTANT_PUPIL_COUNT_TOPUP) * 0.85m, criteria.MinNoPupil);
            Assert.AreEqual((financeObj.NoPupils + CriteriaSearchConfig.QC_DEFAULT_CONSTANT_PUPIL_COUNT_TOPUP) * 1.15m, criteria.MaxNoPupil);
        }
        public void BuildShouldApplyUrbanRuralToCriteria()
        {
            dynamic model = new EdubaseDataObject();

            model.NumberOfPupils = 100;

            var financeObj = new SchoolTrustFinancialDataObject();

            financeObj.NoPupils             = 100;
            financeObj.OverallPhase         = "Secondary";
            financeObj.UrbanRural           = "Urban and city";
            financeObj.PercentageFSM        = 100;
            financeObj.PercentagePupilsWSEN = 100;
            financeObj.PercentagePupilsWEAL = 100;
            financeObj.LA = 831;

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalFinancialDataModels = new List <FinancialDataModel>();
            benchmarkSchool.HistoricalFinancialDataModels.Add(new FinancialDataModel("123", "2014-2015", financeObj, EstablishmentType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalFinancialDataModels.Last(), true, true, true, true, 0);

            Assert.AreEqual(financeObj.UrbanRural, criteria.UrbanRural[0]);
        }
        public void BuildShouldNotApplyOptionalCriteriaIfNotIncluded()
        {
            dynamic model = new EdubaseDataObject();

            model.NumberOfPupils = 100;

            var financeObj = new SchoolTrustFinancialDataObject();

            financeObj.NoPupils             = 100;
            financeObj.OverallPhase         = "Secondary";
            financeObj.UrbanRural           = "Urban and city";
            financeObj.PercentageFSM        = 2;
            financeObj.PercentagePupilsWSEN = 2;
            financeObj.PercentagePupilsWEAL = 2;
            financeObj.LA = 831;

            var benchmarkSchool = new SchoolViewModel(model);

            benchmarkSchool.HistoricalFinancialDataModels = new List <FinancialDataModel>();
            benchmarkSchool.HistoricalFinancialDataModels.Add(new FinancialDataModel("123", "2014-2015", financeObj, EstablishmentType.Maintained));

            var builder = new BenchmarkCriteriaBuilderService();

            var criteria = builder.BuildFromSimpleComparisonCriteria(benchmarkSchool.HistoricalFinancialDataModels.Last(), false, false, false, false, 10);

            Assert.AreEqual(null, criteria.MinPerFSM);
            Assert.AreEqual(null, criteria.MaxPerFSM);
            Assert.AreEqual(null, criteria.MinPerSEN);
            Assert.AreEqual(null, criteria.MaxPerSEN);
            Assert.AreEqual(null, criteria.MinPerEAL);
            Assert.AreEqual(null, criteria.MaxPerEAL);
            Assert.AreEqual(null, criteria.LocalAuthorityCode);
        }
        public async Task DetailShouldKeepUnitTypeBetweenExpenditureAndIncomeTabsAsync()
        {
            var fakeEdubaseObject = new EdubaseDataObject
            {
                URN         = 123,
                FinanceType = "Maintained"
            };

            var mockEdubaseDataService = new Mock <IContextDataService>();

            var GetSchoolDataObjectByUrnAsyncTask = Task.Run(() =>
            {
                return(fakeEdubaseObject);
            });

            mockEdubaseDataService.Setup(m => m.GetSchoolDataObjectByUrnAsync(123)).Returns((long urn) => GetSchoolDataObjectByUrnAsyncTask);

            var financialCalculationsService = new Mock <IFinancialCalculationsService>();

            var mockFinancialDataService = new Mock <IFinancialDataService>();

            var mockDownloadCsvBuilder = new Mock <IDownloadCSVBuilder>();

            var mockCookieManager = new Mock <ISchoolBenchmarkListService>();

            var mockLaSearchService = new Mock <ILocalAuthoritiesService>();

            var mockActiveUrnsService = new Mock <IActiveEstablishmentsService>();

            var mockCscpLookupService = new Mock <ICscpLookupService>();

            var mockGiasLookupService = new Mock <IGiasLookupService>();

            var mockSchoolVMBuilder = new Mock <ISchoolVMBuilder>();
            var fakeSVM             = new SchoolViewModel(fakeEdubaseObject);

            fakeSVM.HistoricalFinancialDataModels = new List <FinancialDataModel> {
                new FinancialDataModel()
            };
            fakeSVM.HistoricalCharts = new List <ChartViewModel> {
                new ChartViewModel()
            };
            mockSchoolVMBuilder.Setup(m => m.GetResult()).Returns(fakeSVM);

            var controller = new SchoolController(mockFinancialDataService.Object, financialCalculationsService.Object,
                                                  mockEdubaseDataService.Object, mockDownloadCsvBuilder.Object, mockCookieManager.Object, mockActiveUrnsService.Object,
                                                  mockSchoolVMBuilder.Object, mockGiasLookupService.Object, mockCscpLookupService.Object);

            controller.ControllerContext = new ControllerContext(_rc, controller);

            await controller.Detail(123, UnitType.PerPupil, CentralFinancingType.Exclude, TabType.Income);

            mockSchoolVMBuilder.Verify(f => f.AddHistoricalChartsAsync(
                                           It.IsAny <TabType>(),
                                           It.IsAny <ChartGroupType>(),
                                           It.IsAny <CentralFinancingType>(),
                                           UnitType.PerPupil));
        }
Пример #6
0
 public BenchmarkSchoolModel(EdubaseDataObject schoolContextData)
 {
     if (schoolContextData.IsFederation)
     {
         Name      = schoolContextData.FederationName;
         Type      = "Federation";
         EstabType = "Maintained";
         Urn       = schoolContextData.URN.ToString();
     }
     else
     {
         Name      = schoolContextData.EstablishmentName;
         Type      = schoolContextData.TypeOfEstablishment;
         EstabType = schoolContextData.FinanceType;
         Urn       = schoolContextData.URN.ToString();
     }
 }
Пример #7
0
 public SchoolViewModel(EdubaseDataObject schoolContextDataModel, SchoolComparisonListModel comparisonList, SchoolComparisonListModel manualComparisonList)
     : this(schoolContextDataModel, comparisonList)
 {
     this.ManualComparisonList = manualComparisonList;
 }
Пример #8
0
 public SchoolViewModel(EdubaseDataObject schoolContextDataModel, SchoolComparisonListModel comparisonList) : this(schoolContextDataModel)
 {
     base.ComparisonList = comparisonList;
 }
 public FederationViewModel(EdubaseDataObject contextDataModel)
 {
     this.ContextData = contextDataModel;
 }
Пример #10
0
        public async Task <ActionResult> Search(
            string nameId,
            string searchType,
            string suggestionUrn,
            string locationorpostcode,
            string locationCoordinates,
            string laCodeName,
            decimal?radius,
            bool openOnly   = false,
            string orderby  = "",
            int page        = 1,
            string tab      = "list",
            string referrer = "home/index")
        {
            ViewBag.OpenOnly     = openOnly;
            ViewBag.SearchMethod = "Manual";
            ViewBag.LaCodeName   = laCodeName;

            var comparisonList       = _schoolBenchmarkListService.GetSchoolBenchmarkList();
            var manualComparisonList = _manualBenchmarkListService.GetManualBenchmarkList();

            EdubaseDataObject contextDataObject = null;

            if (!string.IsNullOrEmpty(comparisonList.HomeSchoolUrn))
            {
                await _contextDataService.GetSchoolDataObjectByUrnAsync(int.Parse(comparisonList.HomeSchoolUrn));
            }

            dynamic searchResp = null;
            string  errorMessage;

            switch (searchType)
            {
            case SearchTypes.SEARCH_BY_NAME_ID:
                if (string.IsNullOrEmpty(comparisonList.HomeSchoolUrn))
                {
                    var vm = new SchoolViewModelWithNoDefaultSchool(manualComparisonList);
                    return(View("AddSchoolsManually", vm));
                }
                else
                {
                    var vm = new SchoolViewModel(contextDataObject, comparisonList, manualComparisonList);
                    return(View("AddSchoolsManually", vm));
                }

            case SearchTypes.SEARCH_BY_LA_CODE_NAME:
                if (!IsNumeric(laCodeName))
                {
                    errorMessage = _valService.ValidateLaNameParameterForComparison(laCodeName);
                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        var exactMatch = _laSearchService.SearchExactMatch(laCodeName);
                        if (exactMatch != null)
                        {
                            laCodeName = exactMatch.Id;
                            return(await Search(nameId, searchType, suggestionUrn, locationorpostcode,
                                                locationCoordinates, laCodeName, radius, openOnly, orderby, page, tab));
                        }
                        var similarMatch = _laSearchService.SearchContains(laCodeName);
                        if (similarMatch.Count == 0)
                        {
                            var svm = new SearchViewModel(comparisonList, searchType)
                            {
                                SearchType   = searchType,
                                Authorities  = _laService.GetLocalAuthorities(),
                                ErrorMessage = SearchErrorMessages.NO_LA_RESULTS
                            };
                            return(View("Index", svm));
                        }
                        TempData["SearchMethod"] = "Manual";
                        return(RedirectToAction("Search", "La", new { name = laCodeName, openOnly = openOnly }));
                    }
                    else
                    {
                        var svm = new SearchViewModel(comparisonList, searchType)
                        {
                            SearchType   = searchType,
                            Authorities  = _laService.GetLocalAuthorities(),
                            ErrorMessage = errorMessage
                        };
                        return(View("Index", svm));
                    }
                }
                else
                {
                    errorMessage = _valService.ValidateLaCodeParameterForComparison(laCodeName);
                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        searchResp = await GetSearchResultsAsync(nameId, searchType, locationorpostcode, locationCoordinates, laCodeName, radius, openOnly, orderby, page);

                        int resultCount = searchResp.NumberOfResults;
                        if (resultCount == 0)
                        {
                            var svm = new SearchViewModel(comparisonList, searchType)
                            {
                                SearchType   = searchType,
                                Authorities  = _laService.GetLocalAuthorities(),
                                ErrorMessage = SearchErrorMessages.NO_LA_RESULTS
                            };
                            return(View("Index", svm));
                        }
                        else
                        {
                            ViewBag.manualCount = manualComparisonList?.BenchmarkSchools?.Count();
                            return(View("ManualSearchResults", GetSearchedSchoolViewModelList(searchResp, manualComparisonList, orderby, page, searchType, nameId, locationorpostcode, _laService.GetLaName(laCodeName))));
                        }
                    }
                    else
                    {
                        var svm = new SearchViewModel(comparisonList, searchType)
                        {
                            SearchType   = searchType,
                            Authorities  = _laService.GetLocalAuthorities(),
                            ErrorMessage = errorMessage
                        };
                        return(View("Index", svm));
                    }
                }

            case SearchTypes.SEARCH_BY_LOCATION:
            default:
                errorMessage = _valService.ValidateLocationParameterForComparison(locationorpostcode);
                if (string.IsNullOrEmpty(errorMessage))
                {
                    if (string.IsNullOrEmpty(locationCoordinates))
                    {
                        var result = _locationSearchService.SuggestLocationName(locationorpostcode);
                        switch (result.Matches.Count)
                        {
                        case 0:
                            var svm = new SearchViewModel(comparisonList, searchType)
                            {
                                SearchType   = searchType,
                                Authorities  = _laService.GetLocalAuthorities(),
                                ErrorMessage = SearchErrorMessages.NO_LOCATION_RESULTS
                            };
                            return(View("Index", svm));

                        default:
                            TempData["LocationResults"] = result;
                            TempData["SearchMethod"]    = "Manual";
                            return(RedirectToAction("Suggest", "Location", new { locationOrPostcode = locationorpostcode, openOnly = openOnly }));
                        }
                    }
                    else
                    {
                        searchResp = await GetSearchResultsAsync(nameId, searchType, locationorpostcode, locationCoordinates, laCodeName, radius, openOnly, orderby, page);

                        if (searchResp.NumberOfResults == 0)
                        {
                            var svm = new SearchViewModel(comparisonList, searchType)
                            {
                                SearchType   = searchType,
                                Authorities  = _laService.GetLocalAuthorities(),
                                ErrorMessage = SearchErrorMessages.NO_LOCATION_RESULTS
                            };
                            return(View("Index", svm));
                        }
                        ViewBag.manualCount = manualComparisonList?.BenchmarkSchools?.Count();
                        return(View("ManualSearchResults", GetSearchedSchoolViewModelList(searchResp, manualComparisonList, orderby, page, searchType, nameId, locationorpostcode, _laService.GetLaName(laCodeName))));
                    }
                }
                else
                {
                    var svm = new SearchViewModel(comparisonList, searchType)
                    {
                        SearchType   = searchType,
                        Authorities  = _laService.GetLocalAuthorities(),
                        ErrorMessage = errorMessage
                    };
                    return(View("Index", svm));
                }
            }
        }
        private async Task <SelfAssesmentModel> BuildSelfAssesmentModel(long id, string name, EstablishmentType financeType, EdubaseDataObject schoolContextData, SchoolTrustFinancialDataObject schoolFinancialData)
        {
            string termYears = await GetLatestTermYears(financeType);

            SelfAssesmentModel model;

            if (schoolFinancialData is not null)
            {
                model = new SelfAssesmentModel(
                    id,
                    name,
                    schoolFinancialData.OverallPhase,
                    financeType.ToString(),
                    schoolFinancialData.LondonWeight,
                    schoolFinancialData.NoPupils.GetValueOrDefault(),
                    schoolFinancialData.PercentageFSM.GetValueOrDefault(),
                    schoolContextData.OfstedRating,
                    FormatOfstedDate(schoolContextData.OfstedLastInsp),
                    schoolFinancialData.Progress8Measure,
                    schoolFinancialData.Ks2Progress,
                    GetProgressScoreType(schoolFinancialData),
                    schoolFinancialData.Progress8Banding.GetValueOrDefault(),
                    bool.Parse(schoolFinancialData.Has6Form),
                    schoolFinancialData.TotalExpenditure.GetValueOrDefault(),
                    schoolFinancialData.TotalIncome.GetValueOrDefault(),
                    termYears,
                    schoolFinancialData.TeachersTotal.GetValueOrDefault(),
                    schoolFinancialData.TeachersLeader.GetValueOrDefault(),
                    schoolFinancialData.WorkforceTotal.GetValueOrDefault(),
                    schoolFinancialData.PeriodCoveredByReturn >= 12,
                    true
                    );

                model.SadSizeLookup = await _selfAssesmentDashboardDataService.GetSADSizeLookupDataObject(schoolFinancialData.OverallPhase, bool.Parse(schoolFinancialData.Has6Form), schoolFinancialData.NoPupils.GetValueOrDefault(), termYears);

                model.SadFSMLookup = await _selfAssesmentDashboardDataService.GetSADFSMLookupDataObject(schoolFinancialData.OverallPhase, bool.Parse(schoolFinancialData.Has6Form), schoolFinancialData.PercentageFSM.GetValueOrDefault(), termYears);

                model.AvailableScenarioTerms = await GetAllAvailableTermYears();
            }
            else
            {
                model = new SelfAssesmentModel(id, name, schoolContextData.OverallPhase, financeType.ToString(), schoolContextData.OfstedRating,
                                               FormatOfstedDate(schoolContextData.OfstedLastInsp),
                                               schoolContextData.GovernmentOfficeRegion,
                                               schoolContextData.OfficialSixthForm);

                model.AvailableScenarioTerms = await GetAllAvailableTermYears();
            }

            await AddAssessmentAreasToModel(termYears, schoolFinancialData, schoolContextData, model);

            return(model);
        }
        private async Task AddAssessmentAreasToModel(string termYears, SchoolTrustFinancialDataObject schoolFinancialData, EdubaseDataObject schoolContextData, SelfAssesmentModel model)
        {
            model.SadAssesmentAreas = new(); //C#9

            await AddAssessmentArea("Spending", "Teaching staff", schoolFinancialData?.TeachingStaff.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Supply staff", schoolFinancialData?.SupplyStaff.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Education support staff", schoolFinancialData?.EducationSupportStaff.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Administrative and clerical staff", schoolFinancialData?.AdministrativeClericalStaff.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Other staff costs", schoolFinancialData?.OtherStaffCosts.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Premises costs", schoolFinancialData?.Premises.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Educational supplies", schoolFinancialData?.EducationalSupplies.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Spending", "Energy", schoolFinancialData?.Energy.GetValueOrDefault(), schoolFinancialData?.TotalExpenditure.GetValueOrDefault(), schoolFinancialData, model, termYears);

            await AddAssessmentArea("Reserve and balance", "In-year balance", schoolFinancialData?.InYearBalance.GetValueOrDefault(), schoolFinancialData?.TotalIncome.GetValueOrDefault(), schoolFinancialData, model, termYears);
            await AddAssessmentArea("Reserve and balance", "Revenue reserve", schoolFinancialData?.RevenueReserve.GetValueOrDefault(), schoolFinancialData?.TotalIncome.GetValueOrDefault(), schoolFinancialData, model, termYears);

            await AddAssessmentArea("School characteristics", "Average teacher cost", null, null, schoolFinancialData, model, termYears);
            await AddAssessmentArea("School characteristics", "Senior leaders as a percentage of workforce", null, null, schoolFinancialData, model, termYears);;;
            await AddAssessmentArea("School characteristics", "Pupil to teacher ratio", null, null, schoolFinancialData, model, termYears);
            await AddAssessmentArea("School characteristics", "Pupil to adult ratio", null, null, schoolFinancialData, model, termYears);

            if (!_exclusionPhaseList.Contains(schoolFinancialData?.OverallPhase ?? schoolContextData.OverallPhase))
            {
                await AddAssessmentArea("School characteristics", "Teacher contact ratio (less than 1)", null, null, schoolFinancialData, model, termYears);
            }

            await AddAssessmentArea("School characteristics", "Predicted percentage pupil number change in 3-5 years", null, null, schoolFinancialData, model, termYears);

            if (!_exclusionPhaseList.Contains(schoolFinancialData?.OverallPhase ?? schoolContextData.OverallPhase))
            {
                await AddAssessmentArea("School characteristics", "Average Class size", null, null, schoolFinancialData, model, termYears);
            }
        }