Description:
problem toggle on/off
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r558:9fc5999b7c8e - - 3 files changed: 14 inserted, 21 deleted

@@ -4,27 +4,22
4 4
5 5 in_place_edit_for :problem, :name
6 6 in_place_edit_for :problem, :full_name
7 7 in_place_edit_for :problem, :full_score
8 8
9 9 def index
10 - list
11 - render :action => 'list'
10 + @problems = Problem.find(:all, :order => 'date_added DESC')
12 11 end
13 12
14 13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
15 14 verify :method => :post, :only => [ :destroy,
16 15 :create, :quick_create,
17 16 :do_manage,
18 17 :do_import,
19 18 :update ],
20 - :redirect_to => { :action => :list }
21 -
22 - def list
23 - @problems = Problem.find(:all, :order => 'date_added DESC')
24 - end
19 + :redirect_to => { :action => :index }
25 20
26 21 def show
27 22 @problem = Problem.find(params[:id])
28 23 end
29 24
30 25 def new
@@ -42,13 +37,13
42 37 else
43 38 @description = nil
44 39 end
45 40 @problem.description = @description
46 41 if @problem.save
47 42 flash[:notice] = 'Problem was successfully created.'
48 - redirect_to :action => 'list'
43 + redirect_to action: :index
49 44 else
50 45 render :action => 'new'
51 46 end
52 47 end
53 48
54 49 def quick_create
@@ -58,16 +53,16
58 53 @problem.available = false
59 54 @problem.test_allowed = true
60 55 @problem.output_only = false
61 56 @problem.date_added = Time.new
62 57 if @problem.save
63 58 flash[:notice] = 'Problem was successfully created.'
64 - redirect_to :action => 'list'
59 + redirect_to action: :index
65 60 else
66 61 flash[:notice] = 'Error saving problem'
67 - redirect_to :action => 'list'
62 + redirect_to action: :index
68 63 end
69 64 end
70 65
71 66 def edit
72 67 @problem = Problem.find(params[:id])
73 68 @description = @problem.description
@@ -118,37 +113,39
118 113 render :action => 'edit'
119 114 end
120 115 end
121 116
122 117 def destroy
123 118 Problem.find(params[:id]).destroy
124 - redirect_to :action => 'list'
119 + redirect_to action: :index
125 120 end
126 121
127 122 def toggle
128 123 @problem = Problem.find(params[:id])
129 - @problem.available = !(@problem.available)
130 - @problem.save
124 + @problem.update_attributes(available: !(@problem.available) )
125 + respond_to do |format|
126 + format.js {}
127 + end
131 128 end
132 129
133 130 def turn_all_off
134 131 Problem.find(:all,
135 132 :conditions => "available = 1").each do |problem|
136 133 problem.available = false
137 134 problem.save
138 135 end
139 - redirect_to :action => 'list'
136 + redirect_to action: :index
140 137 end
141 138
142 139 def turn_all_on
143 140 Problem.find(:all,
144 141 :conditions => "available = 0").each do |problem|
145 142 problem.available = true
146 143 problem.save
147 144 end
148 - redirect_to :action => 'list'
145 + redirect_to action: :index
149 146 end
150 147
151 148 def stat
152 149 @problem = Problem.find(params[:id])
153 150 unless @problem.available or session[:admin]
154 151 redirect_to :controller => 'main', :action => 'list'
@@ -7,12 +7,14
7 7
8 8 resources :announcements
9 9 match 'announcements/toggle/:id' => 'announcements#toggle'
10 10
11 11 resources :sites
12 12
13 + resources :problem
14 +
13 15 resources :grader_configuration, controller: 'configurations'
14 16
15 17 match 'tasks/view/:file.:ext' => 'tasks#view'
16 18 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
17 19 match 'heartbeat/:id/edit' => 'heartbeat#edit'
18 20
deleted file
You need to be logged in to leave comments. Login now