Skip to content

Fix display conditions validations with choices#6837

Merged
tramuntanal merged 4 commits intodevelopfrom
fix/survey-logic-cases
Nov 10, 2020
Merged

Fix display conditions validations with choices#6837
tramuntanal merged 4 commits intodevelopfrom
fix/survey-logic-cases

Conversation

@microstudi
Copy link
Copy Markdown
Contributor

🎩 What? Why?

Solves a couple of bugs:

  1. when admins create a questionnaire using the logic conditions "match text" and this match involves questions with options (such as matrix questions, single option or multiple options).
    The current code tries to use the body of the answer and this is not available if it is a choice, resulting in a 500 error.

  2. Currently, the display_condition method fulffilled? is used for form validations, and it is checking against responses in the database completely unrelated with the current user. As the answer is being validated is not in the database yet so it should check the rectify form. As the form is not created via a model, new context must be added (the other responses) so an answer validation can get information about the related questions involving display conditions.

  3. Matrix questions do not work properly with display conditions. The new approach treats matrixs columns (answer choices) as the source of whats being checked by the user: if the column has a title and the user selects that column in some row, then is a match. This is more predictable.

This needs to be backported to 0.23.

📌 Related Issues

Testing

Describe the best way to test or validate your PR.

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

Please add screenshots of the changes you're proposing
Description

♥️ Thank you!

@microstudi microstudi self-assigned this Nov 10, 2020
@microstudi microstudi changed the title fix display conditions validations cases fix display conditions validations with choices Nov 10, 2020
@microstudi microstudi marked this pull request as ready for review November 10, 2020 12:15
@tramuntanal tramuntanal changed the title fix display conditions validations with choices Fix display conditions validations with choices Nov 10, 2020
@tramuntanal tramuntanal self-assigned this Nov 10, 2020
Copy link
Copy Markdown
Contributor

@tramuntanal tramuntanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @microstudi

@tramuntanal tramuntanal merged commit 0352da1 into develop Nov 10, 2020
@tramuntanal tramuntanal deleted the fix/survey-logic-cases branch November 10, 2020 16:37
edgarlatorre pushed a commit that referenced this pull request Nov 11, 2020
* fix display conditions validations cases

* fix javascript finding ids for questions. fix answer form test

* fix lint

* make array order unimportant
@mrcasals mrcasals added module: forms type: fix PRs that implement a fix for a bug and removed type: bug labels Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in-review module: forms type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants