-
Notifications
You must be signed in to change notification settings - Fork 24
Scoreboard HTML Configuration
As described at Scoreboard Viewing, PC² supports generation of two sets of HTML scoreboard pages: a public set which shows the current standings taking into account any configured "scoreboard freeze period", and a private set which show the current, actual standings ignoring any scoreboard freeze period.
PC² initially generates standings in the form of XML strings, and then uses XSL Transformations (XSLT) to map those XML standings into HTML documents.
The XSL Transformations which PC² uses to control the mapping from XML standings to formatted HTML are contained in the folder data.xsl
under the PC² installation directory. There is one .xsl
file in the folder for each of the types of HTML files which PC² generates:
- full, which contains the full standings including rank, team name, number of problems solved, and penalty time, listed in team rank order.
- fullnums, same as full but also includes the team number in the "name" column.
- summary, which in addition to the data shown in full also shows per-problem details of attempts and solutions by team.
- sumatt, a summary of problem attempts and whether or not the problem was solved, ordered by team name (instead of by rank).
- sumtime, a summary like sumatt but also showing (for solved problems) the time of solution.
There is a default .xsl
file in ./data/xsl
defining how each of these HTML pages should be formatted. These files can be replaced by the user with XSLT files specifying any alternative desired transformations.
Modifying the XSL Transformations used to generate the output HTML requires an understanding of the format of the XML standings string which acts as input to the XSL Transformations. The standings string is a hierarchical XML document tree based on the PC² class XMLMemento
, an instance of which is created by class DefaultScoringAlgorithm
(which is the class used to generate current standings).
The root of the standings XML document tree is a node named contestStandings
. Beneath this root node lies a child node named standingsHeader
which contains fields such as title
, scoreboardMessage
, systemName
, systemVersion
, etc. The title
field is initialized to the contest title as given in the contest configuration (or to the string "title" if no contest title has been defined).
The scoreboardMessage
field is initialized to the string "Live (unfrozen) Scoreboard" if the DefaultScoringAlgorithm
has been configured to ignore any "scoreboard freeze" period; if DefaultScoringAlgorithm
has been told to respect the configured scoreboard freeze period then the scoreboardMessage
is initialized to a message like "Scoreboard will be frozen with XXX minutes remaining" or "Scoreboard was frozen with XXX minutes remaining", depending on whether the start of the scoreboard freeze period has been reached.
The contestStandings
node also contains child nodes problemCount
, containing the number of problems in the contest; siteCount
, containing the number of PC² sites in the contest; groupCount
, containing the number of defined team groups in the contest; and groupList
, itself a tree containing group
child nodes, each of which has an id
, title
, externalId
, and pc2site
field describing each group defined in the contest. contestStandings
also contains additional nodes such as colorList
, a sub-tree containing the balloon colors associated with each contest problem. Finally, contestStandings
contains a complete subtree containing all the team standings in ranked order.
The fields in the XML standings string can be accessed by name in XSL transformations. For example the title
field in the standingsHeader
component of contestStandings
can be referenced in XSL using the XSL value-of
operator using xsl:value-of select="/contestStandings/standingsHeader/@title"/
.
The following listings show portions of the default XSL Transformation which maps an XML standings string into the full.html page.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator="," />
The above specifies that the file contains an XSL stylesheet (xsl:stylesheet
) whose form is based on the XML Namespace (xmlns:xsl=...
) defined at the specified URL, that the output is to be HTML with indentation and using "period" as the decimal/fractional separator and "comma" as the decimal group separator.
<xsl:template match="contestStandings">
<HTML>
<HEAD>
<TITLE>
Full Info - <xsl:value-of select="/contestStandings/standingsHeader/@title"/>
</TITLE>
<META HTTP-EQUIV="EXPIRES" CONTENT="0"/>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"/>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"/>
</HEAD>
The above specifies the beginning of the HTML document, defining a <HEAD>
section containing a <TITLE>
line and several HTML <META HTTP>
tags. The value for the title is set to be the string "Full Info -" followed by the value of the attribute @title
pulled from the contestStandings/standingsHeader
element in the contest standings XML string.
<BODY>
<TABLE border="0">
<tr><th><strong><u>Rank</u></strong></th><th><strong><u>Name</u></strong></th><th><strong><u>Solved</u></strong></th><th><strong><u>Time</u></strong></th></tr>
<xsl:call-template name="teamStanding"/>
</TABLE>
The above defines the body of the HTML document to be a table with a single table-header row followed by a series table rows each of whose contents is defined by an XSL template named teamStanding
(see below).
Created by <A HREF="http://pc2.ecs.csus.edu/">CSUS PC^2 <xsl:value-of select="/contestStandings/standingsHeader/@systemVersion"/></A><br/>
<A HREF="http://pc2.ecs.csus.edu/">http://pc2.ecs.csus.edu/</A><br/>
Last updated
<xsl:value-of select="/contestStandings/standingsHeader/@currentDate"/>
</p>
</BODY>
</HTML>
The above completes the HTML document body (and the HTML document) by adding a footer consisting of various data elements pulled from the contestStandings/standingsHeader
XML node, including the version of PC² which was used to generate the standings as well as the current date.
</xsl:template>
<xsl:template name="teamStanding">
<xsl:for-each select="teamStanding">
<tr>
<td><xsl:value-of select="@rank"/></td>
<td><xsl:value-of select="@teamName"/></td>
<td align="center"><xsl:value-of select="@solved"/></td>
<td align="right"><xsl:value-of select="@points"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The above defines the template for each table data row showing the standings for a single team. The template selects each teamStanding
element from the XML tree and displays the value of that team's rank
, teamName
, solved
(total number of problems solved), and points
(penalty points) in a table data item in the current row..
Using formatting similar to the above, the user can arrange to have the HTML output generated by PC² to have any desired appearance, simply by replacing the corresponding XSL file in the data/xsl
folder with the desired XSL transformation file.