diff --git a/sql/mysql_db_structure.sql b/sql/mysql_db_structure.sql index 44d5745a85..b5a4045d30 100644 --- a/sql/mysql_db_structure.sql +++ b/sql/mysql_db_structure.sql @@ -358,6 +358,7 @@ CREATE TABLE `testcase` ( `probid` varchar(8) NOT NULL COMMENT 'Corresponding problem ID', `rank` int(4) NOT NULL COMMENT 'Determines order of the testcases in judging', `description` varchar(255) default NULL COMMENT 'Description of this testcase', + `sample` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'Sample testcases can be shared with teams.', PRIMARY KEY (`testcaseid`), UNIQUE KEY `rank` (`probid`,`rank`), KEY `probid` (`probid`), diff --git a/sql/upgrade/upgrade_to-online_judge.sql b/sql/upgrade/upgrade_to-online_judge.sql index 88139fd157..fd4a9b5555 100644 --- a/sql/upgrade/upgrade_to-online_judge.sql +++ b/sql/upgrade/upgrade_to-online_judge.sql @@ -8,12 +8,16 @@ -- -- @UPGRADE-CHECK@ -SELECT 1; +ALTER TABLE `testcase` ADD COLUMN `sample` tinyint(1) default NULL; +ALTER TABLE `testcase` DROP COLUMN `sample`; -- -- Create additional structures -- +ALTER TABLE `testcase` + ADD COLUMN `sample` tinyint(1) unsigned NOT NULL default '0' COMMENT 'Sample testcases can be shared with teams.' AFTER `description`; + -- -- Transfer data from old to new structure -- diff --git a/www/js/domjudge.js b/www/js/domjudge.js index 66cd665b14..f79998c6b4 100644 --- a/www/js/domjudge.js +++ b/www/js/domjudge.js @@ -62,6 +62,31 @@ function hideTcDescEdit(descid) node.parentNode.appendChild(span); } +// make corresponding testcase sample dropdown editable +function editTcSample(tcid) +{ + var node = document.getElementById('sample_' + tcid + '_'); + node.parentNode.setAttribute('onclick', ''); + var remove = node.nextSibling; + while (remove.nodeName == '#text') + remove = remove.nextSibling; + node.parentNode.removeChild(remove); + node.style.display = 'block'; + node.setAttribute('name', 'sample[' + tcid + ']'); +} + +// hides sample dropdown field if javascript is enabled +function hideTcSample(tcid, str) +{ + var node = document.getElementById('sample_' + tcid + '_'); + node.style.display = 'none'; + node.setAttribute('name', 'invalid'); + + var span = document.createElement('span'); + span.innerHTML = str; + node.parentNode.appendChild(span); +} + // Autodetection of problem, language in websubmit function detectProblemLanguage(filename) { diff --git a/www/jury/testcase.php b/www/jury/testcase.php index f7171e2664..253cfccf30 100644 --- a/www/jury/testcase.php +++ b/www/jury/testcase.php @@ -128,6 +128,14 @@ } } + if ( isset($_POST['sample'][$rank]) ) { + $DB->q('UPDATE testcase SET sample = %i WHERE probid = %s + AND rank = %i', $_POST['sample'][$rank], $probid, $rank); + $result .= "
Input testdata: | |
Output testdata: | |
Sample testcase: | |
Description: |
Compilation output is disabled.
\n"; } +if ( @$row['result']!='compiler-error' ) { + $runs = $DB->q('SELECT r.*, t.rank, t.description FROM testcase t + LEFT JOIN judging_run r ON ( r.testcaseid = t.testcaseid AND + r.judgingid = %i ) + WHERE t.probid = %s AND t.sample = 1 ORDER BY rank', + $row['judgingid'], $row['probid']); + + $runinfo = $runs->gettable(); + echo 'Run not finished yet.
\n"; + continue; + } + echo "Description: | " . + htmlspecialchars($run['description']) . " |
Runtime: | $run[runtime] sec |
Result: | $run[runresult] |
". + htmlspecialchars($run['output_run'])."\n\n"; + } else { + echo "
There was no program output.
\n"; + } + echo ""; + echo parseDiff($run['output_diff']); + echo "\n\n"; + } else { + echo "
There was no diff output.
\n"; + } + echo "". + htmlspecialchars($run['output_error'])."\n\n"; + } else { + echo "
There was no stderr output.
\n"; + } + } +} + require(LIBWWWDIR . '/footer.php');