qwester 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -43,6 +43,19 @@ answers is given by:
43
43
  However, these can be modified and added to as you require. That is, each
44
44
  question has a unique set of answers that can be modified as required.
45
45
 
46
+ === Answer selection list helper
47
+
48
+ The helper method qwester_answers_selection_list will output a set of form
49
+ elements matching the answers for the given question, as an unordered list.
50
+ The form elements will be radio buttons unless the question is marked as
51
+ 'multi-answer', in which case check boxes will be used.
52
+
53
+ <%= qwester_answers_selection_list(question) %>
54
+
55
+ The controller method update_qwester_answer_store can be used to manage the
56
+ data submitted from these form elements. It will add the answers to the
57
+ current answer store.
58
+
46
59
  === Answer store
47
60
 
48
61
  Submitted answers are stored in an AnswerStore object. On creation, each
@@ -50,6 +63,12 @@ answer_store is assigned a session_id that can then be used within session,
50
63
  to identify the current user's answer_store. In this way, questionnaire
51
64
  submissions can be tracked across multiple submissions.
52
65
 
66
+ By default the current answer_store.session_id is stored in
67
+ session[:qwester_answer_store]. If you wish to use a different session key,
68
+ set Qwester.session_key in the qwester initializer:
69
+
70
+ Qwester.session_key = :your_preferred_key
71
+
53
72
  === Rule set
54
73
 
55
74
  Groups of answers can be matched to rule sets using:
@@ -1,3 +1,3 @@
1
1
  module Qwester
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/qwester.rb CHANGED
@@ -24,4 +24,12 @@ module Qwester
24
24
  @active_admin_menu = menu
25
25
  end
26
26
 
27
+ def self.session_key
28
+ @session_key || :qwester_answer_store
29
+ end
30
+
31
+ def self.session_key=(key)
32
+ @session_key = key
33
+ end
34
+
27
35
  end
@@ -9,7 +9,7 @@ module ActionController
9
9
  end
10
10
 
11
11
  def get_qwester_answer_store(create_new = false)
12
- if session[:qwester_answer_store]
12
+ if session[Qwester.session_key]
13
13
  current_qwester_answer_store
14
14
  elsif create_new
15
15
  new_qwester_answer_store
@@ -18,7 +18,7 @@ module ActionController
18
18
  helper_method :get_qwester_answer_store
19
19
 
20
20
  def current_qwester_answer_store
21
- @qwester_answer_store = Qwester::AnswerStore.find_by_session_id(session[:qwester_answer_store])
21
+ @qwester_answer_store = Qwester::AnswerStore.find_by_session_id(session[Qwester.session_key])
22
22
  end
23
23
 
24
24
  def new_qwester_answer_store
@@ -27,7 +27,7 @@ module ActionController
27
27
 
28
28
  def set_qwester_answer_store(answer_store)
29
29
  @qwester_answer_store = answer_store
30
- session[:qwester_answer_store] = @qwester_answer_store.session_id
30
+ session[Qwester.session_key] = @qwester_answer_store.session_id
31
31
  @qwester_answer_store
32
32
  end
33
33
 
Binary file