decidim-forms 0.30.3 → 0.31.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -10
  3. data/app/cells/decidim/forms/matrix_readonly/show.erb +1 -1
  4. data/app/cells/decidim/forms/matrix_readonly_cell.rb +3 -3
  5. data/app/cells/decidim/forms/question_readonly/show.erb +5 -5
  6. data/app/cells/decidim/forms/question_readonly/title_and_description.erb +3 -3
  7. data/app/cells/decidim/forms/response_readonly_cell.rb +9 -0
  8. data/app/cells/decidim/forms/step_navigation/show.erb +3 -3
  9. data/app/cells/decidim/forms/step_navigation_cell.rb +3 -3
  10. data/app/commands/decidim/forms/admin/update_questions.rb +6 -6
  11. data/app/commands/decidim/forms/{answer_questionnaire.rb → response_questionnaire.rb} +35 -35
  12. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +12 -12
  13. data/app/controllers/decidim/forms/admin/concerns/{has_questionnaire_answers.rb → has_questionnaire_responses.rb} +23 -19
  14. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +38 -33
  15. data/app/forms/decidim/forms/admin/display_condition_form.rb +14 -14
  16. data/app/forms/decidim/forms/admin/question_form.rb +3 -3
  17. data/app/forms/decidim/forms/admin/{answer_option_form.rb → response_option_form.rb} +3 -3
  18. data/app/forms/decidim/forms/questionnaire_form.rb +8 -9
  19. data/app/forms/decidim/forms/{answer_choice_form.rb → response_choice_form.rb} +5 -5
  20. data/app/forms/decidim/forms/{answer_form.rb → response_form.rb} +9 -9
  21. data/app/helpers/decidim/forms/admin/application_helper.rb +2 -2
  22. data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_pagination_helper.rb → has_questionnaire_responses_pagination_helper.rb} +4 -4
  23. data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_url_helper.rb → has_questionnaire_responses_url_helper.rb} +5 -5
  24. data/app/helpers/decidim/forms/admin/questionnaire_responses_helper.rb +32 -0
  25. data/app/helpers/decidim/forms/application_helper.rb +1 -2
  26. data/app/jobs/decidim/forms/{export_questionnaire_answers_job.rb → export_questionnaire_responses_job.rb} +5 -5
  27. data/app/models/decidim/forms/display_condition.rb +20 -20
  28. data/app/models/decidim/forms/question.rb +14 -13
  29. data/app/models/decidim/forms/question_matrix_row.rb +1 -1
  30. data/app/models/decidim/forms/questionnaire.rb +11 -6
  31. data/app/models/decidim/forms/{answer.rb → response.rb} +9 -9
  32. data/app/models/decidim/forms/response_choice.rb +22 -0
  33. data/app/models/decidim/forms/{answer_option.rb → response_option.rb} +5 -5
  34. data/app/packs/entrypoints/decidim_forms_admin.js +3 -3
  35. data/app/packs/src/decidim/forms/admin/collapsible_questions.js +12 -10
  36. data/app/packs/src/decidim/forms/admin/forms.js +35 -35
  37. data/app/packs/src/decidim/forms/admin/{publish_answers_buttons.js → publish_responses_buttons.js} +12 -12
  38. data/app/packs/src/decidim/forms/display_conditions.component.js +12 -12
  39. data/app/packs/src/decidim/forms/forms.js +8 -29
  40. data/app/packs/stylesheets/decidim/forms/forms.scss +2 -2
  41. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +13 -13
  42. data/app/presenters/decidim/forms/admin/{questionnaire_answer_presenter.rb → questionnaire_response_presenter.rb} +15 -15
  43. data/app/presenters/decidim/forms/admin_log/question_presenter.rb +3 -3
  44. data/app/presenters/decidim/forms/{answer_option_presenter.rb → response_option_presenter.rb} +2 -2
  45. data/app/queries/decidim/forms/questionnaire_participant.rb +5 -5
  46. data/app/queries/decidim/forms/questionnaire_participants.rb +6 -6
  47. data/app/queries/decidim/forms/questionnaire_user_responses.rb +32 -0
  48. data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +9 -9
  49. data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +2 -2
  50. data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +3 -3
  51. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +21 -11
  52. data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +13 -41
  53. data/app/views/decidim/forms/admin/questionnaires/{_answer_option.html.erb → _response_option.html.erb} +7 -7
  54. data/app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb +7 -0
  55. data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +11 -1
  56. data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +12 -2
  57. data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +1 -1
  58. data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +8 -8
  59. data/app/views/decidim/forms/admin/questionnaires/responses/index.html.erb +80 -0
  60. data/app/views/decidim/forms/admin/questionnaires/responses/show.html.erb +43 -0
  61. data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +22 -26
  62. data/app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb +8 -3
  63. data/app/views/decidim/forms/questionnaires/_response.html.erb +61 -0
  64. data/app/views/decidim/forms/questionnaires/edit.html.erb +2 -2
  65. data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -0
  66. data/app/views/decidim/forms/questionnaires/responses/_long_response.html.erb +3 -0
  67. data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_multiple.html.erb +16 -15
  68. data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_single.html.erb +17 -16
  69. data/app/views/decidim/forms/questionnaires/responses/_multiple_option.html.erb +26 -0
  70. data/app/views/decidim/forms/questionnaires/responses/_separator.html.erb +1 -0
  71. data/app/views/decidim/forms/questionnaires/responses/_short_response.html.erb +3 -0
  72. data/app/views/decidim/forms/questionnaires/responses/_single_option.html.erb +33 -0
  73. data/app/views/decidim/forms/questionnaires/responses/_sorting.html.erb +26 -0
  74. data/app/views/decidim/forms/questionnaires/responses/_title_and_description.html.erb +1 -0
  75. data/app/views/decidim/forms/questionnaires/show.html.erb +10 -10
  76. data/config/assets.rb +2 -2
  77. data/config/locales/ar.yml +2 -22
  78. data/config/locales/bg.yml +10 -36
  79. data/config/locales/ca-IT.yml +80 -74
  80. data/config/locales/ca.yml +80 -74
  81. data/config/locales/cs.yml +79 -76
  82. data/config/locales/de.yml +79 -72
  83. data/config/locales/el.yml +10 -36
  84. data/config/locales/en.yml +90 -84
  85. data/config/locales/es-MX.yml +82 -76
  86. data/config/locales/es-PY.yml +82 -76
  87. data/config/locales/es.yml +80 -74
  88. data/config/locales/eu.yml +78 -72
  89. data/config/locales/fi-plain.yml +78 -72
  90. data/config/locales/fi.yml +76 -70
  91. data/config/locales/fr-CA.yml +77 -68
  92. data/config/locales/fr.yml +77 -68
  93. data/config/locales/ga-IE.yml +4 -7
  94. data/config/locales/gl.yml +4 -22
  95. data/config/locales/hu.yml +4 -22
  96. data/config/locales/id-ID.yml +2 -22
  97. data/config/locales/it.yml +8 -40
  98. data/config/locales/ja.yml +87 -81
  99. data/config/locales/lb.yml +8 -36
  100. data/config/locales/lt.yml +10 -36
  101. data/config/locales/lv.yml +4 -22
  102. data/config/locales/nl.yml +10 -36
  103. data/config/locales/no.yml +10 -36
  104. data/config/locales/pl.yml +10 -36
  105. data/config/locales/pt-BR.yml +10 -36
  106. data/config/locales/pt.yml +8 -36
  107. data/config/locales/ro-RO.yml +29 -51
  108. data/config/locales/ru.yml +2 -9
  109. data/config/locales/sk.yml +2 -22
  110. data/config/locales/sl.yml +0 -5
  111. data/config/locales/sv.yml +89 -55
  112. data/config/locales/tr-TR.yml +8 -36
  113. data/config/locales/val-ES.yml +2 -0
  114. data/config/locales/zh-CN.yml +8 -36
  115. data/config/locales/zh-TW.yml +10 -36
  116. data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
  117. data/db/migrate/20250314150250_rename_answer_to_response_in_decidim_forms.rb +30 -0
  118. data/db/migrate/20250319130003_change_question_types_in_questions.rb +14 -0
  119. data/lib/decidim/api/question_matrix_row_type.rb +13 -0
  120. data/lib/decidim/api/question_type.rb +4 -3
  121. data/lib/decidim/api/questionnaire_type.rb +1 -0
  122. data/lib/decidim/api/response_option_type.rb +13 -0
  123. data/lib/decidim/exporters/form_pdf.rb +33 -33
  124. data/lib/decidim/forms/api.rb +2 -1
  125. data/lib/decidim/forms/{download_your_data_user_answers_serializer.rb → download_your_data_user_responses_serializer.rb} +3 -3
  126. data/lib/decidim/forms/engine.rb +2 -2
  127. data/lib/decidim/forms/test/factories.rb +24 -24
  128. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +176 -176
  129. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_responses.rb +159 -0
  130. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -19
  131. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +44 -44
  132. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +10 -10
  133. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +43 -140
  134. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -4
  135. data/lib/decidim/forms/test.rb +1 -1
  136. data/lib/decidim/forms/user_responses_serializer.rb +110 -0
  137. data/lib/decidim/forms/version.rb +1 -1
  138. data/lib/decidim/forms.rb +2 -2
  139. metadata +48 -45
  140. data/app/cells/decidim/forms/answer_readonly_cell.rb +0 -9
  141. data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +0 -30
  142. data/app/models/decidim/forms/answer_choice.rb +0 -22
  143. data/app/queries/decidim/forms/questionnaire_user_answers.rb +0 -32
  144. data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +0 -7
  145. data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +0 -49
  146. data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +0 -43
  147. data/app/views/decidim/forms/questionnaires/_answer.html.erb +0 -61
  148. data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +0 -1
  149. data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +0 -3
  150. data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +0 -25
  151. data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +0 -1
  152. data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +0 -3
  153. data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +0 -32
  154. data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +0 -26
  155. data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +0 -1
  156. data/lib/decidim/api/answer_option_type.rb +0 -13
  157. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +0 -149
  158. data/lib/decidim/forms/user_answers_serializer.rb +0 -105
  159. /data/app/cells/decidim/forms/{answer_readonly → response_readonly}/show.erb +0 -0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.3
