Description:
add submissions to users
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r738:d514585a072a - - 1 file changed: 2 inserted, 0 deleted

@@ -1,63 +1,65
1 1 class Problem < ActiveRecord::Base
2 2
3 3 belongs_to :description
4 4 has_and_belongs_to_many :contests, :uniq => true
5 5
6 6 #has_and_belongs_to_many :groups
7 7 has_many :groups_problems, class_name: GroupProblem
8 8 has_many :groups, :through => :groups_problems
9 9
10 10 has_many :problems_tags, class_name: ProblemTag
11 11 has_many :tags, through: :problems_tags
12 12
13 13 has_many :test_pairs, :dependent => :delete_all
14 14 has_many :testcases, :dependent => :destroy
15 15
16 + has_many :submissions
17 +
16 18 validates_presence_of :name
17 19 validates_format_of :name, :with => /\A\w+\z/
18 20 validates_presence_of :full_name
19 21
20 22 scope :available, -> { where(available: true) }
21 23
22 24 DEFAULT_TIME_LIMIT = 1
23 25 DEFAULT_MEMORY_LIMIT = 32
24 26
25 27 def self.available_problems
26 28 available.order(date_added: :desc).order(:name)
27 29 #Problem.available.all(:order => "date_added DESC, name ASC")
28 30 end
29 31
30 32 def self.create_from_import_form_params(params, old_problem=nil)
31 33 org_problem = old_problem || Problem.new
32 34 import_params, problem = Problem.extract_params_and_check(params,
33 35 org_problem)
34 36
35 37 if !problem.errors.empty?
36 38 return problem, 'Error importing'
37 39 end
38 40
39 41 problem.full_score = 100
40 42 problem.date_added = Time.new
41 43 problem.test_allowed = true
42 44 problem.output_only = false
43 45 problem.available = false
44 46
45 47 if not problem.save
46 48 return problem, 'Error importing'
47 49 end
48 50
49 51 import_to_db = params.has_key? :import_to_db
50 52
51 53 importer = TestdataImporter.new(problem)
52 54
53 55 if not importer.import_from_file(import_params[:file],
54 56 import_params[:time_limit],
55 57 import_params[:memory_limit],
56 58 import_params[:checker_name],
57 59 import_to_db)
58 60 problem.errors.add(:base,'Import error.')
59 61 end
60 62
61 63 return problem, importer.log_msg
62 64 end
63 65
You need to be logged in to leave comments. Login now