feat: use template config for dynamic multiple choice#1582
Open
GrantDLS wants to merge 2 commits into
Open
Conversation
| }} | ||
| questionTemplateRelation={selectedQuestion} | ||
| callId={callId} | ||
| templateId={templateId} |
Collaborator
There was a problem hiding this comment.
I think this change has the same problem as the previous PR, are we sure we can't use the selectedQuestion object to pass the templateId in it? If you check out the SDK definition of the object it already contains three references to templateId.
I could be missing something if you think that isn't the right approach
Contributor
Author
There was a problem hiding this comment.
Yeah you're right - it would be good if it was part of that question template relation but I couldn't quite figure it out. Hopefully when someone has time to review the PR they might have an idea on how to achieve this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently, when a dynamic multiple choice question is added to a proposal, the template level config options are being ignored, i.e. only the configuration values set on the question are used.
This is because, the component uses a hook
useGetDynamicMultipleChoiceOptions, which takes a question ID.This PR solves this by obtaining the template ID, and if it is present, passes it to the GraphQL query
getDynamicMultipleChoiceOptions. Within this function,getQuestionTemplateRelationis then called with the question ID and template ID. If the template ID isn't present, it falls back to usinggetQuestionwith just the question ID parameter.It's worth noting that I tried to solve this by passing the config that's available to the react component through to the backend, but since the http headers are stripped for security purposes, this wasn't a viable solution.
How Has This Been Tested
I've added a test to
TemplateQueries.spec.tsthat ensures it calls thegetQuestionTemplateRelationmethod if the template ID is provided. I've also manually tested it.Changes
The changes flow from the front end (getting the template ID from the context within the react component), through to the hook, and then the GraphQL query.