Class: Admin::QuestionSheetsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/qe/admin/question_sheets_controller.rb

Instance Method Summary collapse

Instance Method Details

#archiveObject



23
24
25
26
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 23

def archive
  @question_sheet.update_attribute(:archived, true)
  redirect_to :back
end

#createObject

create sheet with inital page, redirect to show POST /question_sheets



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 52

def create
  @question_sheet = QuestionSheet.new_with_page
  
  respond_to do |format|
    if @question_sheet.save
      format.html { redirect_to admin_question_sheet_path(@question_sheet) }
      format.xml  { head :created, :location => admin_question_sheet_path(@question_sheet) }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @question_sheet.errors.to_xml }
    end
  end
end

#destroyObject

mark sheet as destroyed DELETE /question_sheets/1



93
94
95
96
97
98
99
100
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 93

def destroy
  @question_sheet.destroy
  
  respond_to do |format|
    format.html { redirect_to admin_question_sheets_path }
    format.xml  { head :ok }
  end
end

#duplicateObject



33
34
35
36
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 33

def duplicate
  @question_sheet.duplicate
  redirect_to :back
end

#editObject

display sheet properties panel GET /question_sheets/1/edit



68
69
70
71
72
73
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 68

def edit
  
  respond_to do |format|
    format.js
  end
end

#indexObject

list of all questionnaires/forms to edit GET /question_sheets



13
14
15
16
17
18
19
20
21
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 13

def index
  @active_question_sheets = QuestionSheet.active.order('label')
  @archived_question_sheets = QuestionSheet.archived.order('label')

  respond_to do |format|
    format.html # index.rhtml
    format.xml  { render :xml => @question_sheets.to_xml }
  end
end

#showObject

entry point: display form designer with page 1 and panels loaded GET /question_sheets/1



40
41
42
43
44
45
46
47
48
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 40

def show
  @all_pages = @question_sheet.pages.find(:all)
  @page = @all_pages[0]

  respond_to do |format|
    format.html # show.rhtml
    format.xml  { render :xml => @question_sheet.to_xml }
  end
end

#unarchiveObject



28
29
30
31
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 28

def unarchive
  @question_sheet.update_attribute(:archived, false)
  redirect_to :back
end

#updateObject

save changes to properties panel (label, language) PUT /question_sheets/1



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/controllers/qe/admin/question_sheets_controller.rb', line 77

def update
  respond_to do |format|
    if @question_sheet.update_attributes(params[:question_sheet], :without_protection => true)
      format.html { redirect_to admin_question_sheet_path(@question_sheet) }
      format.js 
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.js { render :action => "error.js.erb"}
      format.xml  { render :xml => @question_sheet.errors.to_xml }
    end
  end
end