4
+ version: 0.31.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2025-10-28 00:00:00.000000000 Z
14
+ date: 2025-09-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: decidim-core
@@ -19,42 +19,42 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.30.3
22
+ version: 0.31.0.rc1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.30.3
29
+ version: 0.31.0.rc1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: decidim-admin
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 0.30.3
36
+ version: 0.31.0.rc1
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 0.30.3
43
+ version: 0.31.0.rc1
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: decidim-dev
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - '='
49
49
  - !ruby/object:Gem::Version
50
- version: 0.30.3
50
+ version: 0.31.0.rc1
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - '='
56
56
  - !ruby/object:Gem::Version
57
- version: 0.30.3
57
+ version: 0.31.0.rc1
58
58
  description: A forms gem for decidim.
59
59
  email:
60
60
  - josepjaume@gmail.com
@@ -67,45 +67,45 @@ extra_rdoc_files: []
67
67
  files:
68
68
  - README.md
69
69
  - Rakefile
70
- - app/cells/decidim/forms/answer_readonly/show.erb
71
- - app/cells/decidim/forms/answer_readonly_cell.rb
72
70
  - app/cells/decidim/forms/matrix_readonly/show.erb
73
71
  - app/cells/decidim/forms/matrix_readonly_cell.rb
74
72
  - app/cells/decidim/forms/question_readonly/show.erb
