affectiva-surveyor 1.5.0.pre.disco.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +198 -0
- data/Gemfile +5 -0
- data/Gemfile.rails_version +27 -0
- data/MIT-LICENSE +20 -0
- data/README.md +166 -0
- data/Rakefile +106 -0
- data/app/controllers/surveyor_controller.rb +5 -0
- data/app/helpers/results_helper.rb +20 -0
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +3 -0
- data/app/inputs/quiet_input.rb +5 -0
- data/app/inputs/surveyor_check_boxes_input.rb +35 -0
- data/app/inputs/surveyor_radio_input.rb +18 -0
- data/app/models/answer.rb +3 -0
- data/app/models/dependency.rb +3 -0
- data/app/models/dependency_condition.rb +3 -0
- data/app/models/question.rb +3 -0
- data/app/models/question_group.rb +4 -0
- data/app/models/response.rb +4 -0
- data/app/models/response_set.rb +3 -0
- data/app/models/survey.rb +3 -0
- data/app/models/survey_section.rb +4 -0
- data/app/models/survey_section_sweeper.rb +15 -0
- data/app/models/survey_translation.rb +4 -0
- data/app/models/validation.rb +3 -0
- data/app/models/validation_condition.rb +3 -0
- data/app/views/layouts/results.html.erb +13 -0
- data/app/views/layouts/surveyor_default.html.erb +12 -0
- data/app/views/partials/_answer.html.haml +25 -0
- data/app/views/partials/_dependents.html.haml +5 -0
- data/app/views/partials/_question.html.haml +28 -0
- data/app/views/partials/_question_group.html.haml +44 -0
- data/app/views/partials/_section.html.haml +12 -0
- data/app/views/partials/_section_menu.html.haml +12 -0
- data/app/views/surveyor/edit.html.haml +24 -0
- data/app/views/surveyor/export.json.rabl +85 -0
- data/app/views/surveyor/new.html.haml +24 -0
- data/app/views/surveyor/show.html.haml +74 -0
- data/app/views/surveyor/show.json.rabl +15 -0
- data/ci-exec.sh +56 -0
- data/config/routes.rb +8 -0
- data/cucumber.yml +10 -0
- data/doc/REPRESENTATIONS.md +34 -0
- data/doc/api_id_schema.json +7 -0
- data/doc/question types.png +0 -0
- data/doc/response_set_schema.json +54 -0
- data/doc/surveyor question combinations.png +0 -0
- data/doc/surveyor reject or delete decision matrix.png +0 -0
- data/doc/surveyor_models.png +0 -0
- data/doc/surveyor_models2.png +0 -0
- data/doc/surveyor_timestamp_schema.json +9 -0
- data/features/ajax_submissions.feature +140 -0
- data/features/export_to_json.feature +344 -0
- data/features/internationalization.feature +121 -0
- data/features/no_duplicates.feature +110 -0
- data/features/show_survey.feature +71 -0
- data/features/step_definitions/parser_steps.rb +145 -0
- data/features/step_definitions/surveyor_steps.rb +325 -0
- data/features/step_definitions/ui_steps.rb +25 -0
- data/features/step_definitions/web_steps.rb +225 -0
- data/features/support/REDCapDemoDatabase_DataDictionary.csv +127 -0
- data/features/support/database_cleaner.rb +16 -0
- data/features/support/env.rb +56 -0
- data/features/support/hooks.rb +4 -0
- data/features/support/paths.rb +39 -0
- data/features/support/redcap_new_headers.csv +1 -0
- data/features/support/redcap_siblings.csv +1 -0
- data/features/support/redcap_whitespace.csv +1 -0
- data/features/support/selectors.rb +39 -0
- data/features/support/simultaneous_ajax.rb +101 -0
- data/features/support/single_quit_selenium_driver.rb +23 -0
- data/features/support/slow_updates.rb +18 -0
- data/features/surveyor.feature +895 -0
- data/features/surveyor_dependencies.feature +476 -0
- data/features/surveyor_parser.feature +504 -0
- data/features/z_redcap_parser.feature +62 -0
- data/lib/assets/images/surveyor/next.gif +0 -0
- data/lib/assets/images/surveyor/prev.gif +0 -0
- data/lib/assets/images/surveyor/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_222222_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_454545_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_888888_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/assets/javascripts/surveyor/jquery-1.9.0.js +9555 -0
- data/lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js +14850 -0
- data/lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js +1919 -0
- data/lib/assets/javascripts/surveyor/jquery.maskedinput.js +338 -0
- data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
- data/lib/assets/javascripts/surveyor/jquery.surveyor.js +154 -0
- data/lib/assets/stylesheets/surveyor.sass +132 -0
- data/lib/assets/stylesheets/surveyor/jquery-ui-1.10.0.custom.css +1174 -0
- data/lib/assets/stylesheets/surveyor/jquery-ui-timepicker-addon.css +11 -0
- data/lib/assets/stylesheets/surveyor/reset.css +48 -0
- data/lib/assets/stylesheets/surveyor/results.css +125 -0
- data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
- data/lib/generators/surveyor/custom_generator.rb +18 -0
- data/lib/generators/surveyor/install_generator.rb +101 -0
- data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +6 -0
- data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
- data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +40 -0
- data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +13 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_en.yml +19 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +19 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +19 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_ko.yml +19 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +14 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +12 -0
- data/lib/generators/surveyor/templates/db/migrate/add_correct_answer_id_to_questions.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_default_value_to_answers.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_display_order_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_display_type_to_answers.rb +14 -0
- data/lib/generators/surveyor/templates/db/migrate/add_index_to_response_sets.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_index_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_input_mask_attributes_to_answer.rb +12 -0
- data/lib/generators/surveyor/templates/db/migrate/add_section_id_to_responses.rb +12 -0
- data/lib/generators/surveyor/templates/db/migrate/add_unique_index_on_access_code_and_version_in_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_unique_indicies.rb +18 -0
- data/lib/generators/surveyor/templates/db/migrate/add_version_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_answers.rb +38 -0
- data/lib/generators/surveyor/templates/db/migrate/create_dependencies.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_dependency_conditions.rb +30 -0
- data/lib/generators/surveyor/templates/db/migrate/create_question_groups.rb +28 -0
- data/lib/generators/surveyor/templates/db/migrate/create_questions.rb +37 -0
- data/lib/generators/surveyor/templates/db/migrate/create_response_sets.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_responses.rb +34 -0
- data/lib/generators/surveyor/templates/db/migrate/create_survey_sections.rb +30 -0
- data/lib/generators/surveyor/templates/db/migrate/create_survey_translations.rb +19 -0
- data/lib/generators/surveyor/templates/db/migrate/create_surveys.rb +32 -0
- data/lib/generators/surveyor/templates/db/migrate/create_validation_conditions.rb +33 -0
- data/lib/generators/surveyor/templates/db/migrate/create_validations.rb +21 -0
- data/lib/generators/surveyor/templates/db/migrate/drop_unique_index_on_access_code_in_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb +22 -0
- data/lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb +13 -0
- data/lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md +52 -0
- data/lib/generators/surveyor/templates/surveys/MODIFYING_SURVEYOR.md +91 -0
- data/lib/generators/surveyor/templates/surveys/date_survey.rb +16 -0
- data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +280 -0
- data/lib/generators/surveyor/templates/surveys/languages.rb +14 -0
- data/lib/generators/surveyor/templates/surveys/quiz.rb +11 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.es.yml +18 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.he.yml +18 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.ko.yml +18 -0
- data/lib/generators/surveyor/templates/vendor/assets/stylesheets/custom.sass +5 -0
- data/lib/surveyor.rb +13 -0
- data/lib/surveyor/acts_as_response.rb +17 -0
- data/lib/surveyor/common.rb +59 -0
- data/lib/surveyor/engine.rb +10 -0
- data/lib/surveyor/helpers/asset_pipeline.rb +18 -0
- data/lib/surveyor/helpers/formtastic_custom_input.rb +13 -0
- data/lib/surveyor/helpers/surveyor_helper_methods.rb +103 -0
- data/lib/surveyor/models/answer_methods.rb +83 -0
- data/lib/surveyor/models/dependency_condition_methods.rb +69 -0
- data/lib/surveyor/models/dependency_methods.rb +57 -0
- data/lib/surveyor/models/question_group_methods.rb +58 -0
- data/lib/surveyor/models/question_methods.rb +112 -0
- data/lib/surveyor/models/response_methods.rb +126 -0
- data/lib/surveyor/models/response_set_methods.rb +188 -0
- data/lib/surveyor/models/survey_methods.rb +100 -0
- data/lib/surveyor/models/survey_section_methods.rb +53 -0
- data/lib/surveyor/models/survey_translation_methods.rb +30 -0
- data/lib/surveyor/models/validation_condition_methods.rb +54 -0
- data/lib/surveyor/models/validation_methods.rb +45 -0
- data/lib/surveyor/mustache_context.rb +11 -0
- data/lib/surveyor/parser.rb +427 -0
- data/lib/surveyor/redcap_parser.rb +288 -0
- data/lib/surveyor/surveyor_controller_methods.rb +236 -0
- data/lib/surveyor/unparser.rb +147 -0
- data/lib/surveyor/version.rb +3 -0
- data/lib/tasks/surveyor_tasks.rake +88 -0
- data/rails/init.rb +1 -0
- data/spec/controllers/surveyor_controller_spec.rb +311 -0
- data/spec/factories.rb +166 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +117 -0
- data/spec/lib/benchmark_spec.rb +22 -0
- data/spec/lib/chinese_survey.rb +14 -0
- data/spec/lib/common_spec.rb +34 -0
- data/spec/lib/parser_spec.rb +204 -0
- data/spec/lib/rake_kitchen_sink.rb +40 -0
- data/spec/lib/redcap_parser_spec.rb +75 -0
- data/spec/lib/tasks_spec.rake +26 -0
- data/spec/lib/unparser_spec.rb +126 -0
- data/spec/models/answer_spec.rb +174 -0
- data/spec/models/dependency_condition_spec.rb +439 -0
- data/spec/models/dependency_spec.rb +101 -0
- data/spec/models/question_group_spec.rb +93 -0
- data/spec/models/question_spec.rb +206 -0
- data/spec/models/response_set_spec.rb +477 -0
- data/spec/models/response_spec.rb +218 -0
- data/spec/models/survey_section_spec.rb +85 -0
- data/spec/models/survey_spec.rb +191 -0
- data/spec/models/validation_condition_spec.rb +113 -0
- data/spec/models/validation_spec.rb +74 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +56 -0
- data/stacktests.sh +65 -0
- data/surveyor.gemspec +53 -0
- metadata +601 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
= div_for @section, :class => @section.custom_class do
|
2
|
+
%span.title= @section.translation(I18n.locale)[:title]
|
3
|
+
- qs ||= []
|
4
|
+
- (questions = @section.questions).each_with_index do |q, i|
|
5
|
+
- if q.part_of_group?
|
6
|
+
- qs << q # gather up the group questions
|
7
|
+
- if (i+1 >= questions.size) or (q.question_group_id != questions[i+1].question_group_id)
|
8
|
+
- # this is the last question of the section, or the group
|
9
|
+
= render q.question_group.custom_renderer || "/partials/question_group", :g => q.question_group, :qs => qs, :f => f
|
10
|
+
- qs = []
|
11
|
+
- else # gather up the group questions
|
12
|
+
= render q.custom_renderer || "/partials/question", :q => q, :f => f
|
@@ -0,0 +1,12 @@
|
|
1
|
+
.surveyor_menu
|
2
|
+
- if !@survey.translations.empty?
|
3
|
+
= hidden_field_tag "current_section", @section.id
|
4
|
+
.surveyor_language_selection
|
5
|
+
= label_tag "locale", t('surveyor.language')
|
6
|
+
%select{:id=>"locale", :name=>"new_locale"}
|
7
|
+
= options_for_select(@survey.translations.map(&:locale),I18n.locale)
|
8
|
+
|
9
|
+
= t('surveyor.sections')
|
10
|
+
%ul
|
11
|
+
- @sections.each do |s|
|
12
|
+
%li{:class => ("active" if s == @section)}= menu_button_for(s)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#surveyor
|
2
|
+
- unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
|
3
|
+
.surveyor_flash
|
4
|
+
= flash_messages(types)
|
5
|
+
.close
|
6
|
+
= semantic_form_for(@response_set, :as => :r, :url => surveyor.update_my_survey_path, :html => {:method => :put, :id => "survey_form", :class => @survey.custom_class}) do |f|
|
7
|
+
|
8
|
+
= hidden_field_tag :surveyor_javascript_enabled, false
|
9
|
+
|
10
|
+
= render 'partials/section_menu' # unless @sections.size < 3
|
11
|
+
.survey_title= @survey.translation(I18n.locale)[:title]
|
12
|
+
.previous_section= previous_section
|
13
|
+
= render 'partials/dependents' unless @dependents.empty?
|
14
|
+
- if false #@response_set.no_responses_for_section?(@section) # cache if response_set has no responses for current section
|
15
|
+
= cache("section_#{@section.id}"){ render "/partials/section", :f => f }
|
16
|
+
- else # no cache
|
17
|
+
= render "/partials/section", :f => f
|
18
|
+
.next_section= next_section
|
19
|
+
%br
|
20
|
+
|
21
|
+
:javascript
|
22
|
+
$(document).ready(function() {
|
23
|
+
$("input#surveyor_javascript_enabled").val(true);
|
24
|
+
});
|
@@ -0,0 +1,85 @@
|
|
1
|
+
object @survey
|
2
|
+
attribute :title
|
3
|
+
attribute :api_id => :uuid
|
4
|
+
node(:description, :if => lambda {|s| !s.description.blank? }){|s| s.description }
|
5
|
+
node(:reference_identifier, :if => lambda {|s| !s.reference_identifier.blank? }){|s| s.reference_identifier }
|
6
|
+
|
7
|
+
child :sections => :sections do
|
8
|
+
attributes :title, :display_order
|
9
|
+
node(:description, :if => lambda {|s| !s.description.blank? }){|s| s.description }
|
10
|
+
node(:reference_identifier, :if => lambda {|s| !s.reference_identifier.blank? }){|s| s.reference_identifier }
|
11
|
+
|
12
|
+
child :questions_and_groups => :questions_and_groups do
|
13
|
+
# both questions and question_groups have uuid, text, help_text, reference_identifier, and type
|
14
|
+
attribute :api_id => :uuid
|
15
|
+
node(:text, :if => lambda { |q| q.is_a?(Question)}){ |q| q.split(q.text, :pre) }
|
16
|
+
node(:text, :if => lambda { |q| q.is_a?(QuestionGroup)}){ |q| q.text }
|
17
|
+
node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
|
18
|
+
node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
|
19
|
+
node(:data_export_identifier, :if => lambda { |q| !q.data_export_identifier.blank? }){ |q| q.data_export_identifier }
|
20
|
+
node(:type, :if => lambda { |q| q.display_type != "default" }){ |q| q.display_type }
|
21
|
+
|
22
|
+
# only questions
|
23
|
+
node(:pick, :if => lambda { |q| q.is_a?(Question) && q.pick != "none" }){ |q| q.pick }
|
24
|
+
node(:post_text, :if => lambda { |q| q.is_a?(Question) && !q.split(q.text, :post).blank? }){ |q| q.split(q.text, :post) }
|
25
|
+
|
26
|
+
child :answers, :if => lambda { |q| q.is_a?(Question) && !q.answers.blank? } do
|
27
|
+
attribute :api_id => :uuid
|
28
|
+
node(:help_text, :if => lambda { |a| !a.help_text.blank? }){ |a| a.help_text }
|
29
|
+
node(:exclusive, :if => lambda { |a| a.is_exclusive }){ |a| a.is_exclusive }
|
30
|
+
node(:text){ |a| a.split(a.text, :pre) }
|
31
|
+
node(:post_text, :if => lambda { |a| !a.split(a.text, :post).blank? }){ |a| a.split(a.text, :post) }
|
32
|
+
node(:type, :if => lambda { |a| a.response_class != "answer" }){ |a| a.response_class }
|
33
|
+
node(:reference_identifier, :if => lambda { |a| !a.reference_identifier.blank? }){ |a| a.reference_identifier }
|
34
|
+
node(:data_export_identifier, :if => lambda { |a| !a.data_export_identifier.blank? }){ |a| a.data_export_identifier }
|
35
|
+
node(:input_mask, :if => lambda { |a| !a.input_mask.blank? }){ |a| a.input_mask }
|
36
|
+
node(:input_mask_placeholder, :if => lambda { |a| !a.input_mask_placeholder.blank? }){ |a| a.input_mask_placeholder }
|
37
|
+
end
|
38
|
+
|
39
|
+
# both questions and question_groups have dependencies
|
40
|
+
child :dependency, :if => lambda { |q| q.dependency } do
|
41
|
+
attributes :rule
|
42
|
+
child :dependency_conditions => :conditions do
|
43
|
+
attributes :rule_key, :operator
|
44
|
+
node(:question){ |d| d.question.api_id }
|
45
|
+
node(:answer, :if => lambda { |d| d.answer }){ |d| d.answer.api_id }
|
46
|
+
node(:value, :if => lambda { |d| d.answer && d.answer.response_class != "answer" && d.as(d.answer.response_class) }){ |d| d.as(d.answer.response_class)}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
child(:questions, :if => lambda{|x| x.is_a?(QuestionGroup)}) do
|
51
|
+
attributes :api_id => :uuid
|
52
|
+
node(:text){ |q| q.split(q.text, :pre) }
|
53
|
+
node(:post_text, :if => lambda { |q| !q.split(q.text, :post).blank? }){ |q| q.split(q.text, :post) }
|
54
|
+
node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
|
55
|
+
node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
|
56
|
+
node(:data_export_identifier, :if => lambda { |q| !q.data_export_identifier.blank? }){ |q| q.data_export_identifier }
|
57
|
+
node(:type, :if => lambda { |q| q.display_type != "default" }){ |q| q.display_type }
|
58
|
+
node(:pick, :if => lambda { |q| q.pick != "none" }){ |q| q.pick }
|
59
|
+
|
60
|
+
child :answers, :if => lambda { |q| !q.answers.blank? } do
|
61
|
+
attributes :api_id => :uuid
|
62
|
+
node(:help_text, :if => lambda { |a| !a.help_text.blank? }){ |a| a.help_text }
|
63
|
+
node(:is_exclusive, :if => lambda { |a| a.is_exclusive }){ |a| a.is_exclusive }
|
64
|
+
node(:text){ |a| a.split(a.text, :pre) }
|
65
|
+
node(:post_text, :if => lambda { |a| !a.split(a.text, :post).blank? }){ |a| a.split(a.text, :post) }
|
66
|
+
node(:type, :if => lambda { |a| a.response_class != "answer" }){ |a| a.response_class }
|
67
|
+
node(:reference_identifier, :if => lambda { |a| !a.reference_identifier.blank? }){ |a| a.reference_identifier }
|
68
|
+
node(:data_export_identifier, :if => lambda { |a| !a.data_export_identifier.blank? }){ |a| a.data_export_identifier }
|
69
|
+
node(:input_mask, :if => lambda { |a| !a.input_mask.blank? }){ |a| a.input_mask }
|
70
|
+
node(:input_mask_placeholder, :if => lambda { |a| !a.input_mask_placeholder.blank? }){ |a| a.input_mask_placeholder }
|
71
|
+
end
|
72
|
+
|
73
|
+
child :dependency, :if => lambda { |q| q.dependency } do
|
74
|
+
attributes :rule
|
75
|
+
child :dependency_conditions => :conditions do
|
76
|
+
attributes :rule_key, :operator
|
77
|
+
node(:question){ |d| d.question.api_id }
|
78
|
+
node(:answer, :if => lambda { |d| d.answer }){ |d| d.answer.api_id }
|
79
|
+
node(:value, :if => lambda { |d| d.answer && d.answer.response_class != "answer" && d.as(d.answer.response_class) }){ |d| d.as(d.answer.response_class)}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#surveyor
|
2
|
+
- unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
|
3
|
+
.surveyor_flash
|
4
|
+
= flash_messages(types)
|
5
|
+
.close
|
6
|
+
.survey_title= t('surveyor.take_these_surveys')
|
7
|
+
%br
|
8
|
+
#survey_list
|
9
|
+
%ul
|
10
|
+
- @surveys_by_access_code.each do |access_code, surveys|
|
11
|
+
%li
|
12
|
+
= form_tag surveyor.take_survey_path(:survey_code => access_code) do
|
13
|
+
= hidden_field_tag :surveyor_javascript_enabled, false
|
14
|
+
= surveys.first.translation(I18n.locale)[:title]
|
15
|
+
|
16
|
+
= label_tag :survey_version, 'version:'
|
17
|
+
= select_tag(:survey_version, options_for_select([["-- Current version --", ""]] + (surveys.map(&:survey_version) || [])))
|
18
|
+
|
19
|
+
= submit_tag( t('surveyor.take_it'), :default => "Take it" )
|
20
|
+
|
21
|
+
:javascript
|
22
|
+
$(document).ready(function() {
|
23
|
+
$("input#surveyor_javascript_enabled").val(true);
|
24
|
+
});
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#surveyor
|
2
|
+
- unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
|
3
|
+
.surveyor_flash
|
4
|
+
= flash_messages(types)
|
5
|
+
.close
|
6
|
+
= semantic_form_for(@response_set, :as => :r, :url => surveyor.update_my_survey_path, :html => {:id => "survey_form", :class => @survey.custom_class}) do |f|
|
7
|
+
.survey_title= @survey.title
|
8
|
+
- @survey.sections.each do |section|
|
9
|
+
= div_for section do
|
10
|
+
%span.title= strip_tags(section.title)
|
11
|
+
- group_questions = []
|
12
|
+
- answered_questions = []
|
13
|
+
- label = nil
|
14
|
+
- answered_count = 0
|
15
|
+
- (questions = section.questions).each_with_index do |q, i|
|
16
|
+
- if q.part_of_group?
|
17
|
+
- group_questions << q # gather up the group questions
|
18
|
+
- unless @response_set.responses.where( :question_id => q.id).empty?
|
19
|
+
- answered_questions << q
|
20
|
+
- answered_count = answered_count + 1
|
21
|
+
- if (i+1 >= questions.size) or (q.question_group_id != questions[i+1].question_group_id) # this is the last question of the section, or the group
|
22
|
+
- if answered_questions.length > 0 # there are answered questions in this section or group
|
23
|
+
- g = q.question_group
|
24
|
+
- renderer = g.renderer
|
25
|
+
|
26
|
+
- unless label.blank?
|
27
|
+
= render q.custom_renderer || "/partials/question", :q => label, :f => f, :disableFlag => true
|
28
|
+
- label = nil
|
29
|
+
= f.inputs g.text_for(@render_context, I18n.locale), :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
|
30
|
+
%li.help= g.help_text
|
31
|
+
- case renderer
|
32
|
+
- when :grid
|
33
|
+
%li
|
34
|
+
%table
|
35
|
+
%col.pre
|
36
|
+
- group_questions.first.answers.each do |a|
|
37
|
+
%col{:class => cycle("odd", "even")}
|
38
|
+
%col.post
|
39
|
+
%tbody
|
40
|
+
- group_questions.each_slice(10) do |ten_questions| # header row every 10
|
41
|
+
%tr
|
42
|
+
%th
|
43
|
+
- ten_questions.first.answers.each do |a|
|
44
|
+
%th
|
45
|
+
= a.text_for(nil, @render_context, I18n.locale)
|
46
|
+
%span.help= a.help_text_for(@render_context, I18n.locale)
|
47
|
+
%th
|
48
|
+
- ten_questions.each_with_index do |q, j|
|
49
|
+
%tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
|
50
|
+
%th
|
51
|
+
= q.text_for(:pre, @render_context, I18n.locale)
|
52
|
+
= q.help_text_for(@render_context, I18n.locale)
|
53
|
+
- q.answers.each do |a|
|
54
|
+
%td= render(a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f, :disableFlag => true) unless q.display_type == "label"
|
55
|
+
%th= q.text_for(:post, @render_context, I18n.locale)
|
56
|
+
- when :repeater
|
57
|
+
- (@response_set.count_group_responses(group_questions) + 1).times do |rg|
|
58
|
+
%li
|
59
|
+
- group_questions.each do |q|
|
60
|
+
= render q.custom_renderer || "/partials/question", :g => g, :rg => rg, :q => q, :f => f, :disableFlag => true
|
61
|
+
- else # :inline
|
62
|
+
- answered_questions.each do |q|
|
63
|
+
= render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f, :disableFlag => true
|
64
|
+
- group_questions = []
|
65
|
+
- answered_questions = []
|
66
|
+
- else
|
67
|
+
- if q.display_type == 'label'
|
68
|
+
= render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
|
69
|
+
- elsif !(@response_set.responses.where(:question_id => q.id).empty?)
|
70
|
+
= render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
|
71
|
+
- answered_count = answered_count + 1
|
72
|
+
- if (i+1 >= questions.size) and (answered_count == 0)
|
73
|
+
#{"--- No data ---"}
|
74
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
object @response_set
|
2
|
+
attribute :api_id => :uuid
|
3
|
+
attribute :created_at
|
4
|
+
attribute :completed_at
|
5
|
+
node(:survey_id){|rs| rs.survey.api_id }
|
6
|
+
|
7
|
+
child (@response_set.responses || []) => :responses do
|
8
|
+
attribute :api_id => :uuid
|
9
|
+
attribute :created_at
|
10
|
+
attribute :updated_at => :modified_at
|
11
|
+
attribute :response_group
|
12
|
+
node(:answer_id){|r| r.answer.api_id }
|
13
|
+
node(:question_id){|r| r.question.api_id }
|
14
|
+
node(:value, :if => lambda{|r| r.answer.response_class != "answer"}){|r| r.json_value }
|
15
|
+
end
|
data/ci-exec.sh
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/bin/bash -xe
|
2
|
+
|
3
|
+
BUNDLER_VERSION=1.3.1
|
4
|
+
GEMSET=surveyor
|
5
|
+
|
6
|
+
if [ -z $CI_RUBY ]; then
|
7
|
+
echo "CI_RUBY must be set"
|
8
|
+
exit 1
|
9
|
+
fi
|
10
|
+
|
11
|
+
# TMPDIR under the workspace causes gconfd-2 to stop responding and eat all
|
12
|
+
# memory when Firefox is running for the Selenium tests. TMPDIR in user home
|
13
|
+
# seems to work fine.
|
14
|
+
export TMPDIR="${HOME}/tmp/surveyor-ci-${CI_RUBY}"
|
15
|
+
|
16
|
+
if [ -n "${RAILS_VERSION}" ]; then
|
17
|
+
GEMSET="${GEMSET}-${RAILS_VERSION}"
|
18
|
+
TMPDIR="${TMPDIR}-${RAILS_VERSION}"
|
19
|
+
fi
|
20
|
+
|
21
|
+
rm -rf "${TMPDIR}"
|
22
|
+
mkdir -p "${TMPDIR}"
|
23
|
+
|
24
|
+
set +xe
|
25
|
+
echo "Initializing RVM"
|
26
|
+
source ~/.rvm/scripts/rvm
|
27
|
+
set -xe
|
28
|
+
|
29
|
+
# On the overnight build, reinstall all gems
|
30
|
+
if [ `date +%H` -lt 5 ]; then
|
31
|
+
set +xe
|
32
|
+
echo "Purging gemset to verify that all deps can still be installed"
|
33
|
+
rvm --force $CI_RUBY gemset delete $GEMSET
|
34
|
+
set -xe
|
35
|
+
fi
|
36
|
+
|
37
|
+
RVM_CONFIG="${CI_RUBY}@${GEMSET}"
|
38
|
+
set +xe
|
39
|
+
echo "Switching to ${RVM_CONFIG}"
|
40
|
+
rvm use $RVM_CONFIG
|
41
|
+
set -xe
|
42
|
+
|
43
|
+
which ruby
|
44
|
+
ruby -v
|
45
|
+
|
46
|
+
set +e
|
47
|
+
gem list -i bundler -v $BUNDLER_VERSION
|
48
|
+
if [ $? -ne 0 ]; then
|
49
|
+
set -e
|
50
|
+
gem install bundler -v $BUNDLER_VERSION
|
51
|
+
fi
|
52
|
+
set -e
|
53
|
+
|
54
|
+
bundle _${BUNDLER_VERSION}_ update
|
55
|
+
|
56
|
+
bundle _${BUNDLER_VERSION}_ exec rake ci:all --trace
|
data/config/routes.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Surveyor::Engine.routes.draw do
|
2
|
+
match '/', :to => 'surveyor#new', :as => 'available_surveys', :via => :get
|
3
|
+
match '/:survey_code', :to => 'surveyor#create', :as => 'take_survey', :via => :post
|
4
|
+
match '/:survey_code', :to => 'surveyor#export', :as => 'export_survey', :via => :get
|
5
|
+
match '/:survey_code/:response_set_code', :to => 'surveyor#show', :as => 'view_my_survey', :via => :get
|
6
|
+
match '/:survey_code/:response_set_code/take', :to => 'surveyor#edit', :as => 'edit_my_survey', :via => :get
|
7
|
+
match '/:survey_code/:response_set_code', :to => 'surveyor#update', :as => 'update_my_survey', :via => :put
|
8
|
+
end
|
data/cucumber.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features
|
7
|
+
wip: --tags @wip --wip features
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
9
|
+
ci: --tags ~@wip --format html --out reports/cucumber.html --format junit --out reports/cucumber-xml --format pretty --strict features
|
10
|
+
ci_wip: --wip --tags @wip --format html --out reports/cucumber_wip.html --format pretty features
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# JSON Representations
|
2
|
+
|
3
|
+
This document describes the JSON representations for the ResponseSet and Survey models. The models can be serialized
|
4
|
+
by calling the `to_json` method.
|
5
|
+
|
6
|
+
## ResponseSet
|
7
|
+
|
8
|
+
An example of the serialized ResponseSet JSON can be found below. The schema will be coming soon.
|
9
|
+
|
10
|
+
/* ResponseSet JSON */
|
11
|
+
{
|
12
|
+
"uuid" : "9af6d142-7fac-4ccb-9bca-58a05308a5a7",
|
13
|
+
"survey_id" : "94b3d750-fb63-4540-a1e2-dd7f88be9b4f",
|
14
|
+
"created_at" : "1970-02-04T05:15:30Z",
|
15
|
+
"completed_at": "1990-03-06T07:21:42Z"
|
16
|
+
"responses": [{
|
17
|
+
"uuid" : "07d72796-ebb2-4be2-91b9-68f5a30a0054",
|
18
|
+
"answer_id" : "9c788711-8373-44d7-b44b-754c31e596a9",
|
19
|
+
"question_id" : "376a501b-c32f-49de-b4d7-e28030a2ea94",
|
20
|
+
"value" : "Chimpanzee",
|
21
|
+
"created_at" : "1970-02-04T05:15:30Z",
|
22
|
+
"modified_at" : "1990-03-06T07:21:42Z"
|
23
|
+
},{
|
24
|
+
"uuid" : "d0467180-e126-44c0-b112-63bb87f0d869",
|
25
|
+
"answer_id" : "86a85d44-9f39-4df9-ae90-da7ff5dbaaf5",
|
26
|
+
"question_id" : "6146c103-4a8b-4869-836b-415b8666babe",
|
27
|
+
"created_at" : "1970-02-04T05:16:30Z",
|
28
|
+
"modified_at" : "1990-03-06T07:22:42Z"
|
29
|
+
}]
|
30
|
+
}
|
31
|
+
|
32
|
+
## Survey
|
33
|
+
|
34
|
+
Example representation and schema coming soon.
|
Binary file
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-03/schema#",
|
3
|
+
"description": "Response set",
|
4
|
+
"properties": {
|
5
|
+
"completed_at": {
|
6
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
7
|
+
},
|
8
|
+
"created_at": {
|
9
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
10
|
+
},
|
11
|
+
"responses": {
|
12
|
+
"description": "Responses in the response set",
|
13
|
+
"items": {
|
14
|
+
"properties": {
|
15
|
+
"answer_id": {
|
16
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
17
|
+
},
|
18
|
+
"created_at": {
|
19
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
20
|
+
},
|
21
|
+
"question_id": {
|
22
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
23
|
+
},
|
24
|
+
"response_group": {
|
25
|
+
"type": [
|
26
|
+
"string",
|
27
|
+
"null"
|
28
|
+
]
|
29
|
+
},
|
30
|
+
"updated_at": {
|
31
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
32
|
+
},
|
33
|
+
"uuid": {
|
34
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
35
|
+
},
|
36
|
+
"value": {
|
37
|
+
"type": [
|
38
|
+
"string",
|
39
|
+
"number",
|
40
|
+
"null"
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
},
|
45
|
+
"type": "array"
|
46
|
+
},
|
47
|
+
"survey_id": {
|
48
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
49
|
+
},
|
50
|
+
"uuid": {
|
51
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|