aboutsummaryrefslogtreecommitdiff
path: root/src/admin/report/stat.php
diff options
context:
space:
mode:
authorBruno Cesar Ribas <bcribas@users.noreply.github.com>2023-03-27 18:44:52 +0000
committerGitHub <noreply@github.com>2023-03-27 18:44:52 +0000
commit78760bb8bb00d26c5f68af884cde9e8b63feb869 (patch)
tree8b065c2dfc1314b571fbf4a48f37604238144588 /src/admin/report/stat.php
parentce8fcbe2a1f267f0ff5dea6ab7508242bb796818 (diff)
parent14114b0b7f8263e0095d9dcceebe5464299eaa9e (diff)
downloadboca-78760bb8bb00d26c5f68af884cde9e8b63feb869.tar.gz
boca-78760bb8bb00d26c5f68af884cde9e8b63feb869.zip
Merge pull request #22 from danielsaad/patch-1
Update stat.php
Diffstat (limited to 'src/admin/report/stat.php')
-rw-r--r--src/admin/report/stat.php223
1 files changed, 171 insertions, 52 deletions
diff --git a/src/admin/report/stat.php b/src/admin/report/stat.php
index 8a706e4..9f2ea60 100644
--- a/src/admin/report/stat.php
+++ b/src/admin/report/stat.php
@@ -30,20 +30,26 @@ echo "<tr><td><b><u>Problems</u></b></td>";
echo "<td>Total</td><td>Accepted</td>";
echo "</tr>\n";
-$str="All Runs by Problem";
$str2="Accepted Runs by Problem";
-reset($d['problem']);
+$color=array();
+$values_ac = array();
$cor = "";
-while (list($keya, $val) = each($d['problem'])) {
+// while (list($keya, $val) = each($d['problem'])) {
+foreach($d['problem'] as $keya => $val){
+
$val = $d['problemyes'][$keya]; if($val=="") $val=0;
+ $values_ac[]="$keya:$val";
$str2 .= chr(1) . $keya . "(" . $val . ")" . chr(1) . $val;
- $cor .= "-" . $d['color'][$keya];
+ $cor .= $d['color'][$keya] . "\r\n";
+ $color[] = "#".$d['color'][$keya];
}
$cor = substr($cor,1);
-reset($d['problem']);
-while (list($keya, $val) = each($d['problem'])) {
- $str .= chr(1) . $keya . "(" . $val . ")" . chr(1) . $val;
+
+$values = array();
+// while (list($keya, $val) = each($d['problem'])) {
+foreach($d['problem'] as $keya => $val){
+ $values[] = $keya . ":" . $val;
echo "<tr><td>$keya ";
echo "<img alt=\"balloon\" width=\"15\" ".
"src=\"" . balloonurl($d['color'][$keya]) ."\" />\n";
@@ -63,27 +69,51 @@ while (list($keya, $val) = each($d['problem'])) {
}
echo "</table></center>";
-echo "<center><table><tr>";
-echo "<td><img alt=\"\" src=\"piechart.php?dados=".rawurlencode($str)."&color=".rawurlencode($cor)."\" /></td>\n";
-echo "<td><img alt=\"\" src=\"piechart.php?dados=".rawurlencode($str2)."&color=".rawurlencode($cor)."\" /></td></tr></table></center>\n";
+$myfile = fopen("runs_by_problems.txt", "w") or die("Unable to open file runs_by_problems.txt!");
+for($i=0;$i<count($values);$i++){
+ fwrite($myfile, $values[$i]);
+ fwrite($myfile, " ");
+ fwrite($myfile, $color[$i]);
+ fwrite($myfile, "\n");
+}
+fclose($myfile);
+
+$myfile = fopen("accepted_runs_by_problems.txt", "w") or die("Unable to open file accepted_runs_by_problems.txt!");
+for($i=0;$i<count($values_ac);$i++){
+ fwrite($myfile, $values_ac[$i]);
+ fwrite($myfile, " ");
+ fwrite($myfile, $color[$i]);
+ fwrite($myfile, "\n");
+}
+fclose($myfile);
+
+shell_exec("python3 piechart.py runs_by_problems.txt 'Runs by Problems'");
+shell_exec("python3 piechart.py accepted_runs_by_problems.txt 'Accepted Runs by Problems'");
+
+echo "<center><table><tr>";
+echo "<td><img alt='runs by problems' src=runs_by_problems.png width=600></td></tr>\n";
+echo "<td><img alt='accepted runs by problems' src=accepted_runs_by_problems.png width=600></td>\n";
+echo "</table> </center>";
//----------------------------------------------------------
echo "<center><h3>Runs by Problem and Answer</h3></center>\n";
echo "<center><table border=1>\n";
echo "<tr><td><b><u>Problems x Answers</u></b></td>";
-reset($d['answer']);
-while (list($key, $val) = each($d['answer']))
+
+foreach($d['answer'] as $key => $val){
+// while (list($key, $val) = each($d['answer']))
echo "<td>$key</td>";
+}
echo "<td>Total</td></tr>\n";
-reset($d['problem']);
-while (list($keya, $vala) = each($d['problem'])) {
+foreach($d['problem'] as $keya => $vala){
+// while (list($keya, $vala) = each($d['problem'])) {
echo "<tr><td>$keya ";
echo "<img alt=\"balloon\" width=\"15\" ".
"src=\"" . balloonurl($d['color'][$keya]) ."\" />\n";
echo "</td>";
- reset($d['answer']);
- while (list($key, $val) = each($d['answer'])) {
+ foreach($d['answer'] as $key => $val){
+ // while (list($key, $val) = each($d['answer'])) {
if(!isset($d['pa'][$keya][$key]))
echo "<td>0</td>";
else {
@@ -100,19 +130,20 @@ echo "</table></center>";
echo "<center><h3>Runs by Problem and Language</h3></center>\n";
echo "<center><table border=1>\n";
echo "<tr><td><b><u>Problems x Languages</u></b></td>";
-reset($d['language']);
-while (list($key, $val) = each($d['language']))
+// while (list($key, $val) = each($d['language']))
+foreach($d['language'] as $key => $val){
echo "<td>$key</td>";
+}
echo "<td>Total</td></tr>\n";
-reset($d['problem']);
-while (list($keya, $vala) = each($d['problem'])) {
+foreach($d['problem'] as $keya => $vala){
+// while (list($keya, $vala) = each($d['problem'])) {
echo "<tr><td>$keya ";
echo "<img alt=\"balloon\" width=\"15\" ".
"src=\"" . balloonurl($d['color'][$keya]) ."\" />\n";
echo "</td>";
- reset($d['language']);
- while (list($key, $val) = each($d['language'])) {
+ // while (list($key, $val) = each($d['language'])) {
+ foreach($d['language'] as $key => $val){
if(!isset($d['pl'][$keya][$key]))
echo "<td>0</td>";
else {
@@ -137,14 +168,16 @@ echo "</tr>\n";
$str="All Runs by Language";
$str2="Accepted Runs by Language";
-reset($d['language']);
-while (list($keya, $val) = each($d['language'])) {
+$values = array();
+$values_ac = array();
+foreach($d['language'] as $keya => $val){
$val = $d['languageyes'][$keya]; if($val=="") $val=0;
$str2 .= chr(1) . $keya . "(" . $val . ")" . chr(1) . $val;
+ $values_ac[] = $keya.":".$val;
}
-reset($d['language']);
-while (list($keya, $val) = each($d['language'])) {
+foreach($d['language'] as $keya => $val){
+ $values[] =$keya . ":" . $val;
$str .= chr(1) . $keya . "(" . $val . ")" . chr(1) . $val;
echo "<tr><td>$keya</td>";
echo "<td>$val</td>";
@@ -158,24 +191,62 @@ while (list($keya, $val) = each($d['language'])) {
}
echo "</table></center>";
+$color = array();
+$color[] = "#2cba00";
+$color[] = "#a3ff00";
+$color[] = "#fff400";
+$color[] = "#ffa700";
+$color[] = "#ff0000";
+
+
+$myfile = fopen("all_runs_by_language.txt", "w") or die("Unable to open file all_runs_by_language.txt!");
+for($i=0;$i<count($values);$i++){
+ fwrite($myfile, $values[$i]);
+ fwrite($myfile, " ");
+ fwrite($myfile, $color[$i]);
+ fwrite($myfile, "\n");
+}
+fclose($myfile);
+
+$myfile = fopen("accepted_runs_by_language.txt", "w") or die("Unable to open file accepted_runs_by_language.txt!");
+for($i=0;$i<count($values);$i++){
+ fwrite($myfile, $values_ac[$i]);
+ fwrite($myfile, " ");
+ fwrite($myfile, $color[$i]);
+ fwrite($myfile, "\n");
+}
+
+fclose($myfile);
+
+
+shell_exec("python3 piechart.py all_runs_by_language.txt 'All Runs by Language' 'lower'");
+shell_exec("python3 piechart.py accepted_runs_by_language.txt 'Accepted Runs by Language' 'lower'");
+
+
+
+
echo "<center><table><tr>";
-echo "<td><img alt=\"\" src=\"piechart.php?dados=".rawurlencode($str)."\" /></td>\n";
-echo "<td><img alt=\"\" src=\"piechart.php?dados=".rawurlencode($str2)."\" /></td></tr></table></center>\n";
+echo "<td><img alt='all runs by language' src=all_runs_by_language.png width=600></td></tr>\n";
+echo "<td><img alt='accepted runs by language' src=accepted_runs_by_language.png width=600></td>\n";
+echo "</table> </center>";
+
//----------------------------------------------------------
echo "<center><h3>Runs by Language and Answer</h3></center>\n";
echo "<center><table border=1>\n";
echo "<tr><td><b><u>Languages x Answers</u></b></td>";
-reset($d['answer']);
-while (list($key, $val) = each($d['answer']))
+foreach($d['answer'] as $key => $val){
+// while (list($key, $val) = each($d['answer']))
echo "<td>$key</td>";
+}
echo "<td>Total</td></tr>\n";
-reset($d['language']);
-while (list($keya, $vala) = each($d['language'])) {
+// while (list($keya, $vala) = each($d['language'])) {
+foreach($d['language'] as $keya => $vala){
echo "<tr><td>$keya</td>";
- reset($d['answer']);
- while (list($key, $val) = each($d['answer'])) {
+ // while (list($key, $val) = each($d['answer'])) {
+ foreach($d['answer'] as $key => $val){
+
if(!isset($d['la'][$keya][$key]))
echo "<td>0</td>";
else {
@@ -203,17 +274,36 @@ echo "<td>Answers</td>";
echo "</tr>\n";
$str="All Runs by Answer";
-reset($d['answer']);
-while (list($keya, $val) = each($d['answer'])) {
+$values = array();
+// while (list($keya, $val) = each($d['answer'])) {
+foreach($d['answer'] as $keya => $val){
$str .= chr(1) . $keya . "(" . $val . ")" . chr(1) . $val;
+ $values[] = $keya . ":" . $val;
echo "<tr><td>$keya</td>";
echo "<td>$val</td>";
echo "</tr>";
}
echo "</table></center>";
-echo "</td>";
-echo "<td><img alt=\"\" src=\"piechart.php?order=1&dados=".rawurlencode($str)."\" /></td></tr></table></center>\n";
+$color[] = "#af7f57";
+$color[] = "#ffffff";
+$myfile = fopen("all_runs_by_answer.txt", "w") or die("Unable to open file all_runs_by_answer.txt!");
+for($i=0;$i<count($values);$i++){
+ fwrite($myfile, $values[$i]);
+ fwrite($myfile, " ");
+ fwrite($myfile, $color[$i]);
+ fwrite($myfile, "\n");
+}
+
+fclose($myfile);
+
+shell_exec("python3 piechart.py all_runs_by_answer.txt 'All Runs by Answer' 'lower'");
+
+
+
+echo "<center><table><tr>";
+echo "<td><img alt='all runs by answer' src=all_runs_by_answer.png width=600></td></tr>\n";
+echo "</table></center>\n";
//----------------------------------------------------------
echo "<br />";
@@ -221,8 +311,9 @@ echo "<hr />";
echo "<center><h3>Runs by User and Problem</h3></center>\n";
echo "<center><table border=1>\n";
echo "<tr><td><b><u>Users x Problems</u></b></td>";
-reset($d['problem']);
-while (list($key, $val) = each($d['problem'])) {
+// while (list($key, $val) = each($d['problem'])) {
+foreach($d['problem'] as $key => $val){
+
echo "<td>$key ";
echo "<img alt=\"balloon\" width=\"15\" ".
"src=\"" . balloonurl($d['color'][$key]) ."\" />\n";
@@ -230,15 +321,16 @@ while (list($key, $val) = each($d['problem'])) {
}
echo "<td>Total</td><td>Accepted</td></tr>\n";
-reset($d['username']);
-while (list($keya, $vala) = each($d['username'])) {
+// while (list($keya, $vala) = each($d['username'])) {
+foreach($d['username'] as $keya => $vala){
+
$keya = $d['username'][$keya];
if(isset($d['user'][$keya]))
$vala = $d['user'][$keya];
else $vala=0;
echo "<tr><td>".$d['userfull'][$keya]."</td>";
- reset($d['problem']);
- while (list($key, $val) = each($d['problem'])) {
+ // while (list($key, $val) = each($d['problem'])) {
+ foreach($d['problem'] as $key => $val){
if(!isset($d['up'][$keya][$key]))
echo "<td bgcolor=\"ffff88\">0</td>";
else {
@@ -285,8 +377,9 @@ $pos = 0;
$res = array();
$m = 0;
sort($d['timestamp']);
-reset($d['timestamp']);
-while (list($keya, $val) = each($d['timestamp'])) {
+
+foreach($d['timestamp'] as $keya => $val){
+// while (list($keya, $val) = each($d['timestamp'])) {
while($atual+$passo < $val) {
$atual += $passo;
$pos++;
@@ -299,15 +392,28 @@ while (list($keya, $val) = each($d['timestamp'])) {
$str="Runs by Time Period" . chr(1) . $m;
$atual=0;
+$values = array();
for($pos=0; $pos<$vezes; $pos++) {
if(!isset($res[$pos]) || $res[$pos]=="") $res[$pos] = 0;
$q = (int) ($atual/60);
$atual += $passo;
$qq = (int) ($atual/60);
$str .= chr(1) . $q . "-" .$qq . chr(1) . $res[$pos];
+ $values[] = $res[$pos];
+}
+
+$myfile = fopen("runs_by_time_period.txt", "w") or die("Unable to open file runs_by_time_period.txt!");
+for($i=0;$i<count($values);$i++){
+ fwrite($myfile, $values[$i]);
+ fwrite($myfile, "\n");
}
-echo "<center><img alt=\"\" src=\"linechart.php?dados=".rawurlencode($str)."\" /></center>\n";
+shell_exec("python3 barplot.py runs_by_time_period.txt 'Runs by Time Period'");
+
+
+echo "<center><img alt=runs_by_time_period src=runs_by_time_period.png width=900></center>\n";
+
+
//------------------------------------------------
$vezes = 30;
@@ -316,28 +422,41 @@ $atual = 0;
$pos = 0;
$res = array();
sort($d['timestampyes']);
-reset($d['timestampyes']);
-while (list($keya, $val) = each($d['timestampyes'])) {
+// while (list($keya, $val) = each($d['timestampyes'])) {
+foreach($d['timestampyes'] as $keya => $val){
while($atual+$passo < $val) {
$atual += $passo;
$pos++;
}
- if(isset($res[$pos]))
- $res[$pos]++;
+ if(isset($res[$pos])){
+ $res[$pos]++;
+ }
else $res[$pos]=1;
}
$str="Accepted Runs by Time Period" . chr(1) . $m;
$atual=0;
+$values_ac = array();
for($pos=0; $pos<$vezes; $pos++) {
if(!isset($res[$pos]) || $res[$pos]=="") $res[$pos] = 0;
$q = (int) ($atual/60);
$atual += $passo;
$qq = (int) ($atual/60);
$str .= chr(1) . $q . "-" .$qq . chr(1) . $res[$pos];
+ $values_ac[] = $res[$pos];
+}
+
+$myfile = fopen("accepted_runs_by_time_period.txt", "w") or die("Unable to open file accepted_runs_by_time_period.txt!");
+for($i=0;$i<count($values_ac);$i++){
+ fwrite($myfile, $values_ac[$i]);
+ fwrite($myfile, "\n");
}
-echo "<center><img alt=\"\" src=\"linechart.php?dados=".rawurlencode($str)."\" /></center>\n";
+shell_exec("python3 barplot.py accepted_runs_by_time_period.txt 'Accepted Runs by Time Period'");
+
+
+echo "<center><img alt=runs_by_time_period src=accepted_runs_by_time_period.png width=900></center>\n";
+
include("$locr/footnote.php");
?>