Description:
merge
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r837:b9faf3362123 - - 7 files changed: 24 inserted, 11 deleted

@@ -64,25 +64,25
64 end
64 end
65
65
66 if (params[:editor_text])
66 if (params[:editor_text])
67 language = Language.find_by_id(params[:language_id])
67 language = Language.find_by_id(params[:language_id])
68 @submission.source = params[:editor_text]
68 @submission.source = params[:editor_text]
69 @submission.source_filename = "live_edit.#{language.ext}"
69 @submission.source_filename = "live_edit.#{language.ext}"
70 @submission.language = language
70 @submission.language = language
71 end
71 end
72
72
73 @submission.submitted_at = Time.new.gmtime
73 @submission.submitted_at = Time.new.gmtime
74 @submission.ip_address = request.remote_ip
74 @submission.ip_address = request.remote_ip
75
75
76 - if GraderConfiguration.time_limit_mode? and user.contest_finished?
76 + if @current_user.admin? == false && GraderConfiguration.time_limit_mode? && @current_user.contest_finished?
77 @submission.errors.add(:base,"The contest is over.")
77 @submission.errors.add(:base,"The contest is over.")
78 prepare_list_information
78 prepare_list_information
79 render :action => 'list' and return
79 render :action => 'list' and return
80 end
80 end
81
81
82 if @submission.valid?(@current_user)
82 if @submission.valid?(@current_user)
83 if @submission.save == false
83 if @submission.save == false
84 flash[:notice] = 'Error saving your submission'
84 flash[:notice] = 'Error saving your submission'
85 elsif Task.create(:submission_id => @submission.id,
85 elsif Task.create(:submission_id => @submission.id,
86 :status => Task::STATUS_INQUEUE) == false
86 :status => Task::STATUS_INQUEUE) == false
87 flash[:notice] = 'Error adding your submission to task queue'
87 flash[:notice] = 'Error adding your submission to task queue'
88 end
88 end
@@ -10,25 +10,25
10
10
11 before_action(only: [:problem_hof]) { |c|
11 before_action(only: [:problem_hof]) { |c|
12 return false unless check_valid_login
12 return false unless check_valid_login
13
13
14 admin_authorization unless GraderConfiguration["right.user_view_submission"]
14 admin_authorization unless GraderConfiguration["right.user_view_submission"]
15 }
15 }
16
16
17 def max_score
17 def max_score
18 end
18 end
19
19
20 def current_score
20 def current_score
21 @problems = Problem.available_problems
21 @problems = Problem.available_problems
22 - if params[:group_id]
22 + if params[:group_id] && params[:users] == 'group'
23 @group = Group.find(params[:group_id])
23 @group = Group.find(params[:group_id])
24 @users = @group.users.where(enabled: true)
24 @users = @group.users.where(enabled: true)
25 else
25 else
26 @users = User.includes(:contests).includes(:contest_stat).where(enabled: true)
26 @users = User.includes(:contests).includes(:contest_stat).where(enabled: true)
27 end
27 end
28 @scorearray = calculate_max_score(@problems, @users,0,0,true)
28 @scorearray = calculate_max_score(@problems, @users,0,0,true)
29
29
30 #rencer accordingly
30 #rencer accordingly
31 if params[:button] == 'download' then
31 if params[:button] == 'download' then
32 csv = gen_csv_from_scorearray(@scorearray,@problems)
32 csv = gen_csv_from_scorearray(@scorearray,@problems)
33 send_data csv, filename: 'max_score.csv'
33 send_data csv, filename: 'max_score.csv'
34 else
34 else
@@ -41,28 +41,30
41 #process parameters
41 #process parameters
42 #problems
42 #problems
43 @problems = []
43 @problems = []
44 if params[:problem_id]
44 if params[:problem_id]
45 params[:problem_id].each do |id|
45 params[:problem_id].each do |id|
46 next unless id.strip != ""
46 next unless id.strip != ""
47 pid = Problem.find_by_id(id.to_i)
47 pid = Problem.find_by_id(id.to_i)
48 @problems << pid if pid
48 @problems << pid if pid
49 end
49 end
50 end
50 end
51
51
52 #users
52 #users
53 - @users = if params[:users] == "all" then
53 + @users = if params[:users] == "group" then
54 + Group.find(params[:group_id]).users.all
55 + elsif params[:users] == 'enabled'
56 + User.includes(:contests).includes(:contest_stat).where(enabled: true)
57 + else
54 User.includes(:contests).includes(:contest_stat)
58 User.includes(:contests).includes(:contest_stat)
55 - else
56 - User.includes(:contests).includes(:contest_stat).where(enabled: true)
57 end
59 end
58
60
59 #set up range from param
61 #set up range from param
60 @since_id = params.fetch(:from_id, 0).to_i
62 @since_id = params.fetch(:from_id, 0).to_i
61 @until_id = params.fetch(:to_id, 0).to_i
63 @until_id = params.fetch(:to_id, 0).to_i
62 @since_id = nil if @since_id == 0
64 @since_id = nil if @since_id == 0
63 @until_id = nil if @until_id == 0
65 @until_id = nil if @until_id == 0
64
66
65 #calculate the routine
67 #calculate the routine
66 @scorearray = calculate_max_score(@problems, @users, @since_id, @until_id)
68 @scorearray = calculate_max_score(@problems, @users, @since_id, @until_id)
67
69
68 #rencer accordingly
70 #rencer accordingly
@@ -86,25 +86,25
86 @task = @submission.task
86 @task = @submission.task
87 @task.status_inqueue! if @task
87 @task.status_inqueue! if @task
88 respond_to do |format|
88 respond_to do |format|
89 format.js
89 format.js
90 end
90 end
91 end
91 end
92
92
93 protected
93 protected
94
94
95 def submission_authorization
95 def submission_authorization
96 #admin always has privileged
96 #admin always has privileged
97 return true if @current_user.admin?
97 return true if @current_user.admin?
98 - return true if @current_user.has_role?('TA') && (['show','download'].include? action_name)
98 + return true if @current_user.has_role?('ta') && (['show','download'].include? action_name)
99
99
100 sub = Submission.find(params[:id])
100 sub = Submission.find(params[:id])
101 if @current_user.available_problems.include? sub.problem
101 if @current_user.available_problems.include? sub.problem
102 return true if GraderConfiguration["right.user_view_submission"] or sub.user == @current_user
102 return true if GraderConfiguration["right.user_view_submission"] or sub.user == @current_user
103 end
103 end
104
104
105 #default to NO
105 #default to NO
106 unauthorized_redirect
106 unauthorized_redirect
107 return false
107 return false
108 end
108 end
109
109
110
110
@@ -1,11 +1,15
1 .container-fluid
1 .container-fluid
2 %h1 Current Score
2 %h1 Current Score
3 = form_tag current_score_report_path, method: 'get' do
3 = form_tag current_score_report_path, method: 'get' do
4 - Show only users from this group
4 + .radio-inline
5 + = radio_button_tag 'users', 'all', (params[:users] == 'all')
6 + = label_tag(:users_all,'Show all users')
7 + %br
8 + .radio-inline
9 + = radio_button_tag 'users', 'group', (params[:users] == 'group')
10 + = label_tag(:users_group, 'Show only users from this group')
5 = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_id]), id: 'group_name',class: 'select2', style: 'width: 20em';
11 = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_id]), id: 'group_name',class: 'select2', style: 'width: 20em';
6 = submit_tag 'Apply',class: 'btn btn-default'
12 = submit_tag 'Apply',class: 'btn btn-default'
7
13
8 %br
14 %br
9 -
10 -
11 = render "score_table"
15 = render "score_table"
@@ -30,20 +30,25
30 .panel.panel-primary
30 .panel.panel-primary
31 .panel-heading
31 .panel-heading
32 Users
32 Users
33 .panel-body
33 .panel-body
34 .radio
34 .radio
35 %label
35 %label
36 = radio_button_tag 'users', 'all', (params[:users] == "all")
36 = radio_button_tag 'users', 'all', (params[:users] == "all")
37 All users
37 All users
38 .radio
38 .radio
39 %label
39 %label
40 = radio_button_tag 'users', 'enabled', (params[:users] == "enabled")
40 = radio_button_tag 'users', 'enabled', (params[:users] == "enabled")
41 Only enabled users
41 Only enabled users
42 + .radio
43 + %label
44 + = radio_button_tag 'users', 'group', (params[:users] == "group")
45 + Only users from this group
46 + = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_id]), id: 'group_name',class: 'select2', style: 'width: 20em';
42 .row
47 .row
43 .col-md-12
48 .col-md-12
44 = button_tag 'Show', class: "btn btn-primary btn-large", value: "show"
49 = button_tag 'Show', class: "btn btn-primary btn-large", value: "show"
45 = button_tag 'Download CSV', class: "btn btn-primary btn-large", value: "download"
50 = button_tag 'Download CSV', class: "btn btn-primary btn-large", value: "download"
46
51
47 - if @scorearray
52 - if @scorearray
48 %h2 Result
53 %h2 Result
49 =render "score_table"
54 =render "score_table"
@@ -80,25 +80,25
80 create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
80 create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
81 t.string "name"
81 t.string "name"
82 t.string "description"
82 t.string "description"
83 t.boolean "enabled", default: true
83 t.boolean "enabled", default: true
84 end
84 end
85
85
86 create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
86 create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
87 t.integer "problem_id", null: false
87 t.integer "problem_id", null: false
88 t.integer "group_id", null: false
88 t.integer "group_id", null: false
89 t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id"
89 t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id"
90 end
90 end
91
91
92 - create_table "groups_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
92 + create_table "groups_users", options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
93 t.integer "group_id", null: false
93 t.integer "group_id", null: false
94 t.integer "user_id", null: false
94 t.integer "user_id", null: false
95 t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
95 t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id"
96 end
96 end
97
97
98 create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
98 create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
99 t.integer "user_id"
99 t.integer "user_id"
100 t.string "ip_address"
100 t.string "ip_address"
101 t.datetime "created_at", null: false
101 t.datetime "created_at", null: false
102 t.datetime "updated_at", null: false
102 t.datetime "updated_at", null: false
103 t.string "status"
103 t.string "status"
104 t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
104 t.index ["updated_at"], name: "index_heart_beats_on_updated_at"
@@ -107,24 +107,25
107 create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
107 create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
108 t.string "name", limit: 10
108 t.string "name", limit: 10
109 t.string "pretty_name"
109 t.string "pretty_name"
110 t.string "ext", limit: 10
110 t.string "ext", limit: 10
111 t.string "common_ext"
111 t.string "common_ext"
112 end
112 end
113
113
114 create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
114 create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
115 t.integer "user_id"
115 t.integer "user_id"
116 t.string "ip_address"
116 t.string "ip_address"
117 t.datetime "created_at", null: false
117 t.datetime "created_at", null: false
118 t.datetime "updated_at", null: false
118 t.datetime "updated_at", null: false
119 + t.index ["user_id"], name: "index_logins_on_user_id"
119 end
120 end
120
121
121 create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
122 create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
122 t.integer "sender_id"
123 t.integer "sender_id"
123 t.integer "receiver_id"
124 t.integer "receiver_id"
124 t.integer "replying_message_id"
125 t.integer "replying_message_id"
125 t.text "body"
126 t.text "body"
126 t.boolean "replied"
127 t.boolean "replied"
127 t.datetime "created_at", null: false
128 t.datetime "created_at", null: false
128 t.datetime "updated_at", null: false
129 t.datetime "updated_at", null: false
129 end
130 end
130
131
@@ -206,24 +207,25
206 t.datetime "submitted_at"
207 t.datetime "submitted_at"
207 t.datetime "compiled_at"
208 t.datetime "compiled_at"
208 t.text "compiler_message"
209 t.text "compiler_message"
209 t.datetime "graded_at"
210 t.datetime "graded_at"
210 t.integer "points"
211 t.integer "points"
211 t.text "grader_comment"
212 t.text "grader_comment"
212 t.integer "number"
213 t.integer "number"
213 t.string "source_filename"
214 t.string "source_filename"
214 t.float "max_runtime"
215 t.float "max_runtime"
215 t.integer "peak_memory"
216 t.integer "peak_memory"
216 t.integer "effective_code_length"
217 t.integer "effective_code_length"
217 t.string "ip_address"
218 t.string "ip_address"
219 + t.index ["submitted_at"], name: "index_submissions_on_submitted_at"
218 t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true
220 t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true
219 t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id"
221 t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id"
220 end
222 end
221
223
222 create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
224 create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t|
223 t.string "name", null: false
225 t.string "name", null: false
224 t.text "description"
226 t.text "description"
225 t.boolean "public"
227 t.boolean "public"
226 t.datetime "created_at", null: false
228 t.datetime "created_at", null: false
227 t.datetime "updated_at", null: false
229 t.datetime "updated_at", null: false
228 end
230 end
229
231
@@ -216,25 +216,25
216 desc = conf[:description]
216 desc = conf[:description]
217 else
217 else
218 desc = ''
218 desc = ''
219 end
219 end
220 create_configuration_key(conf[:key],
220 create_configuration_key(conf[:key],
221 conf[:value_type],
221 conf[:value_type],
222 conf[:default_value],
222 conf[:default_value],
223 desc)
223 desc)
224 end
224 end
225 end
225 end
226
226
227 def seed_roles
227 def seed_roles
228 - Role.find_or_create_by(name: 'TA')
228 + Role.find_or_create_by(name: 'ta')
229 return if Role.find_by_name('admin')
229 return if Role.find_by_name('admin')
230
230
231 role = Role.create(:name => 'admin')
231 role = Role.create(:name => 'admin')
232 user_admin_right = Right.create(:name => 'user_admin',
232 user_admin_right = Right.create(:name => 'user_admin',
233 :controller => 'user_admin',
233 :controller => 'user_admin',
234 :action => 'all')
234 :action => 'all')
235 problem_admin_right = Right.create(:name=> 'problem_admin',
235 problem_admin_right = Right.create(:name=> 'problem_admin',
236 :controller => 'problems',
236 :controller => 'problems',
237 :action => 'all')
237 :action => 'all')
238
238
239 graders_right = Right.create(:name => 'graders_admin',
239 graders_right = Right.create(:name => 'graders_admin',
240 :controller => 'graders',
240 :controller => 'graders',
You need to be logged in to leave comments. Login now