Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r837:b9faf3362123 - - 7 files changed: 24 inserted, 11 deleted
@@ -28,97 +28,97 | |||||
|
28 | # explicitly specify /login |
|
28 | # explicitly specify /login |
|
29 | # |
|
29 | # |
|
30 | # logger.info "PATH: #{request.path}" |
|
30 | # logger.info "PATH: #{request.path}" |
|
31 | # if GraderConfiguration['system.single_user_mode'] and |
|
31 | # if GraderConfiguration['system.single_user_mode'] and |
|
32 | # request.path!='/main/login' |
|
32 | # request.path!='/main/login' |
|
33 | # @hidelogin = true |
|
33 | # @hidelogin = true |
|
34 | # end |
|
34 | # end |
|
35 |
|
35 | ||
|
36 | @announcements = Announcement.frontpage |
|
36 | @announcements = Announcement.frontpage |
|
37 | render :action => 'login', :layout => 'empty' |
|
37 | render :action => 'login', :layout => 'empty' |
|
38 | end |
|
38 | end |
|
39 |
|
39 | ||
|
40 | def logout |
|
40 | def logout |
|
41 | reset_session |
|
41 | reset_session |
|
42 | redirect_to root_path |
|
42 | redirect_to root_path |
|
43 | end |
|
43 | end |
|
44 |
|
44 | ||
|
45 | def list |
|
45 | def list |
|
46 | prepare_list_information |
|
46 | prepare_list_information |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
49 | def help |
|
49 | def help |
|
50 | @user = User.find(session[:user_id]) |
|
50 | @user = User.find(session[:user_id]) |
|
51 | end |
|
51 | end |
|
52 |
|
52 | ||
|
53 | def submit |
|
53 | def submit |
|
54 | user = User.find(session[:user_id]) |
|
54 | user = User.find(session[:user_id]) |
|
55 |
|
55 | ||
|
56 | @submission = Submission.new |
|
56 | @submission = Submission.new |
|
57 | @submission.problem_id = params[:submission][:problem_id] |
|
57 | @submission.problem_id = params[:submission][:problem_id] |
|
58 | @submission.user = user |
|
58 | @submission.user = user |
|
59 | @submission.language_id = 0 |
|
59 | @submission.language_id = 0 |
|
60 | if (params['file']) and (params['file']!='') |
|
60 | if (params['file']) and (params['file']!='') |
|
61 | @submission.source = File.open(params['file'].path,'r:UTF-8',&:read) |
|
61 | @submission.source = File.open(params['file'].path,'r:UTF-8',&:read) |
|
62 | @submission.source.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') |
|
62 | @submission.source.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') |
|
63 | @submission.source_filename = params['file'].original_filename |
|
63 | @submission.source_filename = params['file'].original_filename |
|
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? |
|
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 |
|
89 | else |
|
89 | else |
|
90 | prepare_list_information |
|
90 | prepare_list_information |
|
91 | render :action => 'list' and return |
|
91 | render :action => 'list' and return |
|
92 | end |
|
92 | end |
|
93 | redirect_to edit_submission_path(@submission) |
|
93 | redirect_to edit_submission_path(@submission) |
|
94 | end |
|
94 | end |
|
95 |
|
95 | ||
|
96 | def source |
|
96 | def source |
|
97 | submission = Submission.find(params[:id]) |
|
97 | submission = Submission.find(params[:id]) |
|
98 | if ((submission.user_id == session[:user_id]) and |
|
98 | if ((submission.user_id == session[:user_id]) and |
|
99 | (submission.problem != nil) and |
|
99 | (submission.problem != nil) and |
|
100 | (submission.problem.available)) |
|
100 | (submission.problem.available)) |
|
101 | send_data(submission.source, |
|
101 | send_data(submission.source, |
|
102 | {:filename => submission.download_filename, |
|
102 | {:filename => submission.download_filename, |
|
103 | :type => 'text/plain'}) |
|
103 | :type => 'text/plain'}) |
|
104 | else |
|
104 | else |
|
105 | flash[:notice] = 'Error viewing source' |
|
105 | flash[:notice] = 'Error viewing source' |
|
106 | redirect_to :action => 'list' |
|
106 | redirect_to :action => 'list' |
|
107 | end |
|
107 | end |
|
108 | end |
|
108 | end |
|
109 |
|
109 | ||
|
110 | def compiler_msg |
|
110 | def compiler_msg |
|
111 | @submission = Submission.find(params[:id]) |
|
111 | @submission = Submission.find(params[:id]) |
|
112 | if @submission.user_id == session[:user_id] |
|
112 | if @submission.user_id == session[:user_id] |
|
113 | render :action => 'compiler_msg', :layout => 'empty' |
|
113 | render :action => 'compiler_msg', :layout => 'empty' |
|
114 | else |
|
114 | else |
|
115 | flash[:notice] = 'Error viewing source' |
|
115 | flash[:notice] = 'Error viewing source' |
|
116 | redirect_to :action => 'list' |
|
116 | redirect_to :action => 'list' |
|
117 | end |
|
117 | end |
|
118 | end |
|
118 | end |
|
119 |
|
119 | ||
|
120 | def result |
|
120 | def result |
|
121 | if !GraderConfiguration.show_grading_result |
|
121 | if !GraderConfiguration.show_grading_result |
|
122 | redirect_to :action => 'list' and return |
|
122 | redirect_to :action => 'list' and return |
|
123 | end |
|
123 | end |
|
124 | @user = User.find(session[:user_id]) |
|
124 | @user = User.find(session[:user_id]) |
@@ -1,104 +1,106 | |||||
|
1 | require 'csv' |
|
1 | require 'csv' |
|
2 |
|
2 | ||
|
3 | class ReportController < ApplicationController |
|
3 | class ReportController < ApplicationController |
|
4 |
|
4 | ||
|
5 | before_action :check_valid_login |
|
5 | before_action :check_valid_login |
|
6 |
|
6 | ||
|
7 | before_action :admin_authorization, only: [:login_stat,:submission, :submission_query, |
|
7 | before_action :admin_authorization, only: [:login_stat,:submission, :submission_query, |
|
8 | :login, :login_detail_query, :login_summary_query, |
|
8 | :login, :login_detail_query, :login_summary_query, |
|
9 | :stuck, :cheat_report, :cheat_scrutinize, :show_max_score, :current_score] |
|
9 | :stuck, :cheat_report, :cheat_scrutinize, :show_max_score, :current_score] |
|
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 |
|
35 | #render template: 'user_admin/user_stat' |
|
35 | #render template: 'user_admin/user_stat' |
|
36 | render 'current_score' |
|
36 | render 'current_score' |
|
37 | end |
|
37 | end |
|
38 | end |
|
38 | end |
|
39 |
|
39 | ||
|
40 | def show_max_score |
|
40 | def show_max_score |
|
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] == " |
|
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 |
|
69 | if params[:button] == 'download' then |
|
71 | if params[:button] == 'download' then |
|
70 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
72 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
71 | send_data csv, filename: 'max_score.csv' |
|
73 | send_data csv, filename: 'max_score.csv' |
|
72 | else |
|
74 | else |
|
73 | #render template: 'user_admin/user_stat' |
|
75 | #render template: 'user_admin/user_stat' |
|
74 | render 'max_score' |
|
76 | render 'max_score' |
|
75 | end |
|
77 | end |
|
76 |
|
78 | ||
|
77 | end |
|
79 | end |
|
78 |
|
80 | ||
|
79 | def score |
|
81 | def score |
|
80 | if params[:commit] == 'download csv' |
|
82 | if params[:commit] == 'download csv' |
|
81 | @problems = Problem.all |
|
83 | @problems = Problem.all |
|
82 | else |
|
84 | else |
|
83 | @problems = Problem.available_problems |
|
85 | @problems = Problem.available_problems |
|
84 | end |
|
86 | end |
|
85 | @users = User.includes(:contests, :contest_stat).where(enabled: true) |
|
87 | @users = User.includes(:contests, :contest_stat).where(enabled: true) |
|
86 | @scorearray = Array.new |
|
88 | @scorearray = Array.new |
|
87 | @users.each do |u| |
|
89 | @users.each do |u| |
|
88 | ustat = Array.new |
|
90 | ustat = Array.new |
|
89 | ustat[0] = u |
|
91 | ustat[0] = u |
|
90 | @problems.each do |p| |
|
92 | @problems.each do |p| |
|
91 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
93 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
92 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
94 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
93 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
95 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
94 | else |
|
96 | else |
|
95 | ustat << [0,false] |
|
97 | ustat << [0,false] |
|
96 | end |
|
98 | end |
|
97 | end |
|
99 | end |
|
98 | @scorearray << ustat |
|
100 | @scorearray << ustat |
|
99 | end |
|
101 | end |
|
100 | if params[:commit] == 'download csv' then |
|
102 | if params[:commit] == 'download csv' then |
|
101 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
103 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
102 | send_data csv, filename: 'last_score.csv' |
|
104 | send_data csv, filename: 'last_score.csv' |
|
103 | else |
|
105 | else |
|
104 | render template: 'user_admin/user_stat' |
|
106 | render template: 'user_admin/user_stat' |
@@ -50,62 +50,62 | |||||
|
50 |
|
50 | ||
|
51 | #on-site new submission on specific problem |
|
51 | #on-site new submission on specific problem |
|
52 | def direct_edit_problem |
|
52 | def direct_edit_problem |
|
53 | @problem = Problem.find(params[:problem_id]) |
|
53 | @problem = Problem.find(params[:problem_id]) |
|
54 | unless @current_user.can_view_problem?(@problem) |
|
54 | unless @current_user.can_view_problem?(@problem) |
|
55 | unauthorized_redirect |
|
55 | unauthorized_redirect |
|
56 | return |
|
56 | return |
|
57 | end |
|
57 | end |
|
58 | @source = '' |
|
58 | @source = '' |
|
59 | if (params[:view_latest]) |
|
59 | if (params[:view_latest]) |
|
60 | sub = Submission.find_last_by_user_and_problem(@current_user.id,@problem.id) |
|
60 | sub = Submission.find_last_by_user_and_problem(@current_user.id,@problem.id) |
|
61 | @source = @submission.source.to_s if @submission and @submission.source |
|
61 | @source = @submission.source.to_s if @submission and @submission.source |
|
62 | end |
|
62 | end |
|
63 | render 'edit' |
|
63 | render 'edit' |
|
64 | end |
|
64 | end |
|
65 |
|
65 | ||
|
66 | # GET /submissions/1/edit |
|
66 | # GET /submissions/1/edit |
|
67 | def edit |
|
67 | def edit |
|
68 | @submission = Submission.find(params[:id]) |
|
68 | @submission = Submission.find(params[:id]) |
|
69 | @source = @submission.source.to_s |
|
69 | @source = @submission.source.to_s |
|
70 | @problem = @submission.problem |
|
70 | @problem = @submission.problem |
|
71 | @lang_id = @submission.language.id |
|
71 | @lang_id = @submission.language.id |
|
72 | end |
|
72 | end |
|
73 |
|
73 | ||
|
74 |
|
74 | ||
|
75 | def get_latest_submission_status |
|
75 | def get_latest_submission_status |
|
76 | @problem = Problem.find(params[:pid]) |
|
76 | @problem = Problem.find(params[:pid]) |
|
77 | @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid]) |
|
77 | @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid]) |
|
78 | respond_to do |format| |
|
78 | respond_to do |format| |
|
79 | format.js |
|
79 | format.js |
|
80 | end |
|
80 | end |
|
81 | end |
|
81 | end |
|
82 |
|
82 | ||
|
83 | # GET /submissions/:id/rejudge |
|
83 | # GET /submissions/:id/rejudge |
|
84 | def rejudge |
|
84 | def rejudge |
|
85 | @submission = Submission.find(params[:id]) |
|
85 | @submission = Submission.find(params[:id]) |
|
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?(' |
|
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 | ||
|
111 | end |
|
111 | end |
@@ -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" |
@@ -1,49 +1,54 | |||||
|
1 | %h1 Maximum score |
|
1 | %h1 Maximum score |
|
2 |
|
2 | ||
|
3 | = form_tag show_max_score_report_path |
|
3 | = form_tag show_max_score_report_path |
|
4 | .row |
|
4 | .row |
|
5 | .col-md-4 |
|
5 | .col-md-4 |
|
6 | .panel.panel-primary |
|
6 | .panel.panel-primary |
|
7 | .panel-heading |
|
7 | .panel-heading |
|
8 | Problems |
|
8 | Problems |
|
9 | .panel-body |
|
9 | .panel-body |
|
10 | %p |
|
10 | %p |
|
11 | Select problem(s) that we wish to know the score. |
|
11 | Select problem(s) that we wish to know the score. |
|
12 | = label_tag :problem_id, "Problems" |
|
12 | = label_tag :problem_id, "Problems" |
|
13 | = select_tag 'problem_id[]', |
|
13 | = select_tag 'problem_id[]', |
|
14 | options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},params[:problem_id]), |
|
14 | options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},params[:problem_id]), |
|
15 | { class: 'select2 form-control', multiple: "true" } |
|
15 | { class: 'select2 form-control', multiple: "true" } |
|
16 | .col-md-4 |
|
16 | .col-md-4 |
|
17 | .panel.panel-primary |
|
17 | .panel.panel-primary |
|
18 | .panel-heading |
|
18 | .panel-heading |
|
19 | Submission range |
|
19 | Submission range |
|
20 | .panel-body |
|
20 | .panel-body |
|
21 | %p |
|
21 | %p |
|
22 | Input minimum and maximum range of submission ID that should be included. A blank value for min and max means -1 and infinity, respectively. |
|
22 | Input minimum and maximum range of submission ID that should be included. A blank value for min and max means -1 and infinity, respectively. |
|
23 | .form-group |
|
23 | .form-group |
|
24 | = label_tag :from, "Min" |
|
24 | = label_tag :from, "Min" |
|
25 | = text_field_tag 'from_id', @since_id, class: "form-control" |
|
25 | = text_field_tag 'from_id', @since_id, class: "form-control" |
|
26 | .form-group |
|
26 | .form-group |
|
27 | = label_tag :from, "Max" |
|
27 | = label_tag :from, "Max" |
|
28 | = text_field_tag 'to_id', @until_id, class: "form-control" |
|
28 | = text_field_tag 'to_id', @until_id, class: "form-control" |
|
29 | .col-md-4 |
|
29 | .col-md-4 |
|
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" |
@@ -44,123 +44,124 | |||||
|
44 |
|
44 | ||
|
45 | create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
45 | create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
46 | t.string "name" |
|
46 | t.string "name" |
|
47 | t.datetime "created_at", null: false |
|
47 | t.datetime "created_at", null: false |
|
48 | t.datetime "updated_at", null: false |
|
48 | t.datetime "updated_at", null: false |
|
49 | end |
|
49 | end |
|
50 |
|
50 | ||
|
51 | create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
51 | create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
52 | t.text "body" |
|
52 | t.text "body" |
|
53 | t.boolean "markdowned" |
|
53 | t.boolean "markdowned" |
|
54 | t.datetime "created_at", null: false |
|
54 | t.datetime "created_at", null: false |
|
55 | t.datetime "updated_at", null: false |
|
55 | t.datetime "updated_at", null: false |
|
56 | end |
|
56 | end |
|
57 |
|
57 | ||
|
58 | create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
58 | create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
59 | t.string "key" |
|
59 | t.string "key" |
|
60 | t.string "value_type" |
|
60 | t.string "value_type" |
|
61 | t.string "value" |
|
61 | t.string "value" |
|
62 | t.datetime "created_at", null: false |
|
62 | t.datetime "created_at", null: false |
|
63 | t.datetime "updated_at", null: false |
|
63 | t.datetime "updated_at", null: false |
|
64 | t.text "description" |
|
64 | t.text "description" |
|
65 | end |
|
65 | end |
|
66 |
|
66 | ||
|
67 | create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
67 | create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
68 | t.string "host" |
|
68 | t.string "host" |
|
69 | t.integer "pid" |
|
69 | t.integer "pid" |
|
70 | t.string "mode" |
|
70 | t.string "mode" |
|
71 | t.boolean "active" |
|
71 | t.boolean "active" |
|
72 | t.datetime "created_at", null: false |
|
72 | t.datetime "created_at", null: false |
|
73 | t.datetime "updated_at", null: false |
|
73 | t.datetime "updated_at", null: false |
|
74 | t.integer "task_id" |
|
74 | t.integer "task_id" |
|
75 | t.string "task_type" |
|
75 | t.string "task_type" |
|
76 | t.boolean "terminated" |
|
76 | t.boolean "terminated" |
|
77 | t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid" |
|
77 | t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid" |
|
78 | end |
|
78 | end |
|
79 |
|
79 | ||
|
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" |
|
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" |
|
105 | end |
|
105 | end |
|
106 |
|
106 | ||
|
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 | ||
|
131 | create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
132 | create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
132 | t.string "name", limit: 30 |
|
133 | t.string "name", limit: 30 |
|
133 | t.string "full_name" |
|
134 | t.string "full_name" |
|
134 | t.integer "full_score" |
|
135 | t.integer "full_score" |
|
135 | t.date "date_added" |
|
136 | t.date "date_added" |
|
136 | t.boolean "available" |
|
137 | t.boolean "available" |
|
137 | t.string "url" |
|
138 | t.string "url" |
|
138 | t.integer "description_id" |
|
139 | t.integer "description_id" |
|
139 | t.boolean "test_allowed" |
|
140 | t.boolean "test_allowed" |
|
140 | t.boolean "output_only" |
|
141 | t.boolean "output_only" |
|
141 | t.string "description_filename" |
|
142 | t.string "description_filename" |
|
142 | t.boolean "view_testcase" |
|
143 | t.boolean "view_testcase" |
|
143 | end |
|
144 | end |
|
144 |
|
145 | ||
|
145 | create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| |
|
146 | create_table "problems_tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| |
|
146 | t.integer "problem_id" |
|
147 | t.integer "problem_id" |
|
147 | t.integer "tag_id" |
|
148 | t.integer "tag_id" |
|
148 | t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true |
|
149 | t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true |
|
149 | t.index ["problem_id"], name: "index_problems_tags_on_problem_id" |
|
150 | t.index ["problem_id"], name: "index_problems_tags_on_problem_id" |
|
150 | t.index ["tag_id"], name: "index_problems_tags_on_tag_id" |
|
151 | t.index ["tag_id"], name: "index_problems_tags_on_tag_id" |
|
151 | end |
|
152 | end |
|
152 |
|
153 | ||
|
153 | create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
154 | create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
154 | t.string "name" |
|
155 | t.string "name" |
|
155 | t.string "controller" |
|
156 | t.string "controller" |
|
156 | t.string "action" |
|
157 | t.string "action" |
|
157 | end |
|
158 | end |
|
158 |
|
159 | ||
|
159 | create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
160 | create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
160 | t.integer "right_id" |
|
161 | t.integer "right_id" |
|
161 | t.integer "role_id" |
|
162 | t.integer "role_id" |
|
162 | t.index ["role_id"], name: "index_rights_roles_on_role_id" |
|
163 | t.index ["role_id"], name: "index_rights_roles_on_role_id" |
|
163 | end |
|
164 | end |
|
164 |
|
165 | ||
|
165 | create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
166 | create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
166 | t.string "name" |
|
167 | t.string "name" |
@@ -170,96 +171,97 | |||||
|
170 | t.integer "role_id" |
|
171 | t.integer "role_id" |
|
171 | t.integer "user_id" |
|
172 | t.integer "user_id" |
|
172 | t.index ["user_id"], name: "index_roles_users_on_user_id" |
|
173 | t.index ["user_id"], name: "index_roles_users_on_user_id" |
|
173 | end |
|
174 | end |
|
174 |
|
175 | ||
|
175 | create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
176 | create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
176 | t.string "session_id" |
|
177 | t.string "session_id" |
|
177 | t.text "data" |
|
178 | t.text "data" |
|
178 | t.datetime "updated_at" |
|
179 | t.datetime "updated_at" |
|
179 | t.index ["session_id"], name: "index_sessions_on_session_id" |
|
180 | t.index ["session_id"], name: "index_sessions_on_session_id" |
|
180 | t.index ["updated_at"], name: "index_sessions_on_updated_at" |
|
181 | t.index ["updated_at"], name: "index_sessions_on_updated_at" |
|
181 | end |
|
182 | end |
|
182 |
|
183 | ||
|
183 | create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
184 | create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
184 | t.string "name" |
|
185 | t.string "name" |
|
185 | t.boolean "started" |
|
186 | t.boolean "started" |
|
186 | t.datetime "start_time" |
|
187 | t.datetime "start_time" |
|
187 | t.datetime "created_at", null: false |
|
188 | t.datetime "created_at", null: false |
|
188 | t.datetime "updated_at", null: false |
|
189 | t.datetime "updated_at", null: false |
|
189 | t.integer "country_id" |
|
190 | t.integer "country_id" |
|
190 | t.string "password" |
|
191 | t.string "password" |
|
191 | end |
|
192 | end |
|
192 |
|
193 | ||
|
193 | create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
194 | create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
194 | t.integer "user_id" |
|
195 | t.integer "user_id" |
|
195 | t.integer "submission_id" |
|
196 | t.integer "submission_id" |
|
196 | t.datetime "created_at", null: false |
|
197 | t.datetime "created_at", null: false |
|
197 | t.datetime "updated_at", null: false |
|
198 | t.datetime "updated_at", null: false |
|
198 | end |
|
199 | end |
|
199 |
|
200 | ||
|
200 | create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
201 | create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
201 | t.integer "user_id" |
|
202 | t.integer "user_id" |
|
202 | t.integer "problem_id" |
|
203 | t.integer "problem_id" |
|
203 | t.integer "language_id" |
|
204 | t.integer "language_id" |
|
204 | t.text "source", limit: 16777215 |
|
205 | t.text "source", limit: 16777215 |
|
205 | t.binary "binary" |
|
206 | t.binary "binary" |
|
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 | ||
|
230 | create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
232 | create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
231 | t.integer "submission_id" |
|
233 | t.integer "submission_id" |
|
232 | t.datetime "created_at" |
|
234 | t.datetime "created_at" |
|
233 | t.integer "status" |
|
235 | t.integer "status" |
|
234 | t.datetime "updated_at" |
|
236 | t.datetime "updated_at" |
|
235 | t.index ["submission_id"], name: "index_tasks_on_submission_id" |
|
237 | t.index ["submission_id"], name: "index_tasks_on_submission_id" |
|
236 | end |
|
238 | end |
|
237 |
|
239 | ||
|
238 | create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
240 | create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
239 | t.integer "problem_id" |
|
241 | t.integer "problem_id" |
|
240 | t.text "input", limit: 16777215 |
|
242 | t.text "input", limit: 16777215 |
|
241 | t.text "solution", limit: 16777215 |
|
243 | t.text "solution", limit: 16777215 |
|
242 | t.datetime "created_at", null: false |
|
244 | t.datetime "created_at", null: false |
|
243 | t.datetime "updated_at", null: false |
|
245 | t.datetime "updated_at", null: false |
|
244 | end |
|
246 | end |
|
245 |
|
247 | ||
|
246 | create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
248 | create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| |
|
247 | t.integer "user_id" |
|
249 | t.integer "user_id" |
|
248 | t.integer "problem_id" |
|
250 | t.integer "problem_id" |
|
249 | t.integer "submission_id" |
|
251 | t.integer "submission_id" |
|
250 | t.string "input_file_name" |
|
252 | t.string "input_file_name" |
|
251 | t.string "output_file_name" |
|
253 | t.string "output_file_name" |
|
252 | t.string "running_stat" |
|
254 | t.string "running_stat" |
|
253 | t.integer "status" |
|
255 | t.integer "status" |
|
254 | t.datetime "updated_at", null: false |
|
256 | t.datetime "updated_at", null: false |
|
255 | t.datetime "submitted_at" |
|
257 | t.datetime "submitted_at" |
|
256 | t.datetime "compiled_at" |
|
258 | t.datetime "compiled_at" |
|
257 | t.text "compiler_message" |
|
259 | t.text "compiler_message" |
|
258 | t.datetime "graded_at" |
|
260 | t.datetime "graded_at" |
|
259 | t.string "grader_comment" |
|
261 | t.string "grader_comment" |
|
260 | t.datetime "created_at", null: false |
|
262 | t.datetime "created_at", null: false |
|
261 | t.float "running_time" |
|
263 | t.float "running_time" |
|
262 | t.string "exit_status" |
|
264 | t.string "exit_status" |
|
263 | t.integer "memory_usage" |
|
265 | t.integer "memory_usage" |
|
264 | t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id" |
|
266 | t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id" |
|
265 | end |
|
267 | end |
@@ -180,97 +180,97 | |||||
|
180 | :description => "If true, available problem to the user will be only ones associated with the group of the user." |
|
180 | :description => "If true, available problem to the user will be only ones associated with the group of the user." |
|
181 | }, |
|
181 | }, |
|
182 |
|
182 | ||
|
183 |
|
183 | ||
|
184 | { |
|
184 | { |
|
185 | :key => 'right.whitelist_ignore', |
|
185 | :key => 'right.whitelist_ignore', |
|
186 | :value_type => 'boolean', |
|
186 | :value_type => 'boolean', |
|
187 | :default_value => 'true', |
|
187 | :default_value => 'true', |
|
188 | :description => "If true, no IP check against whitelist_ip is perform. However, when false, non-admin user must have their ip in 'whitelist_ip' to be able to login." |
|
188 | :description => "If true, no IP check against whitelist_ip is perform. However, when false, non-admin user must have their ip in 'whitelist_ip' to be able to login." |
|
189 | }, |
|
189 | }, |
|
190 |
|
190 | ||
|
191 | { |
|
191 | { |
|
192 | :key => 'right.whitelist_ip', |
|
192 | :key => 'right.whitelist_ip', |
|
193 | :value_type => 'string', |
|
193 | :value_type => 'string', |
|
194 | :default_value => '0.0.0.0/0', |
|
194 | :default_value => '0.0.0.0/0', |
|
195 | :description => "list of whitelist ip, given in comma separated CIDR notation. For example '192.168.90.0/23, 192.168.1.23/32'" |
|
195 | :description => "list of whitelist ip, given in comma separated CIDR notation. For example '192.168.90.0/23, 192.168.1.23/32'" |
|
196 | }, |
|
196 | }, |
|
197 |
|
197 | ||
|
198 | ] |
|
198 | ] |
|
199 |
|
199 | ||
|
200 |
|
200 | ||
|
201 | def create_configuration_key(key, |
|
201 | def create_configuration_key(key, |
|
202 | value_type, |
|
202 | value_type, |
|
203 | default_value, |
|
203 | default_value, |
|
204 | description='') |
|
204 | description='') |
|
205 | conf = (GraderConfiguration.find_by_key(key) || |
|
205 | conf = (GraderConfiguration.find_by_key(key) || |
|
206 | GraderConfiguration.new(:key => key, |
|
206 | GraderConfiguration.new(:key => key, |
|
207 | :value_type => value_type, |
|
207 | :value_type => value_type, |
|
208 | :value => default_value)) |
|
208 | :value => default_value)) |
|
209 | conf.description = description |
|
209 | conf.description = description |
|
210 | conf.save |
|
210 | conf.save |
|
211 | end |
|
211 | end |
|
212 |
|
212 | ||
|
213 | def seed_config |
|
213 | def seed_config |
|
214 | CONFIGURATIONS.each do |conf| |
|
214 | CONFIGURATIONS.each do |conf| |
|
215 | if conf.has_key? :description |
|
215 | if conf.has_key? :description |
|
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: ' |
|
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', |
|
241 | :action => 'all') |
|
241 | :action => 'all') |
|
242 |
|
242 | ||
|
243 | role.rights << user_admin_right; |
|
243 | role.rights << user_admin_right; |
|
244 | role.rights << problem_admin_right; |
|
244 | role.rights << problem_admin_right; |
|
245 | role.rights << graders_right; |
|
245 | role.rights << graders_right; |
|
246 | role.save |
|
246 | role.save |
|
247 | end |
|
247 | end |
|
248 |
|
248 | ||
|
249 | def seed_root |
|
249 | def seed_root |
|
250 | return if User.find_by_login('root') |
|
250 | return if User.find_by_login('root') |
|
251 |
|
251 | ||
|
252 | root = User.new(:login => 'root', |
|
252 | root = User.new(:login => 'root', |
|
253 | :full_name => 'Administrator', |
|
253 | :full_name => 'Administrator', |
|
254 | :alias => 'root') |
|
254 | :alias => 'root') |
|
255 | root.password = 'ioionrails'; |
|
255 | root.password = 'ioionrails'; |
|
256 |
|
256 | ||
|
257 | class << root |
|
257 | class << root |
|
258 | public :encrypt_new_password |
|
258 | public :encrypt_new_password |
|
259 | def valid?(context=nil) |
|
259 | def valid?(context=nil) |
|
260 | true |
|
260 | true |
|
261 | end |
|
261 | end |
|
262 | end |
|
262 | end |
|
263 |
|
263 | ||
|
264 | root.encrypt_new_password |
|
264 | root.encrypt_new_password |
|
265 |
|
265 | ||
|
266 | root.roles << Role.find_by_name('admin') |
|
266 | root.roles << Role.find_by_name('admin') |
|
267 |
|
267 | ||
|
268 | root.activated = true |
|
268 | root.activated = true |
|
269 | root.save |
|
269 | root.save |
|
270 | end |
|
270 | end |
|
271 |
|
271 | ||
|
272 | def seed_users_and_roles |
|
272 | def seed_users_and_roles |
|
273 | seed_roles |
|
273 | seed_roles |
|
274 | seed_root |
|
274 | seed_root |
|
275 | end |
|
275 | end |
|
276 |
|
276 |
You need to be logged in to leave comments.
Login now