|
128 | 128 | }
|
129 | 129 | }
|
130 | 130 |
|
| 131 | + if ( isset($_POST['sample'][$rank]) ) { |
| 132 | + $DB->q('UPDATE testcase SET sample = %i WHERE probid = %s |
| 133 | + AND rank = %i', $_POST['sample'][$rank], $probid, $rank); |
| 134 | + $result .= "<li>Set testcase $rank to be " . |
| 135 | + ($_POST['sample'][$rank] ? "" : "not ") . |
| 136 | + "a sample testcase</li>\n"; |
| 137 | + } |
| 138 | + |
131 | 139 | if ( isset($_POST['description'][$rank]) ) {
|
132 | 140 | $DB->q('UPDATE testcase SET description = %s WHERE probid = %s
|
133 | 141 | AND rank = %i', $_POST['description'][$rank], $probid, $rank);
|
|
154 | 162 |
|
155 | 163 | if ( !empty($content['input']) && !empty($content['output']) ) {
|
156 | 164 | $DB->q("INSERT INTO testcase
|
157 |
| - (probid,rank,md5sum_input,md5sum_output,input,output,description) |
158 |
| - VALUES (%s,%i,%s,%s,%s,%s,%s)", |
| 165 | + (probid,rank,md5sum_input,md5sum_output,input,output,description,sample) |
| 166 | + VALUES (%s,%i,%s,%s,%s,%s,%s,%i)", |
159 | 167 | $probid, $rank, md5(@$content['input']), md5(@$content['output']),
|
160 |
| - @$content['input'], @$content['output'], @$_POST['add_desc']); |
| 168 | + @$content['input'], @$content['output'], @$_POST['add_desc'], |
| 169 | + @$_POST['add_sample']); |
161 | 170 | auditlog('testcase', $probid, 'added', "rank $rank");
|
162 | 171 |
|
163 | 172 | $result .= "<li>Added new testcase $rank from " .
|
|
172 | 181 | echo "<ul>\n$result</ul>\n\n";
|
173 | 182 |
|
174 | 183 | // Reload testcase data after updates
|
175 |
| - $data = $DB->q('KEYTABLE SELECT rank AS ARRAYKEY, testcaseid, rank, description, |
| 184 | + $data = $DB->q('KEYTABLE SELECT rank AS ARRAYKEY, testcaseid, rank, |
| 185 | + description, sample, |
176 | 186 | OCTET_LENGTH(input) AS size_input, md5sum_input,
|
177 | 187 | OCTET_LENGTH(output) AS size_output, md5sum_output
|
178 | 188 | FROM testcase WHERE probid = %s ORDER BY rank', $probid);
|
|
196 | 206 | <th scope="col">size</th><th scope="col">md5</th>
|
197 | 207 | <?php
|
198 | 208 | if ( IS_ADMIN ) echo '<th scope="col">upload new</th>';
|
199 |
| -?><th scope="col">description</th> |
| 209 | +?><th scope="col">sample</th><th scope="col">description</th> |
200 | 210 | </tr></thead>
|
201 | 211 | <tbody>
|
202 | 212 | <?php
|
|
222 | 232 | }
|
223 | 233 | if ( $inout=='input' ) {
|
224 | 234 | if ( IS_ADMIN ) {
|
| 235 | + echo "<td rowspan=\"2\" align=\"center]\" onclick=\"editTcSample($rank)\">" . |
| 236 | + addSelect("sample[$rank]",array("no", "yes"), $row['sample'], true) . "</td>"; |
| 237 | + |
| 238 | + // hide sample dropdown field if javascript is enabled |
| 239 | + echo "<script type=\"text/javascript\" language=\"JavaScript\">" . |
| 240 | + "hideTcSample($rank, '". printyn($row['sample'])."');</script>"; |
225 | 241 | echo "<td rowspan=\"2\" class=\"testdesc\" onclick=\"editTcDesc($rank)\">" .
|
226 | 242 | "<textarea id=\"tcdesc_$rank\" name=\"description[$rank]\" cols=\"50\" rows=\"2\">" .
|
227 | 243 | htmlspecialchars($row['description']) . "</textarea></td>" .
|
|
235 | 251 | echo "<script type=\"text/javascript\" language=\"JavaScript\">" .
|
236 | 252 | "hideTcDescEdit($rank);</script>";
|
237 | 253 | } else {
|
| 254 | + echo "<td rowspan=\"2\" align=\"center\">" . |
| 255 | + printyn($row['issample']) . "</td>"; |
238 | 256 | echo "<td rowspan=\"2\" class=\"testdesc\">" .
|
239 | 257 | htmlspecialchars($row['description']) . "</td>";
|
240 | 258 | }
|
|
252 | 270 | <table>
|
253 | 271 | <tr><td>Input testdata: </td><td><?php echo addFileField('add_input') ?></td></tr>
|
254 | 272 | <tr><td>Output testdata:</td><td><?php echo addFileField('add_output') ?></td></tr>
|
| 273 | +<tr><td>Sample testcase:</td><td><?php echo addSelect('add_sample', array("no","yes"), 0, true);?></td></tr> |
255 | 274 | <tr><td>Description: </td><td><?php echo addInput('add_desc','',30); ?></td></tr>
|
256 | 275 | </table>
|
257 | 276 | <?php
|
|
0 commit comments