Class: AssignmentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AssignmentsController
- Defined in:
- app/controllers/assignments_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /assignments POST /assignments.xml.
-
#destroy ⇒ Object
DELETE /assignments/1 DELETE /assignments/1.xml.
-
#edit ⇒ Object
GET /assignments/1/edit.
- #get_course ⇒ Object
- #index ⇒ Object
-
#new ⇒ Object
GET /assignments/new GET /assignments/new.xml.
- #render_grade_book_menu ⇒ Object
-
#reposition ⇒ Object
Inspiration for this technique comes from two sources A: awesomeful.net/posts/47-sortable-lists-with-jquery-in-rails (yield javascript, jquery ui code) B: henrik.nyh.se/2008/11/rails-jquery-sortables#comment-17220662 (model update code).
-
#show ⇒ Object
GET /course/assignment_reorder/1.
-
#update ⇒ Object
PUT /assignments/1 PUT /assignments/1.xml.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
POST /assignments POST /assignments.xml
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/assignments_controller.rb', line 49 def create @assignment = @course.assignments.new(params[:assignment]) :update, @course @assignment.set_due_date(params[:due_date][:date], params[:due_date][:hour], params[:due_date][:minute]) if params.has_key?(:due_date) respond_to do |format| if @assignment.save format.html { redirect_to(course_assignments_path, :notice => "#{@wording} #{@assignment.name} was successfully created.") } format.xml { render :xml => @assignment, :status => :created, :location => @assignment } else format.html { render :action => "new" } format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /assignments/1 DELETE /assignments/1.xml
103 104 105 106 107 108 109 110 111 |
# File 'app/controllers/assignments_controller.rb', line 103 def destroy @assignment = Assignment.find(params[:id]) :destroy, @assignment @assignment.destroy respond_to do |format| format.js end end |
#edit ⇒ Object
GET /assignments/1/edit
42 43 44 45 |
# File 'app/controllers/assignments_controller.rb', line 42 def edit @assignment = Assignment.find(params[:id]) :update, @course end |
#get_course ⇒ Object
10 11 12 13 |
# File 'app/controllers/assignments_controller.rb', line 10 def get_course @course=Course.find(params[:course_id]) @wording = @course.nomenclature_assignment_or_deliverable end |
#index ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/assignments_controller.rb', line 19 def index @assignments = Assignment.all(:conditions => ["course_id = ?", @course.id]) :read, Assignment respond_to do |format| format.html # index.html.erb format.xml { render :xml => @assignments } end end |
#new ⇒ Object
GET /assignments/new GET /assignments/new.xml
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/assignments_controller.rb', line 31 def new @assignment = Assignment.new :update, @course respond_to do |format| format.html # new.html.erb format.xml { render :xml => @assignment } end end |
#render_grade_book_menu ⇒ Object
15 16 17 |
# File 'app/controllers/assignments_controller.rb', line 15 def @is_in_grade_book = true end |
#reposition ⇒ Object
Inspiration for this technique comes from two sources A: awesomeful.net/posts/47-sortable-lists-with-jquery-in-rails (yield javascript, jquery ui code) B: henrik.nyh.se/2008/11/rails-jquery-sortables#comment-17220662 (model update code)
129 130 131 132 133 134 135 136 |
# File 'app/controllers/assignments_controller.rb', line 129 def reposition :reorder_assignments, @course order = params[:assignment] Rails.logger.debug(order) Assignment.reposition(order) render :text => order.inspect end |
#show ⇒ Object
GET /course/assignment_reorder/1
115 116 117 118 119 120 121 122 123 |
# File 'app/controllers/assignments_controller.rb', line 115 def show @no_pad = true @assignments = @course.assignments :read, @course respond_to do |format| format.html # showml.erb end end |
#update ⇒ Object
PUT /assignments/1 PUT /assignments/1.xml
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/assignments_controller.rb', line 66 def update @assignment = Assignment.find(params[:id]) :update, @course @assignment.set_due_date(params[:due_date][:date], params[:due_date][:hour], params[:due_date][:minute]) if params.has_key?(:due_date) deliverable_submitted=Deliverable.find_all_by_assignment_id(@assignment.id).first deliverable_status=0; unless deliverable_submitted.nil? if @assignment.is_team_deliverable.to_s!= params[:assignment]["is_team_deliverable"] deliverable_status=1 flash[:error] = "You cannot change the Type as the student(s) has already submitted for this item." end end if deliverable_status==0 respond_to do |format| if @assignment.update_attributes(params[:assignment]) format.html { redirect_to(course_assignments_path, :notice => "Assignment #{@assignment.name} was successfully updated.") } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity } end end else respond_to do |format| format.html { render :action => "edit" } format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity } end end end |