75
73
  - app/cells/decidim/forms/question_readonly/title_and_description.erb
76
74
  - app/cells/decidim/forms/question_readonly_cell.rb
75
+ - app/cells/decidim/forms/response_readonly/show.erb
76
+ - app/cells/decidim/forms/response_readonly_cell.rb
77
77
  - app/cells/decidim/forms/step_navigation/show.erb
78
78
  - app/cells/decidim/forms/step_navigation_cell.rb
79
79
  - app/commands/decidim/forms/admin/update_questionnaire.rb
80
80
  - app/commands/decidim/forms/admin/update_questions.rb
81
- - app/commands/decidim/forms/answer_questionnaire.rb
81
+ - app/commands/decidim/forms/response_questionnaire.rb
82
82
  - app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb
83
- - app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb
83
+ - app/controllers/decidim/forms/admin/concerns/has_questionnaire_responses.rb
84
84
  - app/controllers/decidim/forms/concerns/has_questionnaire.rb
85
- - app/forms/decidim/forms/admin/answer_option_form.rb
86
85
  - app/forms/decidim/forms/admin/display_condition_form.rb
87
86
  - app/forms/decidim/forms/admin/question_form.rb
88
87
  - app/forms/decidim/forms/admin/question_matrix_row_form.rb
89
88
  - app/forms/decidim/forms/admin/questionnaire_form.rb
90
89
  - app/forms/decidim/forms/admin/questions_form.rb
91
- - app/forms/decidim/forms/answer_choice_form.rb
92
- - app/forms/decidim/forms/answer_form.rb
90
+ - app/forms/decidim/forms/admin/response_option_form.rb
93
91
  - app/forms/decidim/forms/questionnaire_form.rb
92
+ - app/forms/decidim/forms/response_choice_form.rb
93
+ - app/forms/decidim/forms/response_form.rb
94
94
  - app/helpers/decidim/forms/admin/application_helper.rb
95
- - app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb
96
- - app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb
97
- - app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb
95
+ - app/helpers/decidim/forms/admin/concerns/has_questionnaire_responses_pagination_helper.rb
96
+ - app/helpers/decidim/forms/admin/concerns/has_questionnaire_responses_url_helper.rb
97
+ - app/helpers/decidim/forms/admin/questionnaire_responses_helper.rb
98
98
  - app/helpers/decidim/forms/application_helper.rb
