Description:
- remove inplace editor from view - add link to edit announcement directly - modify submission_short display button
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r598:db36298d10ca - - 4 files changed: 55 inserted, 22 deleted

@@ -6,59 +6,63
6 return false unless authenticate
6 return false unless authenticate
7
7
8 if GraderConfiguration["right.user_view_submission"]
8 if GraderConfiguration["right.user_view_submission"]
9 return true;
9 return true;
10 end
10 end
11
11
12 admin_authorization
12 admin_authorization
13 }
13 }
14
14
15 def max_score
15 def max_score
16 end
16 end
17
17
18 + def current_score
19 + @problems = Problem.find_available_problems
20 + @users = User.includes(:contests).includes(:contest_stat).where(enabled: true)
21 + @scorearray = calculate_max_score(problems, users,0,0,{max: true})
22 +
23 + #rencer accordingly
24 + if params[:commit] == 'download csv' then
25 + csv = gen_csv_from_scorearray(@scorearray,@problems)
26 + send_data csv, filename: 'max_score.csv'
27 + else
28 + #render template: 'user_admin/user_stat'
29 + render 'current_score'
30 + end
31 + end
32 +
18 def show_max_score
33 def show_max_score
19 #process parameters
34 #process parameters
20 #problems
35 #problems
21 @problems = []
36 @problems = []
22 params[:problem_id].each do |id|
37 params[:problem_id].each do |id|
23 next unless id.strip != ""
38 next unless id.strip != ""
24 @problems << Problem.find(id.to_i)
39 @problems << Problem.find(id.to_i)
25 end
40 end
26
41
27 #users
42 #users
28 @users = if params[:user] == "all" then
43 @users = if params[:user] == "all" then
29 User.find(:all, :include => [:contests, :contest_stat])
44 User.find(:all, :include => [:contests, :contest_stat])
30 else
45 else
31 User.includes(:contests).includes(:contest_stat).where(enabled: true)
46 User.includes(:contests).includes(:contest_stat).where(enabled: true)
32 end
47 end
33
48
34 #set up range from param
49 #set up range from param
35 since_id = params.fetch(:min_id, 0).to_i
50 since_id = params.fetch(:min_id, 0).to_i
36 until_id = params.fetch(:max_id, 0).to_i
51 until_id = params.fetch(:max_id, 0).to_i
37
52
38 - #get data
53 + #calculate the routine
39 - @scorearray = Array.new
54 + @scorearray = calculate_max_score(problems, users,since_id,until_id)
40 - @users.each do |u|
41 - ustat = Array.new
42 - ustat[0] = u
43 - @problems.each do |p|
44 - max_points = 0
45 - Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub|
46 - max_points = sub.points if sub and sub.points and (sub.points > max_points)
47 - end
48 - ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)]
49 - end
50 - @scorearray << ustat
51 - end
52
55
56 + #rencer accordingly
53 if params[:commit] == 'download csv' then
57 if params[:commit] == 'download csv' then
54 csv = gen_csv_from_scorearray(@scorearray,@problems)
58 csv = gen_csv_from_scorearray(@scorearray,@problems)
55 send_data csv, filename: 'max_score.csv'
59 send_data csv, filename: 'max_score.csv'
56 else
60 else
57 #render template: 'user_admin/user_stat'
61 #render template: 'user_admin/user_stat'
58 render 'max_score'
62 render 'max_score'
59 end
63 end
60
64
61 end
65 end
62
66
63 def score
67 def score
64 if params[:commit] == 'download csv'
68 if params[:commit] == 'download csv'
@@ -439,14 +443,42
439 ORDER BY submitted_at
443 ORDER BY submitted_at
440 SQL
444 SQL
441
445
442 p = [@st,@since_time,@until_time] + @sid + [@since_time,@until_time] + @sid
446 p = [@st,@since_time,@until_time] + @sid + [@since_time,@until_time] + @sid
443 @logs = Submission.joins(:problem).find_by_sql(p)
447 @logs = Submission.joins(:problem).find_by_sql(p)
444
448
445
449
446
450
447
451
448
452
449 end
453 end
450
454
455 + protected
456 +
457 + def calculate_max_score(problems, users,since_id,until_id, get_last_score = false)
458 + scorearray = Array.new
459 + users.each do |u|
460 + ustat = Array.new
461 + ustat[0] = u
462 + problems.each do |p|
463 + unless get_last_score
464 + #get max score
465 + max_points = 0
466 + Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub|
467 + max_points = sub.points if sub and sub.points and (sub.points > max_points)
468 + end
469 + ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)]
470 + else
471 + #get latest score
472 + sub = Submission.find_last_by_user_and_problem(u.id,p.id)
473 + if (sub!=nil) and (sub.points!=nil) and p and p.full_score
474 + ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
475 + else
476 + ustat << [0,false]
477 + end
478 + end
479 + scorearray << ustat
480 + end
481 + return scorearray
482 + end
451
483
452 end
484 end
@@ -1,13 +1,15
1 %li.list-group-item
1 %li.list-group-item
2 %strong
2 %strong
3 = announcement.title
3 = announcement.title
4 + - if @current_user.admin?
5 + = link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-xs btn-default'
4 %small= "(updated #{time_ago_in_words(announcement.updated_at)} ago on #{announcement.updated_at})"
6 %small= "(updated #{time_ago_in_words(announcement.updated_at)} ago on #{announcement.updated_at})"
5
7
6 %br
8 %br
7 = markdown(announcement.body)
9 = markdown(announcement.body)
8 :javascript
10 :javascript
9 Announcement.updateRecentId(#{announcement.id});
11 Announcement.updateRecentId(#{announcement.id});
10 - if (defined? announcement_effect) and announcement_effect
12 - if (defined? announcement_effect) and announcement_effect
11 :javascript
13 :javascript
12 $("announcement-#{announcement.id}").blindDown({duration: 0.2});
14 $("announcement-#{announcement.id}").blindDown({duration: 0.2});
13 $("announcement-#{announcement.id}").appear({duration: 0.5, queue: 'end'});
15 $("announcement-#{announcement.id}").appear({duration: 0.5, queue: 'end'});
@@ -11,17 +11,16
11 %br
11 %br
12 - if GraderConfiguration['ui.show_score']
12 - if GraderConfiguration['ui.show_score']
13 %strong= t 'main.score'
13 %strong= t 'main.score'
14 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 = "#{(submission.points*100/submission.problem.full_score).to_i} "
15 = " ["
15 = " ["
16 %tt
16 %tt
17 = submission.grader_comment
17 = submission.grader_comment
18 = "]"
18 = "]"
19 %br
19 %br
20 %strong View:
20 %strong View:
21 - if GraderConfiguration.show_grading_result
21 - if GraderConfiguration.show_grading_result
22 = link_to '[detailed result]', :action => 'result', :id => submission.id
22 = link_to '[detailed result]', :action => 'result', :id => submission.id
23 - = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
23 + = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
24 - = " | "
24 + = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info'
25 - = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
25 + = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
26 - = " | "
26 +
27 - = link_to "[#{t 'main.submissions_link'}]", problem_submissions_path(problem_id)
@@ -24,27 +24,27
24 %th Date added
24 %th Date added
25 %th.text-center
25 %th.text-center
26 Avail?
26 Avail?
27 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?]
27 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?]
28 %th.text-center
28 %th.text-center
29 Test?
29 Test?
30 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?]
30 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?]
31 - if GraderConfiguration.multicontests?
31 - if GraderConfiguration.multicontests?
32 %th Contests
32 %th Contests
33 - for problem in @problems
33 - for problem in @problems
34 %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
34 %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
35 - @problem=problem
35 - @problem=problem
36 - %td= in_place_editor_field :problem, :name, {}, :rows=>1
36 + %td= problem.name #in_place_editor_field :problem, :name, {}, :rows=>1
37 - %td= in_place_editor_field :problem, :full_name, {}, :rows=>1
37 + %td= problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1
38 - %td.text-right= in_place_editor_field :problem, :full_score, {}, :rows=>1
38 + %td.text-right= problem.full_score #in_place_editor_field :problem, :full_score, {}, :rows=>1
39 %td= problem.date_added
39 %td= problem.date_added
40 %td= toggle_button(@problem.available?, toggle_problem_url(@problem), "problem-avail-#{@problem.id}")
40 %td= toggle_button(@problem.available?, toggle_problem_url(@problem), "problem-avail-#{@problem.id}")
41 %td= toggle_button(@problem.test_allowed?, toggle_test_problem_url(@problem), "problem-test-#{@problem.id}")
41 %td= toggle_button(@problem.test_allowed?, toggle_test_problem_url(@problem), "problem-test-#{@problem.id}")
42 - if GraderConfiguration.multicontests?
42 - if GraderConfiguration.multicontests?
43 %td
43 %td
44 = problem.contests.collect { |c| c.name }.join(', ')
44 = problem.contests.collect { |c| c.name }.join(', ')
45 %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block'
45 %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block'
46 %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-info btn-xs btn-block'
46 %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-info btn-xs btn-block'
47 %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-info btn-xs btn-block'
47 %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-info btn-xs btn-block'
48 %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-xs btn-block'
48 %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-xs btn-block'
49 %br/
49 %br/
50 = link_to '[New problem]', :action => 'new'
50 = link_to '[New problem]', :action => 'new'
You need to be logged in to leave comments. Login now