jakewendt-surveyor 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +285 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/app/controllers/surveyor_controller.rb +142 -0
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +67 -0
- data/app/models/answer.rb +23 -0
- data/app/models/dependency.rb +50 -0
- data/app/models/dependency_condition.rb +47 -0
- data/app/models/question.rb +54 -0
- data/app/models/question_group.rb +33 -0
- data/app/models/response.rb +94 -0
- data/app/models/response_set.rb +316 -0
- data/app/models/survey.rb +172 -0
- data/app/models/survey_section.rb +18 -0
- data/app/models/validation.rb +38 -0
- data/app/models/validation_condition.rb +47 -0
- data/app/views/layouts/surveyor_default.html.erb +13 -0
- data/app/views/partials/_answer.html.haml +58 -0
- data/app/views/partials/_question.html.haml +80 -0
- data/app/views/partials/_question_group.html.haml +39 -0
- data/app/views/surveyor/edit.html.haml +38 -0
- data/app/views/surveyor/new.html.haml +16 -0
- data/app/views/surveyor/show.html.haml +12 -0
- data/config/routes.rb +11 -0
- data/features/step_definitions/surveyor_steps.rb +7 -0
- data/features/step_definitions/web_steps.rb +273 -0
- data/features/support/env.rb +57 -0
- data/features/support/paths.rb +25 -0
- data/features/surveyor.feature +11 -0
- data/generators/extend_surveyor/extend_surveyor_generator.rb +22 -0
- data/generators/extend_surveyor/templates/EXTENDING_SURVEYOR +17 -0
- data/generators/extend_surveyor/templates/extensions/survey_extensions.rb +24 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_controller_extensions.rb +28 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_custom.html.erb +13 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_helper_extensions.rb +17 -0
- data/generators/surveyor/surveyor_generator.rb +67 -0
- data/generators/surveyor/templates/README +10 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
- data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +201 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +3549 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +7616 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.form.js +637 -0
- data/generators/surveyor/templates/assets/javascripts/surveyor.js +47 -0
- data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +71 -0
- data/generators/surveyor/templates/assets/stylesheets/reset.css +50 -0
- data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +243 -0
- data/generators/surveyor/templates/assets/stylesheets/surveyor.css +235 -0
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +851 -0
- data/generators/surveyor/templates/initializers/haml.rb +8 -0
- data/generators/surveyor/templates/initializers/surveyor.rb +10 -0
- data/generators/surveyor/templates/migrate/add_correct_answer_id_to_questions.rb +9 -0
- data/generators/surveyor/templates/migrate/add_display_order_to_surveys.rb +9 -0
- data/generators/surveyor/templates/migrate/add_index_to_response_sets.rb +9 -0
- data/generators/surveyor/templates/migrate/add_index_to_surveys.rb +9 -0
- data/generators/surveyor/templates/migrate/add_manual_numbering.rb +11 -0
- data/generators/surveyor/templates/migrate/add_unique_indicies.rb +17 -0
- data/generators/surveyor/templates/migrate/create_answers.rb +37 -0
- data/generators/surveyor/templates/migrate/create_dependencies.rb +22 -0
- data/generators/surveyor/templates/migrate/create_dependency_conditions.rb +29 -0
- data/generators/surveyor/templates/migrate/create_question_groups.rb +27 -0
- data/generators/surveyor/templates/migrate/create_questions.rb +36 -0
- data/generators/surveyor/templates/migrate/create_response_sets.rb +22 -0
- data/generators/surveyor/templates/migrate/create_responses.rb +33 -0
- data/generators/surveyor/templates/migrate/create_survey_sections.rb +29 -0
- data/generators/surveyor/templates/migrate/create_surveys.rb +31 -0
- data/generators/surveyor/templates/migrate/create_validation_conditions.rb +32 -0
- data/generators/surveyor/templates/migrate/create_validations.rb +20 -0
- data/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +218 -0
- data/generators/surveyor/templates/tasks/surveyor.rb +4 -0
- data/generators/test_surveyor/templates/TESTING_SURVEYOR +0 -0
- data/generators/test_surveyor/templates/environments/cucumber.rb +21 -0
- data/generators/test_surveyor/test_surveyor_generator.rb +15 -0
- data/jakewendt-surveyor.gemspec +212 -0
- data/lib/fixtures_extensions.rb +6 -0
- data/lib/jakewendt-surveyor.rb +1 -0
- data/lib/surveyor.rb +44 -0
- data/lib/surveyor/acts_as_response.rb +33 -0
- data/lib/surveyor/config.rb +45 -0
- data/lib/tasks/surveyor_tasks.rake +33 -0
- data/lib/xml_formatter.rb +12 -0
- data/rails/init.rb +1 -0
- data/script/surveyor/answer.rb +54 -0
- data/script/surveyor/base.rb +77 -0
- data/script/surveyor/dependency.rb +13 -0
- data/script/surveyor/dependency_condition.rb +40 -0
- data/script/surveyor/parser.rb +207 -0
- data/script/surveyor/question.rb +37 -0
- data/script/surveyor/question_group.rb +26 -0
- data/script/surveyor/specs/answer_spec.rb +29 -0
- data/script/surveyor/specs/question_spec.rb +63 -0
- data/script/surveyor/specs/spec_helper.rb +7 -0
- data/script/surveyor/specs/survey_section_spec.rb +23 -0
- data/script/surveyor/specs/validation_condition_spec.rb +20 -0
- data/script/surveyor/specs/validation_spec.rb +20 -0
- data/script/surveyor/survey.rb +35 -0
- data/script/surveyor/survey_section.rb +21 -0
- data/script/surveyor/validation.rb +21 -0
- data/script/surveyor/validation_condition.rb +21 -0
- data/script/surveyor/whr_dsl.tmproj +244 -0
- data/spec/controllers/surveyor_controller_spec.rb +193 -0
- data/spec/factories.rb +145 -0
- data/spec/lib/surveyor_spec.rb +44 -0
- data/spec/models/answer_spec.rb +29 -0
- data/spec/models/dependency_condition_spec.rb +321 -0
- data/spec/models/dependency_spec.rb +81 -0
- data/spec/models/question_group_spec.rb +35 -0
- data/spec/models/question_spec.rb +75 -0
- data/spec/models/response_set_spec.rb +245 -0
- data/spec/models/response_spec.rb +76 -0
- data/spec/models/survey_section_spec.rb +32 -0
- data/spec/models/survey_spec.rb +71 -0
- data/spec/models/validation_condition_spec.rb +105 -0
- data/spec/models/validation_spec.rb +59 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +12 -0
- metadata +254 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'answer'
|
3
|
+
|
4
|
+
describe SurveyParser::Answer, " when first created" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
question = mock("Question", :id => 2, :parser => mock("SurveyParser::Parser", :new_answer_id => 1))
|
8
|
+
question.stub!(:class => SurveyParser::Question)
|
9
|
+
options = {:help_text => "Never or rarely ever", :reference_identifier => "b3a_1"}
|
10
|
+
@ans = SurveyParser::Answer.new(question, ["No / Rarely"], options)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set inititalized variables to those passed in" do
|
14
|
+
@ans.id.should == 1
|
15
|
+
@ans.question_id.should == 2
|
16
|
+
@ans.reference_identifier.should == "b3a_1"
|
17
|
+
@ans.text.should == "No / Rarely"
|
18
|
+
@ans.help_text.should == "Never or rarely ever"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should output current state to yml" do
|
22
|
+
@ans.should.respond_to?(:to_yml)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should create a normalized code automatically when initalized" do
|
26
|
+
@ans.data_export_identifier.should eql("no_rarely")
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'question'
|
3
|
+
|
4
|
+
describe SurveyParser::Question, " when first created" do
|
5
|
+
before do
|
6
|
+
section = mock("SurveyParser::SurveySection", :id => 2, :parser => mock("SurveyParser::Parser", :new_question_id => 1))
|
7
|
+
section.stub!(:class => SurveyParser::SurveySection)
|
8
|
+
args = {:help_text => "Please give a rough estimate", :reference_identifier => "B3"}
|
9
|
+
options = {}
|
10
|
+
@ques = SurveyParser::Question.new(section, ["In the past 12 months how many times have you been to a doctor?", args], options)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set initialization parameters properly" do
|
14
|
+
@ques.id.should == 1
|
15
|
+
@ques.reference_identifier.should == "B3"
|
16
|
+
@ques.survey_section_id.should == 2
|
17
|
+
@ques.help_text.should == "Please give a rough estimate"
|
18
|
+
|
19
|
+
#Checking the defaults
|
20
|
+
@ques.pick.should == :none
|
21
|
+
@ques.display_type.should == :default
|
22
|
+
@ques.is_mandatory.should == true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should output current state to yml" do
|
26
|
+
@ques.should.respond_to?(:to_yml)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create a normalized code automatically when initalized" do
|
30
|
+
@ques.data_export_identifier.should eql("many_times_you_been_doctor")
|
31
|
+
end
|
32
|
+
|
33
|
+
# We don't change titles via the DSL
|
34
|
+
# it "should update the normalized code if the title is changed" do
|
35
|
+
# @ques.data_export_identifier.should == "many_times_you_been_doctor"
|
36
|
+
# @ques.text = "Sometimes or All the time?"
|
37
|
+
# @ques.data_export_identifier.should == "sometimes_all_time"
|
38
|
+
# end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe SurveyParser::Question, "when it contains data" do
|
43
|
+
before(:each) do
|
44
|
+
section = mock("SurveyParser::SurveySection", :id => 2, :parser => mock("SurveyParser::Parser", :new_question_id => 1))
|
45
|
+
args = {:help_text => "Please give a rough estimate", :reference_identifier => "B3"}
|
46
|
+
options = {}
|
47
|
+
@ques = SurveyParser::Question.new(section, ["In the past 12 months how many times have you been to a doctor?", args], options)
|
48
|
+
@ques.answers << mock("SurveyParser::Answer", :reference_identifier => "1", :text => "foo")
|
49
|
+
@ques.answers << mock("SurveyParser::Answer", :reference_identifier => "2", :text => "foo")
|
50
|
+
@ques.answers << mock("SurveyParser::Answer", :reference_identifier => "3", :text => "foo")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have added the test answers correctly" do
|
54
|
+
@ques.answers.length.should eql(3)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should find an answer by reference" do
|
58
|
+
a_to_find = @ques.find_answer_by_reference("2")
|
59
|
+
a_to_find.should_not be_nil
|
60
|
+
a_to_find.reference_identifier.should eql("2")
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../lib/surveyor")
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + "/../parser")
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + "/../base")
|
5
|
+
|
6
|
+
Spec::Runner.configure do |config|
|
7
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'survey_section'
|
3
|
+
|
4
|
+
describe SurveyParser::SurveySection, "when first created" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@section = SurveyParser::SurveySection.new(mock("SurveyParser::Survey", :id => 2, :parser => mock("SurveyParser::Parser", :new_survey_section_id => 1)), ["Demographics"], {})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should generate a data export identifier" do
|
11
|
+
@section.data_export_identifier.should == "demographics"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should find a question by reference" do
|
15
|
+
@section.questions << mock("SurveyParser::Question", :reference_identifier => "1", :text => "foo")
|
16
|
+
@section.questions << mock("SurveyParser::Question", :reference_identifier => "2", :text => "foo")
|
17
|
+
@section.questions << mock("SurveyParser::Question", :reference_identifier => "3", :text => "foo")
|
18
|
+
|
19
|
+
q = @section.find_question_by_reference("2")
|
20
|
+
q.should_not be_nil
|
21
|
+
q.reference_identifier.should == "2"
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'validation_condition'
|
3
|
+
|
4
|
+
describe SurveyParser::ValidationCondition, " when first created" do
|
5
|
+
before do
|
6
|
+
validation = mock("SurveyParser::Validation", :id => 29, :parser => mock("SurveyParser::Parser", :new_validation_condition_id => 21))
|
7
|
+
validation.stub!(:class => SurveyParser::Validation)
|
8
|
+
args = [">=", {:integer_value => 0}]
|
9
|
+
options = {}
|
10
|
+
@validation_condition = SurveyParser::ValidationCondition.new(validation, args, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set initialization parameters properly" do
|
14
|
+
@validation_condition.id.should == 21
|
15
|
+
@validation_condition.validation_id.should == 29
|
16
|
+
@validation_condition.integer_value.should == 0
|
17
|
+
@validation_condition.operator.should == ">="
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'validation'
|
3
|
+
|
4
|
+
describe SurveyParser::Validation, " when first created" do
|
5
|
+
before do
|
6
|
+
answer = mock("SurveyParser::Answer", :id => 2, :parser => mock("SurveyParser::Parser", :new_validation_id => 1))
|
7
|
+
answer.stub!(:class => SurveyParser::Answer)
|
8
|
+
args = [{:rule => "C", :message => "Please select a number between 0 and 120"}]
|
9
|
+
options = {}
|
10
|
+
@validation = SurveyParser::Validation.new(answer, args, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set initialization parameters properly" do
|
14
|
+
@validation.id.should == 1
|
15
|
+
@validation.message.should == "Please select a number between 0 and 120"
|
16
|
+
@validation.answer_id.should == 2
|
17
|
+
@validation.rule.should == "C"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module SurveyParser
|
2
|
+
class Survey < SurveyParser::Base
|
3
|
+
# Context, Content, Reference, Expiry, Display
|
4
|
+
attr_accessor :id, :parser
|
5
|
+
attr_accessor :title, :description
|
6
|
+
attr_accessor :access_code, :reference_identifier, :data_export_identifier, :common_namespace, :common_identitier
|
7
|
+
attr_accessor :active_at, :inactive_at
|
8
|
+
attr_accessor :css_url, :custom_class
|
9
|
+
attr_accessor :manual_numbering
|
10
|
+
has_children :survey_sections
|
11
|
+
|
12
|
+
def parse_args(args)
|
13
|
+
title = args[0]
|
14
|
+
{:title => title, :access_code => Surveyor.to_normalized_string(title)}.merge(args[1] || {})
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_question_by_reference(ref_id)
|
18
|
+
found = nil
|
19
|
+
survey_sections.detect{|s| found = s.find_question_by_reference(ref_id)}
|
20
|
+
return found
|
21
|
+
end
|
22
|
+
|
23
|
+
def reconcile_dependencies
|
24
|
+
survey_sections.each do |section|
|
25
|
+
section.questions.each do |question|
|
26
|
+
question.dependency.dependency_conditions.each { |con| con.reconcile_dependencies} unless question.dependency.nil?
|
27
|
+
end
|
28
|
+
section.question_groups.each do |group|
|
29
|
+
group.dependency.dependency_conditions.each { |con| con.reconcile_dependencies} unless group.dependency.nil?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SurveyParser
|
2
|
+
class SurveySection < SurveyParser::Base
|
3
|
+
# Context, Content, Display, Reference, Children, Placeholders
|
4
|
+
attr_accessor :id, :parser, :survey_id
|
5
|
+
attr_accessor :title, :description
|
6
|
+
attr_accessor :reference_identifier, :data_export_identifier, :common_namespace, :common_identitier
|
7
|
+
attr_accessor :display_order, :custom_class
|
8
|
+
has_children :question_groups, :questions
|
9
|
+
|
10
|
+
def parse_args(args)
|
11
|
+
title = args[0]
|
12
|
+
{:title => title, :data_export_identifier => Surveyor.to_normalized_string(title)}.merge(args[1] || {})
|
13
|
+
end
|
14
|
+
|
15
|
+
# Used to find questions for dependency linking
|
16
|
+
def find_question_by_reference(ref_id)
|
17
|
+
self.questions.detect{|q| q.reference_identifier == ref_id}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SurveyParser
|
2
|
+
class Validation < SurveyParser::Base
|
3
|
+
|
4
|
+
# Context, Conditional, Children
|
5
|
+
attr_accessor :id, :answer_id, :parser
|
6
|
+
attr_accessor :rule, :message
|
7
|
+
has_children :validation_conditions
|
8
|
+
|
9
|
+
|
10
|
+
def default_options
|
11
|
+
{:rule => "A"}
|
12
|
+
end
|
13
|
+
def parse_args(args)
|
14
|
+
args[0] || {}
|
15
|
+
end
|
16
|
+
def parse_opts(opts)
|
17
|
+
{} # toss the method name and reference identifier by default
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SurveyParser
|
2
|
+
class ValidationCondition < SurveyParser::Base
|
3
|
+
# Context, Conditional, Value, Reference
|
4
|
+
attr_accessor :id, :validation_id, :rule_key, :parser
|
5
|
+
attr_accessor :operator
|
6
|
+
attr_accessor :question_id, :answer_id, :datetime_value, :integer_value, :float_value, :unit, :text_value, :string_value, :response_other, :regexp
|
7
|
+
attr_accessor :question_reference, :answer_reference
|
8
|
+
|
9
|
+
def default_options
|
10
|
+
{ :operator => "==" }
|
11
|
+
end
|
12
|
+
def parse_args(args)
|
13
|
+
a0, a1 = args
|
14
|
+
{:operator => a0}.merge(a1 || {})
|
15
|
+
end
|
16
|
+
def parse_opts(opts)
|
17
|
+
{:rule_key => opts[:reference_identifier]}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>currentDocument</key>
|
6
|
+
<string>whrparse.rb</string>
|
7
|
+
<key>documents</key>
|
8
|
+
<array>
|
9
|
+
<dict>
|
10
|
+
<key>expanded</key>
|
11
|
+
<true/>
|
12
|
+
<key>name</key>
|
13
|
+
<string>whr_dsl</string>
|
14
|
+
<key>regexFolderFilter</key>
|
15
|
+
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
16
|
+
<key>sourceDirectory</key>
|
17
|
+
<string></string>
|
18
|
+
</dict>
|
19
|
+
</array>
|
20
|
+
<key>fileHierarchyDrawerWidth</key>
|
21
|
+
<integer>261</integer>
|
22
|
+
<key>metaData</key>
|
23
|
+
<dict>
|
24
|
+
<key>answer.rb</key>
|
25
|
+
<dict>
|
26
|
+
<key>caret</key>
|
27
|
+
<dict>
|
28
|
+
<key>column</key>
|
29
|
+
<integer>5</integer>
|
30
|
+
<key>line</key>
|
31
|
+
<integer>54</integer>
|
32
|
+
</dict>
|
33
|
+
<key>firstVisibleColumn</key>
|
34
|
+
<integer>0</integer>
|
35
|
+
<key>firstVisibleLine</key>
|
36
|
+
<integer>13</integer>
|
37
|
+
</dict>
|
38
|
+
<key>columnizer.rb</key>
|
39
|
+
<dict>
|
40
|
+
<key>caret</key>
|
41
|
+
<dict>
|
42
|
+
<key>column</key>
|
43
|
+
<integer>112</integer>
|
44
|
+
<key>line</key>
|
45
|
+
<integer>3</integer>
|
46
|
+
</dict>
|
47
|
+
<key>firstVisibleColumn</key>
|
48
|
+
<integer>0</integer>
|
49
|
+
<key>firstVisibleLine</key>
|
50
|
+
<integer>0</integer>
|
51
|
+
</dict>
|
52
|
+
<key>partials/_checkboxes.rhtml</key>
|
53
|
+
<dict>
|
54
|
+
<key>caret</key>
|
55
|
+
<dict>
|
56
|
+
<key>column</key>
|
57
|
+
<integer>0</integer>
|
58
|
+
<key>line</key>
|
59
|
+
<integer>0</integer>
|
60
|
+
</dict>
|
61
|
+
<key>firstVisibleColumn</key>
|
62
|
+
<integer>0</integer>
|
63
|
+
<key>firstVisibleLine</key>
|
64
|
+
<integer>0</integer>
|
65
|
+
</dict>
|
66
|
+
<key>partials/_date.rhtml</key>
|
67
|
+
<dict>
|
68
|
+
<key>caret</key>
|
69
|
+
<dict>
|
70
|
+
<key>column</key>
|
71
|
+
<integer>0</integer>
|
72
|
+
<key>line</key>
|
73
|
+
<integer>0</integer>
|
74
|
+
</dict>
|
75
|
+
<key>firstVisibleColumn</key>
|
76
|
+
<integer>0</integer>
|
77
|
+
<key>firstVisibleLine</key>
|
78
|
+
<integer>0</integer>
|
79
|
+
</dict>
|
80
|
+
<key>question.rb</key>
|
81
|
+
<dict>
|
82
|
+
<key>caret</key>
|
83
|
+
<dict>
|
84
|
+
<key>column</key>
|
85
|
+
<integer>68</integer>
|
86
|
+
<key>line</key>
|
87
|
+
<integer>68</integer>
|
88
|
+
</dict>
|
89
|
+
<key>firstVisibleColumn</key>
|
90
|
+
<integer>0</integer>
|
91
|
+
<key>firstVisibleLine</key>
|
92
|
+
<integer>46</integer>
|
93
|
+
</dict>
|
94
|
+
<key>registry_code.rb</key>
|
95
|
+
<dict>
|
96
|
+
<key>caret</key>
|
97
|
+
<dict>
|
98
|
+
<key>column</key>
|
99
|
+
<integer>49</integer>
|
100
|
+
<key>line</key>
|
101
|
+
<integer>19</integer>
|
102
|
+
</dict>
|
103
|
+
<key>firstVisibleColumn</key>
|
104
|
+
<integer>0</integer>
|
105
|
+
<key>firstVisibleLine</key>
|
106
|
+
<integer>0</integer>
|
107
|
+
</dict>
|
108
|
+
<key>section.rb</key>
|
109
|
+
<dict>
|
110
|
+
<key>caret</key>
|
111
|
+
<dict>
|
112
|
+
<key>column</key>
|
113
|
+
<integer>9</integer>
|
114
|
+
<key>line</key>
|
115
|
+
<integer>98</integer>
|
116
|
+
</dict>
|
117
|
+
<key>firstVisibleColumn</key>
|
118
|
+
<integer>0</integer>
|
119
|
+
<key>firstVisibleLine</key>
|
120
|
+
<integer>59</integer>
|
121
|
+
</dict>
|
122
|
+
<key>section_template.rhtml</key>
|
123
|
+
<dict>
|
124
|
+
<key>caret</key>
|
125
|
+
<dict>
|
126
|
+
<key>column</key>
|
127
|
+
<integer>134</integer>
|
128
|
+
<key>line</key>
|
129
|
+
<integer>3</integer>
|
130
|
+
</dict>
|
131
|
+
<key>firstVisibleColumn</key>
|
132
|
+
<integer>0</integer>
|
133
|
+
<key>firstVisibleLine</key>
|
134
|
+
<integer>0</integer>
|
135
|
+
</dict>
|
136
|
+
<key>specs/answer_spec.rb</key>
|
137
|
+
<dict>
|
138
|
+
<key>caret</key>
|
139
|
+
<dict>
|
140
|
+
<key>column</key>
|
141
|
+
<integer>50</integer>
|
142
|
+
<key>line</key>
|
143
|
+
<integer>24</integer>
|
144
|
+
</dict>
|
145
|
+
<key>columnSelection</key>
|
146
|
+
<false/>
|
147
|
+
<key>firstVisibleColumn</key>
|
148
|
+
<integer>0</integer>
|
149
|
+
<key>firstVisibleLine</key>
|
150
|
+
<integer>3</integer>
|
151
|
+
<key>selectFrom</key>
|
152
|
+
<dict>
|
153
|
+
<key>column</key>
|
154
|
+
<integer>60</integer>
|
155
|
+
<key>line</key>
|
156
|
+
<integer>24</integer>
|
157
|
+
</dict>
|
158
|
+
<key>selectTo</key>
|
159
|
+
<dict>
|
160
|
+
<key>column</key>
|
161
|
+
<integer>50</integer>
|
162
|
+
<key>line</key>
|
163
|
+
<integer>24</integer>
|
164
|
+
</dict>
|
165
|
+
</dict>
|
166
|
+
<key>specs/question_spec.rb</key>
|
167
|
+
<dict>
|
168
|
+
<key>caret</key>
|
169
|
+
<dict>
|
170
|
+
<key>column</key>
|
171
|
+
<integer>21</integer>
|
172
|
+
<key>line</key>
|
173
|
+
<integer>5</integer>
|
174
|
+
</dict>
|
175
|
+
<key>firstVisibleColumn</key>
|
176
|
+
<integer>0</integer>
|
177
|
+
<key>firstVisibleLine</key>
|
178
|
+
<integer>0</integer>
|
179
|
+
</dict>
|
180
|
+
<key>specs/section_spec.rb</key>
|
181
|
+
<dict>
|
182
|
+
<key>caret</key>
|
183
|
+
<dict>
|
184
|
+
<key>column</key>
|
185
|
+
<integer>43</integer>
|
186
|
+
<key>line</key>
|
187
|
+
<integer>43</integer>
|
188
|
+
</dict>
|
189
|
+
<key>firstVisibleColumn</key>
|
190
|
+
<integer>0</integer>
|
191
|
+
<key>firstVisibleLine</key>
|
192
|
+
<integer>0</integer>
|
193
|
+
</dict>
|
194
|
+
<key>specs/whrparse_spec.rb</key>
|
195
|
+
<dict>
|
196
|
+
<key>caret</key>
|
197
|
+
<dict>
|
198
|
+
<key>column</key>
|
199
|
+
<integer>5</integer>
|
200
|
+
<key>line</key>
|
201
|
+
<integer>6</integer>
|
202
|
+
</dict>
|
203
|
+
<key>firstVisibleColumn</key>
|
204
|
+
<integer>0</integer>
|
205
|
+
<key>firstVisibleLine</key>
|
206
|
+
<integer>0</integer>
|
207
|
+
</dict>
|
208
|
+
<key>whrparse.rb</key>
|
209
|
+
<dict>
|
210
|
+
<key>caret</key>
|
211
|
+
<dict>
|
212
|
+
<key>column</key>
|
213
|
+
<integer>9</integer>
|
214
|
+
<key>line</key>
|
215
|
+
<integer>20</integer>
|
216
|
+
</dict>
|
217
|
+
<key>firstVisibleColumn</key>
|
218
|
+
<integer>0</integer>
|
219
|
+
<key>firstVisibleLine</key>
|
220
|
+
<integer>0</integer>
|
221
|
+
</dict>
|
222
|
+
</dict>
|
223
|
+
<key>openDocuments</key>
|
224
|
+
<array>
|
225
|
+
<string>registry_code.rb</string>
|
226
|
+
<string>whrparse.rb</string>
|
227
|
+
<string>specs/answer_spec.rb</string>
|
228
|
+
<string>specs/question_spec.rb</string>
|
229
|
+
<string>specs/section_spec.rb</string>
|
230
|
+
<string>section.rb</string>
|
231
|
+
<string>section_template.rhtml</string>
|
232
|
+
<string>partials/_date.rhtml</string>
|
233
|
+
<string>partials/_checkboxes.rhtml</string>
|
234
|
+
<string>columnizer.rb</string>
|
235
|
+
<string>specs/whrparse_spec.rb</string>
|
236
|
+
<string>question.rb</string>
|
237
|
+
<string>answer.rb</string>
|
238
|
+
</array>
|
239
|
+
<key>showFileHierarchyDrawer</key>
|
240
|
+
<true/>
|
241
|
+
<key>windowFrame</key>
|
242
|
+
<string>{{282, 61}, {1119, 816}}</string>
|
243
|
+
</dict>
|
244
|
+
</plist>
|