surveyor_gui 0.0.3 → 0.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +22 -2
- data/app/controllers/surveyor_gui/answers_controller.rb +3 -0
- data/app/controllers/surveyor_gui/application_controller.rb +3 -0
- data/app/controllers/{dependencys_controller.rb → surveyor_gui/dependencys_controller.rb} +5 -5
- data/app/controllers/{question_groups_controller.rb → surveyor_gui/question_groups_controller.rb} +13 -7
- data/app/controllers/{questions_controller.rb → surveyor_gui/questions_controller.rb} +6 -6
- data/app/controllers/surveyor_gui/reports_controller.rb +6 -6
- data/app/controllers/surveyor_gui/responses_controller.rb +3 -1
- data/app/controllers/surveyor_gui/survey_controller.rb +1 -1
- data/app/controllers/{survey_sections_controller.rb → surveyor_gui/survey_sections_controller.rb} +5 -5
- data/app/controllers/{surveyforms_controller.rb → surveyor_gui/surveyforms_controller.rb} +1 -1
- data/app/controllers/{surveyor_controller.rb → surveyor_gui/surveyor_controller.rb} +2 -2
- data/app/helpers/surveyor_gui/application_helper.rb +2 -0
- data/app/helpers/{dependency_helper.rb → surveyor_gui/dependencys_helper.rb} +1 -1
- data/app/helpers/surveyor_gui/question_groups_helper.rb +3 -0
- data/app/helpers/{question_helper.rb → surveyor_gui/questions_helper.rb} +1 -1
- data/app/helpers/surveyor_gui/{report_helper.rb → reports_helper.rb} +1 -1
- data/app/helpers/surveyor_gui/surveyforms_helper.rb +160 -0
- data/app/helpers/{surveyor_helper.rb → surveyor_gui/surveyor_helper.rb} +1 -1
- data/app/models/question_group_tracker.rb +19 -0
- data/app/views/layouts/{application.html.erb → surveyor_gui/application.html.erb} +0 -0
- data/app/views/layouts/{surveyor_gui_blank.html.erb → surveyor_gui/surveyor_gui_blank.html.erb} +1 -0
- data/app/views/layouts/{surveyor_gui_default.html.erb → surveyor_gui/surveyor_gui_default.html.erb} +1 -0
- data/app/views/layouts/{surveyor_modified.html.erb → surveyor_gui/surveyor_modified.html.erb} +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/_column.html.erb +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/_dependency.html.erb +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/_dependency_condition_fields.html.erb +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/_form.html.erb +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/blank.html.erb +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/edit.html.erb +0 -0
- data/app/views/{dependencys → surveyor_gui/dependencys}/new.html.erb +0 -0
- data/app/views/{partials → surveyor_gui/partials}/_answer.html.haml +0 -0
- data/app/views/{partials → surveyor_gui/partials}/_question.html.haml +0 -0
- data/app/views/{partials → surveyor_gui/partials}/_question_group.html.haml +0 -0
- data/app/views/{partials → surveyor_gui/partials}/_section.html.haml +0 -0
- data/app/views/surveyor_gui/partials/_url_helpers.html.erb +5 -0
- data/app/views/{question_groups → surveyor_gui/question_groups}/_form.html.erb +2 -1
- data/app/views/{question_groups → surveyor_gui/question_groups}/_group_inline_field.html.erb +0 -0
- data/app/views/{question_groups → surveyor_gui/question_groups}/_group_inline_fields.html.erb +0 -0
- data/app/views/{question_groups → surveyor_gui/question_groups}/blank.html.erb +0 -0
- data/app/views/{question_groups → surveyor_gui/question_groups}/edit.html.erb +0 -0
- data/app/views/{question_groups → surveyor_gui/question_groups}/new.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_answer_fields.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_answer_options.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_form.html.erb +2 -1
- data/app/views/{questions → surveyor_gui/questions}/_grid_dropdown_columns.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_grid_dropdown_fields.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_grid_fields.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_no_picks.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_pick.html +0 -0
- data/app/views/{questions → surveyor_gui/questions}/_picks.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/blank.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/edit.html.erb +0 -0
- data/app/views/{questions → surveyor_gui/questions}/new.html.erb +0 -0
- data/app/views/surveyor_gui/responses/_survey_results.html.haml +1 -1
- data/app/views/surveyor_gui/responses/index.html.haml +1 -1
- data/app/views/surveyor_gui/shared/_report_data.html.haml +17 -14
- data/app/views/{survey_sections → surveyor_gui/survey_sections}/_form.html.erb +0 -0
- data/app/views/{survey_sections → surveyor_gui/survey_sections}/blank.html.erb +0 -0
- data/app/views/{survey_sections → surveyor_gui/survey_sections}/edit.html.erb +0 -0
- data/app/views/{survey_sections → surveyor_gui/survey_sections}/new.html.erb +0 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_form.html.erb +4 -4
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_question_field.html.erb +0 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_question_group.html.erb +14 -14
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_question_group_fields.html.erb +0 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_question_name_and_number.html.erb +0 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_question_section.html.erb +0 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_question_wrapper.html.erb +14 -15
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/_survey_section_fields.html.erb +11 -12
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/clone_survey.html.erb +0 -0
- data/app/views/surveyor_gui/surveyforms/edit.html.erb +5 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/index.html.erb +2 -2
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/new.html.erb +0 -0
- data/app/views/{surveyforms → surveyor_gui/surveyforms}/show.html.erb +0 -0
- data/config/routes.rb +20 -22
- data/lib/assets/javascripts/surveyor_gui/surveyor_gui.js +25 -14
- data/lib/assets/stylesheets/surveyor_gui/surveyor_gui.sass +2 -0
- data/lib/generators/surveyor_gui/install_generator.rb +1 -1
- data/lib/generators/surveyor_gui/templates/app/views/layouts/{surveyor_gui_default.html.erb → surveyor_gui/surveyor_gui_default.html.erb} +1 -0
- data/lib/surveyor_gui/engine.rb +2 -1
- data/lib/surveyor_gui/models/response_set_methods.rb +2 -1
- data/lib/surveyor_gui/surveyforms_controller_methods.rb +1 -1
- data/lib/surveyor_gui/version.rb +1 -1
- data/spec/controllers/surveyforms_controller_spec.rb +10 -9
- data/spec/features/create_survey_spec.rb +2 -3
- data/spec/features/dependencies_spec.rb +1 -1
- data/spec/support/surveyforms_creation_helpers.rb +4 -4
- data/spec/views/questions/edit.html.erb_spec.rb +4 -3
- data/spec/views/surveyforms/edit.html.erb_spec.rb +1 -1
- metadata +71 -67
- data/app/controllers/answers_controller.rb +0 -3
- data/app/controllers/application_controller.rb +0 -3
- data/app/helpers/application_helper.rb +0 -2
- data/app/helpers/surveyform_helper.rb +0 -179
- data/app/views/surveyforms/edit.html.erb +0 -5
|
@@ -8,7 +8,7 @@ module CapybaraHelper
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
describe "questions/edit.html.erb" do
|
|
11
|
+
describe "surveyor_gui/questions/edit.html.erb" do
|
|
12
12
|
include CapybaraHelper
|
|
13
13
|
|
|
14
14
|
let(:question){ FactoryGirl.create(:question) }
|
|
@@ -16,17 +16,18 @@ describe "questions/edit.html.erb" do
|
|
|
16
16
|
let(:form){find('form')}
|
|
17
17
|
|
|
18
18
|
before do
|
|
19
|
+
@routes = SurveyorGui::Engine.routes
|
|
19
20
|
assign(:question, question)
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
it "renders a form" do
|
|
23
|
-
render
|
|
24
|
+
render
|
|
24
25
|
expect(response).to have_selector("form")
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it "will post a new question on submit" do
|
|
28
29
|
render
|
|
29
|
-
expect(form[:action]).to eql(question_path question)
|
|
30
|
+
expect(form[:action]).to eql(surveyor_gui.question_path question)
|
|
30
31
|
expect(form[:method]).to eql('post')
|
|
31
32
|
end
|
|
32
33
|
|
|
@@ -10,7 +10,7 @@ end
|
|
|
10
10
|
RSpec.configure do |config|
|
|
11
11
|
config.order = :default
|
|
12
12
|
end
|
|
13
|
-
describe "surveyforms/edit.html.erb" do
|
|
13
|
+
describe "surveyor_gui/surveyforms/edit.html.erb" do
|
|
14
14
|
include CapybaraHelper
|
|
15
15
|
let(:surveyform){ FactoryGirl.create(:surveyform) }
|
|
16
16
|
let(:ss){ FactoryGirl.create(:survey_section, :surveyform => surveyform, :title => "Rooms", :display_order => 0)}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: surveyor_gui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Jay
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-08-
|
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -355,31 +355,33 @@ extra_rdoc_files: []
|
|
|
355
355
|
files:
|
|
356
356
|
- ".gitignore"
|
|
357
357
|
- ".travis.yml"
|
|
358
|
+
- CHANGELOG.md
|
|
358
359
|
- Gemfile
|
|
359
360
|
- LICENSE
|
|
360
361
|
- MIT-LICENSE
|
|
361
362
|
- README.md
|
|
362
363
|
- Rakefile
|
|
363
|
-
- app/controllers/answers_controller.rb
|
|
364
|
-
- app/controllers/application_controller.rb
|
|
365
|
-
- app/controllers/dependencys_controller.rb
|
|
366
|
-
- app/controllers/question_groups_controller.rb
|
|
367
|
-
- app/controllers/questions_controller.rb
|
|
368
|
-
- app/controllers/survey_sections_controller.rb
|
|
369
|
-
- app/controllers/surveyforms_controller.rb
|
|
370
|
-
- app/controllers/surveyor_controller.rb
|
|
364
|
+
- app/controllers/surveyor_gui/answers_controller.rb
|
|
365
|
+
- app/controllers/surveyor_gui/application_controller.rb
|
|
366
|
+
- app/controllers/surveyor_gui/dependencys_controller.rb
|
|
367
|
+
- app/controllers/surveyor_gui/question_groups_controller.rb
|
|
368
|
+
- app/controllers/surveyor_gui/questions_controller.rb
|
|
371
369
|
- app/controllers/surveyor_gui/reports_controller.rb
|
|
372
370
|
- app/controllers/surveyor_gui/responses_controller.rb
|
|
373
371
|
- app/controllers/surveyor_gui/survey_controller.rb
|
|
372
|
+
- app/controllers/surveyor_gui/survey_sections_controller.rb
|
|
373
|
+
- app/controllers/surveyor_gui/surveyforms_controller.rb
|
|
374
|
+
- app/controllers/surveyor_gui/surveyor_controller.rb
|
|
374
375
|
- app/facades/report_formatter.rb
|
|
375
376
|
- app/facades/report_preview_wrapper.rb
|
|
376
377
|
- app/facades/report_response_generator.rb
|
|
377
|
-
- app/helpers/application_helper.rb
|
|
378
|
-
- app/helpers/
|
|
379
|
-
- app/helpers/
|
|
380
|
-
- app/helpers/
|
|
381
|
-
- app/helpers/surveyor_gui/
|
|
382
|
-
- app/helpers/
|
|
378
|
+
- app/helpers/surveyor_gui/application_helper.rb
|
|
379
|
+
- app/helpers/surveyor_gui/dependencys_helper.rb
|
|
380
|
+
- app/helpers/surveyor_gui/question_groups_helper.rb
|
|
381
|
+
- app/helpers/surveyor_gui/questions_helper.rb
|
|
382
|
+
- app/helpers/surveyor_gui/reports_helper.rb
|
|
383
|
+
- app/helpers/surveyor_gui/surveyforms_helper.rb
|
|
384
|
+
- app/helpers/surveyor_gui/surveyor_helper.rb
|
|
383
385
|
- app/inputs/currency_input.rb
|
|
384
386
|
- app/inputs/date_picker_input.rb
|
|
385
387
|
- app/inputs/datetime_picker_input.rb
|
|
@@ -394,6 +396,7 @@ files:
|
|
|
394
396
|
- app/models/permitted_params_decorator.rb
|
|
395
397
|
- app/models/question.rb
|
|
396
398
|
- app/models/question_group.rb
|
|
399
|
+
- app/models/question_group_tracker.rb
|
|
397
400
|
- app/models/question_type.rb
|
|
398
401
|
- app/models/response.rb
|
|
399
402
|
- app/models/response_set.rb
|
|
@@ -402,56 +405,40 @@ files:
|
|
|
402
405
|
- app/models/survey_section.rb
|
|
403
406
|
- app/models/surveyform.rb
|
|
404
407
|
- app/uploaders/blob_uploader.rb
|
|
405
|
-
- app/views/
|
|
406
|
-
- app/views/
|
|
407
|
-
- app/views/
|
|
408
|
-
- app/views/
|
|
409
|
-
- app/views/dependencys/
|
|
410
|
-
- app/views/dependencys/
|
|
411
|
-
- app/views/dependencys/
|
|
412
|
-
- app/views/
|
|
413
|
-
- app/views/
|
|
414
|
-
- app/views/
|
|
415
|
-
- app/views/
|
|
416
|
-
- app/views/partials/_answer.html.haml
|
|
417
|
-
- app/views/partials/_question.html.haml
|
|
418
|
-
- app/views/partials/_question_group.html.haml
|
|
419
|
-
- app/views/partials/_section.html.haml
|
|
420
|
-
- app/views/
|
|
421
|
-
- app/views/question_groups/
|
|
422
|
-
- app/views/question_groups/
|
|
423
|
-
- app/views/question_groups/
|
|
424
|
-
- app/views/question_groups/
|
|
425
|
-
- app/views/question_groups/
|
|
426
|
-
- app/views/
|
|
427
|
-
- app/views/questions/
|
|
428
|
-
- app/views/questions/
|
|
429
|
-
- app/views/questions/
|
|
430
|
-
- app/views/questions/
|
|
431
|
-
- app/views/questions/
|
|
432
|
-
- app/views/questions/
|
|
433
|
-
- app/views/questions/
|
|
434
|
-
- app/views/questions/
|
|
435
|
-
- app/views/questions/
|
|
436
|
-
- app/views/questions/
|
|
437
|
-
- app/views/questions/
|
|
438
|
-
- app/views/
|
|
439
|
-
- app/views/survey_sections/blank.html.erb
|
|
440
|
-
- app/views/survey_sections/edit.html.erb
|
|
441
|
-
- app/views/survey_sections/new.html.erb
|
|
442
|
-
- app/views/surveyforms/_form.html.erb
|
|
443
|
-
- app/views/surveyforms/_question_field.html.erb
|
|
444
|
-
- app/views/surveyforms/_question_group.html.erb
|
|
445
|
-
- app/views/surveyforms/_question_group_fields.html.erb
|
|
446
|
-
- app/views/surveyforms/_question_name_and_number.html.erb
|
|
447
|
-
- app/views/surveyforms/_question_section.html.erb
|
|
448
|
-
- app/views/surveyforms/_question_wrapper.html.erb
|
|
449
|
-
- app/views/surveyforms/_survey_section_fields.html.erb
|
|
450
|
-
- app/views/surveyforms/clone_survey.html.erb
|
|
451
|
-
- app/views/surveyforms/edit.html.erb
|
|
452
|
-
- app/views/surveyforms/index.html.erb
|
|
453
|
-
- app/views/surveyforms/new.html.erb
|
|
454
|
-
- app/views/surveyforms/show.html.erb
|
|
408
|
+
- app/views/layouts/surveyor_gui/application.html.erb
|
|
409
|
+
- app/views/layouts/surveyor_gui/surveyor_gui_blank.html.erb
|
|
410
|
+
- app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb
|
|
411
|
+
- app/views/layouts/surveyor_gui/surveyor_modified.html.erb
|
|
412
|
+
- app/views/surveyor_gui/dependencys/_column.html.erb
|
|
413
|
+
- app/views/surveyor_gui/dependencys/_dependency.html.erb
|
|
414
|
+
- app/views/surveyor_gui/dependencys/_dependency_condition_fields.html.erb
|
|
415
|
+
- app/views/surveyor_gui/dependencys/_form.html.erb
|
|
416
|
+
- app/views/surveyor_gui/dependencys/blank.html.erb
|
|
417
|
+
- app/views/surveyor_gui/dependencys/edit.html.erb
|
|
418
|
+
- app/views/surveyor_gui/dependencys/new.html.erb
|
|
419
|
+
- app/views/surveyor_gui/partials/_answer.html.haml
|
|
420
|
+
- app/views/surveyor_gui/partials/_question.html.haml
|
|
421
|
+
- app/views/surveyor_gui/partials/_question_group.html.haml
|
|
422
|
+
- app/views/surveyor_gui/partials/_section.html.haml
|
|
423
|
+
- app/views/surveyor_gui/partials/_url_helpers.html.erb
|
|
424
|
+
- app/views/surveyor_gui/question_groups/_form.html.erb
|
|
425
|
+
- app/views/surveyor_gui/question_groups/_group_inline_field.html.erb
|
|
426
|
+
- app/views/surveyor_gui/question_groups/_group_inline_fields.html.erb
|
|
427
|
+
- app/views/surveyor_gui/question_groups/blank.html.erb
|
|
428
|
+
- app/views/surveyor_gui/question_groups/edit.html.erb
|
|
429
|
+
- app/views/surveyor_gui/question_groups/new.html.erb
|
|
430
|
+
- app/views/surveyor_gui/questions/_answer_fields.html.erb
|
|
431
|
+
- app/views/surveyor_gui/questions/_answer_options.html.erb
|
|
432
|
+
- app/views/surveyor_gui/questions/_form.html.erb
|
|
433
|
+
- app/views/surveyor_gui/questions/_grid_dropdown_columns.html.erb
|
|
434
|
+
- app/views/surveyor_gui/questions/_grid_dropdown_fields.html.erb
|
|
435
|
+
- app/views/surveyor_gui/questions/_grid_fields.html.erb
|
|
436
|
+
- app/views/surveyor_gui/questions/_no_picks.html.erb
|
|
437
|
+
- app/views/surveyor_gui/questions/_pick.html
|
|
438
|
+
- app/views/surveyor_gui/questions/_picks.html.erb
|
|
439
|
+
- app/views/surveyor_gui/questions/blank.html.erb
|
|
440
|
+
- app/views/surveyor_gui/questions/edit.html.erb
|
|
441
|
+
- app/views/surveyor_gui/questions/new.html.erb
|
|
455
442
|
- app/views/surveyor_gui/reports/_graphs.html.haml
|
|
456
443
|
- app/views/surveyor_gui/reports/_grid.html.haml
|
|
457
444
|
- app/views/surveyor_gui/reports/_grid_dropdown.html.haml
|
|
@@ -471,6 +458,23 @@ files:
|
|
|
471
458
|
- app/views/surveyor_gui/shared/_question_number.html.haml
|
|
472
459
|
- app/views/surveyor_gui/shared/_report_data.html.haml
|
|
473
460
|
- app/views/surveyor_gui/shared/_stars_report_data.html.haml
|
|
461
|
+
- app/views/surveyor_gui/survey_sections/_form.html.erb
|
|
462
|
+
- app/views/surveyor_gui/survey_sections/blank.html.erb
|
|
463
|
+
- app/views/surveyor_gui/survey_sections/edit.html.erb
|
|
464
|
+
- app/views/surveyor_gui/survey_sections/new.html.erb
|
|
465
|
+
- app/views/surveyor_gui/surveyforms/_form.html.erb
|
|
466
|
+
- app/views/surveyor_gui/surveyforms/_question_field.html.erb
|
|
467
|
+
- app/views/surveyor_gui/surveyforms/_question_group.html.erb
|
|
468
|
+
- app/views/surveyor_gui/surveyforms/_question_group_fields.html.erb
|
|
469
|
+
- app/views/surveyor_gui/surveyforms/_question_name_and_number.html.erb
|
|
470
|
+
- app/views/surveyor_gui/surveyforms/_question_section.html.erb
|
|
471
|
+
- app/views/surveyor_gui/surveyforms/_question_wrapper.html.erb
|
|
472
|
+
- app/views/surveyor_gui/surveyforms/_survey_section_fields.html.erb
|
|
473
|
+
- app/views/surveyor_gui/surveyforms/clone_survey.html.erb
|
|
474
|
+
- app/views/surveyor_gui/surveyforms/edit.html.erb
|
|
475
|
+
- app/views/surveyor_gui/surveyforms/index.html.erb
|
|
476
|
+
- app/views/surveyor_gui/surveyforms/new.html.erb
|
|
477
|
+
- app/views/surveyor_gui/surveyforms/show.html.erb
|
|
474
478
|
- config.ru
|
|
475
479
|
- config/environment.rb
|
|
476
480
|
- config/routes.rb
|
|
@@ -523,7 +527,7 @@ files:
|
|
|
523
527
|
- lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_gui_all.css.sass
|
|
524
528
|
- lib/generators/surveyor_gui/templates/app/helpers/surveyor_helper.rb
|
|
525
529
|
- lib/generators/surveyor_gui/templates/app/models/response_set_user.rb
|
|
526
|
-
- lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui_default.html.erb
|
|
530
|
+
- lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb
|
|
527
531
|
- lib/generators/surveyor_gui/templates/config/initializers/simple_form.rb
|
|
528
532
|
- lib/generators/surveyor_gui/templates/config/locales/en.yml
|
|
529
533
|
- lib/surveyor_gui.rb
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
module SurveyformHelper
|
|
2
|
-
require 'deep_cloneable'
|
|
3
|
-
|
|
4
|
-
def list_dependencies(o)
|
|
5
|
-
controlling_questions = o.controlling_questions
|
|
6
|
-
|
|
7
|
-
controlling_question_ids = controlling_questions.map{|q| q.question_number.to_s+')'}.uniq
|
|
8
|
-
count = controlling_question_ids.count
|
|
9
|
-
retstr ='This question is shown depending on the '
|
|
10
|
-
retstr += 'answer'.pluralize(count)
|
|
11
|
-
retstr += ' to '
|
|
12
|
-
retstr += 'question'.pluralize(count) + ' '
|
|
13
|
-
retstr + list_phrase(controlling_question_ids)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def list_phrase(args)
|
|
17
|
-
## given a list of word parameters, return a syntactically correct phrase
|
|
18
|
-
## [dog] = "dog"
|
|
19
|
-
## [dog, cat] = "dog and cat"
|
|
20
|
-
## [dog, cat, bird] = "dog, cat and bird"
|
|
21
|
-
case args.count
|
|
22
|
-
when 0
|
|
23
|
-
''
|
|
24
|
-
when 1
|
|
25
|
-
args[0]
|
|
26
|
-
when 2
|
|
27
|
-
args[0] + ' and ' + args[1]
|
|
28
|
-
else
|
|
29
|
-
last = args.count
|
|
30
|
-
args.take(last - 2).join(', ') + ', ' + args[last - 2] + ' and ' + args[last - 1]
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def render_questions_and_groups_helper(q, ss)
|
|
35
|
-
#this method will render either a question or a complete question group.
|
|
36
|
-
#we always iterate through questions, and if we happen to notice a question
|
|
37
|
-
#belongs to a group, we process the group at that time.
|
|
38
|
-
#note that questions carry a question_group_id, and this is how we know
|
|
39
|
-
#that a question is part of a group, and that it should not be rendered individually,
|
|
40
|
-
#but as part of a group.
|
|
41
|
-
if q.object.part_of_group?
|
|
42
|
-
_render_initial_group(q, ss) || _respond_to_a_change_in_group_id(q, ss)
|
|
43
|
-
else
|
|
44
|
-
render "question_wrapper", f: q
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def render_one_group(qg)
|
|
49
|
-
qg.simple_fields_for :questions, @current_group.questions do |f|
|
|
50
|
-
if f.object.is_comment != true
|
|
51
|
-
render "question_group_fields", f: f
|
|
52
|
-
elsif f.object.is_comment == true
|
|
53
|
-
"</div>".html_safe+(render "question_field", f: f)+"<div>".html_safe
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def question_group_heading(f)
|
|
59
|
-
if f.object.question_type_id == :grid_dropdown
|
|
60
|
-
heading = f.object.question_group.columns
|
|
61
|
-
elsif f.object.question_group.display_type == "grid"
|
|
62
|
-
heading = f.object.answers
|
|
63
|
-
else
|
|
64
|
-
heading = []
|
|
65
|
-
end
|
|
66
|
-
heading.map {|a| "<span class=\"question_group_heading #{f.object.question_type_id.to_s}\" >#{a.text}<\/span>"}.join().html_safe
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def row_label_if_question_group(question)
|
|
70
|
-
if question.part_of_group?
|
|
71
|
-
"<span class=\"row_name\">#{question.text}: </span>".html_safe
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def question_group_class(question)
|
|
76
|
-
if @current_group.question_group.display_type == "inline"
|
|
77
|
-
"inline"
|
|
78
|
-
elsif @current_group.question_group.display_type == "default"
|
|
79
|
-
"default"
|
|
80
|
-
else
|
|
81
|
-
if question.question_type_id == :grid_dropdown
|
|
82
|
-
"dropdown"
|
|
83
|
-
else
|
|
84
|
-
"grid"
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
private
|
|
90
|
-
def _render_initial_group(q, ss)
|
|
91
|
-
if @current_group.nil?
|
|
92
|
-
@current_group = QuestionGroupTracker.new(q.object.question_group_id)
|
|
93
|
-
render "question_group", :ss => ss, :f => q
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def _respond_to_a_change_in_group_id(q, ss)
|
|
98
|
-
if @current_group.question_group_id != q.object.question_group_id
|
|
99
|
-
@current_group = QuestionGroupTracker.new(q.object.question_group_id)
|
|
100
|
-
render "question_group", :ss => ss, :f => q
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
class SurveyCloneFactory
|
|
107
|
-
def initialize(id, as_template=false)
|
|
108
|
-
@survey = Surveyform.find(id.to_i)
|
|
109
|
-
@as_template = as_template
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def clone
|
|
113
|
-
cloned_survey = _deep_clone
|
|
114
|
-
_set_api_keys(cloned_survey)
|
|
115
|
-
if cloned_survey.save!
|
|
116
|
-
return cloned_survey
|
|
117
|
-
else
|
|
118
|
-
raise cloned_survey.errors.messages.map{|m| m}.join(',')
|
|
119
|
-
return nil
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
private
|
|
124
|
-
|
|
125
|
-
def _initial_clone
|
|
126
|
-
initial_clone = @survey
|
|
127
|
-
initial_clone.api_id = Surveyor::Common.generate_api_id
|
|
128
|
-
initial_clone.survey_version = Survey.where(access_code: @survey.access_code).maximum(:survey_version) + 1
|
|
129
|
-
return initial_clone
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def _deep_clone
|
|
133
|
-
_initial_clone.deep_clone include: {
|
|
134
|
-
sections:
|
|
135
|
-
{
|
|
136
|
-
questions: [
|
|
137
|
-
:answers,
|
|
138
|
-
{dependency: :dependency_conditions},
|
|
139
|
-
{question_group: :columns}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
use_dictionary: true
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def _set_api_keys(cloned_survey)
|
|
147
|
-
cloned_survey.sections.each do |section|
|
|
148
|
-
section.questions.each do |question|
|
|
149
|
-
question.api_id = Surveyor::Common.generate_api_id
|
|
150
|
-
question.question_group.api_id = Surveyor::Common.generate_api_id if question.part_of_group?
|
|
151
|
-
question.answers.each do |answer|
|
|
152
|
-
answer.api_id = Surveyor::Common.generate_api_id
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
class QuestionGroupTracker
|
|
160
|
-
attr_reader :questions, :question_group_id, :question_group
|
|
161
|
-
def initialize(question_group_id)
|
|
162
|
-
@questions = Question.where('question_group_id=?',question_group_id)
|
|
163
|
-
@counter = 0
|
|
164
|
-
@question_group_id = question_group_id
|
|
165
|
-
@question_group = QuestionGroup.find(question_group_id)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def check_for_new_group(question)
|
|
169
|
-
if question.question_group_id != @question_group_id || !defined?(@initial_check)
|
|
170
|
-
initialize(question.question_group_id)
|
|
171
|
-
@initial_check = true
|
|
172
|
-
return true
|
|
173
|
-
else
|
|
174
|
-
return false
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
|