Description:
fixed task info error in analysis mode
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r290:8a3bce2f983b - - 1 file changed: 5 inserted, 5 deleted

@@ -1,33 +1,33
1 require 'yaml'
1 require 'yaml'
2
2
3 #
3 #
4 # This class also contains various login of the system.
4 # This class also contains various login of the system.
5 #
5 #
6 class Configuration < ActiveRecord::Base
6 class Configuration < ActiveRecord::Base
7
7
8 SYSTEM_MODE_CONF_KEY = 'system.mode'
8 SYSTEM_MODE_CONF_KEY = 'system.mode'
9 TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
9 TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
10
10
11 cattr_accessor :cache
11 cattr_accessor :cache
12 cattr_accessor :config_cache
12 cattr_accessor :config_cache
13 - cattr_accessor :task_grading_info
13 + cattr_accessor :task_grading_info_cache
14 cattr_accessor :contest_time_str
14 cattr_accessor :contest_time_str
15 cattr_accessor :contest_time
15 cattr_accessor :contest_time
16
16
17 # set @@cache = true to only reload once.
17 # set @@cache = true to only reload once.
18 Configuration.cache = false
18 Configuration.cache = false
19
19
20 Configuration.config_cache = nil
20 Configuration.config_cache = nil
21 - Configuration.task_grading_info = nil
21 + Configuration.task_grading_info_cache = nil
22
22
23 def self.get(key)
23 def self.get(key)
24 if Configuration.cache
24 if Configuration.cache
25 if Configuration.config_cache == nil
25 if Configuration.config_cache == nil
26 self.read_config
26 self.read_config
27 end
27 end
28 return Configuration.config_cache[key]
28 return Configuration.config_cache[key]
29 else
29 else
30 return Configuration.read_one_key(key)
30 return Configuration.read_one_key(key)
31 end
31 end
32 end
32 end
33
33
@@ -79,28 +79,28
79 mode = get(SYSTEM_MODE_CONF_KEY)
79 mode = get(SYSTEM_MODE_CONF_KEY)
80 early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
80 early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
81 if (mode=='contest')
81 if (mode=='contest')
82 return false if ((user.site!=nil) and
82 return false if ((user.site!=nil) and
83 ((user.site.started!=true) or
83 ((user.site.started!=true) or
84 (early_timeout and (user.site.time_left < 30.minutes))))
84 (early_timeout and (user.site.time_left < 30.minutes))))
85 end
85 end
86 return false if mode=='analysis'
86 return false if mode=='analysis'
87 return true
87 return true
88 end
88 end
89
89
90 def self.task_grading_info
90 def self.task_grading_info
91 - if Configuration.task_grading_info==nil
91 + if Configuration.task_grading_info_cache==nil
92 read_grading_info
92 read_grading_info
93 end
93 end
94 - return Configuration.task_grading_info
94 + return Configuration.task_grading_info_cache
95 end
95 end
96
96
97 def self.standard_mode?
97 def self.standard_mode?
98 return get(SYSTEM_MODE_CONF_KEY) == 'standard'
98 return get(SYSTEM_MODE_CONF_KEY) == 'standard'
99 end
99 end
100
100
101 def self.contest_mode?
101 def self.contest_mode?
102 return get(SYSTEM_MODE_CONF_KEY) == 'contest'
102 return get(SYSTEM_MODE_CONF_KEY) == 'contest'
103 end
103 end
104
104
105 def self.indv_contest_mode?
105 def self.indv_contest_mode?
106 return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest'
106 return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest'
@@ -166,17 +166,17
166
166
167 def self.read_one_key(key)
167 def self.read_one_key(key)
168 conf = Configuration.find_by_key(key)
168 conf = Configuration.find_by_key(key)
169 if conf
169 if conf
170 return Configuration.convert_type(conf.value,conf.value_type)
170 return Configuration.convert_type(conf.value,conf.value_type)
171 else
171 else
172 return nil
172 return nil
173 end
173 end
174 end
174 end
175
175
176 def self.read_grading_info
176 def self.read_grading_info
177 f = File.open(TASK_GRADING_INFO_FILENAME)
177 f = File.open(TASK_GRADING_INFO_FILENAME)
178 - Configuration.task_grading_info = YAML.load(f)
178 + Configuration.task_grading_info_cache = YAML.load(f)
179 f.close
179 f.close
180 end
180 end
181
181
182 end
182 end
You need to be logged in to leave comments. Login now