decidim-forms 0.30.2 → 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.
- 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 +16 -16
- 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 +10 -7
- data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +7 -7
- 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 -36
- 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 +72 -72
- data/config/locales/el.yml +3 -36
- 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 +71 -71
- data/config/locales/fi-plain.yml +71 -71
- data/config/locales/fi.yml +69 -69
- data/config/locales/fr-CA.yml +70 -67
- data/config/locales/fr.yml +70 -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 -40
- data/config/locales/ja.yml +80 -80
- data/config/locales/lb.yml +3 -36
- data/config/locales/lt.yml +3 -36
- data/config/locales/lv.yml +0 -22
- data/config/locales/nl.yml +3 -36
- data/config/locales/no.yml +3 -36
- data/config/locales/pl.yml +3 -36
- data/config/locales/pt-BR.yml +3 -36
- data/config/locales/pt.yml +3 -36
- 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 -36
- data/config/locales/zh-CN.yml +3 -36
- data/config/locales/zh-TW.yml +3 -36
- 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 +48 -45
- 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: 类型
|
@@ -19,35 +17,18 @@ zh-CN:
|
|
19
17
|
questionnaires:
|
20
18
|
actions:
|
21
19
|
back: 返回问题
|
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: survey_user_answers_%{token}
|
33
|
-
show:
|
34
|
-
title: '答案 #%{number}'
|
35
20
|
display_condition:
|
36
|
-
answer_option: 答案选项
|
37
21
|
condition_question: 问
|
38
22
|
condition_type: 条件
|
39
23
|
condition_types:
|
40
|
-
answered: 已回答
|
41
24
|
equal: 等于
|
42
25
|
match: 包含文本
|
43
|
-
not_answered: 未回答
|
44
26
|
not_equal: 不等于
|
45
27
|
condition_value: 包含文本
|
46
28
|
display_condition: 显示条件
|
47
29
|
mandatory: 无论其他条件的状况如何,总是需要满足这个条件
|
48
30
|
remove: 删除
|
49
31
|
save_warning: 在配置显示条件之前记住保存表单
|
50
|
-
select_answer_option: 选择答案选项
|
51
32
|
select_condition_question: 选择一个问题
|
52
33
|
select_condition_type: 选择一个条件类型
|
53
34
|
edit:
|
@@ -63,7 +44,6 @@ zh-CN:
|
|
63
44
|
remove: 删除
|
64
45
|
statement: 声明
|
65
46
|
question:
|
66
|
-
add_answer_option: 添加答案选项
|
67
47
|
add_display_condition: 添加显示条件
|
68
48
|
add_display_condition_info: 保存表单以配置显示条件
|
69
49
|
add_matrix_row: 添加行
|
@@ -76,6 +56,9 @@ zh-CN:
|
|
76
56
|
remove: 删除
|
77
57
|
statement: 声明
|
78
58
|
up: 上移
|
59
|
+
responses:
|
60
|
+
actions:
|
61
|
+
show: 显示回复
|
79
62
|
separator:
|
80
63
|
down: 向下
|
81
64
|
remove: 删除
|
@@ -87,29 +70,18 @@ zh-CN:
|
|
87
70
|
images:
|
88
71
|
dimensions: "%{width} x %{height} px"
|
89
72
|
question_types:
|
90
|
-
long_answer: 长答案
|
91
73
|
matrix_multiple: 矩阵(多选项)
|
92
74
|
matrix_single: 矩阵(单选项)
|
93
75
|
multiple_option: 多选项
|
94
|
-
short_answer: 简短答案
|
95
76
|
single_option: 单个选项
|
96
77
|
sorting: 排序中
|
97
78
|
questionnaires:
|
98
|
-
answer:
|
99
|
-
invalid: 回答表单时出现问题。
|
100
|
-
success: 表单回答成功。
|
101
79
|
question:
|
102
80
|
max_choices: '最大选择数: %{n}'
|
103
81
|
show:
|
104
|
-
answer_questionnaire:
|
105
|
-
title: 回答表单
|
106
82
|
current_step: 步骤 %{step}
|
107
83
|
of_total_steps: '%{total_steps}'
|
108
|
-
questionnaire_answered:
|
109
|
-
body: 您已经回答过这个表单。
|
110
|
-
title: 已经回答
|
111
84
|
questionnaire_closed:
|
112
|
-
body: 表格已关闭,无法解答。
|
113
85
|
title: 表单已关闭
|
114
86
|
questionnaire_for_private_users:
|
115
87
|
body: 表单仅供私人用户使用
|
@@ -125,8 +97,3 @@ zh-CN:
|
|
125
97
|
back: 后退
|
126
98
|
continue: 继续
|
127
99
|
submit: 提交
|
128
|
-
user_answers_serializer:
|
129
|
-
body: 答案
|
130
|
-
created_at: 回答于
|
131
|
-
id: 答案 ID
|
132
|
-
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: 類別
|
@@ -20,35 +18,18 @@ zh-TW:
|
|
20
18
|
questionnaires:
|
21
19
|
actions:
|
22
20
|
back: 返回問題
|
23
|
-
show: 顯示回應
|
24
|
-
answer_option:
|
25
|
-
answer_option: 答案選項:
|
26
|
-
remove: 移除
|
27
|
-
statement: 聲明
|
28
|
-
answers:
|
29
|
-
actions:
|
30
|
-
show: 顯示答案
|
31
|
-
empty: 目前尚未回答
|
32
|
-
export_response:
|
33
|
-
title: 調查問卷使用者回答_%{token}
|
34
|
-
show:
|
35
|
-
title: '回答#%{number}'
|
36
21
|
display_condition:
|
37
|
-
answer_option: 答案選項
|
38
22
|
condition_question: 問題
|
39
23
|
condition_type: 條件
|
40
24
|
condition_types:
|
41
|
-
answered: 已回答
|
42
25
|
equal: 等於
|
43
26
|
match: 包含文字
|
44
|
-
not_answered: 未回答
|
45
27
|
not_equal: 不等於
|
46
28
|
condition_value: 包含文字
|
47
29
|
display_condition: 顯示條件
|
48
30
|
mandatory: 這個條件必須始終滿足,無論其他條件的狀態如何。
|
49
31
|
remove: 移除
|
50
32
|
save_warning: 在配置顯示條件之前,請記得保存表單。
|
51
|
-
select_answer_option: 選擇答案選項
|
52
33
|
select_condition_question: 選取一個問題
|
53
34
|
select_condition_type: 選擇一個條件類型
|
54
35
|
edit:
|
@@ -65,7 +46,6 @@ zh-TW:
|
|
65
46
|
remove: 移除
|
66
47
|
statement: 聲明
|
67
48
|
question:
|
68
|
-
add_answer_option: 新增答案選項
|
69
49
|
add_display_condition: 新增顯示條件
|
70
50
|
add_display_condition_info: 請先儲存表單再設定顯示條件
|
71
51
|
add_matrix_row: 新增列
|
@@ -78,6 +58,9 @@ zh-TW:
|
|
78
58
|
remove: 移除
|
79
59
|
statement: 聲明
|
80
60
|
up: 往上
|
61
|
+
responses:
|
62
|
+
actions:
|
63
|
+
show: 顯示回應
|
81
64
|
separator:
|
82
65
|
down: 向下
|
83
66
|
remove: 移除
|
@@ -105,30 +88,19 @@ zh-TW:
|
|
105
88
|
resize_to_fit: 此圖片將被調整大小以符合 %{dimensions}。
|
106
89
|
question_types:
|
107
90
|
files: 檔案
|
108
|
-
long_answer: 長回答
|
109
91
|
matrix_multiple: 矩陣(多重選項)
|
110
92
|
matrix_single: 矩陣(單一選項)
|
111
93
|
multiple_option: 多選
|
112
|
-
short_answer: 簡答
|
113
94
|
single_option: 單選
|
114
95
|
sorting: 排序中
|
115
96
|
title_and_description: 標題和描述
|
116
97
|
questionnaires:
|
117
|
-
answer:
|
118
|
-
invalid: 回答表單時出現問題
|
119
|
-
success: 表單已成功回答
|
120
98
|
question:
|
121
99
|
max_choices: '最多選擇數量: %{n}'
|
122
100
|
show:
|
123
|
-
answer_questionnaire:
|
124
|
-
title: 回答表單
|
125
101
|
current_step: 步驟%{step}
|
126
102
|
of_total_steps: 的%{total_steps}
|
127
|
-
questionnaire_answered:
|
128
|
-
body: 您已經回答過此表格。
|
129
|
-
title: 已經回答
|
130
103
|
questionnaire_closed:
|
131
|
-
body: 該表格已關閉,無法回答。
|
132
104
|
title: 表單已關閉
|
133
105
|
questionnaire_for_private_users:
|
134
106
|
body: 此表單僅適用於私人使用者
|
@@ -144,8 +116,3 @@ zh-TW:
|
|
144
116
|
back: 返回
|
145
117
|
continue: 繼續
|
146
118
|
submit: 提交
|
147
|
-
user_answers_serializer:
|
148
|
-
body: 回答
|
149
|
-
created_at: 回答時間
|
150
|
-
id: 回答 ID
|
151
|
-
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
|