Date: Thu, 28 Mar 2024 09:28:52 -0500 (CDT) Message-ID: <592514579.29998.1711636132316@PUBEDFIPRDWEB5.public.local> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_29997_53934081.1711636132311" ------=_Part_29997_53934081.1711636132311 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This section builds upon the Dashboard Architecture Pattern Ove= rview, providing implementation detail and other specifics useful to un= derstanding and working with the Ed-Fi Dashboards application.
The figure below shows an end-to-en= d slice for the School Category List, which is a page for the Local Educati= on Agency that shows all of its schools, grouped by category (e.g., element= ary, middle school, high school).
The figure above shows an end-to-en= d slice for the School Category List, which is a page for the Local Educati= on Agency that shows all of its schools, grouped by category (e.g., element= ary, middle school, high school). The following list describes the steps in= volved in receiving a request for the web page to the point of rendering a = web page.
The ASP.NET MVC model binder translates the route values (the Local = Education Agency Id in this case) into an instance of the Scho= olCategoryListRequest class which is the parameter needed to = invoke the Get action method on the SchoolCategoryListController. This request object is the same req= uest needed for the call to the service.
If no explicit controller implementation is provided, the E= dFiControllerFactory implementation will attempt to identify = the service for the requested resource by convention. If it finds a matchin= g service, it will use a generic passthrough controller to call the service= and initiate rendering of the view. If no special behavior needs to be add= ed in order to render the view for a particular resource, the controller im= plementation is optional.
To make the application data accessible to the C# Presentation Services = layer, the SubSonic data access framework was used (see http://sub= sonic.github.io). The framework provides code generation templates for = use with the T4 engine included with Visual Studio to create classes for ea= ch table as shown in the image below.
The application uses the Generic Repository pattern to provide access to= data. Rather than build custom repository methods for extracting data, the= Generic Repository provides the application developer with access to table= s via an IRepository<T> generic interface.= The repository object is instantiated for a specific entity (i.e., databas= e table), and then LINQ-based queries are formed using the IQu= eryable<T> returned by the GetAll= method. The SubSonic SimpleRepository clas= s translates the LINQ query expressions into SQL for execution.
Sometimes the results of the queries performed in Step 6 (above) ca= n be transformed directly into view model classes that are ready for use in= rendering web pages. The following method shows the simple construction of= a view model object directly from a LINQ query for the categorized school = list for a local education agency:
public IL= ist<SchoolCategoryModel> Get(SchoolCategoryListRequest listRequest) { var listContext =3D uniqueListIdProvider.GetUniqueId(); var results =3D (from data in repository.GetAll() where data.LocalEducationAgencyId =3D=3D listRequest.LocalEducation= AgencyId && schoolGradePopulationRepository.GetAll() .Select(o =3D> o.SchoolId).Contains(data.SchoolId) select data).ToList(); var schoolCategories =3D results.GroupBy(x =3D> x.SchoolCategory= ).OrderBy(y =3D> y.Key,=20 new SchoolCategoryComparer(schoolCategoryProvider)); return (from schoolCategory in schoolCategories select new SchoolCategoryModel { Category =3D schoolCategory.Key =3D=3D ungraded ? other : s= choolCategory.Key, Schools =3D (from c1 in schoolCategory orderby c1.Name select new SchoolCategoryModel.School { SchoolId =3D c1.SchoolId, Name =3D c1.Name, Url =3D schoolLinks.Default(c1.SchoolId, c1= .Name).AppendParameters("listContext=3D" + listContext), Links =3D new List<Link> {=20 new Link {=20 Rel =3D students,=20 Href =3D schoolLinks.StudentsByGrad= e(c1.SchoolId, c1.Name) .AppendParameters("listContext= =3D" + listContext).Resolve() }, new Link {=20 Rel =3D teachers,=20 Href =3D schoolLinks.Teachers(c1.Sc= hoolId, c1.Name) .AppendParameters("listContext=3D" = + listContext).Resolve() } } } ) } ) =20 } ).ToList(); }
However, for other view models such as the one used for rendering the me= tric views, more preparation is needed. The MetricInstanceTree= Factory class combines the metric metadata and metric values = into a hierarchical metric instance view model for use in rendering the use= r interface (discussed in detail below).
This section provides detail about the view models used in rendering pag= es.
The metrics are organized into a logical hierarchy and are generally man= aged by the development team using a separate application. The figure below shows a partial screen shot of this management applica= tion, how the high school metrics are organized, and the web page rendered = using this metadata. As you can see, the metadata hierarchy is used to driv= e both the navigation menus and the metric content on the page. The data fo= r a particular student is combined with the hierarchal metadata into view m= odel classes used to render the page with ASP.NET MVC.
The metric content of the pages is rendered using individual ASP.NET MVC= Razor templates (see listings below) by a custom rendering engine that pro= cesses the Metric View Model hierarchy. Each metric model class in the hier= archy is matched with an appropriate template based on a number of factors = including (but not limited to) the overall rendering context of the page (i= .e., =E2=80=9COverview=E2=80=9D or =E2=80=9CMetric=E2=80=9D), the type of t= he metric (i.e., container, aggregate, or granular), and the depth of the m= etric in the hierarchy. For example, the overview page shown above renders = in a context such that rendering stops once the =E2=80=9Caggregate=E2=80=9D= metrics are rendered.
Contrast that with the figure below where the rendering process starts w= ith the College and Career Readiness =E2=80=9Ccontainer=E2=80=9D metric and= continues all the way down to the =E2=80=9Cgranular=E2=80=9D metric values= .
The following listing shows the contents of the ContainerMetri=
c.Level0.cshtml template.
@model C= ontainerMetric =20 <tr> <td style=3D"height: 23px;" colspan=3D"9"> <table style=3D"width: 100%;" cellpadding=3D"0" cellspacing=3D"0= "> <tr> <td style=3D"width: 10px;"> </td> <td> <span id=3D"vMetricId@(Model.MetricId)" class=3D"met= ricId PageTitleTextStyle"> @(Model.MetricId) </span> <span class=3D"PageTitleTextStyle" style=3D"text-tra= nsform: uppercase;"> @(Model.Name) </span> <br /> <table cellspacing=3D"0" cellpadding=3D"0" border=3D= "0"> <tbody> <tr> <td style=3D"text-align: left;"> @Html.Partial("JumpToMetricSubcategory"= , Model.Children) </td> </tr> </tbody> </table> </td> <td style=3D"text-align: right; vertical-align: top;">= ; </td> </tr> </table> </td> </tr>
The figure below shows the convention-based naming and organization of t= he templates for the =E2=80=9COverview=E2=80=9D and =E2=80=9CMetric=E2=80= =9D rendering modes. Note that there are templates that provide for a Disab= led appearance. Others are =E2=80=9Cnull=E2=80=9D value templates which can= be used to completely hide a metric by providing an empty template. There = are metric-specific templates, and templates for a group of related metrics= (via the =E2=80=9CParentMetricId=E2=80=9D template value).
The metric rendering engine traverses the hierarchal metric view model a= nd evaluates the context and values of each metric instance to match the ap= propriate template for rendering.
A more detailed view of the various layers of the user interface code is= depicted in the diagram below.
Read more about the UI Developers' Guide: