ylecuyer/survey-gizmo-ruby

Unrecognized integer pattern in question_pipe field

ZainW opened this issue · 8 comments

ZainW commented

Users/zain/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/survey-gizmo-ruby-6.2.9/lib/survey_gizmo/api/answer.rb:32:ininitialize': Can't recognize pattern for [question(176), question_pipe(10522)] => This product was too expensive - you may have to parse your answers manually. (RuntimeError)`

This is the error I am getting when trying to run parsed_answers over my response.

my section of the answers hash look like this:

"[question(176), question_pipe(10522)]" => "This product was too expensive", "[question(176), question_pipe(10523)]" => "This product was too expensive", "[question(176), question_pipe(10524)]" => "This product was too expensive", "[question(176), question_pipe(10526)]" => "This product was too expensive", "[question(176), question_pipe(10527)]" => "This product was too expensive", "[question(176), question_pipe(10528)]" => "This product was too expensive", "[question(176), question_pipe(10529)]" => "This product was too expensive", "[question(176), question_pipe(10530)]" => "This product was too expensive"

Any help would be greatly appreciated. I am not too familiar with pattern matching in these kinds of scenarios.

This happens when an answer is piped to be part of the question text

also is there a way to only get parsed answers from a specific page of the survey? as in if a set of questions is on one page that i only parse and import that page?

Any idea @apurvis ?

at our organization we generally avoid the question piping, because we've never really figured out how to parse it. I think you will have to update the responses parsing code to support your case (which would be helpful for others down the road, maybe) and/or use the Response#answers hash directly and not use the parsed_answers method.

also is there a way to only get parsed answers from a specific page of the survey? as in if a set of questions is on one page that i only parse and import that page?

the SurveyResponse REST path only supports the :survey_id parameter, so i think you are out of luck as far as only retrieving results for a given page, though you might be able to parse the raw answer blob yourself and strip out responses for a single page.

question_pipe parsing should theoretically be working... i think i see the bug though - it's expecting a " character that's not there anymore, e.g. it expects '[question(176), question_pipe("10530")]' => "This product was too expensive"

should be easy to fix just by adding * after the " (to indicate 0-many "s); feel free to create a PR but make sure you add a spec.

Ok interesting, about the regexp it should be "? then, for 0 or 1 occurence.

yeah that would be more accurate