<?php
/**    Copyright © 2007 World Wide Web Consortium,
   (Massachusetts Institute of Technology, European Research
    Consortium for Informatics and Mathematics, Keio
    University). All Rights Reserved. 

    This work is distributed under the W3CÂ Software License
    [1] in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
    [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
*/
require_once("mthlib.phi");
require_once("tests.phi");



$ts=$_GET["ts"];
$shownonwireless=isset($_GET["showall"]);
$uafilter = $_GET["ua"];
$exactmatch = (!isset($_GET["exact"]) || $_GET["exact"]!=0);
if (!$ts) {
WriteHTMLTop("Statistics on submitted results");
echo "<p>You can access below the results collected through the <a href='harness'>W3C Mobile Web test harness</a>.</p>";
 echo "<ul><li><a href='results?ts=cssmp'>Results for CSS MP</a></li><li><a href='results?ts=encoding'>Results for Encoding Test Suite</a></li><li><a href='results?ts=svg'>Results for SVG Tiny</a></li><li><a href='results?ts=dom1'>Results for DOM Level 1 Test Suite</a></li></ul>\n" ;
WriteHTMLFoot('$Id: results.php,v 1.3 2007-11-28 15:29:07 dom Exp $');
 exit();
}
$testsuite = new Testsuite('',$ts);
if (!$testsuite->uri) {
  WriteErrorpage("Unknown test suite","There is no test suite known as <code>$ts</code>",404);
}

WriteHTMLTop("Statistics on submitted results for <a href='".htmlify($testsuite->uri)."'>".htmlify($testsuite->title)."</a>");
echo "<p>(see also <a href='results'>the collected results for other test suites</a>)</p>";
echo "<p>(the numbers Y/X in each cell indicates how many time the given result (<span class='res1'>Pass</span>/<span class='res2'>Fail</span>/<span class='res3'>Cannot tell</span>) was submitted for a given test case and a given user agent.)</p>\n";

if ($uafilter) {
  echo "<p>View the results with <a href='results?ts=$ts'>only mobile web user agents</a>,
   or <a href='esults?ts=$ts&amp;showall=1'>all user agents</a> - the current view is restricted to 
   ".($exactmatch ? "": "useragents matching ").
   "\"<code>$ua</code>\".</p>";
} else if ($shownonwireless) {
  echo "<p>View the results with <a href='results?ts=$ts'>only mobile web user agents</a>.</p>\n" ;
} else {
  echo "<p>View the results with <a href='results?ts=$ts&amp;showall=1'>all user agents</a> - the current view is restricted to mobile web user agents.</p>\n" ;
}
$testsuite->loadtestcases();
$results = new TestSuiteResults($testsuite);
$results->load(!$shownonwireless,$uafilter,$exactmatch);
echo "<table border='1'>";
print $results->toHTML();
echo "</table>\n" ;

echo "<h2>List of user agents with results</h2>\n";
echo "<p>Results were collected for the following user agents:</p><ul>\n";
$useragents = $results->listResultsByUserAgent();
foreach ($useragents as $ua=>$count) {
	echo "<li><code>".htmlify($ua)."</code>: <a href='results?ts=$ts&amp;ua=".htmlify(urlencode($ua))."'>$count results</a>, ".round((100*$count/$testsuite->count()))."%</li>\n";
}
echo "</ul>\n";
echo "<form action='results'>";
echo "<p><input type='hidden' name='exact' value='0' /><input type='hidden' name='ts' value='$ts' />
<label>Filter results for user agents matching: 

<input type='text' name='ua' value='".htmlify($uafilter)."' /></label> 
<input type='submit' value='Filter' /></p>";
echo "</form>\n";

WriteHTMLFoot('$Id: results.php,v 1.3 2007-11-28 15:29:07 dom Exp $');
?>