99
- - app/jobs/decidim/forms/export_questionnaire_answers_job.rb
99
+ - app/jobs/decidim/forms/export_questionnaire_responses_job.rb
100
100
  - app/models/concerns/decidim/forms/has_questionnaire.rb
101
- - app/models/decidim/forms/answer.rb
102
- - app/models/decidim/forms/answer_choice.rb
103
- - app/models/decidim/forms/answer_option.rb
104
101
  - app/models/decidim/forms/application_record.rb
105
102
  - app/models/decidim/forms/display_condition.rb
106
103
  - app/models/decidim/forms/question.rb
107
104
  - app/models/decidim/forms/question_matrix_row.rb
108
105
  - app/models/decidim/forms/questionnaire.rb
106
+ - app/models/decidim/forms/response.rb
107
+ - app/models/decidim/forms/response_choice.rb
108
+ - app/models/decidim/forms/response_option.rb
109
109
  - app/packs/entrypoints/decidim_forms.js
110
110
  - app/packs/entrypoints/decidim_forms_admin.js
111
111
  - app/packs/images/decidim/surveys/decidim_surveys.svg
@@ -115,23 +115,21 @@ files:
115
115
  - app/packs/src/decidim/forms/admin/collapsible_questions.js
116
116
  - app/packs/src/decidim/forms/admin/forms.js
117
117
  - app/packs/src/decidim/forms/admin/live_text_update.component.js
118
- - app/packs/src/decidim/forms/admin/publish_answers_buttons.js
118
+ - app/packs/src/decidim/forms/admin/publish_responses_buttons.js
119
119
  - app/packs/src/decidim/forms/display_conditions.component.js
120
120
  - app/packs/src/decidim/forms/forms.js
121
121
  - app/packs/src/decidim/forms/max_choices_alert.component.js
122
122
  - app/packs/src/decidim/forms/option_attached_inputs.component.js
123
123
  - app/packs/stylesheets/decidim/forms/forms.scss
124
- - app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb
125
124
  - app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb
125
+ - app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb
126
126
  - app/presenters/decidim/forms/admin_log/question_presenter.rb
127
127
  - app/presenters/decidim/forms/admin_log/questionnaire_presenter.rb
128
- - app/presenters/decidim/forms/answer_option_presenter.rb
129
128
  - app/presenters/decidim/forms/question_presenter.rb
129
+ - app/presenters/decidim/forms/response_option_presenter.rb
130
130
  - app/queries/decidim/forms/questionnaire_participant.rb
131
131
  - app/queries/decidim/forms/questionnaire_participants.rb
132
- - app/queries/decidim/forms/questionnaire_user_answers.rb
133
- - app/views/decidim/forms/admin/questionnaires/_answer_option.html.erb
134
- - app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb
132
+ - app/queries/decidim/forms/questionnaire_user_responses.rb
135
133
  - app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb
136
134
  - app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb
137
135
  - app/views/decidim/forms/admin/questionnaires/_form.html.erb
@@ -139,26 +137,28 @@ files:
139
137
  - app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb
140
138
  - app/views/decidim/forms/admin/questionnaires/_question.html.erb
141
139
  - app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb
140
+ - app/views/decidim/forms/admin/questionnaires/_response_option.html.erb
141
+ - app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb
142
142
  - app/views/decidim/forms/admin/questionnaires/_separator.html.erb
143
143
  - app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb
144
- - app/views/decidim/forms/admin/questionnaires/answers/index.html.erb
145
- - app/views/decidim/forms/admin/questionnaires/answers/show.html.erb
146
144
  - app/views/decidim/forms/admin/questionnaires/edit.html.erb
147
145
  - app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb
148
- - app/views/decidim/forms/questionnaires/_answer.html.erb
146
+ - app/views/decidim/forms/admin/questionnaires/responses/index.html.erb
147
+ - app/views/decidim/forms/admin/questionnaires/responses/show.html.erb
149
148
  - app/views/decidim/forms/questionnaires/_questionnaire.html.erb
150
149
  - app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb
151
- - app/views/decidim/forms/questionnaires/answers/_files.html.erb
152
- - app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb
153
- - app/views/decidim/forms/questionnaires/answers/_matrix_multiple.html.erb
154
- - app/views/decidim/forms/questionnaires/answers/_matrix_single.html.erb
155
- - app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb
156
- - app/views/decidim/forms/questionnaires/answers/_separator.html.erb
157
- - app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb
158
- - app/views/decidim/forms/questionnaires/answers/_single_option.html.erb
159
- - app/views/decidim/forms/questionnaires/answers/_sorting.html.erb
160
- - app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb
150
+ - app/views/decidim/forms/questionnaires/_response.html.erb
161
151
  - app/views/decidim/forms/questionnaires/edit.html.erb
