Modified:
/trunk/vanillaapp/controllers/class.problemscontroller.php
/trunk/vanillaapp/models/class.submissionmodel.php
/trunk/vanillaapp/modules/class.probleminfomodule.php
/trunk/vanillaapp/views/modules/probleminfo.php
=======================================
--- /trunk/vanillaapp/controllers/class.problemscontroller.php Sat Jul 10
22:16:40 2010
+++ /trunk/vanillaapp/controllers/class.problemscontroller.php Sat Jul 10
22:17:04 2010
@@ -49,6 +49,10 @@
$this->View = "read";
$this->Render();
}
+ public function Ranklist($IdOrNo) {
+ $this->GetProblem($IdOrNo);
+
print_r($this->SubmissionModel->GetProblemStatistics($this->Problem->No));
+ }
public function Add() {
$this->ForceLogin();
$Timestamp = strftime("%F:%T");
=======================================
--- /trunk/vanillaapp/models/class.submissionmodel.php Sat Jul 10 22:16:40
2010
+++ /trunk/vanillaapp/models/class.submissionmodel.php Sat Jul 10 22:17:04
2010
@@ -80,6 +80,20 @@
}
return $ret;
}
+
+ public function GetProblemStatistics($No) {
+ $this->SQL->Select("State")
+ ->Select("Count(No)", "", "Cnt")
+ ->From("Submission")
+ ->Where("Problem", $No)
+ ->GroupBy("State");
+ $ret = array();
+ for($i = 0; $i < 11; ++$i) $ret[$i] = 0;
+ foreach($this->SQL->Get()->Result() as $row) {
+ $ret[SubmissionState::ToString($row->State)] = $row->Cnt;
+ }
+ return $ret;
+ }
public function GetCount($Author, $ShowHidden) {
$Session = Gdn::Session();
=======================================
--- /trunk/vanillaapp/modules/class.probleminfomodule.php Mon May 31
21:48:02 2010
+++ /trunk/vanillaapp/modules/class.probleminfomodule.php Sat Jul 10
22:17:04 2010
@@ -2,9 +2,13 @@
class ProblemInfoModule extends Gdn_Module {
+
+
public function __construct(&$Sender = '') {
$this->Problem = $Sender->Problem;
$this->IsAdmin = $Sender->IsAdmin();
+ $SubmissionModel = new SubmissionModel();
+ $this->Stats =
($SubmissionModel->GetProblemStatistics($this->Problem->No));
parent::__construct($Sender);
}
=======================================
--- /trunk/vanillaapp/views/modules/probleminfo.php Mon May 31 21:48:02 2010
+++ /trunk/vanillaapp/views/modules/probleminfo.php Sat Jul 10 22:17:04 2010
@@ -24,8 +24,13 @@
<? } ?>
<div class="PanelEntry">
<h3><?=$this->Problem->ID?> Stats</h3>
-<?php
-$chart_api
= "http://chart.apis.google.com/chart?cht=p&chs=220x120&chd=t:72,31,16,7&chdl=AC|
WA|TLE|OTHER&chco=C02942|53777A|542437|ECD078&chf=bg,s,00000000";
+<?
+ $AC = $this->Stats["ACCEPTED"];
+ $WA = $this->Stats["WRONG_ANSWER"];
+ $TLE = $this->Stats["TIME_LIMIT_EXCEEDED"];
+ $OTHER = array_sum($this->Stats) - $AC - $WA - $TLE;
+
+$chart_api
= "http://chart.apis.google.com/chart?cht=p&chs=220x120&chp=4.712&chd=t:$AC,$WA,$TLE,$OTHER&chdl=AC|
WA|TLE|OTHER&chco=C02942|53777A|542437|ECD078&chf=bg,s,00000000";
echo Anchor("<img src='$chart_api'/>", "/problems/ranklist/" .
$this->Problem->ID, "", array("title" => "Click for ranklist"));
?>
</div>