Class: Helena::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/helena/sessions_controller.rb

Overview

TODO: Needs refactoring, is really ugly atm :-(

Instance Method Summary collapse

Instance Method Details

#editObject



22
23
24
25
26
# File 'app/controllers/helena/sessions_controller.rb', line 22

def edit
  @questions = question_group_questions
  @answers = session_answers
  @errors = {}
end

#showObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/helena/sessions_controller.rb', line 10

def show
  @session = Helena::Session.find_by view_token: params[:token]
  @survey = @session.survey
  @version = @survey.versions.find @session.version_id
  @question_group = question_group

  respond_to do |format|
    format.html { render html: session_report }
    format.json { render json: @session }
  end
end

#updateObject



28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/helena/sessions_controller.rb', line 28

def update
  if @question_group.last? && @errors.blank?
    @session.update_attribute :completed, true
    render 'end_message'
  else
    @question_group = @question_group.next_item if @errors.blank?
    @questions = question_group_questions
    render 'edit'
  end
end