Description:
added options to enable test-pair import
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r212:e6f50b45f902 - - 3 files changed: 19 inserted, 2 deleted

@@ -126,68 +126,80
126 126 redirect_to :action => 'list'
127 127 end
128 128
129 129 def stat
130 130 @problem = Problem.find(params[:id])
131 131 if !@problem.available
132 132 redirect_to :controller => 'main', :action => 'list'
133 133 else
134 134 @submissions = Submission.find_all_last_by_problem(params[:id])
135 135 end
136 136 end
137 137
138 138 def manage
139 139 @problems = Problem.find(:all, :order => 'date_added DESC')
140 140 end
141 141
142 142 def do_manage
143 143 if params.has_key? 'change_date_added'
144 144 change_date_added
145 145 end
146 146 redirect_to :action => 'manage'
147 147 end
148 148
149 149 def import
150 + @allow_test_pair_import = allow_test_pair_import?
150 151 end
151 152
152 153 def do_import
153 154 old_problem = Problem.find_by_name(params[:name])
155 + if !allow_test_pair_import? and params.has_key? :import_to_db
156 + params.delete :import_to_db
157 + end
154 158 @problem, import_log = Problem.create_from_import_form_params(params,
155 159 old_problem)
156 160
157 161 if @problem.errors.length != 0
158 162 render :action => 'import' and return
159 163 end
160 164
161 165 if old_problem!=nil
162 166 flash[:notice] = "The test data has been replaced for problem #{@problem.name}"
163 167 end
164 168 @log = import_log
165 169 end
166 170
167 171 ##################################
168 172 protected
169 173
174 + def allow_test_pair_import?
175 + if defined? ALLOW_TEST_PAIR_IMPORT
176 + return ALLOW_TEST_PAIR_IMPORT
177 + else
178 + return false
179 + end
180 + end
181 +
170 182 def change_date_added
171 183 problems = get_problems_from_params
172 184 year = params[:date_added][:year].to_i
173 185 month = params[:date_added][:month].to_i
174 186 day = params[:date_added][:day].to_i
175 187 date = Date.new(year,month,day)
176 188 problems.each do |p|
177 189 p.date_added = date
178 190 p.save
179 191 end
180 192 end
181 193
182 194 def get_problems_from_params
183 195 problems = []
184 196 params.keys.each do |k|
185 197 if k.index('prob-')==0
186 198 name, id = k.split('-')
187 199 problems << Problem.find(id)
188 200 end
189 201 end
190 202 problems
191 203 end
192 204
193 205 end
@@ -12,47 +12,48
12 12 - form_tag({:action => 'do_import'}, :multipart => true) do
13 13 .submitbox
14 14 %table
15 15 %tr
16 16 %td Name:
17 17 %td= text_field_tag 'name'
18 18 %tr
19 19 %td Full name:
20 20 %td
21 21 = text_field_tag 'full_name'
22 22 %span{:class => 'help'} Leave blank to use the same value as the name above.
23 23 %tr
24 24 %td Testdata file:
25 25 %td= file_field_tag 'file'
26 26 %tr
27 27 %td
28 28 %td
29 29 %span{:class => 'help'}
30 30 In .zip, .tgz, tar.gz, .tar format.
31 31 It should includes inputs (e.g., 1.in, 2a.in, 2b.in)
32 32 and solutions (e.g., 1.sol, 2a.sol, 2b.sol).
33 33 %br/
34 34 You may put task description in *.html for raw html
35 35 and *.md or *.markdown for markdown.
36 + - if @allow_test_pair_import
36 37 %tr
37 38 %td
38 39 %td
39 40 = check_box_tag 'import_to_db'
40 41 Import test data to database (for a test-pair task)
41 42 %tr
42 43 %td Time limit:
43 44 %td
44 45 = text_field_tag 'time_limit'
45 46 %span{:class => 'help'} In seconds. Leave blank to use 1 sec.
46 47 %tr
47 48 %td Memory limit:
48 49 %td
49 50 = text_field_tag 'memory_limit'
50 51 %span{:class => 'help'} In MB. Leave blank to use 32MB.
51 52 %tr
52 53 %td
53 54 %td= submit_tag 'Import problem'
54 55
55 56 - if @log
56 57 %h3 Import log
57 58 %pre.import-log
58 59 = @log
@@ -69,33 +69,37
69 69
70 70 # Add new mime types for use in respond_to blocks:
71 71 # Mime::Type.register "text/richtext", :rtf
72 72 # Mime::Type.register "application/x-mobile", :mobile
73 73
74 74 # Include your application configuration below
75 75
76 76 # If you want to manage graders through web interface, set the path to
77 77 # the grader directory below. This dir is where raw, ev, ev-exam,
78 78 # scripts reside. All grader scripts will be in
79 79 # #{GRADER_ROOT_DIR}/scripts.
80 80 GRADER_ROOT_DIR = ''
81 81
82 82 # These are where inputs and outputs of test requests are stored
83 83 TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input'
84 84 TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output'
85 85
86 86 # To use ANALYSIS MODE, provide the testcases/testruns breakdown,
87 87 # and the directory of the grading result (usually in judge's dir).
88 88 TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml'
89 89
90 90 # TODO: change this to where results are kept.
91 91 GRADING_RESULT_DIR = 'RESULT-DIR'
92 92
93 - # Uncomment so that configuration is read only once when the server is loaded
94 - # Configuration.enable_caching
93 + # Change this to allow importing testdata into database as test-pairs.
94 + # This is mainly for Code Jom contest.
95 + ALLOW_TEST_PAIR_IMPORT = false
95 96
96 97 # Uncomment so that the system validates user e-mails
97 98 # VALIDATE_USER_EMAILS = true
98 99
99 100 # Uncomment so that Apache X-Sendfile is used when delivering files
100 101 # (e.g., in /tasks/view).
101 102 # USE_APACHE_XSENDFILE = true
103 +
104 + # Uncomment so that configuration is read only once when the server is loaded
105 + # Configuration.enable_caching
You need to be logged in to leave comments. Login now