Description:
fix change date not working in problem bulk manage
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r739:dd100c4f33f7 - - 1 file changed: 1 inserted, 1 deleted

@@ -211,100 +211,100
211 211 flash[:alert] = "The following problems are already in the group #{group.name}: " + failed.join(', ') if failed.count > 0
212 212 elsif params.has_key? 'add_tags'
213 213 get_problems_from_params.each do |p|
214 214 p.tag_ids += params[:tag_ids]
215 215 end
216 216 end
217 217
218 218 redirect_to :action => 'manage'
219 219 end
220 220
221 221 def import
222 222 @allow_test_pair_import = allow_test_pair_import?
223 223 end
224 224
225 225 def do_import
226 226 old_problem = Problem.find_by_name(params[:name])
227 227 if !allow_test_pair_import? and params.has_key? :import_to_db
228 228 params.delete :import_to_db
229 229 end
230 230 @problem, import_log = Problem.create_from_import_form_params(params,
231 231 old_problem)
232 232
233 233 if !@problem.errors.empty?
234 234 render :action => 'import' and return
235 235 end
236 236
237 237 if old_problem!=nil
238 238 flash[:notice] = "The test data has been replaced for problem #{@problem.name}"
239 239 end
240 240 @log = import_log
241 241 end
242 242
243 243 def remove_contest
244 244 problem = Problem.find(params[:id])
245 245 contest = Contest.find(params[:contest_id])
246 246 if problem!=nil and contest!=nil
247 247 problem.contests.delete(contest)
248 248 end
249 249 redirect_to :action => 'manage'
250 250 end
251 251
252 252 ##################################
253 253 protected
254 254
255 255 def allow_test_pair_import?
256 256 if defined? ALLOW_TEST_PAIR_IMPORT
257 257 return ALLOW_TEST_PAIR_IMPORT
258 258 else
259 259 return false
260 260 end
261 261 end
262 262
263 263 def change_date_added
264 264 problems = get_problems_from_params
265 265 date = Date.parse(params[:date_added])
266 266 problems.each do |p|
267 267 p.date_added = date
268 268 p.save
269 269 end
270 270 end
271 271
272 272 def add_to_contest
273 273 problems = get_problems_from_params
274 274 contest = Contest.find(params[:contest][:id])
275 275 if contest!=nil and contest.enabled
276 276 problems.each do |p|
277 277 p.contests << contest
278 278 end
279 279 end
280 280 end
281 281
282 282 def set_available(avail)
283 283 problems = get_problems_from_params
284 284 problems.each do |p|
285 285 p.available = avail
286 286 p.save
287 287 end
288 288 end
289 289
290 290 def get_problems_from_params
291 291 problems = []
292 292 params.keys.each do |k|
293 293 if k.index('prob-')==0
294 294 name, id, order = k.split('-')
295 295 problems << Problem.find(id)
296 296 end
297 297 end
298 298 problems
299 299 end
300 300
301 301 def get_problems_stat
302 302 end
303 303
304 304 private
305 305
306 306 def problem_params
307 - params.require(:problem).permit(:name, :full_name, :full_score, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[])
307 + params.require(:problem).permit(:name, :full_name, :full_score, :change_date_added, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[])
308 308 end
309 309
310 310 end
You need to be logged in to leave comments. Login now