aboutsummaryrefslogtreecommitdiffstats
path: root/toj/pmod
diff options
context:
space:
mode:
authorpzread <netfirewall@gmail.com>2013-03-01 22:30:00 +0800
committerpzread <netfirewall@gmail.com>2013-03-01 22:30:00 +0800
commit56688ed6d0b18f68ac8ddd82c4944c5d2777d20a (patch)
treebb943e164f82b4a826f1d9ce253bfabf912c0004 /toj/pmod
parent69d7b55a1c9d3100d42b9c91ab995de44b13d73b (diff)
downloadtaiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.tar
taiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.tar.gz
taiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.tar.bz2
taiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.tar.lz
taiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.tar.xz
taiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.tar.zst
taiwan-online-judge-56688ed6d0b18f68ac8ddd82c4944c5d2777d20a.zip
Taiwan Online Judge Alpha 1
Diffstat (limited to 'toj/pmod')
-rwxr-xr-xtoj/pmod/pmod_multisub/pmod_multisub.css52
-rwxr-xr-xtoj/pmod/pmod_multisub/pmod_multisub.html40
-rwxr-xr-xtoj/pmod/pmod_multisub/pmod_multisub.js98
-rwxr-xr-xtoj/pmod/pmod_multisub/pmod_multisub.php77
-rwxr-xr-xtoj/pmod/pmod_test/pmod_test.css53
-rwxr-xr-xtoj/pmod/pmod_test/pmod_test.html37
-rwxr-xr-xtoj/pmod/pmod_test/pmod_test.js74
-rwxr-xr-xtoj/pmod/pmod_test/pmod_test.php42
8 files changed, 473 insertions, 0 deletions
diff --git a/toj/pmod/pmod_multisub/pmod_multisub.css b/toj/pmod/pmod_multisub/pmod_multisub.css
new file mode 100755
index 0000000..308cc94
--- /dev/null
+++ b/toj/pmod/pmod_multisub/pmod_multisub.css
@@ -0,0 +1,52 @@
+div.pmod_multisub > div.main_content{
+ margin:32px 0px 32px 256px;
+}
+div.pmod_multisub > table.probox{
+ width:100%;
+ margin:0px 0px 32px 0px;
+ border-collapse:collapse;
+}
+div.pmod_multisub > table.probox td.info{
+ width:250px;
+ padding:0px 0px 0px 6px;
+ vertical-align:top;
+}
+div.pmod_multisub > table.probox td.info > table.statlist{
+ width:100%;
+ text-align:left;
+ border-collapse:collapse;
+}
+div.pmod_multisub > table.probox td.info > table.statlist td.name{
+ width:96px;
+}
+div.pmod_multisub > table.probox td.info > table.statlist td.value{
+ width:auto;
+}
+div.pmod_multisub > table.probox td.info > table.limitlist{
+ width:100%;
+ text-align:left;
+ border-collapse:collapse;
+}
+div.pmod_multisub > table.probox td.info > table.limitlist td.name{
+ width:96px
+}
+div.pmod_multisub > table.probox td.info > table.limitlist td.value{
+ width:auto;
+}
+div.pmod_multisub > table.probox td.info > table.scorelist{
+ width:100%;
+ text-align:left;
+ border-collapse:collapse;
+}
+div.pmod_multisub > table.probox td.info > table.scorelist tr.item{
+ font-size:16;
+}
+div.pmod_multisub > table.probox td.info > table.scorelist th.no,div.pmod_multisub > td.info > table.scorelist td.no{
+ width:64px;
+}
+div.pmod_multisub > table.probox td.info > table.scorelist th.score,div.pmod_multisub > td.info > table.scorelist td.score{
+ width:auto;
+}
+div.pmod_multisub > table.probox td.content{
+ vertical-align:top;
+}
diff --git a/toj/pmod/pmod_multisub/pmod_multisub.html b/toj/pmod/pmod_multisub/pmod_multisub.html
new file mode 100755
index 0000000..07b19a9
--- /dev/null
+++ b/toj/pmod/pmod_multisub/pmod_multisub.html
@@ -0,0 +1,40 @@
+<div class="main_content"></div>
+<table class="probox ori_probox" style="display:none;"><tr>
+ <td class="info">
+ <h2 class="partname"></h2>
+ <button class="submit">上傳</button>
+
+ <h3>狀態</h3>
+ <table class="statlist">
+ <tr>
+ <td class="name">最佳分數</td>
+ <td class="value bscore"></td>
+ </tr>
+ <tr>
+ <td class="name">解題狀態</td>
+ <td class="value stat"></td>
+ </tr>
+ </table>
+
+ <h3>限制</h3>
+ <table class="limitlist">
+ <tr>
+ <td class="name">時間限制</td>
+ <td class="value timelimit"></td>
+ </tr>
+ <tr>
+ <td class="name">記憶體限制</td>
+ <td class="value memlimit"></td>
+ </tr>
+ </table>
+
+ <h3>配分</h3>
+ <table class="scorelist">
+ <tr class="head">
+ <th class="no">#</th>
+ <th class="score">Score</th>
+ </tr>
+ </table>
+ </td>
+ <td class="content"></td>
+</tr></table>
diff --git a/toj/pmod/pmod_multisub/pmod_multisub.js b/toj/pmod/pmod_multisub/pmod_multisub.js
new file mode 100755
index 0000000..9cbd7a3
--- /dev/null
+++ b/toj/pmod/pmod_multisub/pmod_multisub.js
@@ -0,0 +1,98 @@
+var pmod_multisub = {
+ that:null,
+ j_page:null,
+
+ init:function(that,j_page){
+ pmod_multisub.that = that;
+ pmod_multisub.j_page = j_page;
+
+ that.export_urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_page);
+
+ $.post('/toj/pmod/pmod_multisub/pmod_multisub.php',{'proid':JSON.stringify(that.proid)},function(res){
+ var i;
+ var reto;
+
+ reto = JSON.parse(res);
+ if(reto.redirect != undefined){
+ common.pushurl('/toj/pro/' + reto.redirect + '/');
+ }else{
+ j_page.find('div.main_content').text(reto.main_content);
+ index.setcontent($('<span>' + reto.proname + '</span>'));
+
+ for(i = 0;i < reto.pro.length;i++){
+ pmod_multisub.probox_add(reto.pro[i]);
+ }
+ }
+ });
+ }else if(direct == 'out'){
+ that.fadeout(j_page);
+ }else if(direct == 'same'){
+
+ }
+ };
+ },
+ probox_add:function(proo){
+ var i;
+
+ var j_probox;
+ var j_table;
+ var j_item;
+
+ j_probox = pmod_multisub.j_page.find('table.ori_probox').clone();
+ j_probox.removeClass('ori_probox');
+
+ j_probox.find('td.info > h2.partname').text(proo.partname + ' (' + proo.score + '%)');
+ j_probox.find('td.content').html(proo.content);
+
+ $.post('/toj/php/problem.php',{'action':'get_pro_stat','data':JSON.stringify({'proid':proo.proid})},function(res){
+ var reto
+
+ if(res[0] != 'E'){
+ reto = JSON.parse(res);
+ j_probox.find('td.info > table.statlist td.bscore').text(reto.score);
+ if(reto.tried == false){
+ j_probox.find('td.info > table.statlist td.bscore').css('color','#1C1C1C');
+ j_probox.find('td.info > table.statlist td.stat').text('未嘗試');
+ }else{
+ if(reto.score < 60){
+ j_probox.find('td.info > table.statlist td.bscore').css('color','#FF0000');
+ }else if(reto.score < 80){
+ j_probox.find('td.info > table.statlist td.bscore').css('color','#00FF00');
+ }else if(reto.score < 100){
+ j_probox.find('td.info > table.statlist td.bscore').css('color','#FFFF00');
+ }else{
+
+ j_probox.find('td.info > table.statlist td.bscore').css('color','#FFFFFF');
+ }
+
+ if(reto.is_ac == true){
+ j_probox.find('td.info > table.statlist td.stat').text('已通過');
+ }else{
+ j_probox.find('td.info > table.statlist td.stat').text('已嘗試');
+ }
+ }
+ }
+ });
+
+ j_probox.find('td.info > table.limitlist td.timelimit').text(proo.timelimit + ' ms');
+ j_probox.find('td.info > table.limitlist td.memlimit').text(proo.memlimit + ' KB');
+
+ j_table = j_probox.find('table.scorelist');
+ j_table.find('tr.item').remove();
+ for(i = 0;i < proo.partition.count;i++){
+ j_item = $('<tr class="item"><td class="no"></td><td class="score"></td></tr>');
+ j_item.find('td.no').text(i + 1);
+ j_item.find('td.score').text(proo.partition.score[i]);
+ j_table.append(j_item);
+ }
+
+ j_probox.find('td.info > button.submit').on('click',function(e){
+ pmod_multisub.that.submit(proo.proid);
+ });
+
+ j_probox.show();
+ pmod_multisub.j_page.append(j_probox);
+ }
+};
diff --git a/toj/pmod/pmod_multisub/pmod_multisub.php b/toj/pmod/pmod_multisub/pmod_multisub.php
new file mode 100755
index 0000000..342ff41
--- /dev/null
+++ b/toj/pmod/pmod_multisub/pmod_multisub.php
@@ -0,0 +1,77 @@
+<?php
+require_once('../../php/problem.inc.php');
+
+const PMODNAME = 'pmod_multisub';
+
+function get_set($prodir)
+{
+ $fd = fopen($prodir.'setting','r');
+ while($line = fgets($fd))
+ {
+ if($line[0] == '=')break;
+ }
+ $set = '';
+ while(($line = fgets($fd)))
+ {
+ $set = $set.$line;
+ }
+ fclose($fd);
+ return json_decode($set);
+}
+
+$sqlc = db_connect();
+
+$proid = json_decode($_POST['proid']);
+if(gettype($proid) != 'integer' || $proid < 1){
+ exit('Eproid');
+}
+
+if(!problem::is_available($sqlc, $proid)){
+ exit('Epermission');
+}
+
+$pro = problem::get($sqlc, $proid);
+if($pro->pmodname != PMODNAME)
+ exit('Ewrong_pmod');
+
+$prodir = '/srv/http/toj/center/pro/';
+
+$redir = file_get_contents($prodir.$proid.'/redirect');
+if($redir)
+{
+ $ret = new stdClass();
+ $ret->redirect = intval($redir);
+ exit(json_encode($ret));
+}
+
+$ret = new stdClass();
+
+$mfile = file_get_contents($prodir.$proid.'/multiset');
+$multiset = json_decode($mfile);
+
+$main_cont = file_get_contents($prodir.$proid.'/public/main_content');
+$ret->main_content = $main_cont;
+$ret->pro = array();
+$ret->proname = $multiset->proname;
+
+foreach($multiset->prolist as $spro)
+{
+ $apro = new stdClass();
+ $apro->proid = $spro->proid;
+ $apro->score = $spro->score;
+ $apro->partname = $spro->partname;
+
+ $apro->content = file_get_contents($prodir.$apro->proid.'/public/content');
+ $setting = get_set($prodir.$apro->proid.'/');
+ $apro->timelimit = $setting->timelimit;
+ $apro->memlimit = $setting->memlimit;
+ $apro->partition = new stdClass();
+ $apro->partition->count = $setting->count;
+ $apro->partition->score = $setting->score;
+
+ array_push($ret->pro, $apro);
+}
+
+echo(json_encode($ret));
+db_close($sqlc);
+?>
diff --git a/toj/pmod/pmod_test/pmod_test.css b/toj/pmod/pmod_test/pmod_test.css
new file mode 100755
index 0000000..2cd5bfb
--- /dev/null
+++ b/toj/pmod/pmod_test/pmod_test.css
@@ -0,0 +1,53 @@
+div.pmod_test > div.info{
+ width:250px;
+ height:100%;
+ padding:0px 0px 0px 6px;
+ position:absolute;
+ top:0px;
+ left:0px;
+ overflow:auto;
+}
+div.pmod_test > div.info > table.statlist{
+ width:100%;
+ text-align:left;
+ border-collapse:collapse;
+}
+div.pmod_test > div.info > table.statlist td.name{
+ width:96px;
+}
+div.pmod_test > div.info > table.statlist td.value{
+ width:auto;
+}
+div.pmod_test > div.info > table.limitlist{
+ width:100%;
+ text-align:left;
+ border-collapse:collapse;
+}
+div.pmod_test > div.info > table.limitlist td.name{
+ width:96px
+}
+div.pmod_test > div.info > table.limitlist td.value{
+ width:auto;
+}
+div.pmod_test > div.info > table.scorelist{
+ width:100%;
+ text-align:left;
+ border-collapse:collapse;
+}
+div.pmod_test > div.info > table.scorelist tr.item{
+ font-size:16;
+}
+div.pmod_test > div.info > table.scorelist th.no,div.pmod_test > div.info > table.scorelist td.no{
+ width:64px;
+}
+div.pmod_test > div.info > table.scorelist th.score,div.pmod_test > div.info > table.scorelist td.score{
+ width:auto;
+}
+div.pmod_test > div.content{
+ height:100%;
+ padding:0px 6px 0px 0px;
+ position:absolute;
+ top:0px;
+ left:256px;
+ overflow:auto;
+}
diff --git a/toj/pmod/pmod_test/pmod_test.html b/toj/pmod/pmod_test/pmod_test.html
new file mode 100755
index 0000000..10b297b
--- /dev/null
+++ b/toj/pmod/pmod_test/pmod_test.html
@@ -0,0 +1,37 @@
+<div class="info">
+ <h2 class="proid">ProID:</h2>
+ <button class="submit">上傳</button>
+
+ <h3>狀態</h3>
+ <table class="statlist">
+ <tr>
+ <td class="name">最佳分數</td>
+ <td class="value bscore"></td>
+ </tr>
+ <tr>
+ <td class="name">解題狀態</td>
+ <td class="value stat"></td>
+ </tr>
+ </table>
+
+ <h3>限制</h3>
+ <table class="limitlist">
+ <tr>
+ <td class="name">時間限制</td>
+ <td class="value timelimit"></td>
+ </tr>
+ <tr>
+ <td class="name">記憶體限制</td>
+ <td class="value memlimit"></td>
+ </tr>
+ </table>
+
+ <h3>配分</h3>
+ <table class="scorelist">
+ <tr class="head">
+ <th class="no">#</th>
+ <th class="score">Score</th>
+ </tr>
+ </table>
+</div>
+<div class="content"></div>
diff --git a/toj/pmod/pmod_test/pmod_test.js b/toj/pmod/pmod_test/pmod_test.js
new file mode 100755
index 0000000..c691c8a
--- /dev/null
+++ b/toj/pmod/pmod_test/pmod_test.js
@@ -0,0 +1,74 @@
+var pmod_test = {
+ init:function(that,j_page){
+ that.export_urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_page);
+ j_page.find('div.info > h2.proid').text('ProID:' + that.proid);
+ $.post('/toj/pmod/pmod_test/pmod_test.php',{'proid':JSON.stringify(that.proid)},function(res){
+ var i;
+ var reto;
+ var seto;
+ var j_table;
+ var j_item;
+
+ if(res[0] != 'E'){
+ reto = JSON.parse(res);
+ seto = reto.set;
+ index.setcontent($('<span>' + that.proname + '</span>'));
+ j_page.find('div.content').html(reto.content);
+
+ $.post('/toj/php/problem.php',{'action':'get_pro_stat','data':JSON.stringify({'proid':that.proid})},function(res){
+ var reto
+
+ if(res[0] != 'E'){
+ reto = JSON.parse(res);
+ j_page.find('div.info > table.statlist td.bscore').text(reto.score);
+ if(reto.tried == false){
+ j_page.find('div.info > table.statlist td.bscore').css('color','#1C1C1C');
+ j_page.find('div.info > table.statlist td.stat').text('未嘗試');
+ }else{
+ if(reto.score < 60){
+ j_page.find('div.info > table.statlist td.bscore').css('color','#FF0000');
+ }else if(reto.score < 80){
+ j_page.find('div.info > table.statlist td.bscore').css('color','#00FF00');
+ }else if(reto.score < 100){
+ j_page.find('div.info > table.statlist td.bscore').css('color','#FFFF00');
+ }else{
+
+ j_page.find('div.info > table.statlist td.bscore').css('color','#FFFFFF');
+ }
+
+ if(reto.is_ac == true){
+ j_page.find('div.info > table.statlist td.stat').text('已通過');
+ }else{
+ j_page.find('div.info > table.statlist td.stat').text('已嘗試');
+ }
+ }
+ }
+ });
+
+ j_page.find('div.info > table.limitlist td.timelimit').text(seto.timelimit + ' ms');
+ j_page.find('div.info > table.limitlist td.memlimit').text(seto.memlimit + ' KB');
+
+ j_table = j_page.find('table.scorelist');
+ j_table.find('tr.item').remove();
+ for(i = 0;i < seto.count;i++){
+ j_item = $('<tr class="item"><td class="no"></td><td class="score"></td></tr>');
+ j_item.find('td.no').text(i + 1);
+ j_item.find('td.score').text(seto.score[i]);
+ j_table.append(j_item);
+ }
+ }
+ });
+ }else if(direct == 'out'){
+ that.fadeout(j_page);
+ }else if(direct == 'same'){
+
+ }
+ };
+
+ j_page.find('div.info > button.submit').on('click',function(e){
+ that.submit();
+ });
+ }
+};
diff --git a/toj/pmod/pmod_test/pmod_test.php b/toj/pmod/pmod_test/pmod_test.php
new file mode 100755
index 0000000..27eecf2
--- /dev/null
+++ b/toj/pmod/pmod_test/pmod_test.php
@@ -0,0 +1,42 @@
+<?php
+require_once('../../php/problem.inc.php');
+
+const PMODNAME = 'pmod_test';
+
+$proid = json_decode($_POST['proid']);
+if(gettype($proid) != 'integer' || $proid < 1){
+ exit('Eproid');
+}
+
+$sqlc = db_connect();
+if(!problem::is_available($sqlc,$proid)){
+ exit('Epermission');
+}
+
+$pro = problem::get($sqlc, $proid);
+if($pro->pmodname != PMODNAME)
+ exit('Ewrong_pmod');
+
+db_close($sqlc);
+
+$prodir = '/srv/http/toj/center/pro/'.$proid.'/';
+
+$fd = fopen($prodir.'setting','r');
+while($line = fgets($fd)){
+ if($line[0] == '='){
+ break;
+ }
+}
+$set = '';
+while(($line = fgets($fd))){
+ $set = $set.$line;
+}
+fclose($fd);
+
+$content = file_get_contents($prodir.'public/content');
+
+echo(json_encode(array(
+ 'set' => json_decode($set),
+ 'content' => $content
+)));
+?>