152
+ - app/views/decidim/forms/questionnaires/responses/_files.html.erb
153
+ - app/views/decidim/forms/questionnaires/responses/_long_response.html.erb
154
+ - app/views/decidim/forms/questionnaires/responses/_matrix_multiple.html.erb
155
+ - app/views/decidim/forms/questionnaires/responses/_matrix_single.html.erb
156
+ - app/views/decidim/forms/questionnaires/responses/_multiple_option.html.erb
157
+ - app/views/decidim/forms/questionnaires/responses/_separator.html.erb
158
+ - app/views/decidim/forms/questionnaires/responses/_short_response.html.erb
159
+ - app/views/decidim/forms/questionnaires/responses/_single_option.html.erb
160
+ - app/views/decidim/forms/questionnaires/responses/_sorting.html.erb
161
+ - app/views/decidim/forms/questionnaires/responses/_title_and_description.html.erb
162
162
  - app/views/decidim/forms/questionnaires/show.html.erb
163
163
  - config/assets.rb
164
164
  - config/locales/am-ET.yml
@@ -262,28 +262,31 @@ files:
262
262
  - db/migrate/20240416111953_add_display_conditions_counter_cache_to_questions.rb
263
263
  - db/migrate/20240416113926_add_display_conditions_for_other_questions_counter_cache_to_questions.rb
264
264
  - db/migrate/20241122142230_add_survey_answers_published_at_to_questions.rb
265
+ - db/migrate/20250314150250_rename_answer_to_response_in_decidim_forms.rb
266
+ - db/migrate/20250319130003_change_question_types_in_questions.rb
265
267
  - decidim-forms.gemspec
266
- - lib/decidim/api/answer_option_type.rb
268
+ - lib/decidim/api/question_matrix_row_type.rb
267
269
  - lib/decidim/api/question_type.rb
268
270
  - lib/decidim/api/questionnaire_entity_interface.rb
269
271
  - lib/decidim/api/questionnaire_type.rb
272
+ - lib/decidim/api/response_option_type.rb
270
273
  - lib/decidim/exporters/form_pdf.rb
271
274
  - lib/decidim/forms.rb
272
275
  - lib/decidim/forms/admin.rb
273
276
  - lib/decidim/forms/admin_engine.rb
274
277
  - lib/decidim/forms/api.rb
275
- - lib/decidim/forms/download_your_data_user_answers_serializer.rb
278
+ - lib/decidim/forms/download_your_data_user_responses_serializer.rb
276
279
  - lib/decidim/forms/engine.rb
277
280
  - lib/decidim/forms/test.rb
278
281
  - lib/decidim/forms/test/factories.rb
279
282
  - lib/decidim/forms/test/shared_examples/has_questionnaire.rb
280
- - lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb
283
+ - lib/decidim/forms/test/shared_examples/manage_questionnaire_responses.rb
281
284
  - lib/decidim/forms/test/shared_examples/manage_questionnaires.rb
282
285
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb
283
286
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb
284
287
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb
285
288
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb
286
- - lib/decidim/forms/user_answers_serializer.rb
289
+ - lib/decidim/forms/user_responses_serializer.rb
287
290
  - lib/decidim/forms/version.rb
288
291
  homepage: https://decidim.org
