hssc_surveyor 1.4.1.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +28 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +198 -0
- data/Gemfile +5 -0
- data/Gemfile.rails_version +19 -0
- data/MIT-LICENSE +20 -0
- data/README.md +186 -0
- data/Rakefile +105 -0
- data/app/controllers/surveyor_controller.rb +6 -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 +4 -0
- data/app/models/dependency.rb +4 -0
- data/app/models/dependency_condition.rb +4 -0
- data/app/models/question.rb +4 -0
- data/app/models/question_group.rb +5 -0
- data/app/models/response.rb +5 -0
- data/app/models/response_set.rb +4 -0
- data/app/models/survey.rb +4 -0
- data/app/models/survey_section.rb +5 -0
- data/app/models/survey_section_sweeper.rb +15 -0
- data/app/models/survey_translation.rb +5 -0
- data/app/models/validation.rb +4 -0
- data/app/models/validation_condition.rb +4 -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 +41 -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/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/assets/images/ui-icons_222222_256x240.png +0 -0
- data/lib/assets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/assets/images/ui-icons_454545_256x240.png +0 -0
- data/lib/assets/images/ui-icons_888888_256x240.png +0 -0
- data/lib/assets/images/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 +156 -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/assets/stylesheets/surveyor.sass +132 -0
- data/lib/generators/surveyor/custom_generator.rb +18 -0
- data/lib/generators/surveyor/install_generator.rb +102 -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_attachment_to_response.rb +5 -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 +284 -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/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 +13 -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 +86 -0
- data/lib/surveyor/models/dependency_condition_methods.rb +72 -0
- data/lib/surveyor/models/dependency_methods.rb +60 -0
- data/lib/surveyor/models/question_group_methods.rb +61 -0
- data/lib/surveyor/models/question_methods.rb +115 -0
- data/lib/surveyor/models/response_methods.rb +132 -0
- data/lib/surveyor/models/response_set_methods.rb +196 -0
- data/lib/surveyor/models/survey_methods.rb +103 -0
- data/lib/surveyor/models/survey_section_methods.rb +56 -0
- data/lib/surveyor/models/survey_translation_methods.rb +33 -0
- data/lib/surveyor/models/validation_condition_methods.rb +56 -0
- data/lib/surveyor/models/validation_methods.rb +48 -0
- data/lib/surveyor/mustache_context.rb +11 -0
- data/lib/surveyor/parser.rb +428 -0
- data/lib/surveyor/redcap_parser.rb +289 -0
- data/lib/surveyor/surveyor_controller_methods.rb +237 -0
- data/lib/surveyor/unparser.rb +147 -0
- data/lib/surveyor/version.rb +3 -0
- data/lib/surveyor.rb +13 -0
- data/lib/tasks/surveyor_tasks.rake +88 -0
- data/rails/init.rb +1 -0
- data/spec/controllers/surveyor_controller_spec.rb +307 -0
- data/spec/factories.rb +161 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +118 -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 +175 -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 +207 -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 +45 -0
- metadata +657 -0
@@ -0,0 +1,156 @@
|
|
1
|
+
// Javascript UI for surveyor
|
2
|
+
jQuery(document).ready(function(){
|
3
|
+
// if(jQuery.browser.msie){
|
4
|
+
// // IE has trouble with the change event for form radio/checkbox elements - bind click instead
|
5
|
+
// jQuery("form#survey_form input[type=radio], form#survey_form [type=checkbox]").bind("click", function(){
|
6
|
+
// jQuery(this).parents("form").ajaxSubmit({dataType: 'json', success: successfulSave});
|
7
|
+
// });
|
8
|
+
// // IE fires the change event for all other (not radio/checkbox) elements of the form
|
9
|
+
// jQuery("form#survey_form *").not("input[type=radio], input[type=checkbox]").bind("change", function(){
|
10
|
+
// jQuery(this).parents("form").ajaxSubmit({dataType: 'json', success: successfulSave});
|
11
|
+
// });
|
12
|
+
// }else{
|
13
|
+
// // Other browsers just use the change event on the form
|
14
|
+
|
15
|
+
//
|
16
|
+
// Uncomment the following to use the jQuery Tools Datepicker (http://jquerytools.org/demos/dateinput/index.html)
|
17
|
+
// instead of the default jQuery UI Datepicker (http://jqueryui.com/demos/datepicker/)
|
18
|
+
//
|
19
|
+
// For a date input, i.e. using dateinput from jQuery tools, the value is not updated
|
20
|
+
// before the onChange or change event is fired, so we hang this in before the update is
|
21
|
+
// sent to the server and set the correct value from the dateinput object.
|
22
|
+
// jQuery('li.date input').change(function(){
|
23
|
+
// if ( $(this).data('dateinput') ) {
|
24
|
+
// var date_obj = $(this).data('dateinput').getValue();
|
25
|
+
// this.value = date_obj.getFullYear() + "-" + (date_obj.getMonth()+1) + "-" +
|
26
|
+
// date_obj.getDate() + " 00:00:00 UTC";
|
27
|
+
// }
|
28
|
+
// });
|
29
|
+
//
|
30
|
+
// $('li input.date').dateinput({
|
31
|
+
// format: 'dd mmm yyyy'
|
32
|
+
// });
|
33
|
+
|
34
|
+
// Default Datepicker uses jQuery UI Datepicker
|
35
|
+
jQuery("input[type='text'].datetime").datetimepicker({
|
36
|
+
showSecond: true,
|
37
|
+
showMillisec: false,
|
38
|
+
timeFormat: 'HH:mm:ss',
|
39
|
+
dateFormat: 'yy-mm-dd',
|
40
|
+
changeMonth: true,
|
41
|
+
changeYear: true
|
42
|
+
});
|
43
|
+
jQuery("li.date input").datepicker({
|
44
|
+
dateFormat: 'yy-mm-dd',
|
45
|
+
changeMonth: true,
|
46
|
+
changeYear: true
|
47
|
+
});
|
48
|
+
jQuery("input[type='text'].date").datepicker({
|
49
|
+
dateFormat: 'yy-mm-dd',
|
50
|
+
changeMonth: true,
|
51
|
+
changeYear: true
|
52
|
+
});
|
53
|
+
jQuery("input[type='text'].datepicker").datepicker({
|
54
|
+
dateFormat: 'yy-mm-dd',
|
55
|
+
changeMonth: true,
|
56
|
+
changeYear: true
|
57
|
+
});
|
58
|
+
jQuery("input[type='text'].time").timepicker({});
|
59
|
+
|
60
|
+
jQuery('.surveyor_check_boxes input[type=text]').change(function(){
|
61
|
+
var textValue = $(this).val()
|
62
|
+
if (textValue.length > 0) {
|
63
|
+
$(this).parent().children().has('input[type="checkbox"]')[0].children[0].checked = true;
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
jQuery('.surveyor_radio input[type=text]').change(function(){
|
68
|
+
var textValue = $(this).val()
|
69
|
+
if (textValue.length > 0) {
|
70
|
+
$(this).parent().children().has('input[type="radio"]')[0].children[0].checked = true;
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
jQuery("form#survey_form input, form#survey_form select, form#survey_form textarea").change(function(){
|
75
|
+
var elements = [$('[type="submit"]').parent(), $('[name="' + this.name +'"]').closest('li')];
|
76
|
+
|
77
|
+
if($(this).attr('type') != 'file'){ // don't auto save files, these will only get saved when the form is submitted
|
78
|
+
question_data = $(this).parents('fieldset[id^="q_"],tr[id^="q_"]').
|
79
|
+
find("input, select, textarea").
|
80
|
+
add($("form#survey_form input[name='authenticity_token']")).
|
81
|
+
serialize();
|
82
|
+
$.ajax({
|
83
|
+
type: "PUT",
|
84
|
+
url: $(this).parents('form#survey_form').attr("action"),
|
85
|
+
data: question_data, dataType: 'json',
|
86
|
+
success: function(response) {
|
87
|
+
successfulSave(response);
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
// http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support/
|
94
|
+
$('fieldset.q_slider select').each(function(i,e) {
|
95
|
+
$(e).selectToUISlider({"labelSrc": "text"}).hide()
|
96
|
+
});
|
97
|
+
|
98
|
+
// If javascript works, we don't need to show dependents from
|
99
|
+
// previous sections at the top of the page.
|
100
|
+
jQuery("#dependents").remove();
|
101
|
+
|
102
|
+
function successfulSave(responseText) {
|
103
|
+
// surveyor_controller returns a json object to show/hide elements
|
104
|
+
// e.g. {"hide":["question_12","question_13"],"show":["question_14"]}
|
105
|
+
jQuery.each(responseText.show, function(){ showElement(this) });
|
106
|
+
jQuery.each(responseText.hide, function(){ hideElement(this) });
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
|
110
|
+
function showElement(id){
|
111
|
+
group = id.match('^g_') ? true : false;
|
112
|
+
if (group) {
|
113
|
+
jQuery('#' + id).removeClass("g_hidden");
|
114
|
+
} else {
|
115
|
+
jQuery('#' + id).removeClass("q_hidden");
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
function hideElement(id){
|
120
|
+
group = id.match('^g_') ? true : false;
|
121
|
+
if (group) {
|
122
|
+
jQuery('#' + id).addClass("g_hidden");
|
123
|
+
} else {
|
124
|
+
jQuery('#' + id).addClass("q_hidden");
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
// is_exclusive checkboxes should disble sibling checkboxes
|
129
|
+
$('input.exclusive:checked').parents('fieldset[id^="q_"]').
|
130
|
+
find(':checkbox').
|
131
|
+
not(".exclusive").
|
132
|
+
attr('checked', false).
|
133
|
+
attr('disabled', true);
|
134
|
+
|
135
|
+
$('input.exclusive:checkbox').click(function(){
|
136
|
+
var e = $(this);
|
137
|
+
var others = e.parents('fieldset[id^="q_"]').find(':checkbox').not(e);
|
138
|
+
if(e.is(':checked')){
|
139
|
+
others.attr('checked', false).attr('disabled', 'disabled');
|
140
|
+
}else{
|
141
|
+
others.attr('disabled', false);
|
142
|
+
}
|
143
|
+
});
|
144
|
+
|
145
|
+
jQuery("input[data-input-mask]").each(function(i,e){
|
146
|
+
var inputMask = $(e).attr('data-input-mask');
|
147
|
+
var placeholder = $(e).attr('data-input-mask-placeholder');
|
148
|
+
var options = { placeholder: placeholder };
|
149
|
+
$(e).mask(inputMask, options);
|
150
|
+
});
|
151
|
+
|
152
|
+
// translations selection
|
153
|
+
$(".surveyor_language_selection").show();
|
154
|
+
$(".surveyor_language_selection select#locale").change(function(){ this.form.submit(); });
|
155
|
+
|
156
|
+
});
|