Description:
- clean up link to problem stat and user stat
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r606:7b10ea3e4720 - - 6 files changed: 15 inserted, 13 deleted

@@ -88,49 +88,49
88 88
89 89 def forget
90 90 render :action => 'forget', :layout => 'empty'
91 91 end
92 92
93 93 def retrieve_password
94 94 email = params[:email]
95 95 user = User.find_by_email(email)
96 96 if user
97 97 last_updated_time = user.updated_at || user.created_at || (Time.now.gmtime - 1.hour)
98 98 if last_updated_time > Time.now.gmtime - 5.minutes
99 99 flash[:notice] = 'The account has recently created or new password has recently been requested. Please wait for 5 minutes'
100 100 else
101 101 user.password = user.password_confirmation = User.random_password
102 102 user.save
103 103 send_new_password_email(user)
104 104 flash[:notice] = 'New password has been mailed to you.'
105 105 end
106 106 else
107 107 flash[:notice] = I18n.t 'registration.password_retrieval.no_email'
108 108 end
109 109 redirect_to :action => 'forget'
110 110 end
111 111
112 - def profile
112 + def stat
113 113 @user = User.find(params[:id])
114 114 @submission = Submission.includes(:problem).where(user_id: params[:id])
115 115
116 116 range = 120
117 117 @histogram = { data: Array.new(range,0), summary: {} }
118 118 @summary = {count: 0, solve: 0, attempt: 0}
119 119 problem = Hash.new(0)
120 120
121 121 @submission.find_each do |sub|
122 122 #histogram
123 123 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
124 124 @histogram[:data][d.to_i] += 1 if d < range
125 125
126 126 @summary[:count] += 1
127 127 next unless sub.problem
128 128 problem[sub.problem] = [problem[sub.problem], ( (sub.try(:points) || 0) >= sub.problem.full_score) ? 1 : 0].max
129 129 end
130 130
131 131 @histogram[:summary][:max] = [@histogram[:data].max,1].max
132 132 @summary[:attempt] = problem.count
133 133 problem.each_value { |v| @summary[:solve] += 1 if v == 1 }
134 134 end
135 135
136 136 def toggle_activate
@@ -32,51 +32,51
32 32 = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes}
33 33
34 34 %h2 Stalled graders
35 35
36 36 = render :partial => 'grader_list', :locals => {:grader_list => @stalled_processes}
37 37
38 38 %h2 Terminated graders
39 39
40 40 %p= link_to 'Clear data for terminated graders', { action: 'clear_terminated'}, class: 'btn btn-default', method: 'post'
41 41
42 42 = render :partial => 'grader_list', :locals => {:grader_list => @terminated_processes}
43 43 .col-md-6
44 44 %h2 Last 20 submissions
45 45 %table.table.table-striped.table-condensed
46 46 %thead
47 47 %th ID
48 48 %th User
49 49 %th Problem
50 50 %th Submitted
51 51 %th Graded
52 52 %th Result
53 53 %tbody
54 54 - @submission.each do |sub|
55 55 %tr.inactive
56 - %td= link_to sub.id, controller: 'graders' ,action: 'submission', id: sub.id
57 - %td= sub.try(:user).try(:full_name)
58 - %td= sub.try(:problem).try(:full_name)
56 + %td= link_to sub.id, submission_path(sub.id)
57 + %td= link_to sub.try(:user).try(:full_name), stat_user_path(sub.user.id)
58 + %td= link_to sub.try(:problem).try(:full_name), stat_problem_path(sub.problem.id)
59 59 %td= "#{time_ago_in_words(sub.submitted_at)} ago"
60 60 %td= sub.graded_at ? "#{time_ago_in_words(sub.graded_at)} ago" : " "
61 61 %td= sub.grader_comment
62 62 %h2 Ungraded submission
63 63 %table.table.table-striped.table-condensed
64 64 %thead
65 65 %th ID
66 66 %th User
67 67 %th Problem
68 68 %th Submitted
69 69 %th Graded
70 70 %th Result
71 71 %tbody
72 72 - @backlog_submission.each do |sub|
73 73 %tr.inactive
74 - %td= link_to sub.id, controller: 'graders' ,action: 'submission', id: sub.id
75 - %td= sub.try(:user).try(:full_name)
76 - %td= sub.try(:problem).try(:full_name)
74 + %td= link_to sub.id, submission_path(sub.id)
75 + %td= link_to sub.try(:user).try(:full_name), stat_user_path(sub.user.id)
76 + %td= link_to sub.try(:problem).try(:full_name), stat_problem_path(sub.problem.id)
77 77 %td= "#{time_ago_in_words(sub.submitted_at)} ago"
78 78 %td= sub.graded_at ? "#{time_ago_in_words(sub.graded_at)} ago" : " "
79 79 %td= sub.grader_comment
80 80
81 81
82 82
@@ -20,34 +20,34
20 20 %td Solved/Attempted User
21 21 %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
22 22
23 23 %h2 Submissions Count
24 24 = render partial: 'application/bar_graph', locals: { histogram: @histogram }
25 25
26 26 %h2 Submissions
27 27 - if @submissions and @submissions.count > 0
28 28 %table.info#main_table
29 29 %thead
30 30 %tr.info-head
31 31 %th ID
32 32 %th Login
33 33 %th Name
34 34 %th Submitted_at
35 35 %th Points
36 36 %th comment
37 37 %th IP
38 38 %tbody
39 39 - row_odd,curr = true,''
40 40 - @submissions.each do |sub|
41 41 - next unless sub.user
42 42 - row_odd,curr = !row_odd, sub.user if curr != sub.user
43 43 %tr{class: row_odd ? "info-odd" : "info-even"}
44 - %td= link_to sub.id, controller: 'graders', action: 'submission', id: sub.id
45 - %td= link_to sub.user.login, controller: :users, action: :profile, id: sub.user.id
44 + %td= link_to sub.id, submission_path(sub)
45 + %td= link_to sub.user.login, stat_user_path(sub.user)
46 46 %td= sub.user.full_name
47 47 %td= time_ago_in_words(sub.submitted_at) + " ago"
48 48 %td= sub.points
49 49 %td.fix-width= sub.grader_comment
50 50 %td= sub.ip_address
51 51 - else
52 52 No submission
53 53
@@ -8,58 +8,58
8 8 //=@formatted_code.html_safe
9 9 .containter
10 10 .row
11 11 .col-md-7
12 12 %h2 Source Code
13 13 .col-md-5
14 14 %h2 Stat
15 15 .row
16 16 .col-md-7
17 17 %div#editor{ style: "font-size: 14px; height: 400px; border-radius:5px;" }
18 18 :javascript
19 19 e = ace.edit("editor")
20 20 e.setOptions({ maxLines: Infinity })
21 21 e.setValue($("#data").text())
22 22 e.gotoLine(1)
23 23 e.getSession().setMode("#{get_ace_mode(@submission.language)}")
24 24 e.setReadOnly(true)
25 25 .col-md-5
26 26 %table.table.table-striped
27 27 %tr
28 28 %td.text-right
29 29 %strong User
30 30 %td
31 31 - if @submission.user
32 - = link_to "(#{@submission.user.login})", controller: "users", action: "profile", id: @submission.user
32 + = link_to "#{@submission.user.login}", stat_user_path(@submission.user)
33 33 = @submission.user.full_name
34 34 - else
35 35 = "(n/a)"
36 36 %tr
37 37 %td.text-right
38 38 %strong Task
39 39 %td
40 40 - if @submission.problem!=nil
41 - = link_to "(#{@submission.problem.name})", controller: "problems", action: "stat", id: @submission.problem
41 + = link_to "[#{@submission.problem.name}]", stat_problem_path(@submission.problem)
42 42 = @submission.problem.full_name
43 43 - else
44 44 = "(n/a)"
45 45 %tr
46 46 %td.text-right
47 47 %strong Tries
48 48 %td= @submission.number
49 49 %tr
50 50 %td.text-right
51 51 %strong Language
52 52 %td= @submission.language.pretty_name
53 53 %tr
54 54 %td.text-right
55 55 %strong Submitted
56 56 %td #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
57 57 %tr
58 58 %td.text-right
59 59 %strong Graded
60 60 - if @submission.graded_at
61 61 %td #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
62 62 - else
63 63 %td -
64 64 %tr
65 65 %td.text-right
@@ -31,36 +31,36
31 31 %td.info_param Solved/Attempted Problem
32 32 %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
33 33
34 34 %h2 Submission History
35 35
36 36 =render partial: 'application/bar_graph', locals: {histogram: @histogram, param: {bar_width: 7}}
37 37
38 38
39 39 %table.tablesorter-cafe#submission_table
40 40 %thead
41 41 %tr
42 42 %th ID
43 43 %th Problem code
44 44 %th Problem full name
45 45 %th Language
46 46 %th Submitted at
47 47 %th Result
48 48 %th Score
49 49 - if session[:admin]
50 50 %th IP
51 51 %tbody
52 52 - @submission.each do |s|
53 53 - next unless s.problem
54 54 %tr
55 - %td= link_to "#{s.id}", controller: "graders", action: "submission", id: s.id
56 - %td= link_to s.problem.name, controller: "problems", action: "stat", id: s.problem
55 + %td= link_to s.id, submission_path(s)
56 + %td= link_to s.problem.name, stat_problem_path(s.problem)
57 57 %td= s.problem.full_name
58 58 %td= s.language.pretty_name
59 59 %td #{s.submitted_at.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(s.submitted_at)} ago)
60 60 %td.fix-width= s.grader_comment
61 61 %td= ( s.try(:points) ? (s.points*100/s.problem.full_score) : '' )
62 62 - if session[:admin]
63 63 %td= s.ip_address
64 64
65 65
66 66
@@ -1,57 +1,59
1 1 CafeGrader::Application.routes.draw do
2 2 get "sources/direct_edit"
3 3
4 4 root :to => 'main#login'
5 5
6 6 resources :contests
7 7
8 8 resources :sites
9 9
10 10 resources :announcements do
11 11 member do
12 12 get 'toggle','toggle_front'
13 13 end
14 14 end
15 15
16 16 resources :problems do
17 17 member do
18 18 get 'toggle'
19 19 get 'toggle_test'
20 + get 'stat'
20 21 end
21 22 collection do
22 23 get 'turn_all_off'
23 24 get 'turn_all_on'
24 25 get 'import'
25 26 get 'manage'
26 27 end
27 28 end
28 29
29 30 resources :grader_configuration, controller: 'configurations'
30 31
31 32 resources :users do
32 33 member do
33 34 get 'toggle_activate', 'toggle_enable'
35 + get 'stat'
34 36 end
35 37 end
36 38
37 39 resources :submissions do
38 40 collection do
39 41 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
40 42 get 'direct_edit_problem/:problem_id', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem'
41 43 get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status'
42 44 end
43 45 end
44 46
45 47 match 'tasks/view/:file.:ext' => 'tasks#view'
46 48 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
47 49 match 'heartbeat/:id/edit' => 'heartbeat#edit'
48 50
49 51 #main
50 52 get "main/list"
51 53 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
52 54
53 55 #report
54 56 get 'report/current_score', to: 'report#current_score', as: 'report_current_score'
55 57 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
56 58 get "report/login"
57 59 get 'report/max_score', to: 'report#max_score', as: 'report_max_score'
You need to be logged in to leave comments. Login now