public
Created

  • Download Gist
gistfile1.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
class SpracticeClient.AppController extends Batman.Controller
question_list: null
step: 0
current: null
answer_text: null
step_message: null
options: [
new Option(body: "N/A", value: 0, image:'assets/options/na.png', skip: true)
new Option(body: "Sad", value: 1, image:'assets/options/1.png')
new Option(body: "Unhappy", value: 2, image:'assets/options/2.png')
new Option(body: "Indifferent", value: 3, image:'assets/options/3.png')
new Option(body: "Happy", value: 4, image:'assets/options/4.png')
new Option(body: "Ecstacy", value: 5, image:'assets/options/5.png')
]
 
index: ->
Question.load (error, questions) =>
throw error if error
if questions.length < 1
q_list = [
new Question(body: 'Was it easy to reach us?')
new Question(body: 'Was the person answering the phone friendly and helpful?')
new Question(body: 'Was it easy to make an appointment?')
new Question(body: 'Was the office easy to find? Was ample parking available?')
new Question(body: 'Was the staff friendly and did they greet you promptly?')
new Question(body: 'Was the waiting room clean and comfortable?')
new Question(body: 'Were you seen close to your appointment time?')
new Question(body: 'Did the doctor greet you promptly?')
new Question(body: 'Was the doctor approachable and have a good bedside manner?')
]
for q in q_list
q.save (error) -> throw error if error
@set 'question_list', questions
 
rec = @question_list[@step]
if rec
@set 'current', rec
if @step_message is null
@set 'step_message', "Step #{@step+1} of #{@question_list.length}"
 
prev: ->
if @step-1 >= 0
@step--
@set 'step_message', "Step #{@step+1} of #{@question_list.length}"
rec = @question_list[@step]
@set 'current', rec
next: ->
if @step+1 < @question_list.length
@step++
@set 'step_message', "Step #{@step+1} of #{@question_list.length}"
rec = @question_list[@step]
@set 'current', rec
else
@set 'step_message', 'Thanks!, Survey Finished!'
 
update: (node, event) ->
_id = parseInt node.getAttribute('id')
@set 'current.selected_answer', _id
@current.save (error) -> throw error if error

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.