289
292
  licenses:
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Forms
5
- # This cell renders a possible answer of a question (readonly)
6
- class AnswerReadonlyCell < Decidim::ViewModel
7
- end
8
- end
9
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Forms
5
- module Admin
6
- # Custom helpers for questionnaire answers
7
- #
8
- module QuestionnaireAnswersHelper
9
- def first_table_th(answer)
10
- if answer.first_short_answer
11
- @first_short_answer = answer.first_short_answer
12
- return translated_attribute @first_short_answer.question.body
13
- end
14
-
15
- t("session_token", scope: "decidim.forms.user_answers_serializer")
16
- end
17
-
18
- def first_table_td(answer)
19
- return answer.first_short_answer&.body if @first_short_answer
20
-
21
- answer.session_token
22
- end
23
-
24
- def display_percentage(number)
25
- number_to_percentage(number, precision: 0, strip_insignificant_zeros: true, locale: I18n.locale)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Forms
5
- class AnswerChoice < Forms::ApplicationRecord
6
- belongs_to :answer,
7
- class_name: "Answer",
8
- foreign_key: "decidim_answer_id"
9
-
10
- belongs_to :answer_option,
11
- class_name: "AnswerOption",
12
- foreign_key: "decidim_answer_option_id"
13
-
14
- belongs_to :matrix_row,
15
- class_name: "QuestionMatrixRow",
16
- foreign_key: "decidim_question_matrix_row_id",
17
- optional: true
18
-
19
- validates :matrix_row, presence: true, if: -> { answer.question.matrix? }
20
- end
21
- end
22
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Forms
5
- # A class used to collect user answers for a questionnaire
6
- class QuestionnaireUserAnswers < Decidim::Query
7
- # Syntactic sugar to initialize the class and return the queried objects.
8
- #
9
- # questionnaire - a Questionnaire object
10
- def self.for(questionnaire)
11
- new(questionnaire).query
12
- end
13
-
14
- # Initializes the class.
15
- #
16
- # questionnaire = a Questionnaire object
17
- def initialize(questionnaire)
18
- @questionnaire = questionnaire
19
- end
20
-
21
- # Finds and group answers by user for each questionnaire's question.
22
- def query
23
- answers = Answer.not_separator
24
- .not_title_and_description
25
- .joins(:question)
26
- .where(questionnaire: @questionnaire)
27
-
28
- answers.sort_by { |answer| answer.question.position.to_i }.group_by { |a| a.user || a.session_token }.values
29
- end
30
- end
31
- end
32
- end
@@ -1,7 +0,0 @@
1
- <% question = form.object %>
2
-
3
- <script type="text/template" class="decidim-answer-option-template decidim-template" id="<%= template_id %>">
4
- <%= fields_for "questions[questions][#{question.to_param}][answer_options][]", blank_answer_option do |answer_option_form| %>
5
- <%= render "decidim/forms/admin/questionnaires/answer_option", form: answer_option_form, question:, editable: %>
6
- <% end %>
7
- </script>
@@ -1,49 +0,0 @@
1
- <div class="card" id="answers">
2
- <div class="item_show__header">
3
- <h1 class="item_show__header-title">
4
- <%= t ".title", total: @total %>
5
- <%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires"), questionnaire_url, class: "button button__sm button__secondary new" %>
6
- </h1>
7
- </div>
8
- <div class="table-scroll">
9
- <table class="table-list">
10
- <thead>
11
- <tr>
12
- <th>#</th>
13
- <th><%= first_table_th(@participants.first) %></th>
14
- <th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
15
- <th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
16
- <th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
17
- <th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
18
- <th></th>
19
- </tr>
20
- </thead>
21
- <tbody>
22
- <% @participants.each_with_index do |participant, idx| %>
23
- <tr>
24
- <td><%= idx + 1 + page_offset %></td>
25
- <td>
26
- <% if allowed_to? :show, :questionnaire_answers %>
27
- <%= link_to first_table_td(participant), questionnaire_participant_answers_url(participant.session_token) %>
28
- <% else %>
29
- <%= first_table_td(participant) %></td>
30
- <% end %>
31
- <td><%= participant.status %></td>
32
- <td><%= participant.ip_hash %></td>
33
- <td><%= display_percentage(participant.completion) %></td>
34
- <td><%= l participant.answered_at, format: :short %></td>
35
- <td class="table-list__actions">
36
- <% if allowed_to? :show, :questionnaire_answers %>
37
- <%= icon_link_to "eye-line", questionnaire_participant_answers_url(participant.session_token), t("actions.show", scope: "decidim.forms.admin.questionnaires.answers"), class: "action-icon--eye", target: "_blank", data: { "external-link": false } %>
38
- <% end %>
39
- <% if allowed_to? :export_response, :questionnaire_answers %>
40
- <%= icon_link_to "download-line", questionnaire_export_response_url(participant.session_token), t("actions.export", scope: "decidim.forms.admin.questionnaires.answers"), class: "action-icon--data-transfer-download" %>
41
- <% end %>
42
- </td>
43
- </tr>
44
- <% end %>
45
- </tbody>
46
- </table>
47
- </div>
48
- </div>
49
- <%= decidim_paginate @query %>
@@ -1,43 +0,0 @@
1
- <div class="card" id="answers">
2
- <div class="item_show__header">
3
- <h1 class="item_show__header-title">
4
- <%= t ".title", number: current_idx %>
5
-
6
- <%= link_to t("actions.next", scope: "decidim.forms.admin.questionnaires.answers").html_safe, next_url, rel: "next", class: "button button__sm button__secondary next" unless last? %>
7
- <%= link_to t("actions.previous", scope: "decidim.forms.admin.questionnaires.answers").html_safe, prev_url, rel: "prev", class: "button button__sm button__secondary prev" unless first? %>
8
- <%= link_to t("actions.export", scope: "decidim.forms.admin.questionnaires.answers"), questionnaire_export_response_url(@participant.session_token), class: "button button__sm button__secondary export" %>
9
- <%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires.answers"), questionnaire_participants_url, class: "button button__sm button__secondary back" %>
10
- </h1>
11
- </div>
12
- <div class="card-section">
13
- <div class="table">
14
- <table class="table-list">
15
- <thead>
16
- <tr>
17
- <th><%= t("session_token", scope: "decidim.forms.user_answers_serializer") %></th>
18
- <th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
19
- <th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
20
- <th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
21
- <th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
22
- <th></th>
23
- </tr>
24
- </thead>
25
- <tbody>
26
- <tr>
27
- <td><%= @participant.session_token %></td>
28
- <td><%= @participant.status %></td>
29
- <td><%= @participant.ip_hash %></td>
30
- <td><%= display_percentage(@participant.completion) %></td>
31
- <td><%= l @participant.answered_at, format: :short %></td>
32
- </tr>
33
- </tbody>
34
- </table>
35
- </div>
36
- <dl class="p-4 [&_ul]:list-disc [&_ul]:pl-4">
37
- <% @participant.answers.each do |answer| %>
38
- <dt class="font-semibold"><%= answer.question %></dt>
39
- <dd><%= answer.body %></dd>
40
- <% end %>
41
- </dl>
42
- </div>
43
- </div>
@@ -1,61 +0,0 @@
1
- <% field_id = "questionnaire_responses_#{answer_idx}" %>
2
-
3
- <% if answer.question.separator? %>
4
-
5
- <%= render partial: "decidim/forms/questionnaires/answers/#{answer.question.question_type}", locals: { answer:, answer_form:, answer_idx:, field_id:, disabled: } %>
6
- <%= answer_form.hidden_field :question_id %>
7
-
8
- <% elsif answer.question.title_and_description? %>
9
-
10
- <div class="answer-questionnaire__step-heading">
11
- <h3 class="h3"><%= translated_attribute(answer.question.body) %></h3>
12
- <% if translated_attribute(answer.question.description).present? %>
13
- <div>
14
- <%= decidim_sanitize_editor_admin translated_attribute(answer.question.description) %>
15
- </div>
16
- <% end %>
17
- </div>
18
-
19
- <%= render partial: "decidim/forms/questionnaires/answers/#{answer.question.question_type}", locals: { answer:, answer_form:, answer_idx:, field_id:, disabled: } %>
20
- <%= answer_form.hidden_field :question_id %>
21
-
22
- <% else %>
23
-
24
- <div class="answer-questionnaire__question">
25
- <%
26
- label_options = {
27
- class: "answer-questionnaire__question-label questionnaire-question",
28
- data: { "answer-idx": cleaned_answer_idx }
29
- }
30
- label_options[:for] = nil if %w(matrix_single matrix_multiple single_option multiple_option).include?(answer.question.question_type)
31
- %>
32
-
33
- <%= label_tag field_id, **label_options do %>
34
- <%= translated_attribute(answer.question.body) %>
35
- <% if answer.question.mandatory? %>
36
- <%= answer_form.send(:required_indicator) %>
37
- <% end %>
38
- <% if answer.question.max_choices %>
39
- <%= " (#{answer.send(:max_choices_label)})" %>
40
- <% end %>
41
- <% end %>
42
-
43
- <% if translated_attribute(answer.question.description).present? %>
44
- <div class="answer-questionnaire__question-description">
45
- <%= decidim_sanitize_editor_admin translated_attribute(answer.question.description) %>
46
- </div>
47
- <% end %>
48
-
49
- <% if answer.question.max_choices %>
50
- <small class="form-error max-choices-alert"><%= t(".max_choices_alert") %></small>
51
- <% end %>
52
-
53
- <% %w(short_answer long_answer).exclude?(answer&.question&.question_type) && answer.errors.full_messages.each do |msg| %>
54
- <small class="form-error is-visible"><%= msg %></small>
55
- <% end %>
56
-
57
- <%= render partial: "decidim/forms/questionnaires/answers/#{answer.question.question_type}", locals: { answer:, answer_form:, answer_idx:, field_id:, disabled:, maxlength: (answer.question.max_characters if answer.question.max_characters.positive?) } %>
58
- <%= answer_form.hidden_field :question_id %>
59
- </div>
60
-
61
- <% end %>
@@ -1 +0,0 @@
1
- <%= answer_form.upload :add_documents, attachments: answer.documents, label: false, multiple: true, id: field_id, disabled:, button_class: "button button__lg button__transparent-secondary w-full" %>
@@ -1,3 +0,0 @@
1
- <div>
2
- <%= answer_form.text_area :body, label: false, id: field_id, rows: 10, disabled:, maxlength:, class: "w-full", required: false %>
3
- </div>
@@ -1,25 +0,0 @@
1
- <div class="answer-questionnaire__single-option js-check-box-collection">
2
- <% answer.question.answer_options.each_with_index do |answer_option, idx| %>
3
- <% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
4
-
5
- <div class="js-collection-input">
6
- <%= label_tag do %>
7
- <%= check_box_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][body]",
8
- translated_attribute(answer_option.body),
9
- choice.present?, disabled: %>
10
-
11
- <%= translated_attribute(answer_option.body) %>
12
-
13
- <%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
14
- <% end %>
15
-
16
- <% if answer_option.free_text %>
17
- <%= text_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][custom_body]",
18
- choice.try(:custom_body),
19
- disabled: true,
20
- maxlength:,
21
- class: "w-full" %>
22
- <% end %>
23
- </div>
24
- <% end %>
25
- </div>
@@ -1 +0,0 @@
1
- <%= answer_form.hidden_field :body, value: "separator", id: field_id, disabled: %>
@@ -1,3 +0,0 @@
1
- <div>
2
- <%= answer_form.text_field :body, label: false, id: field_id, disabled:, maxlength:, class: "w-full", required: false %>
3
- </div>
@@ -1,32 +0,0 @@
1
- <div class="answer-questionnaire__single-option js-radio-button-collection">
2
- <% choice = answer.choices.first %>
3
-
4
- <% answer.question.answer_options.each_with_index do |answer_option, idx| %>
5
- <% choice_id = "#{field_id}_choices_#{idx}" %>
6
-
7
- <div class="js-collection-input">
8
- <%= label_tag "#{choice_id}_body" do %>
9
- <%= radio_button_tag "questionnaire[responses][#{answer_idx}][choices][][body]",
10
- translated_attribute(answer_option.body),
11
- answer_option.id == choice.try(:answer_option_id),
12
- id: "#{choice_id}_body", disabled: %>
13
-
14
- <%= translated_attribute(answer_option.body) %>
15
-
16
- <%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][][answer_option_id]",
17
- answer_option.id,
18
- id: "#{choice_id}_answer_option",
19
- disabled: true %>
20
- <% end %>
21
-
22
- <% if answer_option.free_text %>
23
- <%= text_field_tag "questionnaire[responses][#{answer_idx}][choices][][custom_body]",
24
- choice.try(:custom_body),
25
- id: "#{choice_id}_custom_body",
26
- disabled: true,
27
- maxlength:,
28
- class: "w-full" %>
29
- <% end %>
30
- </div>
31
- <% end %>
32
- </div>
@@ -1,26 +0,0 @@
1
- <div class="answer-questionnaire__sorting-container js-sortable-check-box-collection">
2
- <%
3
- # This is a block that aims to identify the order to the answer questions, and if there is an user answer, use that
4
- # to order the date that needs to be displayed. It is done like this to help with edit user answer form
5
- %>
6
- <% ordering = answer.question.answer_options.pluck(:id) %>
7
- <% if answer.selected_choices.present? %>
8
- <% ordering = answer.selected_choices.map(&:answer_option_id) %>
9
- <% end %>
10
-
11
- <% ids_for_order = ordering.map.with_index { |id, index| "#{id}=#{index + 1}" }.join(", ") %>
12
-
13
- <% answer.question.reload.answer_options.reorder(Arel.sql("POSITION(id::text in '#{ids_for_order}')")).each_with_index do |answer_option, idx| %>
14
- <% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
15
-
16
- <div class="answer-questionnaire__sorting js-collection-input" role="button">
17
- <%= translated_attribute(answer_option.body) %>
18
-
19
- <%= icon "drag-move-2-line" %>
20
-
21
- <%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][position]", choice.try(:position) %>
22
- <%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][body]", translated_attribute(answer_option.body) %>
23
- <%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
24
- </div>
25
- <% end %>
26
- </div>
@@ -1 +0,0 @@
1
- <%= answer_form.hidden_field :body, value: "title-and-description", id: field_id, disabled: %>
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Forms
5
- class AnswerOptionType < Decidim::Api::Types::BaseObject
6
- description "An answer option for a multi-choice question in a questionnaire"
7
-
8
- field :body, Decidim::Core::TranslatedFieldType, "The text answer response option.", null: false
9
- field :free_text, GraphQL::Types::Boolean, "Whether if this answer accepts any free text from the user.", null: false
10
- field :id, GraphQL::Types::ID, "ID of this answer option", null: false
11
- end
12
- end
13
- end