Description:
problems sorted by update time
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r258:1821e2e3aeb0 - - 4 files changed: 25 inserted, 13 deleted

@@ -0,0 +1,9
1 + class AddTimestampToProblems < ActiveRecord::Migration
2 + def self.up
3 + add_column :problems, :updated_at, :timestamp
4 + end
5 +
6 + def self.down
7 + remove_column :problems, :updated_at
8 + end
9 + end
@@ -16,49 +16,51
16 16
17 17 DEFAULT_TIME_LIMIT = 1
18 18 DEFAULT_MEMORY_LIMIT = 32
19 19
20 20 def test_pair_count
21 21 @test_pair_count ||= test_pairs.size
22 22 end
23 23
24 24 def uses_random_test_pair?
25 25 test_pair_count != 0
26 26 end
27 27
28 28 def random_test_pair(forbidden_numbers=nil)
29 29 if forbidden_numbers.length < test_pair_count
30 30 begin
31 31 test_num = 1 + rand(test_pair_count)
32 32 end while forbidden_numbers!=nil and forbidden_numbers.include? test_num
33 33 else
34 34 test_num = 1 + rand(test_pair_count)
35 35 end
36 36 test_pairs.find_by_number test_num
37 37 end
38 38
39 39 def self.find_available_problems
40 - find(:all, :conditions => {:available => true}, :order => "date_added DESC")
40 + find(:all,
41 + :conditions => {:available => true},
42 + :order => "updated_at DESC")
41 43 end
42 44
43 45 # TODO: may try to optimize this using cache
44 46 def self.available_problem_count
45 47 return Problem.find_available_problems.length
46 48 end
47 49
48 50 def self.create_from_import_form_params(params, old_problem=nil)
49 51 problem = old_problem || Problem.new
50 52 import_params = Problem.extract_params_and_check(params, problem)
51 53
52 54 if not problem.valid?
53 55 return problem, 'Error importing'
54 56 end
55 57
56 58 problem.full_score = 100
57 59 problem.date_added = Time.new
58 60 problem.test_allowed = true
59 61 problem.output_only = false
60 62 problem.available = false
61 63
62 64 if not problem.save
63 65 return problem, 'Error importing'
64 66 end
@@ -16,27 +16,27
16 16 - if (Configuration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
17 17 %p=t 'main.start_soon'
18 18
19 19 - if Configuration.show_tasks_to?(@user)
20 20 .problem-list{:id => 'problem-list'}
21 21 = render :partial => 'problem_title', :collection => @problems, :as => :problem
22 22 .problem-content
23 23 %span{:id => "problem-panel-filler", :style => (@current_problem_id!=nil) ? "display:none" : ""}
24 24 %h2
25 25 Welcome to Code Jom
26 26 %br/
27 27 Choose problems from the list on the right.
28 28 = render :partial => 'problem', :collection => @problems
29 29
30 30 %br{:clear=>'both'}/
31 31 %hr/
32 32
33 33 %script{:type => 'text/javascript'}
34 34 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
35 35 Announcement.registerRefreshEventTimer();
36 36 = render :partial => 'submission_timeouts'
37 37 CodejomTimeout.updateProblemMessages();
38 38 CodejomTimeout.registerRefreshEvent();
39 39
40 - = periodically_call_remote(:url => { :action => 'problems' }, :update => 'problem-list')
40 + = periodically_call_remote(:url => { :action => 'problems' }, :update => 'problem-list', :frequency => '3')
41 41
42 42
@@ -1,36 +1,36
1 1 # This file is auto-generated from the current state of the database. Instead of editing this file,
2 2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 3 # then regenerate this schema definition.
4 4 #
5 5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 6 # to create the application database on another system, you should be using db:schema:load, not running
7 7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 8 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 9 #
10 10 # It's strongly recommended to check this file into your version control system.
11 11
12 - ActiveRecord::Schema.define(:version => 20100209145331) do
12 + ActiveRecord::Schema.define(:version => 20100210012432) do
13 13
14 14 create_table "announcements", :force => true do |t|
15 15 t.string "author"
16 16 t.text "body"
17 17 t.boolean "published"
18 18 t.datetime "created_at"
19 19 t.datetime "updated_at"
20 20 t.boolean "frontpage", :default => false
21 21 t.boolean "contest_only", :default => false
22 22 t.string "title"
23 23 end
24 24
25 25 create_table "codejom_statuses", :force => true do |t|
26 26 t.integer "user_id"
27 27 t.boolean "alive"
28 28 t.integer "num_problems_passed"
29 29 t.datetime "created_at"
30 30 t.datetime "updated_at"
31 31 end
32 32
33 33 create_table "configurations", :force => true do |t|
34 34 t.string "key"
35 35 t.string "value_type"
36 36 t.string "value"
@@ -63,58 +63,59
63 63 t.string "task_type"
64 64 t.boolean "terminated"
65 65 end
66 66
67 67 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
68 68
69 69 create_table "languages", :force => true do |t|
70 70 t.string "name", :limit => 10
71 71 t.string "pretty_name"
72 72 t.string "ext", :limit => 10
73 73 t.string "common_ext"
74 74 end
75 75
76 76 create_table "messages", :force => true do |t|
77 77 t.integer "sender_id"
78 78 t.integer "receiver_id"
79 79 t.integer "replying_message_id"
80 80 t.text "body"
81 81 t.boolean "replied"
82 82 t.datetime "created_at"
83 83 t.datetime "updated_at"
84 84 end
85 85
86 86 create_table "problems", :force => true do |t|
87 - t.string "name", :limit => 30
88 - t.string "full_name"
89 - t.integer "full_score"
90 - t.date "date_added"
91 - t.boolean "available"
92 - t.string "url"
93 - t.integer "description_id"
94 - t.boolean "test_allowed"
95 - t.boolean "output_only"
96 - t.integer "level", :default => 0
87 + t.string "name", :limit => 30
88 + t.string "full_name"
89 + t.integer "full_score"
90 + t.date "date_added"
91 + t.boolean "available"
92 + t.string "url"
93 + t.integer "description_id"
94 + t.boolean "test_allowed"
95 + t.boolean "output_only"
96 + t.integer "level", :default => 0
97 + t.datetime "updated_at"
97 98 end
98 99
99 100 create_table "rights", :force => true do |t|
100 101 t.string "name"
101 102 t.string "controller"
102 103 t.string "action"
103 104 end
104 105
105 106 create_table "rights_roles", :id => false, :force => true do |t|
106 107 t.integer "right_id"
107 108 t.integer "role_id"
108 109 end
109 110
110 111 add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
111 112
112 113 create_table "roles", :force => true do |t|
113 114 t.string "name"
114 115 end
115 116
116 117 create_table "roles_users", :id => false, :force => true do |t|
117 118 t.integer "role_id"
118 119 t.integer "user_id"
119 120 end
120 121
You need to be logged in to leave comments. Login now