Description:
forgot to change prob controller back before commit last change git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@288 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r149:c4d6d4f3628c - - 1 file changed: 0 inserted, 4 deleted

@@ -37,84 +37,80
37 end
37 end
38 else
38 else
39 @description = nil
39 @description = nil
40 end
40 end
41 @problem.description = @description
41 @problem.description = @description
42 if @problem.save
42 if @problem.save
43 flash[:notice] = 'Problem was successfully created.'
43 flash[:notice] = 'Problem was successfully created.'
44 redirect_to :action => 'list'
44 redirect_to :action => 'list'
45 else
45 else
46 render :action => 'new'
46 render :action => 'new'
47 end
47 end
48 end
48 end
49
49
50 def edit
50 def edit
51 @problem = Problem.find(params[:id])
51 @problem = Problem.find(params[:id])
52 @description = @problem.description
52 @description = @problem.description
53 end
53 end
54
54
55 def update
55 def update
56 @problem = Problem.find(params[:id])
56 @problem = Problem.find(params[:id])
57 @description = @problem.description
57 @description = @problem.description
58 if @description == nil and params[:description][:body]!=''
58 if @description == nil and params[:description][:body]!=''
59 @description = Description.new(params[:description])
59 @description = Description.new(params[:description])
60 if !@description.save
60 if !@description.save
61 flash[:notice] = 'Error saving description'
61 flash[:notice] = 'Error saving description'
62 render :action => 'edit' and return
62 render :action => 'edit' and return
63 end
63 end
64 @problem.description = @description
64 @problem.description = @description
65 elsif @description!=nil
65 elsif @description!=nil
66 if !@description.update_attributes(params[:description])
66 if !@description.update_attributes(params[:description])
67 flash[:notice] = 'Error saving description'
67 flash[:notice] = 'Error saving description'
68 render :action => 'edit' and return
68 render :action => 'edit' and return
69 end
69 end
70 end
70 end
71 if @problem.update_attributes(params[:problem])
71 if @problem.update_attributes(params[:problem])
72 flash[:notice] = 'Problem was successfully updated.'
72 flash[:notice] = 'Problem was successfully updated.'
73 redirect_to :action => 'show', :id => @problem
73 redirect_to :action => 'show', :id => @problem
74 else
74 else
75 render :action => 'edit'
75 render :action => 'edit'
76 end
76 end
77 end
77 end
78
78
79 def destroy
79 def destroy
80 Problem.find(params[:id]).destroy
80 Problem.find(params[:id]).destroy
81 redirect_to :action => 'list'
81 redirect_to :action => 'list'
82 end
82 end
83
83
84 def toggle
84 def toggle
85 - respond_to do |wants|
86 - wants.js {
87 @problem = Problem.find(params[:id])
85 @problem = Problem.find(params[:id])
88 @problem.available = !(@problem.available)
86 @problem.available = !(@problem.available)
89 @problem.save
87 @problem.save
90 - }
91 - end
92 end
88 end
93
89
94 def turn_all_off
90 def turn_all_off
95 Problem.find(:all,
91 Problem.find(:all,
96 :conditions => "available = 1").each do |problem|
92 :conditions => "available = 1").each do |problem|
97 problem.available = false
93 problem.available = false
98 problem.save
94 problem.save
99 end
95 end
100 redirect_to :action => 'list'
96 redirect_to :action => 'list'
101 end
97 end
102
98
103 def turn_all_on
99 def turn_all_on
104 Problem.find(:all,
100 Problem.find(:all,
105 :conditions => "available = 0").each do |problem|
101 :conditions => "available = 0").each do |problem|
106 problem.available = true
102 problem.available = true
107 problem.save
103 problem.save
108 end
104 end
109 redirect_to :action => 'list'
105 redirect_to :action => 'list'
110 end
106 end
111
107
112 def stat
108 def stat
113 @problem = Problem.find(params[:id])
109 @problem = Problem.find(params[:id])
114 if !@problem.available
110 if !@problem.available
115 redirect_to :controller => 'main', :action => 'list'
111 redirect_to :controller => 'main', :action => 'list'
116 else
112 else
117 @submissions = Submission.find_all_last_by_problem(params[:id])
113 @submissions = Submission.find_all_last_by_problem(params[:id])
118 end
114 end
119 end
115 end
120 end
116 end
You need to be logged in to leave comments. Login now