-
Notifications
You must be signed in to change notification settings - Fork 0
/
dj.patch
174 lines (159 loc) · 6.18 KB
/
dj.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
diff -aur lib/lib.misc.php lib/lib.misc.php
--- lib/lib.misc.php 2019-04-15 14:22:59.349029276 +0200
+++ lib/lib.misc.php 2019-04-12 20:52:17.760227545 +0200
@@ -95,17 +95,32 @@
*/
function problemVisible($probid)
{
- global $DB, $cdata;
+ global $DB, $cdata, $userdata;
if ( empty($probid) ) return FALSE;
$fdata = calcFreezeData($cdata);
if ( !$fdata['cstarted'] ) return FALSE;
+ // Subquery to see if team solved the prerequisite problem.
+ $teamsolved = ' FALSE %_';
+ if ( !empty($userdata['teamid']) ) {
+ $teamsolved = "EXISTS(SELECT submitid FROM submission s
+ LEFT JOIN judging j USING (submitid)
+ WHERE s.cid = contestproblem.cid
+ AND s.teamid = %i
+ AND s.probid = contestproblem.previd
+ AND j.result = 'correct'
+ AND j.valid = 1)";
+ }
+
return $DB->q('MAYBETUPLE SELECT probid FROM problem
INNER JOIN contestproblem USING (probid)
- WHERE cid = %i AND allow_submit = 1 AND probid = %i',
- $cdata['cid'], $probid) !== NULL;
+ WHERE cid = %i AND allow_submit = 1 AND probid = %i
+ AND ( previd is NULL
+ OR ' . ( $fdata['showfinal'] ? 'TRUE' : 'FALSE' ) . '
+ OR ' . $teamsolved . ' )',
+ $cdata['cid'], $probid, $userdata['teamid']) !== NULL;
}
/**
diff -aur lib/www/common.php lib/www/common.php
--- lib/www/common.php 2019-04-15 14:22:59.353029254 +0200
+++ lib/www/common.php 2019-04-12 21:09:44.786216953 +0200
@@ -1,4 +1,5 @@
<?php
+
/**
* Common functions shared between team/public/jury interface
*
@@ -529,7 +530,7 @@
}
if ( empty($prob) || (!IS_JURY && !problemVisible($probid)) ) {
- error("Problem p$probid not found or not available");
+ error("Problem p$probid not found or not available, you may need to solve another problem first");
}
switch ( $prob['problemtext_type'] ) {
@@ -621,6 +622,7 @@
if ( $res->count() > 0 ) {
echo "<ul>\n";
while($row = $res->next()) {
+ if(problemVisible($row['probid'])) {
print '<li><strong> Problem ' . specialchars($row['shortname']) . ': ' .
specialchars($row['name']) . "</strong><br />\n";
if ( isset($row['problemtext_type']) ) {
@@ -640,6 +642,7 @@
}
}
print "<br /></li>\n";
+ }
}
echo "</ul>\n";
} else {
diff -aur lib/www/printing.php lib/www/printing.php
--- lib/www/printing.php 2019-04-15 14:22:59.353029254 +0200
+++ lib/www/printing.php 2019-04-13 14:10:44.741507433 +0200
@@ -156,11 +156,12 @@
$highlight = "-E" . escapeshellarg($language);
}
- $teamname = $DB->q('MAYBEVALUE SELECT t.name FROM user u
- LEFT JOIN team t USING (teamid)
- WHERE username = %s', $username);
+ $team = $DB->q('TUPLE SELECT t.name, t.room FROM user u
+ LEFT JOIN team t USING (teamid)
+ WHERE username = %s', $username);
- $header = "User: $username Team: $teamname| File: $origname |Page $% of $=";
+ $header = "Team: $username " . $team['name'] . " | " . $team['room']
+ . " | Page $% of $=";
// For debugging or spooling to a different host.
// Also uncomment '-p $tmp' below.
@@ -170,7 +171,8 @@
. " -b " . escapeshellarg($header)
. " -a 0-10 "
. " -f Courier9 "
- //. " -p $tmp "
+ . " -q "
+ . " -p /opt/domjudge/print/" . uniqid(rand(), true) . ".ps "
. escapeshellarg($filename) . " 2>&1";
exec($cmd, $output, $retval);
diff -aur www/jury/contest.php www/jury/contest.php
--- www/jury/contest.php 2019-04-15 14:22:59.561028103 +0200
+++ www/jury/contest.php 2019-04-12 20:19:17.855256768 +0200
@@ -200,7 +200,8 @@
allow_submit: true,
allow_judge: true,
color: '',
- lazy_eval_results: ''
+ lazy_eval_results: '',
+ previd: ''
};
for ( var i = 0; i < current_problems.length; i++ ) {
@@ -217,7 +218,8 @@
.replace(/\{shortname\}/g, contest_problem_data.shortname)
.replace(/\{points\}/g, contest_problem_data.points)
.replace(/\{color\}/g, contest_problem_data.color)
- .replace(/\{lazy_eval_results\}/g, contest_problem_data.lazy_eval_results);
+ .replace(/\{lazy_eval_results\}/g, contest_problem_data.lazy_eval_results)
+ .replace(/\{previd\}/g, contest_problem_data.previd == null ? '' : contest_problem_data.previd);
$('tbody', $table).append(templateContents);
@@ -284,6 +286,9 @@
<?php echo addInputField('number',"data[0][mapping][0][extra][{id}][lazy_eval_results]",
'{lazy_eval_results}', ' style="width:10ex" min="0" max="1"'); ?>
</td>
+ <td>
+ <?php echo addInput("data[0][mapping][0][extra][{id}][previd]", '{previd}'); ?>
+ </td>
</tr>
</script>
<table id="problems_table">
@@ -299,6 +304,7 @@
<a target="_blank" href="http://www.w3schools.com/cssref/css_colornames.asp">
<img src="../images/b_help.png" class="smallpicto" alt="?"></a></th>
<th>lazy eval</th>
+ <th>depends on</th>
</tr>
</thead>
<tbody>
@@ -453,6 +459,7 @@
echo "<th scope=\"col\">allow<br />judge</th>";
echo "<th class=\"sorttable_nosort\" scope=\"col\">colour</th>\n";
echo "<th scope=\"col\">lazy eval</th>\n";
+ echo "<th scope=\"col\">depends on</th>\n";
echo "<th scope=\"col\"></th>\n";
echo "</tr>\n</thead>\n<tbody>\n";
@@ -478,6 +485,7 @@
: '<td>'. $link . ' </a></td>' );
echo "<td>" . $link . ( isset($row['lazy_eval_results']) ?
printyn($row['lazy_eval_results']) : '-' ) . "</a></td>\n";
+ echo "<td>" . ( isset($row['previd']) ? $row['previd'] : '-' ) . "</td>\n";
if ( IS_ADMIN ) {
echo "<td>" .
delLinkMultiple('contestproblem',array('cid','probid'),
diff -aur www/team/index.php www/team/index.php
--- www/team/index.php 2019-04-15 14:22:59.573028036 +0200
+++ www/team/index.php 2019-04-12 20:19:48.103088626 +0200
@@ -83,7 +83,9 @@
$probs = array();
foreach($probdata as $probinfo) {
- $probs[$probinfo['probid']]=$probinfo['shortname'];
+ if(problemVisible($probinfo['probid'])) {
+ $probs[$probinfo['probid']]=$probinfo['shortname'];
+ }
}
$probs[''] = 'problem';
echo addSelect('probid', $probs, '', true);