surveyor 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +26 -0
- data/Gemfile +11 -0
- data/Gemfile.rails_version +13 -0
- data/README.md +40 -22
- data/Rakefile +92 -29
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +9 -9
- data/app/views/partials/_answer.html.haml +1 -1
- data/app/views/partials/_question.html.haml +3 -3
- data/app/views/partials/_question_group.html.haml +2 -2
- data/app/views/partials/_section.html.haml +1 -1
- data/app/views/surveyor/edit.html.haml +11 -3
- data/app/views/surveyor/new.html.haml +8 -1
- data/ci-exec.sh +50 -0
- data/config/routes.rb +9 -13
- data/cucumber.yml +10 -0
- data/doc/question types.png +0 -0
- data/features/redcap_parser.feature +1 -1
- data/features/step_definitions/common_setps.rb +3 -0
- data/features/step_definitions/parser_steps.rb +8 -1
- data/features/step_definitions/surveyor_steps.rb +33 -9
- data/features/step_definitions/web_steps.rb +85 -165
- data/features/support/env.rb +40 -46
- data/features/support/paths.rb +4 -4
- data/features/support/selectors.rb +39 -0
- data/features/surveyor.feature +63 -13
- data/features/surveyor_dependencies.feature +289 -0
- data/features/surveyor_parser.feature +29 -20
- data/lib/formtastic/surveyor_builder.rb +9 -9
- data/lib/generators/surveyor/custom_generator.rb +17 -0
- data/lib/generators/surveyor/install_generator.rb +50 -0
- data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/controllers}/surveyor_controller.rb +0 -0
- data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/views/layouts}/surveyor_custom.html.erb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_en.yml +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_es.yml +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_he.yml +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_api_ids.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_correct_answer_id_to_questions.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_default_value_to_answers.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_order_to_surveys.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_type_to_answers.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_response_sets.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_surveys.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_section_id_to_responses.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_unique_indicies.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_answers.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependencies.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependency_conditions.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_question_groups.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_questions.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_response_sets.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_responses.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_survey_sections.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_surveys.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validation_conditions.rb +0 -0
- data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validations.rb +0 -0
- data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/next.gif +0 -0
- data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/prev.gif +0 -0
- data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +499 -0
- data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.surveyor.js +47 -4
- data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.tools.min.js +0 -0
- data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/custom.sass +0 -0
- data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/surveyor.sass +2 -2
- data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/dateinput.css +0 -0
- data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/reset.css +0 -0
- data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/results.css +0 -0
- data/{generators/extend_surveyor/templates/EXTENDING_SURVEYOR → lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md} +0 -0
- data/{generators → lib/generators}/surveyor/templates/surveys/kitchen_sink_survey.rb +0 -0
- data/{generators → lib/generators}/surveyor/templates/surveys/quiz.rb +0 -0
- data/lib/surveyor.rb +7 -0
- data/lib/surveyor/engine.rb +12 -0
- data/lib/surveyor/models/answer_methods.rb +0 -1
- data/lib/surveyor/models/dependency_condition_methods.rb +1 -3
- data/lib/surveyor/models/question_methods.rb +0 -1
- data/lib/surveyor/models/response_methods.rb +2 -2
- data/lib/surveyor/models/response_set_methods.rb +30 -14
- data/lib/surveyor/models/survey_methods.rb +2 -1
- data/lib/surveyor/models/survey_section_methods.rb +1 -2
- data/lib/surveyor/parser.rb +9 -7
- data/lib/surveyor/redcap_parser.rb +10 -7
- data/lib/surveyor/surveyor_controller_methods.rb +45 -11
- data/lib/surveyor/version.rb +3 -0
- data/lib/tasks/surveyor_tasks.rake +2 -2
- data/rails/init.rb +0 -1
- data/spec/controllers/surveyor_controller_spec.rb +81 -35
- data/spec/helpers/surveyor_helper_spec.rb +7 -1
- data/spec/models/dependency_condition_spec.rb +76 -63
- data/spec/models/response_set_spec.rb +52 -47
- data/spec/models/response_spec.rb +19 -16
- data/spec/spec_helper.rb +21 -44
- data/surveyor.gemspec +25 -176
- metadata +302 -77
- data/CHANGELOG +0 -335
- data/VERSION +0 -1
- data/ci-env.sh +0 -29
- data/generators/extend_surveyor/extend_surveyor_generator.rb +0 -21
- data/generators/surveyor/surveyor_generator.rb +0 -69
- data/generators/surveyor/templates/README +0 -10
- data/generators/surveyor/templates/tasks/surveyor.rb +0 -4
- data/hudson.rakefile +0 -33
- data/init_testbed.rakefile +0 -55
- data/testbed/Gemfile +0 -13
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
Gemfile.lock
|
21
|
+
reports
|
22
|
+
|
23
|
+
## PROJECT::SPECIFIC
|
24
|
+
testbed
|
25
|
+
surveys/fixtures/*.yml
|
26
|
+
.rvmrc
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
eval(File.read File.expand_path('../Gemfile.rails_version', __FILE__))
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
# use git version for the ci:setup:rspecbase task; not there in
|
9
|
+
# 1.6.5, but might be in a later version.
|
10
|
+
gem 'ci_reporter', :git => 'git://github.com/nicksieger/ci_reporter.git'
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# For testing against different releases of Rails. This is in a
|
2
|
+
# separate fragment so that it can be sourced from the test
|
3
|
+
# application's Gemfile in addition to the main development Gemfile.
|
4
|
+
if ENV['RAILS_VERSION']
|
5
|
+
case ENV['RAILS_VERSION']
|
6
|
+
when /3.0$/
|
7
|
+
gem 'rails', '~> 3.0.10'
|
8
|
+
when /3.1$/
|
9
|
+
gem 'rails', '~> 3.1.0'
|
10
|
+
else
|
11
|
+
fail "Unknown Rails version #{ENV['RAILS_VERSION']}"
|
12
|
+
end
|
13
|
+
end
|
data/README.md
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# Surveys On Rails
|
2
2
|
|
3
|
-
Surveyor is a ruby gem and developer tool that brings surveys into Rails applications. Surveys are written in the Surveyor DSL (Domain Specific Language).
|
4
|
-
|
5
|
-
Before Rails 2.3, it was implemented as a Rails Engine. It also existed previously as a plugin. Today it is a gem only.
|
6
|
-
|
7
|
-
The rails3 branch is functional for use with Rails 3.
|
3
|
+
Surveyor is a ruby gem and developer tool that brings surveys into Rails applications. Surveys are written in the Surveyor DSL (Domain Specific Language). Before Rails 2.3, it was implemented as a Rails Engine. It also existed previously as a plugin. Today it is a gem only.
|
8
4
|
|
9
5
|
## Why you might want to use Surveyor
|
10
6
|
|
@@ -17,11 +13,11 @@ The Surveyor DSL defines questions, answers, question groups, survey sections, d
|
|
17
13
|
The Surveyor DSL supports a wide range of question types (too many to list here) and complex dependency logic. Here are the first few questions of the "kitchen sink" survey which should give you and idea of how it works. The full example with all the types of questions available if you follow the installation instructions below.
|
18
14
|
|
19
15
|
survey "Kitchen Sink survey" do
|
20
|
-
|
16
|
+
|
21
17
|
section "Basic questions" do
|
22
18
|
# A label is a question that accepts no answers
|
23
19
|
label "These questions are examples of the basic supported input types"
|
24
|
-
|
20
|
+
|
25
21
|
# A basic question with radio buttons
|
26
22
|
question_1 "What is your favorite color?", :pick => :one
|
27
23
|
answer "red"
|
@@ -29,7 +25,7 @@ The Surveyor DSL supports a wide range of question types (too many to list here)
|
|
29
25
|
answer "green"
|
30
26
|
answer "yellow"
|
31
27
|
answer :other
|
32
|
-
|
28
|
+
|
33
29
|
# A basic question with checkboxes
|
34
30
|
# "question" and "answer" may be abbreviated as "q" and "a"
|
35
31
|
q_2 "Choose the colors you don't like", :pick => :any
|
@@ -38,8 +34,8 @@ The Surveyor DSL supports a wide range of question types (too many to list here)
|
|
38
34
|
a_3 "green"
|
39
35
|
a_4 "yellow"
|
40
36
|
a :omit
|
41
|
-
|
42
|
-
# A dependent question, with conditions and rule to logically join them
|
37
|
+
|
38
|
+
# A dependent question, with conditions and rule to logically join them
|
43
39
|
# the question's reference identifier is "2a", and the answer's reference_identifier is "1"
|
44
40
|
# question reference identifiers used in conditions need to be unique on a survey for the lookups to work
|
45
41
|
q_2a "Please explain why you don't like this color?"
|
@@ -49,25 +45,28 @@ The Surveyor DSL supports a wide range of question types (too many to list here)
|
|
49
45
|
condition_B :q_2, "==", :a_2
|
50
46
|
condition_C :q_2, "==", :a_3
|
51
47
|
condition_D :q_2, "==", :a_4
|
52
|
-
|
48
|
+
|
53
49
|
# ... other question, sections and such. See surveys/kitchen_sink_survey.rb for more.
|
54
|
-
end
|
55
|
-
|
50
|
+
end
|
51
|
+
|
56
52
|
end
|
57
|
-
|
53
|
+
|
58
54
|
The first question is "pick one" (radio buttons) with "other". The second question is "pick any" (checkboxes) with the option to "omit". It also features a dependency with a follow up question. Notice the dependency rule is defined as a string. We support complex dependency such as "A and (B or C) and D" or "A or ((B and C) or D)". The conditions are evaluated separately using the operators "==","!=","<>", ">=","<" the substituted by letter into to the dependency rule and evaluated.
|
59
55
|
|
60
56
|
# Installation
|
61
57
|
|
62
|
-
1. Add
|
58
|
+
1. Add surveyor to your Gemfile (add add haml too if you haven't already):
|
63
59
|
|
64
60
|
gem "surveyor"
|
61
|
+
gem "haml"
|
62
|
+
|
63
|
+
Then run:
|
65
64
|
|
66
65
|
`bundle install`
|
67
66
|
|
68
67
|
2. Generate assets, run migrations:
|
69
|
-
|
70
|
-
`script/generate surveyor`
|
68
|
+
|
69
|
+
`script/rails generate surveyor:install`
|
71
70
|
`rake db:migrate`
|
72
71
|
|
73
72
|
3. Try out the "kitchen sink" survey. The rake task above generates surveys from our custom survey DSL (a good format for end users and stakeholders).
|
@@ -89,7 +88,7 @@ There are two other useful rake tasks for removing (only surveys without respons
|
|
89
88
|
|
90
89
|
Surveyor's controller, models, and views may be customized via classes in your app/models, app/helpers and app/controllers directories. To generate a sample custom controller and layout, run:
|
91
90
|
|
92
|
-
`script/generate
|
91
|
+
`script/rails generate surveyor:custom`
|
93
92
|
|
94
93
|
and read surveys/EXTENDING\_SURVEYOR
|
95
94
|
|
@@ -98,17 +97,36 @@ and read surveys/EXTENDING\_SURVEYOR
|
|
98
97
|
Surveyor depends on:
|
99
98
|
|
100
99
|
* Ruby (1.8.7 - 1.9.2)
|
101
|
-
* Rails
|
100
|
+
* Rails 3.x
|
102
101
|
* HAML
|
103
102
|
* SASS
|
104
103
|
* fastercsv (or CSV for ruby 1.9) for csv exports
|
105
104
|
* formtastic
|
106
105
|
* UUID
|
107
106
|
|
108
|
-
|
107
|
+
Specific versions of the gem dependencies are listed in the gemspec.
|
108
|
+
|
109
|
+
# Contributing, testing
|
110
|
+
|
111
|
+
To work on the code, fork this github project. Install [bundler][] if
|
112
|
+
you don't have it, then run
|
113
|
+
|
114
|
+
$ bundle update
|
115
|
+
|
116
|
+
to install all the necessary gems. Then
|
117
|
+
|
118
|
+
$ bundle exec rake testbed
|
119
|
+
|
120
|
+
to generate a test app in `testbed`. Now you can run
|
121
|
+
|
122
|
+
$ bundle exec rake spec
|
123
|
+
|
124
|
+
to run the specs and
|
125
|
+
|
126
|
+
$ bundle exec rake cucumber
|
109
127
|
|
110
|
-
|
128
|
+
to run the features and start writing tests!
|
111
129
|
|
112
|
-
|
130
|
+
[bundler]: http://gembundler.com/
|
113
131
|
|
114
132
|
Copyright (c) 2008-2011 Brian Chamberlain and Mark Yoon, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,33 +1,96 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'cucumber/rake/task'
|
6
|
+
require 'ci/reporter/rake/rspec'
|
7
|
+
|
8
|
+
###### RSPEC
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
13
|
+
spec.rcov = true
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :spec
|
17
|
+
|
18
|
+
###### CUCUMBER
|
19
|
+
|
20
|
+
namespace :cucumber do
|
21
|
+
Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
|
22
|
+
t.profile = 'default'
|
23
|
+
end
|
24
|
+
|
25
|
+
Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Run all features'
|
30
|
+
task :all => [:ok, :wip]
|
31
|
+
end
|
32
|
+
desc 'Alias for cucumber:ok'
|
33
|
+
task :cucumber => 'cucumber:ok'
|
34
|
+
|
35
|
+
###### TESTBED
|
36
|
+
|
37
|
+
desc 'Set up the rails app that the specs and features use'
|
38
|
+
task :testbed => 'testbed:rebuild'
|
39
|
+
|
40
|
+
namespace :testbed do
|
41
|
+
desc 'Generate a minimal surveyor-using rails app'
|
42
|
+
task :generate do
|
43
|
+
sh 'bundle exec rails new testbed'
|
44
|
+
chdir('testbed') do
|
45
|
+
File.open('Gemfile', 'w') do |f|
|
46
|
+
f.puts %q{source :rubygems}
|
47
|
+
f.puts %q{plugin_root = File.expand_path('../..', __FILE__)}
|
48
|
+
f.puts %q{eval(File.read File.join(plugin_root, 'Gemfile.rails_version'))}
|
49
|
+
f.puts %q{gem 'sqlite3'}
|
50
|
+
f.puts %q{gem 'surveyor', :path => plugin_root}
|
51
|
+
end
|
52
|
+
|
53
|
+
Bundler.with_clean_env do
|
54
|
+
sh 'bundle update'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'Prepare the databases for the testbed'
|
60
|
+
task :migrate do
|
61
|
+
chdir('testbed') do
|
62
|
+
Bundler.with_clean_env do
|
63
|
+
sh 'bundle exec rails generate surveyor:install'
|
64
|
+
sh 'bundle exec rake db:migrate db:test:prepare'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'Remove the testbed entirely'
|
70
|
+
task :remove do
|
71
|
+
rm_rf 'testbed'
|
72
|
+
end
|
73
|
+
|
74
|
+
task :rebuild => [:remove, :generate, :migrate]
|
24
75
|
end
|
25
76
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
77
|
+
###### CI
|
78
|
+
|
79
|
+
namespace :ci do
|
80
|
+
task :all => ['rake:testbed', :spec, :cucumber, 'cucumber:wip']
|
81
|
+
|
82
|
+
task :env do
|
83
|
+
ENV['CI_REPORTS'] = 'reports/spec-xml'
|
84
|
+
ENV['SPEC_OPTS'] = "#{ENV['SPEC_OPTS']} --format nested"
|
85
|
+
end
|
86
|
+
|
87
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features using the CI profile') do |t|
|
88
|
+
t.profile = 'ci'
|
32
89
|
end
|
90
|
+
|
91
|
+
Cucumber::Rake::Task.new('cucumber:wip', 'Run WIP features using the CI profile') do |t|
|
92
|
+
t.profile = 'ci_wip'
|
93
|
+
end
|
94
|
+
|
95
|
+
task :spec => [:env, 'ci:setup:rspecbase', 'rake:spec']
|
33
96
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class SurveyFormBuilder < ActionView::Helpers::FormBuilder
|
2
|
+
def survey_check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
|
3
|
+
fields = @template.survey_check_box(@object_name, method, options.merge(:object => @object), checked_value, unchecked_value)
|
4
|
+
fields[1]
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ActionView
|
9
|
+
module Helpers
|
10
|
+
module FormHelper
|
11
|
+
def survey_check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
|
12
|
+
if (Rails::VERSION::STRING.to_f > 2.1)
|
13
|
+
InstanceTag.new(object_name, method, self, options.delete(:object)).to_survey_check_box_tag(options, checked_value, unchecked_value)
|
14
|
+
else
|
15
|
+
InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_survey_check_box_tag(options, checked_value, unchecked_value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class InstanceTag
|
21
|
+
def to_survey_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
|
22
|
+
options = options.stringify_keys
|
23
|
+
options["type"] = "checkbox"
|
24
|
+
options["value"] = checked_value
|
25
|
+
if options.has_key?("checked")
|
26
|
+
cv = options.delete "checked"
|
27
|
+
checked = cv == true || cv == "checked"
|
28
|
+
else
|
29
|
+
checked = self.class.check_box_checked?(value(object), checked_value)
|
30
|
+
end
|
31
|
+
options["checked"] = "checked" if checked
|
32
|
+
add_default_name_and_id(options)
|
33
|
+
[tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value), tag("input", options)]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module SurveyorHelper
|
2
2
|
# Layout: stylsheets and javascripts
|
3
3
|
def surveyor_includes
|
4
|
-
surveyor_stylsheets + surveyor_javascripts
|
4
|
+
surveyor_stylsheets + surveyor_javascripts
|
5
5
|
end
|
6
6
|
def surveyor_stylsheets
|
7
7
|
stylesheet_link_tag 'surveyor/reset', 'surveyor/dateinput', 'surveyor', 'custom'
|
8
8
|
end
|
9
9
|
def surveyor_javascripts
|
10
|
-
javascript_include_tag 'surveyor/jquery.tools.min', 'surveyor/jquery.surveyor'
|
10
|
+
javascript_include_tag 'surveyor/jquery.tools.min', 'surveyor/jquery.surveyor', 'surveyor/jquery.blockUI'
|
11
11
|
end
|
12
12
|
# Helper for displaying warning/notice/error flash messages
|
13
13
|
def flash_messages(types)
|
@@ -28,13 +28,13 @@ module SurveyorHelper
|
|
28
28
|
end
|
29
29
|
def previous_section
|
30
30
|
# use copy in memory instead of making extra db calls
|
31
|
-
submit_tag(t('surveyor.previous_section'), :name => "section[#{@sections[@sections.index(@section)-1].id}]") unless @sections.first == @section
|
31
|
+
submit_tag(t('surveyor.previous_section').html_safe, :name => "section[#{@sections[@sections.index(@section)-1].id}]") unless @sections.first == @section
|
32
32
|
end
|
33
33
|
def next_section
|
34
34
|
# use copy in memory instead of making extra db calls
|
35
|
-
@sections.last == @section ? submit_tag(t('surveyor.click_here_to_finish'), :name => "finish") : submit_tag(t('surveyor.next_section'), :name => "section[#{@sections[@sections.index(@section)+1].id}]")
|
35
|
+
@sections.last == @section ? submit_tag(t('surveyor.click_here_to_finish').html_safe, :name => "finish") : submit_tag(t('surveyor.next_section').html_safe, :name => "section[#{@sections[@sections.index(@section)+1].id}]")
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Questions
|
39
39
|
def q_text(obj)
|
40
40
|
@n ||= 0
|
@@ -48,12 +48,12 @@ module SurveyorHelper
|
|
48
48
|
# def question_help_helper(question)
|
49
49
|
# question.help_text.blank? ? "" : %Q(<span class="question-help">#{question.help_text}</span>)
|
50
50
|
# end
|
51
|
-
|
51
|
+
|
52
52
|
# Answers
|
53
53
|
def a_text(obj, pos=nil)
|
54
54
|
return image_tag(obj.text) if obj.is_a?(Answer) and obj.display_type == "image"
|
55
55
|
obj.split_or_hidden_text(pos)
|
56
|
-
end
|
56
|
+
end
|
57
57
|
def rc_to_attr(type_sym)
|
58
58
|
case type_sym.to_s
|
59
59
|
when /^date|time$/ then :datetime_value
|
@@ -73,7 +73,7 @@ module SurveyorHelper
|
|
73
73
|
html[:value] = default_value if response_class.blank?
|
74
74
|
html
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# Responses
|
78
78
|
def response_for(response_set, question, answer = nil, response_group = nil)
|
79
79
|
return nil unless response_set && question && question.id
|
@@ -83,5 +83,5 @@ module SurveyorHelper
|
|
83
83
|
def response_idx(increment = true)
|
84
84
|
@rc ||= 0
|
85
85
|
(increment ? @rc += 1 : @rc).to_s
|
86
|
-
end
|
86
|
+
end
|
87
87
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
- rg ||= nil
|
3
3
|
- r = response_for(@response_set, q, a, rg)
|
4
4
|
- i = response_idx(q.pick != "one") # argument will be false (don't increment i) if we're on radio buttons
|
5
|
-
|
5
|
+
= f.semantic_fields_for i, r do |ff|
|
6
6
|
= ff.quiet_input :question_id unless q.pick == "one" # don't repeat question_id if we're on radio buttons
|
7
7
|
= ff.quiet_input :id unless q.pick == "one" or r.new_record?
|
8
8
|
= ff.quiet_input :response_group, :value => rg if q.pick != "one" && g && g.display_type == "repeater"
|
@@ -1,14 +1,14 @@
|
|
1
1
|
-# TODO: js for slider
|
2
2
|
- rg ||= nil
|
3
3
|
- renderer = q.renderer(g ||= nil)
|
4
|
-
|
4
|
+
= f.inputs q_text(q), :id => rg ? "q_#{q.id}_#{rg}" : "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}" do
|
5
5
|
%span.help= q.help_text
|
6
6
|
- case renderer
|
7
7
|
- when :image, :label
|
8
8
|
- when :dropdown, :inline_dropdown, :slider, :repeater_dropdown
|
9
9
|
- r = response_for(@response_set, q, nil, rg)
|
10
10
|
- i = response_idx
|
11
|
-
|
11
|
+
= f.semantic_fields_for i, r do |ff|
|
12
12
|
= ff.quiet_input :question_id
|
13
13
|
= ff.quiet_input :response_group, :value => rg if g && g.display_type == "repeater"
|
14
14
|
= ff.quiet_input :id unless r.new_record?
|
@@ -17,7 +17,7 @@
|
|
17
17
|
- if q.pick == "one"
|
18
18
|
- r = response_for(@response_set, q, nil, rg)
|
19
19
|
- i = response_idx # increment the response index since the answer partial skips for q.pick == one
|
20
|
-
|
20
|
+
= f.semantic_fields_for i, r do |ff|
|
21
21
|
= ff.quiet_input :question_id
|
22
22
|
= ff.quiet_input :response_group, :value => rg if g && g.display_type == "repeater"
|
23
23
|
= ff.quiet_input :id unless r.new_record?
|