diff options
author | pzread <netfirewall@gmail.com> | 2013-03-01 22:30:00 +0800 |
---|---|---|
committer | pzread <netfirewall@gmail.com> | 2013-03-01 22:30:00 +0800 |
commit | 56688ed6d0b18f68ac8ddd82c4944c5d2777d20a (patch) | |
tree | bb943e164f82b4a826f1d9ce253bfabf912c0004 /toj/pmod/pmod_test | |
parent | 69d7b55a1c9d3100d42b9c91ab995de44b13d73b (diff) | |
download | taiwan-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/pmod_test')
-rwxr-xr-x | toj/pmod/pmod_test/pmod_test.css | 53 | ||||
-rwxr-xr-x | toj/pmod/pmod_test/pmod_test.html | 37 | ||||
-rwxr-xr-x | toj/pmod/pmod_test/pmod_test.js | 74 | ||||
-rwxr-xr-x | toj/pmod/pmod_test/pmod_test.php | 42 |
4 files changed, 206 insertions, 0 deletions
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 +))); +?> |