decidim-forms 0.30.3 → 0.31.0.rc2
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.
- checksums.yaml +4 -4
- data/README.md +10 -10
- data/app/cells/decidim/forms/matrix_readonly/show.erb +1 -1
- data/app/cells/decidim/forms/matrix_readonly_cell.rb +3 -3
- data/app/cells/decidim/forms/question_readonly/show.erb +5 -5
- data/app/cells/decidim/forms/question_readonly/title_and_description.erb +3 -3
- data/app/cells/decidim/forms/response_readonly_cell.rb +9 -0
- data/app/cells/decidim/forms/step_navigation/show.erb +3 -3
- data/app/cells/decidim/forms/step_navigation_cell.rb +3 -3
- data/app/commands/decidim/forms/admin/update_questions.rb +6 -6
- data/app/commands/decidim/forms/{answer_questionnaire.rb → response_questionnaire.rb} +35 -35
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +12 -12
- data/app/controllers/decidim/forms/admin/concerns/{has_questionnaire_answers.rb → has_questionnaire_responses.rb} +23 -19
- data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +38 -33
- data/app/forms/decidim/forms/admin/display_condition_form.rb +14 -14
- data/app/forms/decidim/forms/admin/question_form.rb +3 -3
- data/app/forms/decidim/forms/admin/{answer_option_form.rb → response_option_form.rb} +3 -3
- data/app/forms/decidim/forms/questionnaire_form.rb +8 -9
- data/app/forms/decidim/forms/{answer_choice_form.rb → response_choice_form.rb} +5 -5
- data/app/forms/decidim/forms/{answer_form.rb → response_form.rb} +9 -9
- data/app/helpers/decidim/forms/admin/application_helper.rb +2 -2
- data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_pagination_helper.rb → has_questionnaire_responses_pagination_helper.rb} +4 -4
- data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_url_helper.rb → has_questionnaire_responses_url_helper.rb} +5 -5
- data/app/helpers/decidim/forms/admin/questionnaire_responses_helper.rb +32 -0
- data/app/helpers/decidim/forms/application_helper.rb +1 -2
- data/app/jobs/decidim/forms/{export_questionnaire_answers_job.rb → export_questionnaire_responses_job.rb} +5 -5
- data/app/models/decidim/forms/display_condition.rb +20 -20
- data/app/models/decidim/forms/question.rb +14 -13
- data/app/models/decidim/forms/question_matrix_row.rb +1 -1
- data/app/models/decidim/forms/questionnaire.rb +11 -6
- data/app/models/decidim/forms/{answer.rb → response.rb} +9 -9
- data/app/models/decidim/forms/response_choice.rb +22 -0
- data/app/models/decidim/forms/{answer_option.rb → response_option.rb} +5 -5
- data/app/packs/entrypoints/decidim_forms_admin.js +3 -3
- data/app/packs/src/decidim/forms/admin/collapsible_questions.js +12 -10
- data/app/packs/src/decidim/forms/admin/forms.js +35 -35
- data/app/packs/src/decidim/forms/admin/{publish_answers_buttons.js → publish_responses_buttons.js} +12 -12
- data/app/packs/src/decidim/forms/display_conditions.component.js +12 -12
- data/app/packs/src/decidim/forms/forms.js +4 -4
- data/app/packs/stylesheets/decidim/forms/forms.scss +2 -2
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +13 -13
- data/app/presenters/decidim/forms/admin/{questionnaire_answer_presenter.rb → questionnaire_response_presenter.rb} +15 -15
- data/app/presenters/decidim/forms/admin_log/question_presenter.rb +3 -3
- data/app/presenters/decidim/forms/{answer_option_presenter.rb → response_option_presenter.rb} +2 -2
- data/app/queries/decidim/forms/questionnaire_participant.rb +5 -5
- data/app/queries/decidim/forms/questionnaire_participants.rb +6 -6
- data/app/queries/decidim/forms/questionnaire_user_responses.rb +32 -0
- data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +9 -9
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +2 -2
- data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +3 -3
- data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +11 -11
- data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +11 -10
- data/app/views/decidim/forms/admin/questionnaires/{_answer_option.html.erb → _response_option.html.erb} +7 -7
- data/app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb +7 -0
- data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +2 -2
- data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +8 -8
- data/app/views/decidim/forms/admin/questionnaires/responses/index.html.erb +80 -0
- data/app/views/decidim/forms/admin/questionnaires/responses/show.html.erb +43 -0
- data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +22 -26
- data/app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb +8 -3
- data/app/views/decidim/forms/questionnaires/_response.html.erb +61 -0
- data/app/views/decidim/forms/questionnaires/edit.html.erb +2 -2
- data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/responses/_long_response.html.erb +3 -0
- data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_multiple.html.erb +16 -15
- data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_single.html.erb +17 -16
- data/app/views/decidim/forms/questionnaires/responses/_multiple_option.html.erb +26 -0
- data/app/views/decidim/forms/questionnaires/responses/_separator.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/responses/_short_response.html.erb +3 -0
- data/app/views/decidim/forms/questionnaires/responses/_single_option.html.erb +33 -0
- data/app/views/decidim/forms/questionnaires/responses/_sorting.html.erb +26 -0
- data/app/views/decidim/forms/questionnaires/responses/_title_and_description.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +10 -10
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +0 -22
- data/config/locales/bg.yml +3 -37
- data/config/locales/ca-IT.yml +73 -73
- data/config/locales/ca.yml +73 -73
- data/config/locales/cs.yml +72 -75
- data/config/locales/de.yml +73 -74
- data/config/locales/el.yml +3 -37
- data/config/locales/en.yml +83 -83
- data/config/locales/es-MX.yml +75 -75
- data/config/locales/es-PY.yml +75 -75
- data/config/locales/es.yml +73 -73
- data/config/locales/eu.yml +72 -72
- data/config/locales/fi-plain.yml +71 -71
- data/config/locales/fi.yml +69 -69
- data/config/locales/fr-CA.yml +71 -67
- data/config/locales/fr.yml +71 -67
- data/config/locales/ga-IE.yml +0 -7
- data/config/locales/gl.yml +0 -22
- data/config/locales/hu.yml +0 -22
- data/config/locales/id-ID.yml +0 -22
- data/config/locales/it.yml +3 -41
- data/config/locales/ja.yml +80 -80
- data/config/locales/lb.yml +3 -37
- data/config/locales/lt.yml +3 -37
- data/config/locales/lv.yml +0 -22
- data/config/locales/nl.yml +3 -37
- data/config/locales/no.yml +3 -37
- data/config/locales/pl.yml +3 -37
- data/config/locales/pt-BR.yml +3 -37
- data/config/locales/pt.yml +3 -37
- data/config/locales/ro-RO.yml +22 -51
- data/config/locales/ru.yml +0 -9
- data/config/locales/sk.yml +0 -22
- data/config/locales/sl.yml +0 -5
- data/config/locales/sv.yml +82 -54
- data/config/locales/tr-TR.yml +3 -37
- data/config/locales/zh-CN.yml +3 -37
- data/config/locales/zh-TW.yml +3 -37
- data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
- data/db/migrate/20250314150250_rename_answer_to_response_in_decidim_forms.rb +30 -0
- data/db/migrate/20250319130003_change_question_types_in_questions.rb +14 -0
- data/lib/decidim/api/question_matrix_row_type.rb +13 -0
- data/lib/decidim/api/question_type.rb +4 -3
- data/lib/decidim/api/questionnaire_type.rb +1 -0
- data/lib/decidim/api/response_option_type.rb +13 -0
- data/lib/decidim/exporters/form_pdf.rb +33 -33
- data/lib/decidim/forms/api.rb +2 -1
- data/lib/decidim/forms/{download_your_data_user_answers_serializer.rb → download_your_data_user_responses_serializer.rb} +3 -3
- data/lib/decidim/forms/engine.rb +2 -2
- data/lib/decidim/forms/test/factories.rb +24 -24
- data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +176 -176
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_responses.rb +159 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -19
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +44 -44
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +10 -10
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +18 -18
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -4
- data/lib/decidim/forms/test.rb +1 -1
- data/lib/decidim/forms/user_responses_serializer.rb +110 -0
- data/lib/decidim/forms/version.rb +1 -1
- data/lib/decidim/forms.rb +2 -2
- metadata +47 -44
- data/app/cells/decidim/forms/answer_readonly_cell.rb +0 -9
- data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +0 -30
- data/app/models/decidim/forms/answer_choice.rb +0 -22
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +0 -32
- data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +0 -7
- data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +0 -49
- data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +0 -43
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +0 -61
- data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +0 -1
- data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +0 -3
- data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +0 -25
- data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +0 -1
- data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +0 -3
- data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +0 -32
- data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +0 -26
- data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +0 -1
- data/lib/decidim/api/answer_option_type.rb +0 -13
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +0 -149
- data/lib/decidim/forms/user_answers_serializer.rb +0 -105
- /data/app/cells/decidim/forms/{answer_readonly → response_readonly}/show.erb +0 -0
data/config/locales/zh-CN.yml
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
zh-CN:
|
|
3
3
|
activemodel:
|
|
4
4
|
attributes:
|
|
5
|
-
answer:
|
|
6
|
-
body: 答案
|
|
7
5
|
question:
|
|
8
6
|
max_choices: 选择的最大数量
|
|
9
7
|
question_type: 类型
|
|
@@ -17,36 +15,18 @@ zh-CN:
|
|
|
17
15
|
description: 描述
|
|
18
16
|
tos: 服务条款
|
|
19
17
|
questionnaires:
|
|
20
|
-
actions:
|
|
21
|
-
show: 显示回复
|
|
22
|
-
answer_option:
|
|
23
|
-
answer_option: 答案选项
|
|
24
|
-
remove: 删除
|
|
25
|
-
statement: 声明
|
|
26
|
-
answers:
|
|
27
|
-
actions:
|
|
28
|
-
show: 显示答案
|
|
29
|
-
empty: 尚无答案
|
|
30
|
-
export_response:
|
|
31
|
-
title: survey_user_answers_%{token}
|
|
32
|
-
show:
|
|
33
|
-
title: '答案 #%{number}'
|
|
34
18
|
display_condition:
|
|
35
|
-
answer_option: 答案选项
|
|
36
19
|
condition_question: 问
|
|
37
20
|
condition_type: 条件
|
|
38
21
|
condition_types:
|
|
39
|
-
answered: 已回答
|
|
40
22
|
equal: 等于
|
|
41
23
|
match: 包含文本
|
|
42
|
-
not_answered: 未回答
|
|
43
24
|
not_equal: 不等于
|
|
44
25
|
condition_value: 包含文本
|
|
45
26
|
display_condition: 显示条件
|
|
46
27
|
mandatory: 无论其他条件的状况如何,总是需要满足这个条件
|
|
47
28
|
remove: 删除
|
|
48
29
|
save_warning: 在配置显示条件之前记住保存表单
|
|
49
|
-
select_answer_option: 选择答案选项
|
|
50
30
|
select_condition_question: 选择一个问题
|
|
51
31
|
select_condition_type: 选择一个条件类型
|
|
52
32
|
edit:
|
|
@@ -62,7 +42,6 @@ zh-CN:
|
|
|
62
42
|
remove: 删除
|
|
63
43
|
statement: 声明
|
|
64
44
|
question:
|
|
65
|
-
add_answer_option: 添加答案选项
|
|
66
45
|
add_display_condition: 添加显示条件
|
|
67
46
|
add_display_condition_info: 保存表单以配置显示条件
|
|
68
47
|
add_matrix_row: 添加行
|
|
@@ -73,6 +52,9 @@ zh-CN:
|
|
|
73
52
|
question: 问
|
|
74
53
|
remove: 删除
|
|
75
54
|
statement: 声明
|
|
55
|
+
responses:
|
|
56
|
+
actions:
|
|
57
|
+
show: 显示回复
|
|
76
58
|
separator:
|
|
77
59
|
remove: 删除
|
|
78
60
|
separator: 分隔符
|
|
@@ -82,29 +64,18 @@ zh-CN:
|
|
|
82
64
|
images:
|
|
83
65
|
dimensions: "%{width} x %{height} px"
|
|
84
66
|
question_types:
|
|
85
|
-
long_answer: 长答案
|
|
86
67
|
matrix_multiple: 矩阵(多选项)
|
|
87
68
|
matrix_single: 矩阵(单选项)
|
|
88
69
|
multiple_option: 多选项
|
|
89
|
-
short_answer: 简短答案
|
|
90
70
|
single_option: 单个选项
|
|
91
71
|
sorting: 排序中
|
|
92
72
|
questionnaires:
|
|
93
|
-
answer:
|
|
94
|
-
invalid: 回答表单时出现问题。
|
|
95
|
-
success: 表单回答成功。
|
|
96
73
|
question:
|
|
97
74
|
max_choices: '最大选择数: %{n}'
|
|
98
75
|
show:
|
|
99
|
-
answer_questionnaire:
|
|
100
|
-
title: 回答表单
|
|
101
76
|
current_step: 步骤 %{step}
|
|
102
77
|
of_total_steps: '%{total_steps}'
|
|
103
|
-
questionnaire_answered:
|
|
104
|
-
body: 您已经回答过这个表单。
|
|
105
|
-
title: 已经回答
|
|
106
78
|
questionnaire_closed:
|
|
107
|
-
body: 表格已关闭,无法解答。
|
|
108
79
|
title: 表单已关闭
|
|
109
80
|
questionnaire_for_private_users:
|
|
110
81
|
body: 表单仅供私人用户使用
|
|
@@ -120,8 +91,3 @@ zh-CN:
|
|
|
120
91
|
back: 后退
|
|
121
92
|
continue: 继续
|
|
122
93
|
submit: 提交
|
|
123
|
-
user_answers_serializer:
|
|
124
|
-
body: 答案
|
|
125
|
-
created_at: 回答于
|
|
126
|
-
id: 答案 ID
|
|
127
|
-
question: 问
|
data/config/locales/zh-TW.yml
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
zh-TW:
|
|
3
3
|
activemodel:
|
|
4
4
|
attributes:
|
|
5
|
-
answer:
|
|
6
|
-
body: 回答
|
|
7
5
|
question:
|
|
8
6
|
max_choices: 選擇的最大數量
|
|
9
7
|
question_type: 類別
|
|
@@ -18,36 +16,18 @@ zh-TW:
|
|
|
18
16
|
description: 說明
|
|
19
17
|
tos: 服務條款
|
|
20
18
|
questionnaires:
|
|
21
|
-
actions:
|
|
22
|
-
show: 顯示回應
|
|
23
|
-
answer_option:
|
|
24
|
-
answer_option: 答案選項:
|
|
25
|
-
remove: 移除
|
|
26
|
-
statement: 聲明
|
|
27
|
-
answers:
|
|
28
|
-
actions:
|
|
29
|
-
show: 顯示答案
|
|
30
|
-
empty: 目前尚未回答
|
|
31
|
-
export_response:
|
|
32
|
-
title: 調查問卷使用者回答_%{token}
|
|
33
|
-
show:
|
|
34
|
-
title: '回答#%{number}'
|
|
35
19
|
display_condition:
|
|
36
|
-
answer_option: 答案選項
|
|
37
20
|
condition_question: 問題
|
|
38
21
|
condition_type: 條件
|
|
39
22
|
condition_types:
|
|
40
|
-
answered: 已回答
|
|
41
23
|
equal: 等於
|
|
42
24
|
match: 包含文字
|
|
43
|
-
not_answered: 未回答
|
|
44
25
|
not_equal: 不等於
|
|
45
26
|
condition_value: 包含文字
|
|
46
27
|
display_condition: 顯示條件
|
|
47
28
|
mandatory: 這個條件必須始終滿足,無論其他條件的狀態如何。
|
|
48
29
|
remove: 移除
|
|
49
30
|
save_warning: 在配置顯示條件之前,請記得保存表單。
|
|
50
|
-
select_answer_option: 選擇答案選項
|
|
51
31
|
select_condition_question: 選取一個問題
|
|
52
32
|
select_condition_type: 選擇一個條件類型
|
|
53
33
|
edit:
|
|
@@ -64,7 +44,6 @@ zh-TW:
|
|
|
64
44
|
remove: 移除
|
|
65
45
|
statement: 聲明
|
|
66
46
|
question:
|
|
67
|
-
add_answer_option: 新增答案選項
|
|
68
47
|
add_display_condition: 新增顯示條件
|
|
69
48
|
add_display_condition_info: 請先儲存表單再設定顯示條件
|
|
70
49
|
add_matrix_row: 新增列
|
|
@@ -75,6 +54,9 @@ zh-TW:
|
|
|
75
54
|
question: 問題
|
|
76
55
|
remove: 移除
|
|
77
56
|
statement: 聲明
|
|
57
|
+
responses:
|
|
58
|
+
actions:
|
|
59
|
+
show: 顯示回應
|
|
78
60
|
separator:
|
|
79
61
|
remove: 移除
|
|
80
62
|
separator: 分隔線
|
|
@@ -98,30 +80,19 @@ zh-TW:
|
|
|
98
80
|
resize_to_fit: 此圖片將被調整大小以符合 %{dimensions}。
|
|
99
81
|
question_types:
|
|
100
82
|
files: 檔案
|
|
101
|
-
long_answer: 長回答
|
|
102
83
|
matrix_multiple: 矩陣(多重選項)
|
|
103
84
|
matrix_single: 矩陣(單一選項)
|
|
104
85
|
multiple_option: 多選
|
|
105
|
-
short_answer: 簡答
|
|
106
86
|
single_option: 單選
|
|
107
87
|
sorting: 排序中
|
|
108
88
|
title_and_description: 標題和描述
|
|
109
89
|
questionnaires:
|
|
110
|
-
answer:
|
|
111
|
-
invalid: 回答表單時出現問題
|
|
112
|
-
success: 表單已成功回答
|
|
113
90
|
question:
|
|
114
91
|
max_choices: '最多選擇數量: %{n}'
|
|
115
92
|
show:
|
|
116
|
-
answer_questionnaire:
|
|
117
|
-
title: 回答表單
|
|
118
93
|
current_step: 步驟%{step}
|
|
119
94
|
of_total_steps: 的%{total_steps}
|
|
120
|
-
questionnaire_answered:
|
|
121
|
-
body: 您已經回答過此表格。
|
|
122
|
-
title: 已經回答
|
|
123
95
|
questionnaire_closed:
|
|
124
|
-
body: 該表格已關閉,無法回答。
|
|
125
96
|
title: 表單已關閉
|
|
126
97
|
questionnaire_for_private_users:
|
|
127
98
|
body: 此表單僅適用於私人使用者
|
|
@@ -137,8 +108,3 @@ zh-TW:
|
|
|
137
108
|
back: 返回
|
|
138
109
|
continue: 繼續
|
|
139
110
|
submit: 提交
|
|
140
|
-
user_answers_serializer:
|
|
141
|
-
body: 回答
|
|
142
|
-
created_at: 回答時間
|
|
143
|
-
id: 回答 ID
|
|
144
|
-
question: 問題
|
|
@@ -10,7 +10,7 @@ class AddSessionTokenToDecidimFormsAnswers < ActiveRecord::Migration[5.2]
|
|
|
10
10
|
add_index :decidim_forms_answers, :session_token
|
|
11
11
|
|
|
12
12
|
Answer.find_each do |answer|
|
|
13
|
-
answer.session_token = Digest::
|
|
13
|
+
answer.session_token = Digest::SHA256.hexdigest("#{answer.decidim_user_id}-#{Rails.application.secret_key_base}")
|
|
14
14
|
answer.save!
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RenameAnswerToResponseInDecidimForms < ActiveRecord::Migration[7.0]
|
|
4
|
+
def change
|
|
5
|
+
rename_index :decidim_forms_response_choices, "index_decidim_forms_answer_choices_answer_id", "index_decidim_forms_response_choices_response_id"
|
|
6
|
+
rename_index :decidim_forms_response_choices, "index_decidim_forms_answer_choices_answer_option_id", "index_decidim_forms_response_choices_response_option_id"
|
|
7
|
+
|
|
8
|
+
rename_index :decidim_forms_response_options, "index_decidim_forms_answer_options_question_id", "index_decidim_forms_response_options_question_id"
|
|
9
|
+
|
|
10
|
+
rename_index :decidim_forms_responses, "index_decidim_forms_answers_question_id", "index_decidim_forms_responses_question_id"
|
|
11
|
+
rename_index :decidim_forms_responses, "index_decidim_forms_answers_on_decidim_questionnaire_id", "index_decidim_forms_responses_on_decidim_questionnaire_id"
|
|
12
|
+
rename_index :decidim_forms_responses, "index_decidim_forms_answers_on_decidim_user_id", "index_decidim_forms_responses_on_decidim_user_id"
|
|
13
|
+
rename_index :decidim_forms_responses, "index_decidim_forms_answers_on_ip_hash", "index_decidim_forms_responses_on_ip_hash"
|
|
14
|
+
rename_index :decidim_forms_responses, "index_decidim_forms_answers_on_session_token", "index_decidim_forms_responses_on_session_token"
|
|
15
|
+
|
|
16
|
+
rename_index :decidim_forms_display_conditions, "decidim_forms_display_condition_answer_option", "decidim_forms_display_condition_response_option"
|
|
17
|
+
|
|
18
|
+
rename_table :decidim_forms_answers, :decidim_forms_responses
|
|
19
|
+
rename_table :decidim_forms_answer_choices, :decidim_forms_response_choices
|
|
20
|
+
rename_table :decidim_forms_answer_options, :decidim_forms_response_options
|
|
21
|
+
|
|
22
|
+
rename_column :decidim_forms_response_choices, :decidim_answer_id, :decidim_response_id
|
|
23
|
+
rename_column :decidim_forms_response_choices, :decidim_answer_option_id, :decidim_response_option_id
|
|
24
|
+
|
|
25
|
+
rename_column :decidim_forms_display_conditions, :decidim_answer_option_id, :decidim_response_option_id
|
|
26
|
+
|
|
27
|
+
rename_column :decidim_forms_questions, :answer_options_count, :response_options_count
|
|
28
|
+
rename_column :decidim_forms_questions, :survey_answers_published_at, :survey_responses_published_at
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ChangeQuestionTypesInQuestions < ActiveRecord::Migration[7.0]
|
|
4
|
+
class Question < ApplicationRecord
|
|
5
|
+
self.table_name = :decidim_forms_questions
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def change
|
|
9
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
10
|
+
Decidim::Forms::Question.where(question_type: "short_answer").update_all(question_type: "short_response")
|
|
11
|
+
Decidim::Forms::Question.where(question_type: "long_answer").update_all(question_type: "long_response")
|
|
12
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Forms
|
|
5
|
+
class QuestionMatrixRowType < Decidim::Api::Types::BaseObject
|
|
6
|
+
description "An response option for a multi-choice question in a questionnaire"
|
|
7
|
+
|
|
8
|
+
field :body, Decidim::Core::TranslatedFieldType, "The matrix row option text.", null: false
|
|
9
|
+
field :id, GraphQL::Types::ID, "ID of this matrix row option", null: false
|
|
10
|
+
field :position, GraphQL::Types::Int, "The position of this matrix row option.", null: false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -7,15 +7,16 @@ module Decidim
|
|
|
7
7
|
|
|
8
8
|
implements Decidim::Core::TimestampsInterface
|
|
9
9
|
|
|
10
|
-
field :answer_options, [AnswerOptionType, { null: true }], "List of answer options in multi-choice questions.", null: false
|
|
11
10
|
field :body, Decidim::Core::TranslatedFieldType, "What is being asked in this question.", null: false
|
|
12
11
|
field :description, Decidim::Core::TranslatedFieldType, "The description of this question.", null: true
|
|
13
12
|
field :id, GraphQL::Types::ID, "ID of this question", null: false
|
|
14
13
|
field :mandatory, GraphQL::Types::Boolean, "Whether if this question is mandatory.", null: false
|
|
15
|
-
field :
|
|
16
|
-
field :
|
|
14
|
+
field :matrix_rows, [QuestionMatrixRowType, { null: true }], "List of matrix rows in matrix questions.", null: true
|
|
15
|
+
field :max_characters, GraphQL::Types::Int, "On questions with free text responses, maximum number of characters the response can have (0 if no limit)", null: false
|
|
16
|
+
field :max_choices, GraphQL::Types::Int, "On questions with response options, maximum number of choices the user has", null: true
|
|
17
17
|
field :position, GraphQL::Types::Int, "Order position of the question in the questionnaire", null: true
|
|
18
18
|
field :question_type, GraphQL::Types::String, "Type of question.", null: true
|
|
19
|
+
field :response_options, [ResponseOptionType, { null: true }], "List of response options in multi-choice questions.", null: false
|
|
19
20
|
end
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -11,6 +11,7 @@ module Decidim
|
|
|
11
11
|
field :for_entity, QuestionnaireEntityInterface, "Entity using this questionnaire.", method: :questionnaire_for, null: true
|
|
12
12
|
field :for_type, GraphQL::Types::String, "Type of entity using this questionnaire.", method: :questionnaire_for_type, null: true
|
|
13
13
|
field :id, GraphQL::Types::ID, "ID of this questionnaire", null: false
|
|
14
|
+
field :published_at, Decidim::Core::DateTimeType, description: "The date and time this questionnaire was published", null: true
|
|
14
15
|
field :questions, [Decidim::Forms::QuestionType, { null: true }], "Questions in this questionnaire.", null: false
|
|
15
16
|
field :title, Decidim::Core::TranslatedFieldType, "The title of this questionnaire.", null: false
|
|
16
17
|
field :tos, Decidim::Core::TranslatedFieldType, "The Terms of Service for this questionnaire.", null: true
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Forms
|
|
5
|
+
class ResponseOptionType < Decidim::Api::Types::BaseObject
|
|
6
|
+
description "An response option for a multi-choice question in a questionnaire"
|
|
7
|
+
|
|
8
|
+
field :body, Decidim::Core::TranslatedFieldType, "The response option text.", null: false
|
|
9
|
+
field :free_text, GraphQL::Types::Boolean, "Whether if this response accepts any free text from the user.", null: false
|
|
10
|
+
field :id, GraphQL::Types::ID, "ID of this response option", null: false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -3,41 +3,41 @@
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Exporters
|
|
5
5
|
# Inherits from abstract PDF exporter. This class is used to set
|
|
6
|
-
# the parameters used to create a PDF when exporting Survey
|
|
6
|
+
# the parameters used to create a PDF when exporting Survey Responses.
|
|
7
7
|
#
|
|
8
8
|
class FormPDF < PDF
|
|
9
9
|
# i18n-tasks-use t('decidim.admin.exports.formats.FormPDF')
|
|
10
10
|
include ActionView::Helpers::NumberHelper
|
|
11
|
-
include Decidim::Forms::Admin::
|
|
11
|
+
include Decidim::Forms::Admin::QuestionnaireResponsesHelper
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class QuestionnaireResponsePresenter < Decidim::Forms::Admin::QuestionnaireResponsePresenter
|
|
14
14
|
def choice(choice_hash)
|
|
15
15
|
render_body_for choice_hash
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
delegate :attachments, to: :
|
|
18
|
+
delegate :attachments, to: :response
|
|
19
19
|
|
|
20
20
|
def body
|
|
21
|
-
return { string:
|
|
22
|
-
return { attachments:
|
|
23
|
-
return { string: "-" } if
|
|
21
|
+
return { string: response.body } if response.body.present?
|
|
22
|
+
return { attachments: response.attachments } if response.attachments.any?
|
|
23
|
+
return { string: "-" } if response.choices.empty?
|
|
24
24
|
|
|
25
|
-
choices =
|
|
25
|
+
choices = response.choices.map do |choice|
|
|
26
26
|
{
|
|
27
|
-
|
|
27
|
+
response_option_body: choice.try(:response_option).try(:translated_body),
|
|
28
28
|
choice_body: body_or_custom_body(choice)
|
|
29
29
|
}
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
return { single_option: choice(choices.first) } if
|
|
32
|
+
return { single_option: choice(choices.first) } if response.question.question_type == "single_option"
|
|
33
33
|
|
|
34
34
|
{ multiple_option: choices.map { |c| choice(c) } }
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
class ParticipantPresenter < Decidim::Forms::Admin::QuestionnaireParticipantPresenter
|
|
39
|
-
def
|
|
40
|
-
siblings.map { |
|
|
39
|
+
def responses
|
|
40
|
+
siblings.map { |response| QuestionnaireResponsePresenter.new(response:) }
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -46,9 +46,9 @@ module Decidim
|
|
|
46
46
|
def add_data!
|
|
47
47
|
composer.text(decidim_sanitize(translated_attribute(questionnaire.title), strip_tags: true), style: :h1)
|
|
48
48
|
composer.text(decidim_sanitize(translated_attribute(questionnaire.description), strip_tags: true), style: :description)
|
|
49
|
-
composer.text(I18n.t("title", scope: "decidim.forms.admin.questionnaires.
|
|
49
|
+
composer.text(I18n.t("title", scope: "decidim.forms.admin.questionnaires.responses.index", total: collection.count), style: :section_title)
|
|
50
50
|
|
|
51
|
-
local_collection = collection.map { |
|
|
51
|
+
local_collection = collection.map { |response| ParticipantPresenter.new(participant: response.first) }
|
|
52
52
|
|
|
53
53
|
local_collection.each_with_index do |record, index|
|
|
54
54
|
add_response_box(record, index)
|
|
@@ -65,7 +65,7 @@ module Decidim
|
|
|
65
65
|
description: { font:, margin: [0, 0, 10, 0], font_size: 10 },
|
|
66
66
|
section_title: { font: bold_font, margin: [15, 0, 15, 0], font_size: 16 },
|
|
67
67
|
question_title: { font: bold_font, margin: [10, 0, 10, 0], font_size: 12 },
|
|
68
|
-
|
|
68
|
+
question_response: { font:, margin: [10, 0, 10, 0], font_size: 10 },
|
|
69
69
|
file_info: { font:, margin: [10, 0, 10, 0], font_size: 8 },
|
|
70
70
|
link: { font:, margin: [10, 0, 10, 0], font_size: 10, underline: true }
|
|
71
71
|
}
|
|
@@ -73,11 +73,11 @@ module Decidim
|
|
|
73
73
|
|
|
74
74
|
def header
|
|
75
75
|
[
|
|
76
|
-
layout.text(I18n.t("session_token", scope: "decidim.forms.
|
|
77
|
-
layout.text(I18n.t("user_status", scope: "decidim.forms.
|
|
78
|
-
layout.text(I18n.t("ip_hash", scope: "decidim.forms.
|
|
79
|
-
layout.text(I18n.t("completion", scope: "decidim.forms.
|
|
80
|
-
layout.text(I18n.t("created_at", scope: "decidim.forms.
|
|
76
|
+
layout.text(I18n.t("session_token", scope: "decidim.forms.user_responses_serializer"), style: :th),
|
|
77
|
+
layout.text(I18n.t("user_status", scope: "decidim.forms.user_responses_serializer"), style: :th),
|
|
78
|
+
layout.text(I18n.t("ip_hash", scope: "decidim.forms.user_responses_serializer"), style: :th),
|
|
79
|
+
layout.text(I18n.t("completion", scope: "decidim.forms.user_responses_serializer"), style: :th),
|
|
80
|
+
layout.text(I18n.t("created_at", scope: "decidim.forms.user_responses_serializer"), style: :th)
|
|
81
81
|
]
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -87,31 +87,31 @@ module Decidim
|
|
|
87
87
|
layout.text(record.status, style: :td),
|
|
88
88
|
layout.text(record.ip_hash, style: :td),
|
|
89
89
|
layout.text(display_percentage(record.completion), style: :td),
|
|
90
|
-
layout.text(I18n.l(record.
|
|
90
|
+
layout.text(I18n.l(record.responded_at, format: :short), style: :td)
|
|
91
91
|
]
|
|
92
92
|
composer.table([cells], header: ->(_table) { [header] }, cell_style: { border: { width: 0 } })
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def add_response_box(record, index)
|
|
96
|
-
composer.text(I18n.t("title", number: index + 1, scope: "decidim.forms.admin.questionnaires.
|
|
96
|
+
composer.text(I18n.t("title", number: index + 1, scope: "decidim.forms.admin.questionnaires.responses.export.response"), style: :section_title)
|
|
97
97
|
add_user_data(record)
|
|
98
98
|
|
|
99
|
-
record.
|
|
100
|
-
composer.text(
|
|
101
|
-
|
|
99
|
+
record.responses.each do |response|
|
|
100
|
+
composer.text(response.question, style: :question_title)
|
|
101
|
+
add_response_body(response)
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
def
|
|
106
|
-
return composer.text(
|
|
105
|
+
def add_response_body(response)
|
|
106
|
+
return composer.text(response.body[:string], style: :question_response) if response.body.has_key?(:string)
|
|
107
107
|
|
|
108
|
-
if
|
|
108
|
+
if response.attachments.any?
|
|
109
109
|
composer.list(marker_type: :disc) do |sub_list|
|
|
110
|
-
|
|
110
|
+
response.attachments.each do |attachment|
|
|
111
111
|
sub_list.formatted_text(
|
|
112
112
|
[{ link: attachment.url,
|
|
113
113
|
text: translated_attribute(attachment.title).presence ||
|
|
114
|
-
I18n.t("download_attachment", scope: "decidim.forms.
|
|
114
|
+
I18n.t("download_attachment", scope: "decidim.forms.questionnaire_response_presenter"),
|
|
115
115
|
style: :link },
|
|
116
116
|
" (#{attachment.file_type} #{number_to_human_size(attachment.file_size)})"],
|
|
117
117
|
style: :file_info
|
|
@@ -121,13 +121,13 @@ module Decidim
|
|
|
121
121
|
return
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
if
|
|
124
|
+
if response.body.has_key?(:single_option)
|
|
125
125
|
composer.list(marker_type: :disc) do |sub_list|
|
|
126
|
-
sub_list.text(
|
|
126
|
+
sub_list.text(response.body[:single_option], style: :question_response)
|
|
127
127
|
end
|
|
128
128
|
else
|
|
129
129
|
composer.list(marker_type: :disc) do |sub_list|
|
|
130
|
-
|
|
130
|
+
response.body[:multiple_option].map { |choice| sub_list.text(choice, style: :question_response) }
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
end
|
data/lib/decidim/forms/api.rb
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Forms
|
|
5
5
|
autoload :QuestionnaireEntityInterface, "decidim/api/questionnaire_entity_interface"
|
|
6
|
-
autoload :
|
|
6
|
+
autoload :ResponseOptionType, "decidim/api/response_option_type"
|
|
7
7
|
autoload :QuestionType, "decidim/api/question_type"
|
|
8
8
|
autoload :QuestionnaireType, "decidim/api/questionnaire_type"
|
|
9
|
+
autoload :QuestionMatrixRowType, "decidim/api/question_matrix_row_type"
|
|
9
10
|
end
|
|
10
11
|
end
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Forms
|
|
5
|
-
class
|
|
5
|
+
class DownloadYourDataUserResponsesSerializer < Decidim::Exporters::Serializer
|
|
6
6
|
include Decidim::TranslationsHelper
|
|
7
|
-
# Serializes an user
|
|
7
|
+
# Serializes an user response for download your data
|
|
8
8
|
def serialize
|
|
9
9
|
{
|
|
10
10
|
id: resource.id,
|
|
@@ -19,7 +19,7 @@ module Decidim
|
|
|
19
19
|
body: translated_attribute(resource.question.body),
|
|
20
20
|
description: translated_attribute(resource.question.description)
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
response: normalize_body(resource)
|
|
23
23
|
}
|
|
24
24
|
end
|
|
25
25
|
|
data/lib/decidim/forms/engine.rb
CHANGED
|
@@ -12,14 +12,14 @@ module Decidim
|
|
|
12
12
|
Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Forms::Engine.root}/app/cells")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
initializer "decidim_forms.
|
|
15
|
+
initializer "decidim_forms.shakapacker.assets_path" do
|
|
16
16
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
initializer "decidim_forms.authorization_transfer" do
|
|
20
20
|
config.to_prepare do
|
|
21
21
|
Decidim::AuthorizationTransfer.register(:forms) do |transfer|
|
|
22
|
-
transfer.move_records(Decidim::Forms::
|
|
22
|
+
transfer.move_records(Decidim::Forms::Response, :decidim_user_id)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|