]>
Commit | Line | Data |
---|---|---|
4ed3f8e7 MG |
1 | use utf8; |
2 | package Gruntmaster::Data::Result::Problem; | |
3 | ||
4 | # Created by DBIx::Class::Schema::Loader | |
5 | # DO NOT MODIFY THE FIRST PART OF THIS FILE | |
6 | ||
7 | =head1 NAME | |
8 | ||
be2f7678 | 9 | Gruntmaster::Data::Result::Problem - List of problems |
4ed3f8e7 MG |
10 | |
11 | =cut | |
12 | ||
13 | use strict; | |
14 | use warnings; | |
15 | ||
16 | use base 'DBIx::Class::Core'; | |
17 | ||
18 | =head1 TABLE: C<problems> | |
19 | ||
20 | =cut | |
21 | ||
22 | __PACKAGE__->table("problems"); | |
23 | ||
24 | =head1 ACCESSORS | |
25 | ||
26 | =head2 id | |
27 | ||
28 | data_type: 'text' | |
29 | is_nullable: 0 | |
30 | ||
31 | =head2 author | |
32 | ||
33 | data_type: 'text' | |
85d3f015 | 34 | is_nullable: 1 |
4ed3f8e7 | 35 | |
be2f7678 MG |
36 | Full name(s) of problem author(s)/problemsetter(s)/tester(s)/etc |
37 | ||
6a03bf0d MG |
38 | =head2 writer |
39 | ||
40 | data_type: 'text' | |
41 | is_nullable: 1 | |
42 | ||
be2f7678 MG |
43 | Full name(s) of statement writer(s) (DEPRECATED) |
44 | ||
4ed3f8e7 MG |
45 | =head2 generator |
46 | ||
9bb39921 | 47 | data_type: 'text' |
4ed3f8e7 MG |
48 | is_nullable: 0 |
49 | ||
be2f7678 MG |
50 | Generator class, without the leading Gruntmaster::Daemon::Generator:: |
51 | ||
4ed3f8e7 MG |
52 | =head2 judge |
53 | ||
9bb39921 | 54 | data_type: 'text' |
4ed3f8e7 MG |
55 | is_nullable: 0 |
56 | ||
be2f7678 MG |
57 | Judge class, without the leading Gruntmaster::Daemon::Judge:: |
58 | ||
4ed3f8e7 MG |
59 | =head2 level |
60 | ||
9bb39921 | 61 | data_type: 'text' |
4ed3f8e7 MG |
62 | is_nullable: 0 |
63 | ||
be2f7678 MG |
64 | Problem level, one of beginner, easy, medium, hard |
65 | ||
4ed3f8e7 MG |
66 | =head2 name |
67 | ||
68 | data_type: 'text' | |
69 | is_nullable: 0 | |
70 | ||
71 | =head2 olimit | |
72 | ||
73 | data_type: 'integer' | |
74 | is_nullable: 1 | |
75 | ||
be2f7678 MG |
76 | Output limit (in bytes) |
77 | ||
4ed3f8e7 MG |
78 | =head2 owner |
79 | ||
80 | data_type: 'text' | |
81 | is_foreign_key: 1 | |
82 | is_nullable: 0 | |
83 | ||
84 | =head2 private | |
85 | ||
86 | data_type: 'boolean' | |
b2725d9d | 87 | default_value: false |
4ed3f8e7 MG |
88 | is_nullable: 0 |
89 | ||
90 | =head2 runner | |
91 | ||
9bb39921 | 92 | data_type: 'text' |
4ed3f8e7 MG |
93 | is_nullable: 0 |
94 | ||
be2f7678 MG |
95 | Runner class, without the leading Gruntmaster::Daemon::Runner:: |
96 | ||
1980106a MG |
97 | =head2 solution |
98 | ||
99 | data_type: 'text' | |
100 | is_nullable: 1 | |
101 | ||
be2f7678 MG |
102 | Solution (HTML) |
103 | ||
4ed3f8e7 MG |
104 | =head2 statement |
105 | ||
106 | data_type: 'text' | |
107 | is_nullable: 0 | |
108 | ||
be2f7678 MG |
109 | Statement (HTML) |
110 | ||
4ed3f8e7 MG |
111 | =head2 testcnt |
112 | ||
113 | data_type: 'integer' | |
114 | is_nullable: 0 | |
115 | ||
be2f7678 MG |
116 | Number of tests |
117 | ||
b2725d9d MG |
118 | =head2 tests |
119 | ||
120 | data_type: 'text' | |
121 | is_nullable: 1 | |
122 | ||
be2f7678 MG |
123 | JSON array of test values for ::Runner::File |
124 | ||
4ed3f8e7 MG |
125 | =head2 timeout |
126 | ||
127 | data_type: 'real' | |
128 | is_nullable: 0 | |
129 | ||
be2f7678 MG |
130 | Time limit (in seconds) |
131 | ||
4ed3f8e7 MG |
132 | =head2 value |
133 | ||
134 | data_type: 'integer' | |
aaa9eb7d | 135 | is_nullable: 0 |
4ed3f8e7 | 136 | |
be2f7678 MG |
137 | Problem value when used in a contest. |
138 | ||
85d3f015 MG |
139 | =head2 genformat |
140 | ||
141 | data_type: 'text' | |
142 | is_nullable: 1 | |
143 | ||
be2f7678 MG |
144 | Format (programming language) of the generator if using the Run generator |
145 | ||
85d3f015 MG |
146 | =head2 gensource |
147 | ||
148 | data_type: 'text' | |
149 | is_nullable: 1 | |
150 | ||
be2f7678 MG |
151 | Source code of generator if using the Run generator |
152 | ||
4ed3f8e7 MG |
153 | =head2 verformat |
154 | ||
155 | data_type: 'text' | |
156 | is_nullable: 1 | |
157 | ||
be2f7678 MG |
158 | Format (programming language) of the verifier if using the Verifier runner |
159 | ||
4ed3f8e7 MG |
160 | =head2 versource |
161 | ||
162 | data_type: 'text' | |
163 | is_nullable: 1 | |
164 | ||
be2f7678 MG |
165 | Source code of verifier if using the Verifier runner |
166 | ||
4ed3f8e7 MG |
167 | =cut |
168 | ||
169 | __PACKAGE__->add_columns( | |
170 | "id", | |
171 | { data_type => "text", is_nullable => 0 }, | |
172 | "author", | |
85d3f015 | 173 | { data_type => "text", is_nullable => 1 }, |
6a03bf0d MG |
174 | "writer", |
175 | { data_type => "text", is_nullable => 1 }, | |
4ed3f8e7 | 176 | "generator", |
9bb39921 | 177 | { data_type => "text", is_nullable => 0 }, |
4ed3f8e7 | 178 | "judge", |
9bb39921 | 179 | { data_type => "text", is_nullable => 0 }, |
4ed3f8e7 | 180 | "level", |
9bb39921 | 181 | { data_type => "text", is_nullable => 0 }, |
4ed3f8e7 MG |
182 | "name", |
183 | { data_type => "text", is_nullable => 0 }, | |
184 | "olimit", | |
185 | { data_type => "integer", is_nullable => 1 }, | |
186 | "owner", | |
187 | { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, | |
188 | "private", | |
b2725d9d | 189 | { data_type => "boolean", default_value => \"false", is_nullable => 0 }, |
4ed3f8e7 | 190 | "runner", |
9bb39921 | 191 | { data_type => "text", is_nullable => 0 }, |
1980106a MG |
192 | "solution", |
193 | { data_type => "text", is_nullable => 1 }, | |
4ed3f8e7 MG |
194 | "statement", |
195 | { data_type => "text", is_nullable => 0 }, | |
196 | "testcnt", | |
197 | { data_type => "integer", is_nullable => 0 }, | |
b2725d9d MG |
198 | "tests", |
199 | { data_type => "text", is_nullable => 1 }, | |
4ed3f8e7 MG |
200 | "timeout", |
201 | { data_type => "real", is_nullable => 0 }, | |
202 | "value", | |
aaa9eb7d | 203 | { data_type => "integer", is_nullable => 0 }, |
85d3f015 MG |
204 | "genformat", |
205 | { data_type => "text", is_nullable => 1 }, | |
206 | "gensource", | |
207 | { data_type => "text", is_nullable => 1 }, | |
4ed3f8e7 MG |
208 | "verformat", |
209 | { data_type => "text", is_nullable => 1 }, | |
210 | "versource", | |
211 | { data_type => "text", is_nullable => 1 }, | |
212 | ); | |
213 | ||
214 | =head1 PRIMARY KEY | |
215 | ||
216 | =over 4 | |
217 | ||
218 | =item * L</id> | |
219 | ||
220 | =back | |
221 | ||
222 | =cut | |
223 | ||
224 | __PACKAGE__->set_primary_key("id"); | |
225 | ||
226 | =head1 RELATIONS | |
227 | ||
228 | =head2 contest_problems | |
229 | ||
230 | Type: has_many | |
231 | ||
232 | Related object: L<Gruntmaster::Data::Result::ContestProblem> | |
233 | ||
234 | =cut | |
235 | ||
236 | __PACKAGE__->has_many( | |
237 | "contest_problems", | |
238 | "Gruntmaster::Data::Result::ContestProblem", | |
239 | { "foreign.problem" => "self.id" }, | |
240 | { cascade_copy => 0, cascade_delete => 0 }, | |
241 | ); | |
242 | ||
243 | =head2 jobs | |
244 | ||
245 | Type: has_many | |
246 | ||
247 | Related object: L<Gruntmaster::Data::Result::Job> | |
248 | ||
249 | =cut | |
250 | ||
251 | __PACKAGE__->has_many( | |
252 | "jobs", | |
253 | "Gruntmaster::Data::Result::Job", | |
254 | { "foreign.problem" => "self.id" }, | |
255 | { cascade_copy => 0, cascade_delete => 0 }, | |
256 | ); | |
257 | ||
258 | =head2 opens | |
259 | ||
260 | Type: has_many | |
261 | ||
262 | Related object: L<Gruntmaster::Data::Result::Open> | |
263 | ||
264 | =cut | |
265 | ||
266 | __PACKAGE__->has_many( | |
267 | "opens", | |
268 | "Gruntmaster::Data::Result::Open", | |
269 | { "foreign.problem" => "self.id" }, | |
270 | { cascade_copy => 0, cascade_delete => 0 }, | |
271 | ); | |
272 | ||
273 | =head2 owner | |
274 | ||
275 | Type: belongs_to | |
276 | ||
277 | Related object: L<Gruntmaster::Data::Result::User> | |
278 | ||
279 | =cut | |
280 | ||
281 | __PACKAGE__->belongs_to( | |
282 | "owner", | |
283 | "Gruntmaster::Data::Result::User", | |
284 | { id => "owner" }, | |
9bb39921 | 285 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, |
4ed3f8e7 MG |
286 | ); |
287 | ||
adb42d4d MG |
288 | =head2 problem_statuses |
289 | ||
290 | Type: has_many | |
291 | ||
292 | Related object: L<Gruntmaster::Data::Result::ProblemStatus> | |
293 | ||
294 | =cut | |
295 | ||
296 | __PACKAGE__->has_many( | |
297 | "problem_statuses", | |
298 | "Gruntmaster::Data::Result::ProblemStatus", | |
299 | { "foreign.problem" => "self.id" }, | |
300 | { cascade_copy => 0, cascade_delete => 0 }, | |
301 | ); | |
302 | ||
4ed3f8e7 MG |
303 | =head2 contests |
304 | ||
305 | Type: many_to_many | |
306 | ||
307 | Composing rels: L</contest_problems> -> contest | |
308 | ||
309 | =cut | |
310 | ||
311 | __PACKAGE__->many_to_many("contests", "contest_problems", "contest"); | |
312 | ||
313 | ||
be2f7678 MG |
314 | # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-19 16:54:00 |
315 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QZHyWOWaPmTm/EQ5M22CGA | |
4ed3f8e7 | 316 | |
4a8747ef MG |
317 | sub is_private { |
318 | my ($self, $time) = @_; | |
319 | return 1 if $self->private; | |
320 | grep { $_->contest->is_pending($time) } $self->contest_problems; | |
321 | } | |
322 | ||
323 | sub is_in_archive { | |
324 | my ($self, $time) = @_; | |
325 | 0 == grep { $_->contest->is_running($time) } $self->contest_problems; | |
326 | } | |
327 | ||
328 | sub rerun { | |
329 | $_->rerun for shift->jobs | |
330 | } | |
4ed3f8e7 | 331 | |
4ed3f8e7 | 332 | 1; |
4a8747ef MG |
333 | |
334 | __END__ | |
335 | ||
336 | =head1 METHODS | |
337 | ||
338 | =head2 is_private(I<[$time]>) | |
339 | ||
340 | Returns true if the problem is private at time I<$time> (which defaults to C<time>). | |
341 | ||
342 | =head2 is_in_archive(I<[$time]>) | |
343 | ||
344 | Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>). | |
345 | ||
346 | =head2 rerun | |
347 | ||
348 | Reruns all jobs for this problem. | |
349 | ||
350 | =head1 AUTHOR | |
351 | ||
352 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
353 | ||
354 | =head1 COPYRIGHT AND LICENSE | |
355 | ||
356 | Copyright (C) 2014 by Marius Gavrilescu | |
357 | ||
358 | This library is free software; you can redistribute it and/or modify | |
359 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
360 | at your option, any later version of Perl 5 you may have available. | |
361 | ||
362 | ||
363 | =cut |