Description:
fixed problem description refresh bug
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r259:fd4ff20f8070 - - 3 files changed: 22 inserted, 8 deleted
@@ -0,0 +1,17 | |||
|
1 | + <div class="problem-bar" id="problem-bar-<%= problem.id %>"> | |
|
2 | + <% if @page_reload_when_view_problem %> | |
|
3 | + <a href="<%= url_for :action => 'list', :id => problem.id %>"> | |
|
4 | + <% else %> | |
|
5 | + <a href="#" | |
|
6 | + onclick="$$('.problem-panel').each(function(elt) {elt.hide();}); $('problem-panel-<%= problem.id %>').show(); $('problem-panel-filler').hide(); return false;"> | |
|
7 | + <% end %> | |
|
8 | + <span class="problem-title"> | |
|
9 | + <%= problem.full_name %> | |
|
10 | + <% if @prob_submissions[problem_title_counter][:count] > 0 %> | |
|
11 | + [<%= @prob_submissions[problem_title_counter][:count] %> trials(s)] | |
|
12 | + <% else %> | |
|
13 | + [No trials] | |
|
14 | + <% end %> | |
|
15 | + </span> | |
|
16 | + </a> | |
|
17 | + </div> |
@@ -233,155 +233,160 | |||
|
233 | 233 | flash[:notice] = 'You have already submitted an incorrect solution for this input. Please download a new input data.' |
|
234 | 234 | session[:current_problem_id] = problem.id |
|
235 | 235 | redirect_to :action => 'list' and return |
|
236 | 236 | end |
|
237 | 237 | |
|
238 | 238 | if params[:file] == nil |
|
239 | 239 | flash[:notice] = 'You have not submitted any output.' |
|
240 | 240 | session[:current_problem_id] = problem.id |
|
241 | 241 | redirect_to :action => 'list' and return |
|
242 | 242 | end |
|
243 | 243 | |
|
244 | 244 | submitted_solution = params[:file].read |
|
245 | 245 | test_pair = recent_assignment.test_pair |
|
246 | 246 | passed = test_pair.grade(submitted_solution) |
|
247 | 247 | points = passed ? 100 : 0 |
|
248 | 248 | submission = Submission.new(:user => user, |
|
249 | 249 | :problem => problem, |
|
250 | 250 | :source => submitted_solution, |
|
251 | 251 | :source_filename => params['file'].original_filename, |
|
252 | 252 | :language_id => 0, |
|
253 | 253 | :submitted_at => Time.new.gmtime, |
|
254 | 254 | :graded_at => Time.new.gmtime, |
|
255 | 255 | :points => points) |
|
256 | 256 | submission.save |
|
257 | 257 | recent_assignment.submitted = true |
|
258 | 258 | recent_assignment.save |
|
259 | 259 | |
|
260 | 260 | status = user.get_submission_status_for(problem) |
|
261 | 261 | if status == nil |
|
262 | 262 | status = SubmissionStatus.new :user => user, :problem => problem, :submission_count => 0 |
|
263 | 263 | end |
|
264 | 264 | |
|
265 | 265 | status.submission_count += 1 |
|
266 | 266 | status.passed = passed |
|
267 | 267 | status.save |
|
268 | 268 | |
|
269 | 269 | if passed |
|
270 | 270 | flash[:notice] = 'Correct solution.' |
|
271 | 271 | user.update_codejom_status |
|
272 | 272 | else |
|
273 | 273 | session[:current_problem_id] = problem.id |
|
274 | 274 | flash[:notice] = 'Incorrect solution.' |
|
275 | 275 | end |
|
276 | 276 | redirect_to :action => 'list' |
|
277 | 277 | end |
|
278 | 278 | |
|
279 | 279 | def problems |
|
280 | 280 | prepare_list_information |
|
281 | + @page_reload_when_view_problem = true | |
|
281 | 282 | render :partial => 'problem_title', :collection => @problems, :as => :problem |
|
282 | 283 | end |
|
283 | 284 | |
|
284 | 285 | def splash |
|
285 | 286 | render :text => '<div class="notice">Most recent task:</span>' |
|
286 | 287 | end |
|
287 | 288 | |
|
288 | 289 | protected |
|
289 | 290 | |
|
290 | 291 | def prepare_announcements(recent=nil) |
|
291 | 292 | if Configuration.show_tasks_to?(@user) |
|
292 | 293 | @announcements = Announcement.find_published(true) |
|
293 | 294 | else |
|
294 | 295 | @announcements = Announcement.find_published |
|
295 | 296 | end |
|
296 | 297 | if recent!=nil |
|
297 | 298 | recent_id = recent.to_i |
|
298 | 299 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
299 | 300 | end |
|
300 | 301 | end |
|
301 | 302 | |
|
302 | 303 | def prepare_timeout_information(problems) |
|
303 | 304 | @submission_timeouts = {} |
|
304 | 305 | problems.each do |problem| |
|
305 | 306 | assignment = @user.get_recent_test_pair_assignment_for(problem) |
|
306 | 307 | if assignment == nil |
|
307 | 308 | timeout = nil |
|
308 | 309 | else |
|
309 | 310 | if (assignment.expired?) or (assignment.submitted) |
|
310 | 311 | timeout = 0 |
|
311 | 312 | else |
|
312 | 313 | timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime |
|
313 | 314 | end |
|
314 | 315 | end |
|
315 | 316 | @submission_timeouts[problem.id] = timeout |
|
316 | 317 | end |
|
317 | 318 | @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"} |
|
318 | 319 | end |
|
319 | 320 | |
|
320 | 321 | def prepare_list_information |
|
321 | 322 | @user = User.find(session[:user_id]) |
|
322 | 323 | |
|
323 | 324 | all_problems = Problem.find_available_problems |
|
324 | 325 | |
|
325 | 326 | passed = {} |
|
326 | 327 | sub_count = {} |
|
327 | 328 | @user.submission_statuses.each do |status| |
|
328 | 329 | if status.passed |
|
329 | 330 | passed[status.problem_id] = true |
|
330 | 331 | end |
|
331 | 332 | sub_count[status.problem_id] = status.submission_count |
|
332 | 333 | end |
|
333 | 334 | |
|
334 | 335 | if session.has_key? :current_problem_id |
|
335 | 336 | @current_problem_id = session[:current_problem_id] |
|
336 | 337 | session.delete(:current_problem_id) |
|
337 | 338 | else |
|
339 | + if params.has_key? :id | |
|
340 | + @current_problem_id = params[:id].to_i | |
|
341 | + else | |
|
338 | 342 | @current_problem_id = nil |
|
339 | 343 | end |
|
344 | + end | |
|
340 | 345 | |
|
341 | 346 | @problems = all_problems.reject { |problem| passed.has_key? problem.id } |
|
342 | 347 | |
|
343 | 348 | prepare_timeout_information(@problems) |
|
344 | 349 | |
|
345 | 350 | @prob_submissions = Array.new |
|
346 | 351 | @problems.each do |p| |
|
347 | 352 | if sub_count.has_key? p.id |
|
348 | 353 | @prob_submissions << { :count => sub_count[p.id] } |
|
349 | 354 | else |
|
350 | 355 | @prob_submissions << { :count => 0 } |
|
351 | 356 | end |
|
352 | 357 | end |
|
353 | 358 | prepare_announcements |
|
354 | 359 | end |
|
355 | 360 | |
|
356 | 361 | def check_viewability |
|
357 | 362 | @user = User.find(session[:user_id]) |
|
358 | 363 | if (!Configuration.show_tasks_to?(@user)) and |
|
359 | 364 | ((action_name=='submission') or (action_name=='submit')) |
|
360 | 365 | redirect_to :action => 'list' and return |
|
361 | 366 | end |
|
362 | 367 | end |
|
363 | 368 | |
|
364 | 369 | def prepare_grading_result(submission) |
|
365 | 370 | if Configuration.task_grading_info.has_key? submission.problem.name |
|
366 | 371 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
367 | 372 | else |
|
368 | 373 | # guess task info from problem.full_score |
|
369 | 374 | cases = submission.problem.full_score / 10 |
|
370 | 375 | grading_info = { |
|
371 | 376 | 'testruns' => cases, |
|
372 | 377 | 'testcases' => cases |
|
373 | 378 | } |
|
374 | 379 | end |
|
375 | 380 | @test_runs = [] |
|
376 | 381 | if grading_info['testruns'].is_a? Integer |
|
377 | 382 | trun_count = grading_info['testruns'] |
|
378 | 383 | trun_count.times do |i| |
|
379 | 384 | @test_runs << [ read_grading_result(@user.login, |
|
380 | 385 | submission.problem.name, |
|
381 | 386 | submission.id, |
|
382 | 387 | i+1) ] |
|
383 | 388 | end |
|
384 | 389 | else |
|
385 | 390 | grading_info['testruns'].keys.sort.each do |num| |
|
386 | 391 | run = [] |
|
387 | 392 | testrun = grading_info['testruns'][num] |
deleted file |
You need to be logged in to leave comments.
Login now