aboutsummaryrefslogtreecommitdiffstats
path: root/toj
diff options
context:
space:
mode:
authorpzread <netfirewall@gmail.com>2013-04-09 14:12:17 +0800
committerpzread <netfirewall@gmail.com>2013-04-09 14:12:17 +0800
commit6935a81c6b852d78e1fb6e2454ef50f353ad6ae0 (patch)
treeef7e9681a389c3f24d073c1f887ca27111dd69c5 /toj
parent31e170379d567a71f1792e0bad9aea6ca3c6478a (diff)
downloadtaiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.tar
taiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.tar.gz
taiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.tar.bz2
taiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.tar.lz
taiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.tar.xz
taiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.tar.zst
taiwan-online-judge-6935a81c6b852d78e1fb6e2454ef50f353ad6ae0.zip
Add rejudge button
Diffstat (limited to 'toj')
-rwxr-xr-xtoj/index.html1
-rwxr-xr-xtoj/jcs/stat.js12
-rwxr-xr-xtoj/jcs/user.js7
-rwxr-xr-xtoj/php/problem.inc.php11
-rwxr-xr-xtoj/php/problem.php15
-rwxr-xr-xtoj/php/status.php23
6 files changed, 65 insertions, 4 deletions
diff --git a/toj/index.html b/toj/index.html
index b295ed9..294fa35 100755
--- a/toj/index.html
+++ b/toj/index.html
@@ -358,6 +358,7 @@ input,select{
<h1>更新題目</h1>
<span class="cacheid"></span><br><br>
<button class="update">更新</button>
+ <button class="rejudge">重測</button>
</div>
<div class="error"></div>
diff --git a/toj/jcs/stat.js b/toj/jcs/stat.js
index 41a2796..67edcf1 100755
--- a/toj/jcs/stat.js
+++ b/toj/jcs/stat.js
@@ -139,6 +139,14 @@ var stat = new function(){
});
j_subres_mbox.prepend(j_button);
}
+ if(user.level == -1){
+ j_button = $('<button style="margin:6px 0px 0px 6px; float:right;">重測</button>');
+ j_button.on('click',function(e){
+ $.post('/toj/php/status.php',{'action':'rejudge_submit','data':JSON.stringify({'subid':that.sub_subid})});
+ com.url_pull();
+ });
+ j_subres_mbox.prepend(j_button);
+ }
$.getScript('/toj/smod/' + subid_node.smodname + '/' + subid_node.smodname + '.js',function(script,stat,res){
subres_mbox = new class_stat_subres_mbox(that.sub_subid,reto);
@@ -148,7 +156,7 @@ var stat = new function(){
});
});
}else{
- com.url_update('/toj/node/');
+ com.url_update('/toj/none/');
}
});
}
@@ -435,7 +443,7 @@ var class_stat_subfile_mbox = function(){
that.node.url_chg = function(direct,url_upart,url_dpart){
if(direct == 'in'){
that.fadein(j_mbox);
- j_mbox.find('h2.subid').text('SubID:' + stat.sub_subid);
+ j_mbox.find('h2.subid').text('SubID: ' + stat.sub_subid);
$.post('/toj/php/status.php',{'action':'get_submit_data','data':JSON.stringify({'subid':stat.sub_subid})},function(res){
var i;
diff --git a/toj/jcs/user.js b/toj/jcs/user.js
index 230aed5..505d3ad 100755
--- a/toj/jcs/user.js
+++ b/toj/jcs/user.js
@@ -1131,7 +1131,12 @@ var class_user_editpro_mbox = function(){
j_mbox.find('button.update').on('click',function(e){
$.post('/toj/php/problem.php',{'action':'update_pro_cache','data':JSON.stringify({'proid':proid})},function(res){
-
+ defer.resolve();
+ com.url_pull();
+ });
+ });
+ j_mbox.find('button.rejudge').on('click',function(e){
+ $.post('/toj/php/problem.php',{'action':'rejudge_pro','data':JSON.stringify({'proid':proid})},function(res){
defer.resolve();
com.url_pull();
});
diff --git a/toj/php/problem.inc.php b/toj/php/problem.inc.php
index a7a717e..d4c8e45 100755
--- a/toj/php/problem.inc.php
+++ b/toj/php/problem.inc.php
@@ -319,6 +319,12 @@ class problem
$ok = true;
$sublist = pg_fetch_all_columns($res, 0);
if(!$sublist)return false;
+
+ $sqlstr = 'UPDATE "submit" SET "result"=100,"runtime"=0,"memory"=0,"score"=0 WHERE "proid"=$1;';
+ $sqlarr = array($proid);
+ $res = pg_query_params($sqlc, $sqlstr, $sqlarr);
+ pg_free_result($res);
+
foreach($sublist as $sub)
{
$subid = intval($sub);
@@ -335,6 +341,11 @@ class problem
$proid = intval(pg_fetch_result($res, 0));
if(!$proid)return false;
+ $sqlstr = 'UPDATE "submit" SET "result"=100,"runtime"=0,"memory"=0,"score"=0 WHERE "subid"=$1;';
+ $sqlarr = array($subid);
+ $res = pg_query_params($sqlc, $sqlstr, $sqlarr);
+ pg_free_result($res);
+
return problem::send_socket($subid);
}
}
diff --git a/toj/php/problem.php b/toj/php/problem.php
index 1d6a2ba..69bb2f4 100755
--- a/toj/php/problem.php
+++ b/toj/php/problem.php
@@ -187,13 +187,26 @@ if($action == 'update_pro_cache')
die('Epermission_denied');
$dt = json_decode($data);
-
$proid = intval($dt->proid);
if(!problem::update_pro_cache($sqlc,$proid))
die('Eupdate_problem_cache');
echo('S');
}
+if($action == 'rejudge_pro')
+{
+ if(!sec_is_login())
+ die('Enot_login');
+ if(!sec_check_level($sqlc, USER_LEVEL_SUPERADMIN))
+ die('Epermission_denied');
+
+ $dt = json_decode($data);
+ $proid = intval($dt->proid);
+ if(!problem::rejudge_pro($sqlc, $proid))
+ die('Erejudge_pro');
+
+ echo('S');
+}
db_close($sqlc);
diff --git a/toj/php/status.php b/toj/php/status.php
index 8f0074f..488fb95 100755
--- a/toj/php/status.php
+++ b/toj/php/status.php
@@ -3,6 +3,7 @@ ini_set("display_errors", "On");
error_reporting(E_ALL & ~E_NOTICE);
require_once('status.inc.php');
+require_once('problem.inc.php');
$sqlc = db_connect();
@@ -91,6 +92,28 @@ if($action == 'get_submit_data')
echo(json_encode($ret));
}
+if($action == 'rejudge_submit')
+{
+ if(!sec_is_login())
+ die('Enot_login');
+
+ $dt = json_decode($data);
+ $subid = intval($dt->subid);
+ if(!$subid)
+ die('Eno_subid');
+
+ $sub = status::get_by_subid($sqlc, $subid);
+ if(!$sub)
+ die('Ewrong_subid');
+
+ if(!sec_check_level($sqlc, USER_LEVEL_SUPERADMIN))
+ die('Epermission_denied');
+
+ if(!problem::rejudge_sub($sqlc, $subid))
+ die('Erejudge_sub');
+
+ echo('S');
+}
db_close($sqlc);
?>