New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JotForm API client, translation, and question helper classes. #22474
Conversation
@@ -0,0 +1,61 @@ | |||
module Pd | |||
module JotForm | |||
class MatrixQuestion < QuestionWithOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example of a matrix question in a comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
# Hash includes other, in form {'0' => value1, '1' => value2, ..., 'other' => otherText}. | ||
# Note "other" can be chosen and blank, in which case we use the other text from the question. | ||
values_with_other = answer.map {|k, v| k == 'other' ? v.presence || other_text : v} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 'other' provided by jotform? Suggest making it a const up top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is provided by JotForm, and it seems to be hardcoded, independent of the otherText
which is the placeholder we can set. I'll add a const
options: %w(From To), | ||
values: [1, 2, 3] | ||
), | ||
MatrixQuestion.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this to look like the actual matrix questions - with the text
"I feel..."
and name "like this course is good", "like I learned a lot"...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…none, referenced as parent in the sub questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks well organized and thought out. :)
This PR contains a self-contained set of classes in
dashboard/lib
to interact with JotForm's API, parse questions and submissions, serialize to/from a question format we can store in the DB (as JSON) and use to process answers.The JotForm answer data alone is insufficient until it's combined with the question data.
There is a bit of complexity with, and differences between, the various types of questions we want to support and how JotForm describes them, so I have created a
Question
class hierarchy that should make that easier to reason about and test. There are a number of extraneous fields in the JotForm question data that we don't need (formatting, redundant with other fields, etc) that are ignored and not mentioned in this PR. This also should help simplify things.This will be used for workshop daily surveys and their facilitator-specific questions in a set of forthcoming additional PRs, and it's also flexible enough to be used in future JotForm-based forms with minimal additional code.