• No se han encontrado resultados

D. Imposibilidad de una conceptualización clara

5. CONCEPTUALIZACION DE LOS CONTRATOS LEY

As well as the preexisting HTML templating tools discussed earlier, an application-specific rendering tool has been developed as part of MMS. A significant proportion of all pages within MMS include one or more tables of data. These require to be presented consistently, both in terms of layout of the table and formatting of data contained within, to ensure a coherent user interface experience. The same content may need to be rendered in a number of different formats, or different views of the data presented depending on use-case. Flex is a rendering engine which provides a table abstraction layer, which can target a num- ber of different output formats including HTML, Excel and PDF options. These formats

are also further subdivided, for example the HTML target has variants for read-only (for student views of data) and jQuery DataTables11.

Flex does not directly follow from the design principles, but supports exposing data as widely as possible, allowing data in MMS to be delivered readily in a wide variety of forms and formats as needed.

5.10.1

Data Model

Flex’s table data model consists of column headings, body and footer elements, along with metadata describing how the table is sorted, a list of columns to be rendered (the view), and optionally a list of statistics to be generated for each column and added to the footer. The table body and footer are represented by a list of rows (maps), with each map associating a column identifier to cell value. Column headings are stored as a single map of columns to labels, and may be rendered across two rows if any column has sub-columns.

The table stores a list of columns representing the outermost columns of the table. For example consider a table with a “Student” column and a “Grade” column. The “Student” column might be subdivided into “Student ID”, “Forename” and “Surname” columns, as shown in figure 5.10. Here the “Student” and “Grade” columns would be directly refer- enced by the table object, while the “Student ID”, “Forename” and “Surname” columns are stored as a list contained within the “Student” column.

Student Grade

Student ID Forename Surname 1101234567 Dave Smith 15 1112345678 Diane Jones 17 Figure 5.10: Example Table with Sub-columns

Beyond the common types for table data, numbers, string, and dates/times, Flex also has types for representing URL links, annotated values (such as a number or string with a status icon attached), and most common form elements such as text input fields, drop-down selection fields, submit buttons, etc.

5.10.2

Rendering Process

All of the different renderers (HTML, Excel, PDF, etc.) perform loosely the same process for rendering a table:

1. Create the table itself, for example in HTML, this involves writing out the HTML tag.

2. Iterate through the list of columns to be rendered. For each column, look up its label from the map provided in the table, and note whether it has sub-columns. Render these column labels as the first header row.

3. Where sub-columns have been found, iterate through the sub-columns, looking up their labels in the map, and render them as the second header row.

4. For each row of the table body, iterate through the list of columns to be rendered. Where a column has sub-columns, use those instead of the outermost column. For each column to be rendered, look up the matching value in the row and render it. 5. Render any conventional table footer, using the same process as for the table body. 6. Where statistics have been requested (such as mean, standard deviation, record count,

etc.), calculate those on each column (where possible) and render the results into the table footer.

5.10.3

Render Configuration

By providing table-specific views, Flex simplifies the process of ensuring tables are ren- dered correctly and consistently. Consider the rendering of a table where some columns are displayed or hidden depending on user privileges. A template based renderer might have separate conditionals for the optional columns in each of the table head, body and footer rendering parts. A natural approach to this is to test on the relevant privilege before render- ing the table cells in question, however such an approach risks later requirement changes introducing mismatches between the rendering conditions.

Flex’s rendering is driven by a common configuration option (the list of columns to be rendered), which is only specified once by the controller rather than 2 –3 times in view

logic. In having a re-usable rendering layer, any problems in the implementation are also much more likely to be spotted early, rather than risking most tables working correctly but some having subtle corner cases that can easily be missed during testing.

Read-only or read-write is also configured, although in this case by choice of view by the renderer. Again this is defined once and then re-usable code handles the logic of how to render the model, reducing risk of subtle bugs. This can be useful in cases where a table may be read-write for some users, and read-only for others, for example exam marks for editing by academics and auditing by external examiners.

5.10.4

Calculated Fields

One of the frequent pieces of feedback from staff using MMS was that even where they could download spreadsheets from MMS, because the data was all pre-calculated, it was difficult to see how numbers were calculated and required work to create formulae if they wished to experiment with changes to the values. The statistics footer primarily was added to unify code for calculating summary statistics (sum, mean, mode, row count, standard deviation, etc.) of data sets, but also led into the first stages of allowing Flex to provide formulae where downloading in spreadsheet formats (by providing cells that contained instructions on how to calculate their values, rather than values directly).