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

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