Description:
add options to allow hall of fame viewing by any user add menu item for normal user
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r424:217b94aa4f76 - - 6 files changed: 40 inserted, 27 deleted

@@ -2,48 +2,52
2 protect_from_forgery
2 protect_from_forgery
3
3
4 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
4 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
5
5
6 def admin_authorization
6 def admin_authorization
7 return false unless authenticate
7 return false unless authenticate
8 user = User.find(session[:user_id], :include => ['roles'])
8 user = User.find(session[:user_id], :include => ['roles'])
9 redirect_to :controller => 'main', :action => 'login' unless user.admin?
9 redirect_to :controller => 'main', :action => 'login' unless user.admin?
10 end
10 end
11
11
12 def authorization_by_roles(allowed_roles)
12 def authorization_by_roles(allowed_roles)
13 return false unless authenticate
13 return false unless authenticate
14 user = User.find(session[:user_id])
14 user = User.find(session[:user_id])
15 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
15 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
16 flash[:notice] = 'You are not authorized to view the page you requested'
16 flash[:notice] = 'You are not authorized to view the page you requested'
17 redirect_to :controller => 'main', :action => 'login'
17 redirect_to :controller => 'main', :action => 'login'
18 return false
18 return false
19 end
19 end
20 end
20 end
21
21
22 protected
22 protected
23
23
24 def authenticate
24 def authenticate
25 unless session[:user_id]
25 unless session[:user_id]
26 + flash[:notice] = 'You need to login'
27 + if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
28 + flash[:notice] = 'You need to login but you cannot log in at this time'
29 + end
26 redirect_to :controller => 'main', :action => 'login'
30 redirect_to :controller => 'main', :action => 'login'
27 return false
31 return false
28 end
32 end
29
33
30 # check if run in single user mode
34 # check if run in single user mode
31 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
35 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
32 user = User.find(session[:user_id])
36 user = User.find(session[:user_id])
33 if user==nil or (not user.admin?)
37 if user==nil or (not user.admin?)
34 flash[:notice] = 'You cannot log in at this time'
38 flash[:notice] = 'You cannot log in at this time'
35 redirect_to :controller => 'main', :action => 'login'
39 redirect_to :controller => 'main', :action => 'login'
36 return false
40 return false
37 end
41 end
38 return true
42 return true
39 end
43 end
40
44
41 if GraderConfiguration.multicontests?
45 if GraderConfiguration.multicontests?
42 user = User.find(session[:user_id])
46 user = User.find(session[:user_id])
43 return true if user.admin?
47 return true if user.admin?
44 begin
48 begin
45 if user.contest_stat(true).forced_logout
49 if user.contest_stat(true).forced_logout
46 flash[:notice] = 'You have been automatically logged out.'
50 flash[:notice] = 'You have been automatically logged out.'
47 redirect_to :controller => 'main', :action => 'index'
51 redirect_to :controller => 'main', :action => 'index'
48 end
52 end
49 rescue
53 rescue
@@ -1,39 +1,35
1 class ReportController < ApplicationController
1 class ReportController < ApplicationController
2
2
3 before_filter :admin_authorization, only: [:login_stat,:submission_stat]
3 before_filter :admin_authorization, only: [:login_stat,:submission_stat]
4 - before_filter(only: :problem_hof) { |c|
4 + before_filter { |c|
5 - user = User.find(session[:user_id]) if session[:user_id]
5 + return false unless authenticate
6 - if user==nil
6 +
7 - flash[:notice] = 'You have to login first'
7 + if GraderConfiguration["system.hall_of_fame_available"]
8 - redirect_to :controller => 'main', :action => 'login'
8 + return true;
9 - return false
10 end
9 end
11 -
10 +
12 - unless GraderConfiguration["hall_of_fame_available"]
11 + admin_authorization
13 - flash[:notice] = 'You are not authorized to view the page you requested'
14 - redirect_to :controller => 'main', :action => 'login' unless GraderConfiguration[ "hall_of_fame_available" ]
15 - end
16 }
12 }
17
13
18 def login_stat
14 def login_stat
19 @logins = Array.new
15 @logins = Array.new
20
16
21 date_and_time = '%Y-%m-%d %H:%M'
17 date_and_time = '%Y-%m-%d %H:%M'
22 begin
18 begin
23 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
19 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
24 rescue
20 rescue
25 @since_time = DateTime.new(1000,1,1)
21 @since_time = DateTime.new(1000,1,1)
26 end
22 end
27 begin
23 begin
28 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
24 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
29 rescue
25 rescue
30 @until_time = DateTime.new(3000,1,1)
26 @until_time = DateTime.new(3000,1,1)
31 end
27 end
32
28
33 User.all.each do |user|
29 User.all.each do |user|
34 @logins << { login: user.login,
30 @logins << { login: user.login,
35 full_name: user.full_name,
31 full_name: user.full_name,
36 count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
32 count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
37 user.id,@since_time,@until_time)
33 user.id,@since_time,@until_time)
38 .count(:id),
34 .count(:id),
39 min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
35 min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
@@ -9,48 +9,52
9 # admin menu
9 # admin menu
10 menu_items << "<b>Administrative task:</b> "
10 menu_items << "<b>Administrative task:</b> "
11 append_to menu_items, '[Announcements]', 'announcements', 'index'
11 append_to menu_items, '[Announcements]', 'announcements', 'index'
12 append_to menu_items, '[Msg console]', 'messages', 'console'
12 append_to menu_items, '[Msg console]', 'messages', 'console'
13 append_to menu_items, '[Problems]', 'problems', 'index'
13 append_to menu_items, '[Problems]', 'problems', 'index'
14 append_to menu_items, '[Users]', 'user_admin', 'index'
14 append_to menu_items, '[Users]', 'user_admin', 'index'
15 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
15 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
16 append_to menu_items, '[Report]', 'report', 'login_stat'
16 append_to menu_items, '[Report]', 'report', 'login_stat'
17 append_to menu_items, '[Graders]', 'graders', 'list'
17 append_to menu_items, '[Graders]', 'graders', 'list'
18 append_to menu_items, '[Contests]', 'contest_management', 'index'
18 append_to menu_items, '[Contests]', 'contest_management', 'index'
19 append_to menu_items, '[Sites]', 'sites', 'index'
19 append_to menu_items, '[Sites]', 'sites', 'index'
20 append_to menu_items, '[System config]', 'configurations', 'index'
20 append_to menu_items, '[System config]', 'configurations', 'index'
21 menu_items << "<br/>"
21 menu_items << "<br/>"
22 end
22 end
23
23
24 # main page
24 # main page
25 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
25 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
26 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
26 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
27
27
28 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
28 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
29 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
29 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
30 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
30 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
31 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
31 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
32 end
32 end
33 +
34 + if GraderConfiguration['system.hall_of_fame_available']
35 + append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
36 + end
33 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
37 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
34
38
35 if GraderConfiguration['system.user_setting_enabled']
39 if GraderConfiguration['system.user_setting_enabled']
36 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
40 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
37 end
41 end
38 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
42 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
39
43
40 menu_items.html_safe
44 menu_items.html_safe
41 end
45 end
42
46
43 def append_to(option,label, controller, action)
47 def append_to(option,label, controller, action)
44 option << ' ' if option!=''
48 option << ' ' if option!=''
45 option << link_to_unless_current(label,
49 option << link_to_unless_current(label,
46 :controller => controller,
50 :controller => controller,
47 :action => action)
51 :action => action)
48 end
52 end
49
53
50 def format_short_time(time)
54 def format_short_time(time)
51 now = Time.now.gmtime
55 now = Time.now.gmtime
52 st = ''
56 st = ''
53 if (time.yday != now.yday) or
57 if (time.yday != now.yday) or
54 (time.year != now.year)
58 (time.year != now.year)
55 st = time.strftime("%x ")
59 st = time.strftime("%x ")
56 end
60 end
@@ -1,46 +1,47
1 # Sample localization file for English. Add more files in this directory for other locales.
1 # Sample localization file for English. Add more files in this directory for other locales.
2 # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
2 # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
4 en:
4 en:
5 cancel: 'Cancel'
5 cancel: 'Cancel'
6
6
7 login_label: 'Login'
7 login_label: 'Login'
8 full_name_label: 'Full name'
8 full_name_label: 'Full name'
9 email_label: 'E-mail'
9 email_label: 'E-mail'
10 password_label: 'Password'
10 password_label: 'Password'
11
11
12 go_ahead_to: "Go ahead to"
12 go_ahead_to: "Go ahead to"
13 go_back_to: "Go back to"
13 go_back_to: "Go back to"
14 login_page: "login page"
14 login_page: "login page"
15 home_page: "home page"
15 home_page: "home page"
16
16
17 menu:
17 menu:
18 main: 'Main'
18 main: 'Main'
19 messages: 'Messages'
19 messages: 'Messages'
20 tasks: 'Tasks'
20 tasks: 'Tasks'
21 submissions: 'Submissions'
21 submissions: 'Submissions'
22 test: 'Test Interface'
22 test: 'Test Interface'
23 + hall_of_fame: 'Hall of Fame'
23 help: 'Help'
24 help: 'Help'
24 settings: 'Settings'
25 settings: 'Settings'
25 log_out: 'Log out'
26 log_out: 'Log out'
26
27
27 title_bar:
28 title_bar:
28 current_time: "Current time is"
29 current_time: "Current time is"
29 remaining_time: "Time left: "
30 remaining_time: "Time left: "
30 contest_not_started: "The contest has not started."
31 contest_not_started: "The contest has not started."
31
32
32 login:
33 login:
33 message: 'Please login to see the problem list'
34 message: 'Please login to see the problem list'
34 login_submit: 'Login'
35 login_submit: 'Login'
35 participation: 'Want to participate?'
36 participation: 'Want to participate?'
36 please: 'Please'
37 please: 'Please'
37 register: 'register'
38 register: 'register'
38 forget_password: 'Forget password?'
39 forget_password: 'Forget password?'
39
40
40 main:
41 main:
41 start_soon: "The contest at your site will start soon. Please wait."
42 start_soon: "The contest at your site will start soon. Please wait."
42 specified_in_header: "Specified in header"
43 specified_in_header: "Specified in header"
43
44
44 problem_desc: "desc"
45 problem_desc: "desc"
45 submitted_at: "Submitted at"
46 submitted_at: "Submitted at"
46 graded_at: "Graded at"
47 graded_at: "Graded at"
@@ -1,46 +1,47
1 # Sample localization file for English. Add more files in this directory for other locales.
1 # Sample localization file for English. Add more files in this directory for other locales.
2 # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
2 # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
4 th:
4 th:
5 cancel: 'ฒกเΰΈ₯ิก'
5 cancel: 'ฒกเΰΈ₯ิก'
6
6
7 login_label: 'ΰΈŠΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš (login)'
7 login_label: 'ΰΈŠΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš (login)'
8 full_name_label: 'ΰΈŠΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ•ΰΉ‡ΰΈ‘'
8 full_name_label: 'ΰΈŠΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ•ΰΉ‡ΰΈ‘'
9 email_label: 'E-mail'
9 email_label: 'E-mail'
10 password_label: 'ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™'
10 password_label: 'ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™'
11
11
12 go_ahead_to: "ΰΉ„ΰΈ›ΰΈ’ΰΈ±ΰΈ‡"
12 go_ahead_to: "ΰΉ„ΰΈ›ΰΈ’ΰΈ±ΰΈ‡"
13 go_back_to: "กΰΈ₯ΰΈ±ΰΈšΰΉ„ΰΈ›ΰΈ’ΰΈ±ΰΈ‡"
13 go_back_to: "กΰΈ₯ΰΈ±ΰΈšΰΉ„ΰΈ›ΰΈ’ΰΈ±ΰΈ‡"
14 login_page: "ΰΈ«ΰΈ™ΰΉ‰ΰΈ²ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš"
14 login_page: "ΰΈ«ΰΈ™ΰΉ‰ΰΈ²ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš"
15 home_page: "หน้าแรก"
15 home_page: "หน้าแรก"
16
16
17 menu:
17 menu:
18 main: 'ΰΈ«ΰΈ™ΰΉ‰ΰΈ²ΰΈ«ΰΈ₯ัก'
18 main: 'ΰΈ«ΰΈ™ΰΉ‰ΰΈ²ΰΈ«ΰΈ₯ัก'
19 messages: 'ΰΈ‚ΰΉ‰ΰΈ­ΰΈ„ΰΈ§ΰΈ²ΰΈ‘'
19 messages: 'ΰΈ‚ΰΉ‰ΰΈ­ΰΈ„ΰΈ§ΰΈ²ΰΈ‘'
20 tasks: 'ΰΉ‚ΰΈˆΰΈ—ΰΈ’ΰΉŒ'
20 tasks: 'ΰΉ‚ΰΈˆΰΈ—ΰΈ’ΰΉŒ'
21 submissions: 'ΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘ΰΈ—ΰΈ΅ΰΉˆΰΈͺΰΉˆΰΈ‡'
21 submissions: 'ΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘ΰΈ—ΰΈ΅ΰΉˆΰΈͺΰΉˆΰΈ‡'
22 test: 'ΰΈ—ΰΈ”ΰΈͺΰΈ­ΰΈšΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘'
22 test: 'ΰΈ—ΰΈ”ΰΈͺΰΈ­ΰΈšΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘'
23 + hall_of_fame: 'หอเกมฒรติฒศ'
23 help: 'ΰΈ„ΰΈ§ΰΈ²ΰΈ‘ΰΈŠΰΉˆΰΈ§ΰΈ’ΰΉ€ΰΈ«ΰΈ₯ΰΈ·ΰΈ­'
24 help: 'ΰΈ„ΰΈ§ΰΈ²ΰΈ‘ΰΈŠΰΉˆΰΈ§ΰΈ’ΰΉ€ΰΈ«ΰΈ₯ΰΈ·ΰΈ­'
24 settings: 'ΰΉ€ΰΈ›ΰΈ₯ΰΈ΅ΰΉˆΰΈ’ΰΈ™ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™'
25 settings: 'ΰΉ€ΰΈ›ΰΈ₯ΰΈ΅ΰΉˆΰΈ’ΰΈ™ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™'
25 log_out: 'ออกจากระบบ'
26 log_out: 'ออกจากระบบ'
26
27
27 title_bar:
28 title_bar:
28 current_time: "ΰΉ€ΰΈ§ΰΈ₯ΰΈ²ΰΈ›ΰΈ±ΰΈˆΰΈˆΰΈΈΰΈšΰΈ±ΰΈ™ΰΈ„ΰΈ·ΰΈ­"
29 current_time: "ΰΉ€ΰΈ§ΰΈ₯ΰΈ²ΰΈ›ΰΈ±ΰΈˆΰΈˆΰΈΈΰΈšΰΈ±ΰΈ™ΰΈ„ΰΈ·ΰΈ­"
29 remaining_time: "ΰΉ€ΰΈ«ΰΈ₯ΰΈ·ΰΈ­ΰΉ€ΰΈ§ΰΈ₯าอมก"
30 remaining_time: "ΰΉ€ΰΈ«ΰΈ₯ΰΈ·ΰΈ­ΰΉ€ΰΈ§ΰΈ₯าอมก"
30 contest_not_started: "ΰΈ’ΰΈ±ΰΈ‡ΰΉ„ΰΈ‘ΰΉˆΰΉ€ΰΈ£ΰΈ΄ΰΉˆΰΈ‘ΰΉΰΈ‚ΰΉˆΰΈ‡ΰΈ‚ΰΈ±ΰΈ™"
31 contest_not_started: "ΰΈ’ΰΈ±ΰΈ‡ΰΉ„ΰΈ‘ΰΉˆΰΉ€ΰΈ£ΰΈ΄ΰΉˆΰΈ‘ΰΉΰΈ‚ΰΉˆΰΈ‡ΰΈ‚ΰΈ±ΰΈ™"
31
32
32 login:
33 login:
33 message: 'กรุณา login ΰΉ€ΰΈžΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΈͺู่ระบบ'
34 message: 'กรุณา login ΰΉ€ΰΈžΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΈͺู่ระบบ'
34 login_submit: 'ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš'
35 login_submit: 'ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΉƒΰΈŠΰΉ‰ΰΈ£ΰΈ°ΰΈšΰΈš'
35 participation: 'ΰΈ•ΰΉ‰ΰΈ­ΰΈ‡ΰΈΰΈ²ΰΈ£ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΈ£ΰΉˆΰΈ§ΰΈ‘?'
36 participation: 'ΰΈ•ΰΉ‰ΰΈ­ΰΈ‡ΰΈΰΈ²ΰΈ£ΰΉ€ΰΈ‚ΰΉ‰ΰΈ²ΰΈ£ΰΉˆΰΈ§ΰΈ‘?'
36 please: 'กรุณา'
37 please: 'กรุณา'
37 register: 'ΰΈ₯ΰΈ‡ΰΈ—ΰΈ°ΰΉ€ΰΈšΰΈ΅ΰΈ’ΰΈ™'
38 register: 'ΰΈ₯ΰΈ‡ΰΈ—ΰΈ°ΰΉ€ΰΈšΰΈ΅ΰΈ’ΰΈ™'
38 forget_password: 'ΰΈ₯ΰΈ·ΰΈ‘ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™?'
39 forget_password: 'ΰΈ₯ΰΈ·ΰΈ‘ΰΈ£ΰΈ«ΰΈ±ΰΈͺΰΈœΰΉˆΰΈ²ΰΈ™?'
39
40
40 main:
41 main:
41 start_soon: "ΰΈΰΈ²ΰΈ£ΰΉΰΈ‚ΰΉˆΰΈ‡ΰΈ‚ΰΈ±ΰΈ™ΰΈΰΈ³ΰΈ₯ΰΈ±ΰΈ‡ΰΈˆΰΈ°ΰΉ€ΰΈ£ΰΈ΄ΰΉˆΰΈ‘ ΰΈΰΈ£ΰΈΈΰΈ“ΰΈ²ΰΈ£ΰΈ­ΰΈΰΉˆΰΈ­ΰΈ™"
42 start_soon: "ΰΈΰΈ²ΰΈ£ΰΉΰΈ‚ΰΉˆΰΈ‡ΰΈ‚ΰΈ±ΰΈ™ΰΈΰΈ³ΰΈ₯ΰΈ±ΰΈ‡ΰΈˆΰΈ°ΰΉ€ΰΈ£ΰΈ΄ΰΉˆΰΈ‘ ΰΈΰΈ£ΰΈΈΰΈ“ΰΈ²ΰΈ£ΰΈ­ΰΈΰΉˆΰΈ­ΰΈ™"
42 specified_in_header: "ΰΈ£ΰΈ°ΰΈšΰΈΈΰΈ—ΰΈ΅ΰΉˆΰΈ«ΰΈ±ΰΈ§ΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘ΰΉΰΈ₯ΰΉ‰ΰΈ§"
43 specified_in_header: "ΰΈ£ΰΈ°ΰΈšΰΈΈΰΈ—ΰΈ΅ΰΉˆΰΈ«ΰΈ±ΰΈ§ΰΉ‚ΰΈ›ΰΈ£ΰΉΰΈΰΈ£ΰΈ‘ΰΉΰΈ₯ΰΉ‰ΰΈ§"
43
44
44 problem_desc: "ΰΈ­ΰΉˆΰΈ²ΰΈ™"
45 problem_desc: "ΰΈ­ΰΉˆΰΈ²ΰΈ™"
45 submitted_at: "ΰΈͺΰΉˆΰΈ‡ΰΉ€ΰΈ‘ΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ§ΰΈ₯ΰΈ²"
46 submitted_at: "ΰΈͺΰΉˆΰΈ‡ΰΉ€ΰΈ‘ΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ§ΰΈ₯ΰΈ²"
46 graded_at: "ΰΈ•ΰΈ£ΰΈ§ΰΈˆΰΉ€ΰΈ‘ΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ§ΰΈ₯ΰΈ²"
47 graded_at: "ΰΈ•ΰΈ£ΰΈ§ΰΈˆΰΉ€ΰΈ‘ΰΈ·ΰΉˆΰΈ­ΰΉ€ΰΈ§ΰΈ₯ΰΈ²"
@@ -1,142 +1,149
1 CONFIGURATIONS =
1 CONFIGURATIONS =
2 [
2 [
3 {
3 {
4 :key => 'system.single_user_mode',
4 :key => 'system.single_user_mode',
5 :value_type => 'boolean',
5 :value_type => 'boolean',
6 :default_value => 'false',
6 :default_value => 'false',
7 :description => 'Only admins can log in to the system when running under single user mode.'
7 :description => 'Only admins can log in to the system when running under single user mode.'
8 },
8 },
9 -
9 +
10 {
10 {
11 :key => 'ui.front.title',
11 :key => 'ui.front.title',
12 :value_type => 'string',
12 :value_type => 'string',
13 :default_value => 'Grader'
13 :default_value => 'Grader'
14 },
14 },
15 -
15 +
16 {
16 {
17 :key => 'ui.front.welcome_message',
17 :key => 'ui.front.welcome_message',
18 :value_type => 'string',
18 :value_type => 'string',
19 :default_value => 'Welcome!'
19 :default_value => 'Welcome!'
20 },
20 },
21 -
21 +
22 {
22 {
23 :key => 'ui.show_score',
23 :key => 'ui.show_score',
24 :value_type => 'boolean',
24 :value_type => 'boolean',
25 :default_value => 'true'
25 :default_value => 'true'
26 },
26 },
27 -
27 +
28 {
28 {
29 :key => 'contest.time_limit',
29 :key => 'contest.time_limit',
30 :value_type => 'string',
30 :value_type => 'string',
31 :default_value => 'unlimited',
31 :default_value => 'unlimited',
32 :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.'
32 :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.'
33 },
33 },
34 -
34 +
35 {
35 {
36 :key => 'system.mode',
36 :key => 'system.mode',
37 :value_type => 'string',
37 :value_type => 'string',
38 :default_value => 'standard',
38 :default_value => 'standard',
39 :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".'
39 :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".'
40 },
40 },
41 -
41 +
42 {
42 {
43 :key => 'contest.name',
43 :key => 'contest.name',
44 :value_type => 'string',
44 :value_type => 'string',
45 :default_value => 'Grader',
45 :default_value => 'Grader',
46 :description => 'This name will be shown on the user header bar.'
46 :description => 'This name will be shown on the user header bar.'
47 },
47 },
48 -
48 +
49 {
49 {
50 :key => 'contest.multisites',
50 :key => 'contest.multisites',
51 :value_type => 'boolean',
51 :value_type => 'boolean',
52 :default_value => 'false',
52 :default_value => 'false',
53 :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.'
53 :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.'
54 },
54 },
55 -
55 +
56 {
56 {
57 - :key => 'system.online_registration',
57 + :key => 'system.hall_of_fame_available',
58 :value_type => 'boolean',
58 :value_type => 'boolean',
59 :default_value => 'false',
59 :default_value => 'false',
60 - :description => 'This option enables online registration.'
60 + :description => 'If true, any user can access hall of fame page.'
61 },
61 },
62 -
62 +
63 # If Configuration['system.online_registration'] is true, the
63 # If Configuration['system.online_registration'] is true, the
64 # system allows online registration, and will use these
64 # system allows online registration, and will use these
65 # information for sending confirmation emails.
65 # information for sending confirmation emails.
66 {
66 {
67 :key => 'system.online_registration.smtp',
67 :key => 'system.online_registration.smtp',
68 :value_type => 'string',
68 :value_type => 'string',
69 :default_value => 'smtp.somehost.com'
69 :default_value => 'smtp.somehost.com'
70 },
70 },
71 -
71 +
72 {
72 {
73 :key => 'system.online_registration.from',
73 :key => 'system.online_registration.from',
74 :value_type => 'string',
74 :value_type => 'string',
75 :default_value => 'your.email@address'
75 :default_value => 'your.email@address'
76 },
76 },
77 -
77 +
78 {
78 {
79 :key => 'system.admin_email',
79 :key => 'system.admin_email',
80 :value_type => 'string',
80 :value_type => 'string',
81 :default_value => 'admin@admin.email'
81 :default_value => 'admin@admin.email'
82 },
82 },
83 -
83 +
84 {
84 {
85 :key => 'system.user_setting_enabled',
85 :key => 'system.user_setting_enabled',
86 :value_type => 'boolean',
86 :value_type => 'boolean',
87 :default_value => 'true',
87 :default_value => 'true',
88 :description => 'If this option is true, users can change their settings'
88 :description => 'If this option is true, users can change their settings'
89 },
89 },
90 -
90 +
91 + {
92 + :key => 'system.user_setting_enabled',
93 + :value_type => 'boolean',
94 + :default_value => 'true',
95 + :description => 'If this option is true, users can change their settings'
96 + }
97 +
91 # If Configuration['contest.test_request.early_timeout'] is true
98 # If Configuration['contest.test_request.early_timeout'] is true
92 # the user will not be able to use test request at 30 minutes
99 # the user will not be able to use test request at 30 minutes
93 # before the contest ends.
100 # before the contest ends.
94 {
101 {
95 :key => 'contest.test_request.early_timeout',
102 :key => 'contest.test_request.early_timeout',
96 :value_type => 'boolean',
103 :value_type => 'boolean',
97 :default_value => 'false'
104 :default_value => 'false'
98 },
105 },
99
106
100 {
107 {
101 :key => 'system.multicontests',
108 :key => 'system.multicontests',
102 :value_type => 'boolean',
109 :value_type => 'boolean',
103 :default_value => 'false'
110 :default_value => 'false'
104 },
111 },
105
112
106 {
113 {
107 :key => 'contest.confirm_indv_contest_start',
114 :key => 'contest.confirm_indv_contest_start',
108 :value_type => 'boolean',
115 :value_type => 'boolean',
109 :default_value => 'false'
116 :default_value => 'false'
110 },
117 },
111
118
112 {
119 {
113 :key => 'contest.default_contest_name',
120 :key => 'contest.default_contest_name',
114 :value_type => 'string',
121 :value_type => 'string',
115 :default_value => 'none',
122 :default_value => 'none',
116 :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest."
123 :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest."
117 }
124 }
118 -
125 +
119 ]
126 ]
120
127
121
128
122 def create_configuration_key(key,
129 def create_configuration_key(key,
123 value_type,
130 value_type,
124 default_value,
131 default_value,
125 description='')
132 description='')
126 conf = (GraderConfiguration.find_by_key(key) ||
133 conf = (GraderConfiguration.find_by_key(key) ||
127 GraderConfiguration.new(:key => key,
134 GraderConfiguration.new(:key => key,
128 :value_type => value_type,
135 :value_type => value_type,
129 :value => default_value))
136 :value => default_value))
130 conf.description = description
137 conf.description = description
131 conf.save
138 conf.save
132 end
139 end
133
140
134 def seed_config
141 def seed_config
135 CONFIGURATIONS.each do |conf|
142 CONFIGURATIONS.each do |conf|
136 if conf.has_key? :description
143 if conf.has_key? :description
137 desc = conf[:description]
144 desc = conf[:description]
138 else
145 else
139 desc = ''
146 desc = ''
140 end
147 end
141 create_configuration_key(conf[:key],
148 create_configuration_key(conf[:key],
142 conf[:value_type],
149 conf[:value_type],
You need to be logged in to leave comments. Login now