upgrade_surveyor_gui 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/MIT-LICENSE +20 -0
- data/README.md +244 -0
- data/Rakefile +66 -0
- data/app/controllers/surveyor_controller.rb +89 -0
- data/app/controllers/surveyor_gui/answers_controller.rb +3 -0
- data/app/controllers/surveyor_gui/application_controller.rb +3 -0
- data/app/controllers/surveyor_gui/dependencys_controller.rb +286 -0
- data/app/controllers/surveyor_gui/question_groups_controller.rb +90 -0
- data/app/controllers/surveyor_gui/questions_controller.rb +187 -0
- data/app/controllers/surveyor_gui/reports_controller.rb +339 -0
- data/app/controllers/surveyor_gui/responses_controller.rb +41 -0
- data/app/controllers/surveyor_gui/survey_controller.rb +16 -0
- data/app/controllers/surveyor_gui/survey_sections_controller.rb +80 -0
- data/app/controllers/surveyor_gui/surveyforms_controller.rb +4 -0
- data/app/facades/report_formatter.rb +46 -0
- data/app/facades/report_preview_wrapper.rb +11 -0
- data/app/facades/report_response_generator.rb +147 -0
- data/app/helpers/surveyor_gui/application_helper.rb +2 -0
- data/app/helpers/surveyor_gui/dependencys_helper.rb +5 -0
- data/app/helpers/surveyor_gui/question_groups_helper.rb +3 -0
- data/app/helpers/surveyor_gui/questions_helper.rb +22 -0
- data/app/helpers/surveyor_gui/reports_helper.rb +19 -0
- data/app/helpers/surveyor_gui/surveyforms_helper.rb +164 -0
- data/app/helpers/surveyor_helper.rb +4 -0
- data/app/inputs/currency_input.rb +5 -0
- data/app/inputs/date_picker_input.rb +7 -0
- data/app/inputs/datetime_picker_input.rb +5 -0
- data/app/inputs/percent_input.rb +5 -0
- data/app/inputs/time_picker_input.rb +5 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/answer.rb +4 -0
- data/app/models/column.rb +3 -0
- data/app/models/dependency.rb +4 -0
- data/app/models/dependency_condition.rb +4 -0
- data/app/models/permitted_params_decorator.rb +80 -0
- data/app/models/question.rb +4 -0
- data/app/models/question_group.rb +4 -0
- data/app/models/question_group_tracker.rb +19 -0
- data/app/models/question_type.rb +7 -0
- data/app/models/response.rb +4 -0
- data/app/models/response_set.rb +4 -0
- data/app/models/row.rb +3 -0
- data/app/models/survey.rb +4 -0
- data/app/models/survey_section.rb +4 -0
- data/app/models/surveyform.rb +103 -0
- data/app/uploaders/blob_uploader.rb +48 -0
- data/app/views/layouts/surveyor_gui/application.html.erb +14 -0
- data/app/views/layouts/surveyor_gui/surveyor_gui_blank.html.erb +13 -0
- data/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb +17 -0
- data/app/views/layouts/surveyor_gui/surveyor_modified.html.erb +14 -0
- data/app/views/partials/_answer.html.haml +33 -0
- data/app/views/partials/_question.html.haml +33 -0
- data/app/views/partials/_question_group.html.haml +73 -0
- data/app/views/partials/_section.html.haml +13 -0
- data/app/views/surveyor/edit.html.haml +21 -0
- data/app/views/surveyor_gui/dependencys/_column.html.erb +1 -0
- data/app/views/surveyor_gui/dependencys/_dependency.html.erb +22 -0
- data/app/views/surveyor_gui/dependencys/_dependency_condition_fields.html.erb +48 -0
- data/app/views/surveyor_gui/dependencys/_form.html.erb +20 -0
- data/app/views/surveyor_gui/dependencys/blank.html.erb +0 -0
- data/app/views/surveyor_gui/dependencys/edit.html.erb +1 -0
- data/app/views/surveyor_gui/dependencys/new.html.erb +1 -0
- data/app/views/surveyor_gui/partials/_url_helpers.html.erb +5 -0
- data/app/views/surveyor_gui/question_groups/_form.html.erb +57 -0
- data/app/views/surveyor_gui/question_groups/_group_inline_field.html.erb +21 -0
- data/app/views/surveyor_gui/question_groups/_group_inline_fields.html.erb +25 -0
- data/app/views/surveyor_gui/question_groups/blank.html.erb +0 -0
- data/app/views/surveyor_gui/question_groups/edit.html.erb +1 -0
- data/app/views/surveyor_gui/question_groups/new.html.erb +1 -0
- data/app/views/surveyor_gui/questions/_answer_fields.html.erb +23 -0
- data/app/views/surveyor_gui/questions/_answer_options.html.erb +28 -0
- data/app/views/surveyor_gui/questions/_form.html.erb +66 -0
- data/app/views/surveyor_gui/questions/_grid_dropdown_columns.html.erb +10 -0
- data/app/views/surveyor_gui/questions/_grid_dropdown_fields.html.erb +42 -0
- data/app/views/surveyor_gui/questions/_grid_fields.html.erb +9 -0
- data/app/views/surveyor_gui/questions/_no_picks.html.erb +29 -0
- data/app/views/surveyor_gui/questions/_pick.html +21 -0
- data/app/views/surveyor_gui/questions/_picks.html.erb +12 -0
- data/app/views/surveyor_gui/questions/blank.html.erb +0 -0
- data/app/views/surveyor_gui/questions/edit.html.erb +1 -0
- data/app/views/surveyor_gui/questions/new.html.erb +1 -0
- data/app/views/surveyor_gui/reports/_graphs.html.haml +21 -0
- data/app/views/surveyor_gui/reports/_grid.html.haml +42 -0
- data/app/views/surveyor_gui/reports/_grid_dropdown.html.haml +56 -0
- data/app/views/surveyor_gui/reports/_repeater.html.haml +27 -0
- data/app/views/surveyor_gui/reports/_show_report.html.haml +33 -0
- data/app/views/surveyor_gui/reports/_single_question.html.haml +70 -0
- data/app/views/surveyor_gui/reports/show.html.erb +14 -0
- data/app/views/surveyor_gui/responses/_grid.html.haml +20 -0
- data/app/views/surveyor_gui/responses/_grid_dropdown.html.haml +20 -0
- data/app/views/surveyor_gui/responses/_repeater.html.haml +22 -0
- data/app/views/surveyor_gui/responses/_survey_results.html.haml +40 -0
- data/app/views/surveyor_gui/responses/index.html.haml +24 -0
- data/app/views/surveyor_gui/responses/show.html.haml +42 -0
- data/app/views/surveyor_gui/shared/_grid_comments.html.haml +10 -0
- data/app/views/surveyor_gui/shared/_new_line.html.haml +2 -0
- data/app/views/surveyor_gui/shared/_pick_comments.html.haml +15 -0
- data/app/views/surveyor_gui/shared/_question_number.html.haml +11 -0
- data/app/views/surveyor_gui/shared/_report_data.html.haml +27 -0
- data/app/views/surveyor_gui/shared/_stars_report_data.html.haml +14 -0
- data/app/views/surveyor_gui/survey_sections/_form.html.erb +13 -0
- data/app/views/surveyor_gui/survey_sections/blank.html.erb +0 -0
- data/app/views/surveyor_gui/survey_sections/edit.html.erb +1 -0
- data/app/views/surveyor_gui/survey_sections/new.html.erb +1 -0
- data/app/views/surveyor_gui/surveyforms/_form.html.erb +50 -0
- data/app/views/surveyor_gui/surveyforms/_question_field.html.erb +148 -0
- data/app/views/surveyor_gui/surveyforms/_question_group.html.erb +116 -0
- data/app/views/surveyor_gui/surveyforms/_question_group_fields.html.erb +3 -0
- data/app/views/surveyor_gui/surveyforms/_question_name_and_number.html.erb +6 -0
- data/app/views/surveyor_gui/surveyforms/_question_section.html.erb +15 -0
- data/app/views/surveyor_gui/surveyforms/_question_wrapper.html.erb +108 -0
- data/app/views/surveyor_gui/surveyforms/_survey_section_fields.html.erb +137 -0
- data/app/views/surveyor_gui/surveyforms/clone_survey.html.erb +13 -0
- data/app/views/surveyor_gui/surveyforms/edit.html.erb +5 -0
- data/app/views/surveyor_gui/surveyforms/index.html.erb +40 -0
- data/app/views/surveyor_gui/surveyforms/new.html.erb +1 -0
- data/app/views/surveyor_gui/surveyforms/show.html.erb +5 -0
- data/config/environment.rb +0 -0
- data/config/routes.rb +71 -0
- data/config.ru +4 -0
- data/db/migrate/20140307204049_add_template_to_surveys.rb +5 -0
- data/db/migrate/20140307235607_add_test_data_to_response_sets.rb +5 -0
- data/db/migrate/20140308171947_add_original_choice_to_answers.rb +5 -0
- data/db/migrate/20140308172118_add_blob_to_responses.rb +5 -0
- data/db/migrate/20140308172417_add_modifiable_to_survey_section.rb +5 -0
- data/db/migrate/20140308174532_add_modifiable_to_question.rb +5 -0
- data/db/migrate/20140308175305_add_dynamically_generate_to_questions.rb +5 -0
- data/db/migrate/20140311032923_add_dummy_blob_to_questions.rb +5 -0
- data/db/migrate/20140311160609_add_dynamic_source_to_questions.rb +5 -0
- data/db/migrate/20140311161714_add_report_code_to_questions.rb +5 -0
- data/db/migrate/20140530181134_add_is_comment_to_questions.rb +5 -0
- data/db/migrate/20140531012006_add_is_comment_to_answers.rb +5 -0
- data/db/migrate/20140531225529_create_rows.rb +9 -0
- data/db/migrate/20140601011151_create_columns.rb +11 -0
- data/db/migrate/20140602030330_add_column_id_to_answers.rb +5 -0
- data/db/migrate/20140603155606_add_column_id_to_responses.rb +5 -0
- data/db/migrate/20140606023527_add_column_id_to_dependency_conditions.rb +5 -0
- data/db/migrate/20140815165307_add_user_id_to_survey.rb +5 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/assets/images/addicon.png +0 -0
- data/lib/assets/images/datepicker.gif +0 -0
- data/lib/assets/images/delete.gif +0 -0
- data/lib/assets/images/delete.png +0 -0
- data/lib/assets/images/images/border.png +0 -0
- data/lib/assets/images/images/controls.png +0 -0
- data/lib/assets/images/images/loading.gif +0 -0
- data/lib/assets/images/images/loading_background.png +0 -0
- data/lib/assets/images/images/overlay.png +0 -0
- data/lib/assets/images/rails.png +0 -0
- data/lib/assets/images/star.gif +0 -0
- data/lib/assets/javascripts/.gitkeep +0 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.MetaData.js +121 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.blockUI.js +619 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.rating.js +377 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.validate.js +1188 -0
- data/lib/assets/javascripts/surveyor_gui/surveyor_add_ons.js +10 -0
- data/lib/assets/javascripts/surveyor_gui/surveyor_gui.js +1428 -0
- data/lib/assets/stylesheets/.gitkeep +0 -0
- data/lib/assets/stylesheets/surveyor_gui/jquery.rating.css +12 -0
- data/lib/assets/stylesheets/surveyor_gui/surveyor_add_ons.css +3 -0
- data/lib/assets/stylesheets/surveyor_gui/surveyor_gui.sass +652 -0
- data/lib/enumerable_extenders.rb +31 -0
- data/lib/generators/surveyor_gui/install_generator.rb +57 -0
- data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_add_ons.js +2 -0
- data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_gui_all.js +24 -0
- data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_add_ons.css.sass +1 -0
- data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_gui_all.css.sass +8 -0
- data/lib/generators/surveyor_gui/templates/app/helpers/surveyor_helper.rb +4 -0
- data/lib/generators/surveyor_gui/templates/app/models/response_set_user.rb +13 -0
- data/lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb +17 -0
- data/lib/generators/surveyor_gui/templates/config/initializers/simple_form.rb +140 -0
- data/lib/generators/surveyor_gui/templates/config/locales/en.yml +5 -0
- data/lib/surveyor_gui/engine.rb +31 -0
- data/lib/surveyor_gui/helpers/surveyor_helper_methods.rb +19 -0
- data/lib/surveyor_gui/models/answer_methods.rb +24 -0
- data/lib/surveyor_gui/models/column_methods.rb +43 -0
- data/lib/surveyor_gui/models/dependency_condition_methods.rb +53 -0
- data/lib/surveyor_gui/models/dependency_methods.rb +83 -0
- data/lib/surveyor_gui/models/question_and_group_shared_methods.rb +11 -0
- data/lib/surveyor_gui/models/question_group_methods.rb +55 -0
- data/lib/surveyor_gui/models/question_methods.rb +435 -0
- data/lib/surveyor_gui/models/question_type_methods.rb +493 -0
- data/lib/surveyor_gui/models/response_methods.rb +71 -0
- data/lib/surveyor_gui/models/response_set_methods.rb +56 -0
- data/lib/surveyor_gui/models/row_methods.rb +11 -0
- data/lib/surveyor_gui/models/survey_methods.rb +32 -0
- data/lib/surveyor_gui/models/survey_section_methods.rb +32 -0
- data/lib/surveyor_gui/surveyforms_controller_methods.rb +258 -0
- data/lib/surveyor_gui/version.rb +3 -0
- data/lib/surveyor_gui.rb +17 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/surveyor_gui_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/controllers/surveyforms_controller_spec.rb +362 -0
- data/spec/controllers/surveyor_controller_spec.rb +303 -0
- data/spec/factories.rb +181 -0
- data/spec/features/create_survey_spec.rb +417 -0
- data/spec/features/dependencies_spec.rb +65 -0
- data/spec/features/make_and_take_spec.rb +187 -0
- data/spec/features/rearrange_survey_spec.rb +118 -0
- data/spec/features/ui_spec.rb +469 -0
- data/spec/fixtures/REDCapDemoDatabase_DataDictionary.csv +127 -0
- data/spec/fixtures/chinese_survey.rb +14 -0
- data/spec/fixtures/everything.rb +215 -0
- data/spec/fixtures/favorites-ish.rb +22 -0
- data/spec/fixtures/favorites.rb +22 -0
- data/spec/fixtures/feelings.rb +38 -0
- data/spec/fixtures/lifestyle.rb +55 -0
- data/spec/fixtures/numbers.rb +21 -0
- data/spec/fixtures/redcap_new_headers.csv +1 -0
- data/spec/fixtures/redcap_siblings.csv +1 -0
- data/spec/fixtures/redcap_whitespace.csv +1 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +116 -0
- data/spec/lib/common_spec.rb +37 -0
- data/spec/lib/parser_spec.rb +393 -0
- data/spec/lib/rake_kitchen_sink.rb +42 -0
- data/spec/lib/redcap_parser_spec.rb +129 -0
- data/spec/lib/unparser_spec.rb +126 -0
- data/spec/models/answer_spec.rb +144 -0
- data/spec/models/dependency_condition_spec.rb +428 -0
- data/spec/models/dependency_spec.rb +90 -0
- data/spec/models/question_group_spec.rb +66 -0
- data/spec/models/question_spec.rb +176 -0
- data/spec/models/response_set_spec.rb +452 -0
- data/spec/models/response_spec.rb +208 -0
- data/spec/models/survey_section_spec.rb +58 -0
- data/spec/models/survey_spec.rb +155 -0
- data/spec/models/surveyor_gui/question_spec.rb +60 -0
- data/spec/models/surveyor_gui/question_type_spec.rb +268 -0
- data/spec/models/validation_condition_spec.rb +98 -0
- data/spec/models/validation_spec.rb +64 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +119 -0
- data/spec/support/scenario_outline_helper.rb +39 -0
- data/spec/support/shared.rb +10 -0
- data/spec/support/surveyforms_creation_helpers.rb +313 -0
- data/spec/support/surveyforms_rearrangement_helpers.rb +170 -0
- data/spec/support/surveyor_api_helpers.rb +15 -0
- data/spec/support/surveyor_ui_helpers.rb +108 -0
- data/spec/support/wait_for_ajax.rb +11 -0
- data/spec/views/questions/edit.html.erb_spec.rb +74 -0
- data/spec/views/surveyforms/edit.html.erb_spec.rb +126 -0
- data/surveyor_gui.gemspec +52 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/surveyor-gui_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
- data/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/custom.sass +5 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +600 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module Enumerable
|
2
|
+
def dups
|
3
|
+
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys
|
4
|
+
end
|
5
|
+
|
6
|
+
# sum of an array of numbers
|
7
|
+
def arraysum
|
8
|
+
return self.inject(0){|acc,i|acc +i}
|
9
|
+
end
|
10
|
+
|
11
|
+
# average of an array of numbers
|
12
|
+
def average
|
13
|
+
return self.sum/self.length.to_f
|
14
|
+
end
|
15
|
+
|
16
|
+
# variance of an array of numbers
|
17
|
+
def sample_variance
|
18
|
+
avg=self.average
|
19
|
+
sum=self.inject(0){|acc,i|acc +(i-avg)**2}
|
20
|
+
return(1/self.length.to_f*sum)
|
21
|
+
end
|
22
|
+
|
23
|
+
# standard deviation of an array of numbers
|
24
|
+
def standard_deviation
|
25
|
+
return Math.sqrt(self.sample_variance)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module SurveyorGui
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
desc "Generate surveyor README, migrations, assets and sample survey"
|
8
|
+
class_option :skip_migrations, :type => :boolean, :desc => "skip migrations, but generate everything else"
|
9
|
+
|
10
|
+
def dependencies
|
11
|
+
generate "simple_form:install"
|
12
|
+
generate "surveyor:install"
|
13
|
+
rake "db:migrate db:test:prepare"
|
14
|
+
rake "highcharts:update"
|
15
|
+
unless options[:skip_migration]
|
16
|
+
rake 'railties:install:migrations'
|
17
|
+
end
|
18
|
+
rake "db:migrate db:test:prepare"
|
19
|
+
end
|
20
|
+
|
21
|
+
def configurations
|
22
|
+
replace_simple_forms_configuration_rb
|
23
|
+
add_i18n_enforce_locales
|
24
|
+
end
|
25
|
+
|
26
|
+
def routes
|
27
|
+
route('mount SurveyorGui::Engine => "/surveyor_gui", :as => "surveyor_gui"')
|
28
|
+
end
|
29
|
+
|
30
|
+
def assets
|
31
|
+
directory "app/assets"
|
32
|
+
directory "app/models"
|
33
|
+
directory "app/views"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def replace_simple_forms_configuration_rb
|
39
|
+
#formatting of radio buttons and checkboxes sensitive to the configuration.
|
40
|
+
#The newer version of simple_forms defaults to a form_building approach
|
41
|
+
#that changes the wrapping of input fields; it breaks selectors in jquery
|
42
|
+
#code. Flipping a few switches in the configuration gets the code to work.
|
43
|
+
remove_file File.expand_path('config/initializers/simple_form.rb',Rails.root)
|
44
|
+
template "config/initializers/simple_form.rb"
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_i18n_enforce_locales
|
48
|
+
#gets rid of 18n deprecation message:
|
49
|
+
#"I18n.enforce_available_locales will default to true in the future. If you really
|
50
|
+
#want to skip validation of your locale you can set I18n.enforce_available_locales
|
51
|
+
#= false to avoid this message."
|
52
|
+
inject_into_file "config/application.rb",
|
53
|
+
"config.i18n.enforce_available_locales = true",
|
54
|
+
:after => "config.encoding = \"utf-8\"\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
//= require jquery
|
2
|
+
//= require jquery_ujs
|
3
|
+
//= require jquery.ui.draggable
|
4
|
+
//= require jquery.ui.droppable
|
5
|
+
//= require jquery.ui.sortable
|
6
|
+
//= require jquery.ui.accordion
|
7
|
+
//= require jquery.ui.autocomplete
|
8
|
+
//= require jquery.ui.button
|
9
|
+
//= require jquery.ui.datepicker
|
10
|
+
//= require jquery.ui.slider
|
11
|
+
//= require jquery.ui.tabs
|
12
|
+
//= require jquery.ui.tooltip
|
13
|
+
//= require jquery.ui.datepicker-pt-BR
|
14
|
+
//= require colorbox-rails
|
15
|
+
//= require jquery.form
|
16
|
+
//= require surveyor/jquery.selectToUISlider
|
17
|
+
//= require surveyor/jquery-ui-timepicker-addon
|
18
|
+
//= require surveyor_gui/jquery.validate
|
19
|
+
//= require surveyor_gui/jquery.blockUI
|
20
|
+
//= require surveyor_gui/jquery.MetaData.js
|
21
|
+
//= require surveyor_gui/jquery.rating
|
22
|
+
//= require surveyor_gui/surveyor_gui
|
23
|
+
//= require highcharts/highcharts
|
24
|
+
//= require highcharts/highcharts-more
|
@@ -0,0 +1 @@
|
|
1
|
+
@import surveyor_gui/jquery.rating
|
@@ -0,0 +1,8 @@
|
|
1
|
+
@import surveyor_gui/surveyor_gui
|
2
|
+
@import jquery.ui.all
|
3
|
+
@import themes/jquery.ui.ui-lightness
|
4
|
+
@import colorbox-rails
|
5
|
+
@import surveyor/ui.slider.extras
|
6
|
+
@import surveyor/jquery-ui-timepicker-addon
|
7
|
+
@import surveyor_gui/jquery.rating
|
8
|
+
@import surveyor_gui/surveyor_add_ons
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class ResponseSetUser
|
2
|
+
def initialize(user_id)
|
3
|
+
#find the user. You can use the commented code below, but switch the model name
|
4
|
+
#if your user model is not User.
|
5
|
+
#
|
6
|
+
#@user = User.find_by_id(user_id)
|
7
|
+
end
|
8
|
+
|
9
|
+
def report_user_name
|
10
|
+
#return a value to identify users on a report, e.g.:
|
11
|
+
#@user ? @user.email : nil
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>SurveyorGui</title>
|
5
|
+
<%= stylesheet_link_tag "surveyor_gui_all", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "surveyor_gui_all" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="surveyor-gui-mount-point" data-surveyor-gui-mount-point="<%= surveyor_gui.surveyforms_path %>"></div>
|
11
|
+
<% flash.each do |key, value| %>
|
12
|
+
<%= content_tag(:div, value, :class => "flash #{key}") %>
|
13
|
+
<% end %>
|
14
|
+
<%= yield %>
|
15
|
+
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# surveyor_gui mods to the simple_form config
|
2
|
+
# Use this setup block to configure all options available in SimpleForm.
|
3
|
+
SimpleForm.setup do |config|
|
4
|
+
# Wrappers are used by the form builder to generate a
|
5
|
+
# complete input. You can remove any component from the
|
6
|
+
# wrapper, change the order or even add your own to the
|
7
|
+
# stack. The options given below are used to wrap the
|
8
|
+
# whole input.
|
9
|
+
config.wrappers :default, :class => :input,
|
10
|
+
:hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
|
11
|
+
## Extensions enabled by default
|
12
|
+
# Any of these extensions can be disabled for a
|
13
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
14
|
+
# You can make any of these extensions optional by
|
15
|
+
# renaming `b.use` to `b.optional`.
|
16
|
+
|
17
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
18
|
+
# and required attributes
|
19
|
+
b.use :html5
|
20
|
+
|
21
|
+
# Calculates placeholders automatically from I18n
|
22
|
+
# You can also pass a string as f.input :placeholder => "Placeholder"
|
23
|
+
b.use :placeholder
|
24
|
+
|
25
|
+
## Optional extensions
|
26
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
|
27
|
+
# to the input. If so, they will retrieve the values from the model
|
28
|
+
# if any exists. If you want to enable the lookup for any of those
|
29
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
30
|
+
|
31
|
+
# Calculates maxlength from length validations for string inputs
|
32
|
+
b.optional :maxlength
|
33
|
+
|
34
|
+
# Calculates pattern from format validations for string inputs
|
35
|
+
b.optional :pattern
|
36
|
+
|
37
|
+
# Calculates min and max from length validations for numeric inputs
|
38
|
+
b.optional :min_max
|
39
|
+
|
40
|
+
# Calculates readonly automatically from readonly attributes
|
41
|
+
b.optional :readonly
|
42
|
+
|
43
|
+
## Inputs
|
44
|
+
b.use :label_input
|
45
|
+
b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
|
46
|
+
b.use :error, :wrap_with => { :tag => :span, :class => :error }
|
47
|
+
end
|
48
|
+
|
49
|
+
# The default wrapper to be used by the FormBuilder.
|
50
|
+
config.default_wrapper = :default
|
51
|
+
|
52
|
+
# Define the way to render check boxes / radio buttons with labels.
|
53
|
+
# Defaults to :nested for bootstrap config.
|
54
|
+
# :inline => input + label
|
55
|
+
# :nested => label > input
|
56
|
+
config.boolean_style = :inline
|
57
|
+
|
58
|
+
# Default class for buttons
|
59
|
+
config.button_class = 'btn'
|
60
|
+
|
61
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
62
|
+
# :first lists the first message for each field.
|
63
|
+
# Use :to_sentence to list all errors for each field.
|
64
|
+
# config.error_method = :first
|
65
|
+
|
66
|
+
# Default tag used for error notification helper.
|
67
|
+
config.error_notification_tag = :div
|
68
|
+
|
69
|
+
# CSS class to add for error notification helper.
|
70
|
+
config.error_notification_class = 'alert alert-error'
|
71
|
+
|
72
|
+
# ID to add for error notification helper.
|
73
|
+
# config.error_notification_id = nil
|
74
|
+
|
75
|
+
# Series of attempts to detect a default label method for collection.
|
76
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
77
|
+
|
78
|
+
# Series of attempts to detect a default value method for collection.
|
79
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
80
|
+
|
81
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
82
|
+
# config.collection_wrapper_tag = nil
|
83
|
+
|
84
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
85
|
+
# config.collection_wrapper_class = nil
|
86
|
+
|
87
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
88
|
+
# defaulting to :span. Please note that when using :boolean_style = :nested,
|
89
|
+
# SimpleForm will force this option to be a label.
|
90
|
+
# config.item_wrapper_tag = :span
|
91
|
+
|
92
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
93
|
+
# config.item_wrapper_class = nil
|
94
|
+
|
95
|
+
# How the label text should be generated altogether with the required text.
|
96
|
+
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
97
|
+
|
98
|
+
# You can define the class to use on all labels. Default is nil.
|
99
|
+
config.label_class = 'control-label'
|
100
|
+
|
101
|
+
# You can define the class to use on all forms. Default is simple_form.
|
102
|
+
# config.form_class = :simple_form
|
103
|
+
|
104
|
+
# You can define which elements should obtain additional classes
|
105
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
106
|
+
|
107
|
+
# Whether attributes are required by default (or not). Default is true.
|
108
|
+
# config.required_by_default = true
|
109
|
+
|
110
|
+
# Tell browsers whether to use default HTML5 validations (novalidate option).
|
111
|
+
# Default is enabled.
|
112
|
+
config.browser_validations = false
|
113
|
+
|
114
|
+
# Collection of methods to detect if a file type was given.
|
115
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
116
|
+
|
117
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
118
|
+
# to match as key, and the input type that will be used when the field name
|
119
|
+
# matches the regexp as value.
|
120
|
+
# config.input_mappings = { /count/ => :integer }
|
121
|
+
|
122
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
123
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
124
|
+
# config.wrapper_mappings = { :string => :prepend }
|
125
|
+
|
126
|
+
# Default priority for time_zone inputs.
|
127
|
+
# config.time_zone_priority = nil
|
128
|
+
|
129
|
+
# Default priority for country inputs.
|
130
|
+
# config.country_priority = nil
|
131
|
+
|
132
|
+
# When false, do not use translations for labels.
|
133
|
+
# config.translate_labels = true
|
134
|
+
|
135
|
+
# Automatically discover new inputs in Rails' autoload path.
|
136
|
+
# config.inputs_discovery = true
|
137
|
+
|
138
|
+
# Cache SimpleForm inputs discovery
|
139
|
+
# config.cache_discovery = !Rails.env.development?
|
140
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'surveyor_gui'
|
3
|
+
require 'haml' # required for view resolution
|
4
|
+
|
5
|
+
module SurveyorGui
|
6
|
+
class Engine < Rails::Engine
|
7
|
+
isolate_namespace SurveyorGui
|
8
|
+
root = File.expand_path('../../', __FILE__)
|
9
|
+
config.autoload_paths << root
|
10
|
+
|
11
|
+
config.to_prepare do
|
12
|
+
Dir.glob(root + "/surveyor_gui/models/*.rb").each do |c|
|
13
|
+
require_dependency(c)
|
14
|
+
end
|
15
|
+
Dir.glob(root + "/surveyor_gui/helpers/*.rb").each do |c|
|
16
|
+
require_dependency(c)
|
17
|
+
end
|
18
|
+
Dir.glob(root + "app/facades/*.rb").each do |c|
|
19
|
+
require_dependency(c)
|
20
|
+
end
|
21
|
+
c = Dir.glob(File.expand_path('../',root)+'/app/controllers/surveyor_controller.rb').first
|
22
|
+
require_dependency(c)
|
23
|
+
Dir.glob(File.expand_path('../',root)+'/app/models/*.rb').each do |c|
|
24
|
+
require_dependency(c)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
initializer "surveyor_gui.assets.precompile" do |app|
|
28
|
+
app.config.assets.precompile += %w[surveyor_all.js surveyor_gui_all.js surveyor_all.css surveyor_gui_all.css surveyor_add_ons.js surveyor_add_ons.css *.png *.gif]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SurveyorGui
|
2
|
+
module Helpers
|
3
|
+
module SurveyorGuiHelperMethods
|
4
|
+
# Responses
|
5
|
+
def response_for(response_set, question, answer = nil, response_group = nil, column_id = nil)
|
6
|
+
return nil unless response_set && question && question.id
|
7
|
+
result = response_set.responses.detect{|r|
|
8
|
+
(r.question_id == question.id) &&
|
9
|
+
(answer.blank? ? true : r.answer_id == answer.id) &&
|
10
|
+
(r.response_group.blank? ? true : r.response_group.to_i == response_group.to_i) &&
|
11
|
+
(r.column_id.blank? ? true : r.column_id == column_id.to_i)}
|
12
|
+
result.blank? ? response_set.responses.build(
|
13
|
+
question_id: question.id,
|
14
|
+
response_group: response_group,
|
15
|
+
column_id: column_id) : result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SurveyorGui
|
2
|
+
module Models
|
3
|
+
module AnswerMethods
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.send :belongs_to, :question
|
7
|
+
base.send :has_many, :responses
|
8
|
+
base.send :belongs_to, :column
|
9
|
+
base.send :default_scope, lambda { base.order('display_order') }
|
10
|
+
base.send :attr_accessible, :text, :response_class, :display_order, :original_choice, :hide_label, :question_id,
|
11
|
+
:display_type, :is_comment, :column if defined? ActiveModel::MassAssignmentSecurity
|
12
|
+
base.send :scope, :is_not_comment, -> { base.where(is_comment: false) }
|
13
|
+
base.send :scope, :is_comment, -> { base.where(is_comment: true) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def split_or_hidden_text(part = nil)
|
17
|
+
#return "" if hide_label.to_s == "true"
|
18
|
+
return "" if display_type.to_s == "hidden_label"
|
19
|
+
part == :pre ? text.split("|",2)[0] : (part == :post ? text.split("|",2)[1] : text)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'surveyor/common'
|
2
|
+
module SurveyorGui
|
3
|
+
module Models
|
4
|
+
module ColumnMethods
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include ActiveModel::Validations
|
7
|
+
include Surveyor::MustacheContext
|
8
|
+
include ActiveModel::ForbiddenAttributesProtection
|
9
|
+
|
10
|
+
included do
|
11
|
+
belongs_to :question_group
|
12
|
+
has_many :answers
|
13
|
+
attr_accessible *PermittedParams.new.column_attributes if defined? ActiveModel::MassAssignmentSecurity
|
14
|
+
end
|
15
|
+
def text_for(position = nil, context = nil, locale = nil)
|
16
|
+
split(in_context(translation(locale)[:text], context), position)
|
17
|
+
end
|
18
|
+
def help_text_for(context = nil, locale = nil)
|
19
|
+
in_context(translation(locale)[:help_text], context)
|
20
|
+
end
|
21
|
+
def split(text, position=nil)
|
22
|
+
case position
|
23
|
+
when :pre
|
24
|
+
text.split("|",2)[0]
|
25
|
+
when :post
|
26
|
+
text.split("|",2)[1]
|
27
|
+
else
|
28
|
+
text
|
29
|
+
end.to_s
|
30
|
+
end
|
31
|
+
def translation(locale)
|
32
|
+
{:text => self.text, :help_text => self.help_text}.with_indifferent_access.merge(
|
33
|
+
(self.question_group.questions.first.survey_section.translation(locale)[:columns] || {})[self.reference_identifier] || {}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
def help_text
|
37
|
+
#stub
|
38
|
+
end
|
39
|
+
def reference_identifier
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|