Added:
/trunk/vanillaapp/views/problems/ranklist.php
Modified:
/trunk/vanillaapp/controllers/class.problemscontroller.php
/trunk/vanillaapp/design/problems.css
/trunk/vanillaapp/models/class.submissionmodel.php
/trunk/vanillaapp/views/problems/listsubmissions.php
/trunk/vanillaapp/views/problems/submissions.php
=======================================
--- /dev/null
+++ /trunk/vanillaapp/views/problems/ranklist.php Sat Jul 10 22:17:14 2010
@@ -0,0 +1,133 @@
+<div class="Section">
+ <h2>Statistics For Problem <?=$this->Problem->Name?></h2>
+ <table cellpadding="0" cellspacing="0" border="0" class="display"
id="ProblemStats" width="100%">
+ <thead>
+ <tr>
+ <th><?=T("ID")?></th>
+ <th><?=T("# Submissions")?></th>
+ <th><?=T("Acceptance Rate")?></th>
+ <th><?=T("Source")?></th>
+ <th><?=T("Category")?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><?=$this->Problem->ID?></td>
+ <td><?=array_sum($this->Stats)?></td>
+ <td><?=sprintf("%.2lf%%", $this->Stats["ACCEPTED"] * 100.0
/ array_sum($this->Stats))?></td>
+ <td><?=$this->Problem->Source?></td>
+ <td></td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<div class="Section">
+ <h2><?=T("Accepted Submissions")?></h2>
+ <table cellpadding="0" cellspacing="0" border="0" class="display"
id="SubmissionListTable" width="100%">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th><?=T("Problem")?></th>
+ <th><?=T("Author")?></th>
+ <th><?=T("Language")?></th>
+ <th><?=T("Verdict")?></th>
+ <th><?=T("Time/Mem")?></th>
+ <th><?=T("Submitted")?></th>
+ </tr>
+ </thead>
+ <tbody>
+ </tbody>
+ </table>
+
+</div>
+<script language="javascript">
+ function hasPermission(row) {
+ var author = row[2][0];
+ if(<?=($this->IsAdmin ? "true" : "false")?>) return true;
+ <? if($this->Session->IsValid()) { ?>
+ return author == <?=$this->Session->UserID?>;
+ <? } else { ?>
+ return false;
+ <? } ?>
+ }
+ var table = null;
+ $(document).ready(function() {
+ $('#SubmissionInfo').dataTable( {
+ "bProcessing": false,
+ "bLengthChange": false,
+ "bFilter": false,
+ "bInfo": false,
+ "bSort": false,
+ "bPaginate": false,
+ "bSearch": false });
+ table = $('#SubmissionListTable').dataTable( {
+ "bProcessing": true,
+ "bFilter": false,
+ "bSort": false,
+ "bServerSide": true,
+ "bLengthChange": false,
+ "iDisplayLength": 25,
+ "sPaginationType": "full_numbers",
+ "sAjaxSource": "<?=Url("/problems/listsubmissions")?>",
+ "fnServerData": function ( sSource, aoData, fnCallback ) {
+ if(aoData == null) {
+ aoData = [];
+ }
+ aoData.push({ name: "DeliveryType", value: 3});
+ aoData.push({ name: "State", value:
<?=SubmissionState::ACCEPTED?>});
+ $.getJSON( sSource, aoData, fnCallback);
+ },
+ "aoColumns": [
+ null,
+ {
+ fnRender: function(obj) {
+ var dat = obj.aData[1];
+ return '<a href="<?=Url("/problems/read")?>/' +
dat[1] + '">' + dat[0] + "</a>";
+ }
+ },
+ {
+ fnRender: function(obj) {
+ var dat = obj.aData[2];
+ return '<a href="<?=Url("/profile/")?>/' + dat[0]
+ '/' + dat[1] + '">' + dat[1] + "</a>";
+ }
+ },
+ {
+ sWidth: "4%",
+ fnRender: function(obj) {
+ var language = obj.aData[3], no = obj.aData[0];
+ if(hasPermission(obj.aData)) return "<a
href='<?=Url("problems/submission/")?>/" + no + "'>" + language + "</a>";
+ return language;
+
+ }
+ },
+ {
+ fnRender: function(obj) {
+ var no = obj.aData[0];
+ var dat = obj.aData[4];
+ var ret = "<span class='Submission" + dat + "'>" +
dat.replace(/_/g, " ") + "</span>";
+ if(hasPermission(obj.aData) && (dat
== "COMPILE_ERROR" || dat == "RUNTIME_ERROR")) {
+ ret = "<a
href='<?=Url("problems/submission/")?>/" + no + "'>" + ret + "</a>";
+ }
+ return ret;
+ }
+ },
+ {
+ fnRender: function(obj) {
+ var dat = obj.aData[5];
+ if(dat[0] == "" || dat[1] == "")
+ return "";
+ return dat[0] + "ms/" + dat[1] + "KB";
+ }
+ },
+ {
+ fnRender: function(obj) {
+ var dat = obj.aData[6];
+ return "<span title='" + dat[1] + "'>" + dat[0] +
+ "</span>";
+ }
+ },
+
+ ]
+ } );
+ });
+</script>
=======================================
--- /trunk/vanillaapp/controllers/class.problemscontroller.php Sat Jul 10
22:17:04 2010
+++ /trunk/vanillaapp/controllers/class.problemscontroller.php Sat Jul 10
22:17:14 2010
@@ -51,7 +51,13 @@
}
public function Ranklist($IdOrNo) {
$this->GetProblem($IdOrNo);
-
print_r($this->SubmissionModel->GetProblemStatistics($this->Problem->No));
+ $this->AddModule("ProblemInfoModule");
+ $this->AddModule("SubmitModule");
+ $this->SetData("Stats",
$this->SubmissionModel->GetProblemStatistics($this->Problem->No), TRUE);
+ $this->AddCssFile("tables.css");
+ $this->AddJsFile("jquery.dataTables.min.js");
+ $this->AddJsFile("jquery.dataTables.plugins.js");
+ $this->Render();
}
public function Add() {
$this->ForceLogin();
=======================================
--- /trunk/vanillaapp/design/problems.css Sat Jul 10 22:16:40 2010
+++ /trunk/vanillaapp/design/problems.css Sat Jul 10 22:17:14 2010
@@ -95,7 +95,7 @@
color: red;
}
-.Submission {
+.Submission, .Section {
margin-bottom: 24px;
}
=======================================
--- /trunk/vanillaapp/models/class.submissionmodel.php Sat Jul 10 22:17:04
2010
+++ /trunk/vanillaapp/models/class.submissionmodel.php Sat Jul 10 22:17:14
2010
@@ -86,6 +86,7 @@
->Select("Count(No)", "", "Cnt")
->From("Submission")
->Where("Problem", $No)
+ ->Where("IsPublic", 1)
->GroupBy("State");
$ret = array();
for($i = 0; $i < 11; ++$i) $ret[$i] = 0;
=======================================
--- /trunk/vanillaapp/views/problems/listsubmissions.php Sun Jun 27
16:04:18 2010
+++ /trunk/vanillaapp/views/problems/listsubmissions.php Sat Jul 10
22:17:14 2010
@@ -9,7 +9,7 @@
if($i > 0) echo(",");
?>
[
- <?=$Submission->No?>,
+ [<?=$Submission->No?>, <?=$Submission->IsPublic?>],
["<?=$Submission->ProblemName?>", "<?=$Submission->ProblemID?>"],
[<?=$Submission->Author?>, "<?=$Submission->AuthorInfo->Name?>"],
"<?=$Submission->Language?>",
=======================================
--- /trunk/vanillaapp/views/problems/submissions.php Sat Jul 10 22:16:51
2010
+++ /trunk/vanillaapp/views/problems/submissions.php Sat Jul 10 22:17:14
2010
@@ -58,7 +58,13 @@
$.getJSON( sSource, aoData, fnCallback);
},
"aoColumns": [
- null,
+ {
+ fnRender: function(obj) {
+ var dat = obj.aData[0];
+ if(dat[1]) return dat[0];
+ return "<span title='<?=T("Non-public submission.
Does not count in statistics.")?>'>*</a>";
+ }
+ },
{
fnRender: function(obj) {
var dat = obj.aData[1];
@@ -74,7 +80,7 @@
{
sWidth: "4%",
fnRender: function(obj) {
- var language = obj.aData[3], no = obj.aData[0];
+ var language = obj.aData[3], no = obj.aData[0][0];
if(hasPermission(obj.aData)) return "<a
href='<?=Url("problems/submission/")?>/" + no + "'>" + language + "</a>";
return language;
@@ -82,7 +88,7 @@
},
{
fnRender: function(obj) {
- var no = obj.aData[0];
+ var no = obj.aData[0][0];
var dat = obj.aData[4];
var ret = "<span class='Submission" + dat + "'>" +
dat.replace(/_/g, " ") + "</span>";
if(hasPermission(obj.aData) && (dat
== "COMPILE_ERROR" || dat == "RUNTIME_ERROR")) {