Description:
fixed problem description refresh bug
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

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>
@@ -257,48 +257,49
257 recent_assignment.submitted = true
257 recent_assignment.submitted = true
258 recent_assignment.save
258 recent_assignment.save
259
259
260 status = user.get_submission_status_for(problem)
260 status = user.get_submission_status_for(problem)
261 if status == nil
261 if status == nil
262 status = SubmissionStatus.new :user => user, :problem => problem, :submission_count => 0
262 status = SubmissionStatus.new :user => user, :problem => problem, :submission_count => 0
263 end
263 end
264
264
265 status.submission_count += 1
265 status.submission_count += 1
266 status.passed = passed
266 status.passed = passed
267 status.save
267 status.save
268
268
269 if passed
269 if passed
270 flash[:notice] = 'Correct solution.'
270 flash[:notice] = 'Correct solution.'
271 user.update_codejom_status
271 user.update_codejom_status
272 else
272 else
273 session[:current_problem_id] = problem.id
273 session[:current_problem_id] = problem.id
274 flash[:notice] = 'Incorrect solution.'
274 flash[:notice] = 'Incorrect solution.'
275 end
275 end
276 redirect_to :action => 'list'
276 redirect_to :action => 'list'
277 end
277 end
278
278
279 def problems
279 def problems
280 prepare_list_information
280 prepare_list_information
281 + @page_reload_when_view_problem = true
281 render :partial => 'problem_title', :collection => @problems, :as => :problem
282 render :partial => 'problem_title', :collection => @problems, :as => :problem
282 end
283 end
283
284
284 def splash
285 def splash
285 render :text => '<div class="notice">Most recent task:</span>'
286 render :text => '<div class="notice">Most recent task:</span>'
286 end
287 end
287
288
288 protected
289 protected
289
290
290 def prepare_announcements(recent=nil)
291 def prepare_announcements(recent=nil)
291 if Configuration.show_tasks_to?(@user)
292 if Configuration.show_tasks_to?(@user)
292 @announcements = Announcement.find_published(true)
293 @announcements = Announcement.find_published(true)
293 else
294 else
294 @announcements = Announcement.find_published
295 @announcements = Announcement.find_published
295 end
296 end
296 if recent!=nil
297 if recent!=nil
297 recent_id = recent.to_i
298 recent_id = recent.to_i
298 @announcements = @announcements.find_all { |a| a.id > recent_id }
299 @announcements = @announcements.find_all { |a| a.id > recent_id }
299 end
300 end
300 end
301 end
301
302
302 def prepare_timeout_information(problems)
303 def prepare_timeout_information(problems)
303 @submission_timeouts = {}
304 @submission_timeouts = {}
304 problems.each do |problem|
305 problems.each do |problem|
@@ -314,50 +315,54
314 end
315 end
315 @submission_timeouts[problem.id] = timeout
316 @submission_timeouts[problem.id] = timeout
316 end
317 end
317 @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
318 @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
318 end
319 end
319
320
320 def prepare_list_information
321 def prepare_list_information
321 @user = User.find(session[:user_id])
322 @user = User.find(session[:user_id])
322
323
323 all_problems = Problem.find_available_problems
324 all_problems = Problem.find_available_problems
324
325
325 passed = {}
326 passed = {}
326 sub_count = {}
327 sub_count = {}
327 @user.submission_statuses.each do |status|
328 @user.submission_statuses.each do |status|
328 if status.passed
329 if status.passed
329 passed[status.problem_id] = true
330 passed[status.problem_id] = true
330 end
331 end
331 sub_count[status.problem_id] = status.submission_count
332 sub_count[status.problem_id] = status.submission_count
332 end
333 end
333
334
334 if session.has_key? :current_problem_id
335 if session.has_key? :current_problem_id
335 @current_problem_id = session[:current_problem_id]
336 @current_problem_id = session[:current_problem_id]
336 session.delete(:current_problem_id)
337 session.delete(:current_problem_id)
337 else
338 else
339 + if params.has_key? :id
340 + @current_problem_id = params[:id].to_i
341 + else
338 @current_problem_id = nil
342 @current_problem_id = nil
339 end
343 end
344 + end
340
345
341 @problems = all_problems.reject { |problem| passed.has_key? problem.id }
346 @problems = all_problems.reject { |problem| passed.has_key? problem.id }
342
347
343 prepare_timeout_information(@problems)
348 prepare_timeout_information(@problems)
344
349
345 @prob_submissions = Array.new
350 @prob_submissions = Array.new
346 @problems.each do |p|
351 @problems.each do |p|
347 if sub_count.has_key? p.id
352 if sub_count.has_key? p.id
348 @prob_submissions << { :count => sub_count[p.id] }
353 @prob_submissions << { :count => sub_count[p.id] }
349 else
354 else
350 @prob_submissions << { :count => 0 }
355 @prob_submissions << { :count => 0 }
351 end
356 end
352 end
357 end
353 prepare_announcements
358 prepare_announcements
354 end
359 end
355
360
356 def check_viewability
361 def check_viewability
357 @user = User.find(session[:user_id])
362 @user = User.find(session[:user_id])
358 if (!Configuration.show_tasks_to?(@user)) and
363 if (!Configuration.show_tasks_to?(@user)) and
359 ((action_name=='submission') or (action_name=='submit'))
364 ((action_name=='submission') or (action_name=='submit'))
360 redirect_to :action => 'list' and return
365 redirect_to :action => 'list' and return
361 end
366 end
362 end
367 end
363
368
deleted file
You need to be logged in to leave comments. Login now