decidim-surveys 0.30.1 → 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 +3 -3
- data/app/commands/decidim/surveys/admin/create_survey.rb +14 -2
- data/app/commands/decidim/surveys/admin/publish_survey.rb +3 -3
- data/app/commands/decidim/surveys/admin/update_survey.rb +0 -13
- data/app/commands/decidim/surveys/admin/update_survey_settings.rb +53 -0
- data/app/commands/decidim/surveys/{publish_answers.rb → publish_responses.rb} +8 -8
- data/app/commands/decidim/surveys/{unpublish_answers.rb → unpublish_responses.rb} +8 -8
- data/app/controllers/decidim/surveys/admin/application_controller.rb +13 -0
- data/app/controllers/decidim/surveys/admin/{publish_answers_controller.rb → publish_responses_controller.rb} +9 -9
- data/app/controllers/decidim/surveys/admin/questions/surveys_controller.rb +48 -0
- data/app/controllers/decidim/surveys/admin/{answers_controller.rb → responses_controller.rb} +18 -13
- data/app/controllers/decidim/surveys/admin/settings/surveys_controller.rb +42 -0
- data/app/controllers/decidim/surveys/admin/surveys_controller.rb +20 -39
- data/app/controllers/decidim/surveys/surveys_controller.rb +15 -12
- data/app/forms/decidim/surveys/admin/survey_form.rb +3 -7
- data/app/forms/decidim/surveys/admin/survey_settings_form.rb +18 -0
- data/app/helpers/decidim/surveys/{publish_answers_helper.rb → publish_responses_helper.rb} +11 -11
- data/app/helpers/decidim/surveys/survey_helper.rb +1 -1
- data/app/jobs/decidim/surveys/{clean_survey_answers_job.rb → clean_survey_responses_job.rb} +4 -4
- data/app/jobs/decidim/surveys/settings_change_job.rb +5 -5
- data/app/mailers/decidim/surveys/survey_confirmation_mailer.rb +6 -6
- data/app/models/decidim/surveys/survey.rb +4 -4
- data/app/permissions/decidim/surveys/admin/permissions.rb +6 -4
- data/app/permissions/decidim/surveys/permissions.rb +1 -1
- data/app/serializers/decidim/surveys/data_importer.rb +5 -5
- data/app/serializers/decidim/surveys/data_serializer.rb +5 -5
- data/app/views/decidim/surveys/admin/publish_responses/_toggle_button.html.erb +22 -0
- data/app/views/decidim/surveys/admin/{publish_answers → publish_responses}/index.html.erb +4 -4
- data/app/views/decidim/surveys/admin/questions/surveys/edit.html.erb +44 -0
- data/app/views/decidim/surveys/admin/responses/index.html.erb +101 -0
- data/app/views/decidim/surveys/admin/responses/show.html.erb +43 -0
- data/app/views/decidim/surveys/admin/{surveys → settings/surveys}/_form.html.erb +2 -3
- data/app/views/decidim/surveys/admin/settings/surveys/edit.html.erb +23 -0
- data/app/views/decidim/surveys/admin/surveys/_tabs_menu.html.erb +11 -0
- data/app/views/decidim/surveys/admin/surveys/edit.html.erb +18 -18
- data/app/views/decidim/surveys/admin/surveys/index.html.erb +89 -23
- data/app/views/decidim/surveys/admin/surveys/new.html.erb +23 -0
- data/app/views/decidim/surveys/survey_confirmation_mailer/confirmation.html.erb +1 -1
- data/app/views/decidim/surveys/surveys/{_published_questions_answers.html.erb → _published_questions_responses.html.erb} +2 -2
- data/app/views/decidim/surveys/surveys/not_allowed.html.erb +2 -2
- data/app/views/layouts/decidim/admin/surveys.html.erb +18 -0
- data/config/assets.rb +1 -1
- data/config/locales/ar.yml +0 -20
- data/config/locales/bg.yml +0 -28
- data/config/locales/ca-IT.yml +45 -29
- data/config/locales/ca.yml +45 -29
- data/config/locales/cs.yml +33 -39
- data/config/locales/de.yml +43 -27
- data/config/locales/el.yml +0 -23
- data/config/locales/en.yml +49 -33
- data/config/locales/es-MX.yml +44 -28
- data/config/locales/es-PY.yml +44 -28
- data/config/locales/es.yml +44 -28
- data/config/locales/eu.yml +43 -27
- data/config/locales/fi-plain.yml +41 -25
- data/config/locales/fi.yml +41 -25
- data/config/locales/fr-CA.yml +35 -32
- data/config/locales/fr.yml +35 -32
- data/config/locales/ga-IE.yml +0 -13
- data/config/locales/gl.yml +0 -22
- data/config/locales/hu.yml +0 -16
- data/config/locales/id-ID.yml +0 -15
- data/config/locales/is-IS.yml +0 -2
- data/config/locales/it.yml +0 -22
- data/config/locales/ja.yml +43 -27
- data/config/locales/lb.yml +0 -22
- data/config/locales/lt.yml +0 -25
- data/config/locales/lv.yml +0 -17
- data/config/locales/nl.yml +0 -22
- data/config/locales/no.yml +0 -22
- data/config/locales/pl.yml +0 -30
- data/config/locales/pt-BR.yml +0 -22
- data/config/locales/pt.yml +0 -22
- data/config/locales/ro-RO.yml +18 -23
- data/config/locales/ru.yml +0 -13
- data/config/locales/sk.yml +0 -18
- data/config/locales/sl.yml +0 -8
- data/config/locales/sv.yml +8 -26
- data/config/locales/tr-TR.yml +0 -22
- data/config/locales/uk.yml +0 -13
- data/config/locales/zh-CN.yml +0 -15
- data/config/locales/zh-TW.yml +0 -22
- data/db/migrate/20250317110501_rename_answer_to_response_in_decidim_surveys.rb +8 -0
- data/lib/decidim/api/survey_type.rb +12 -0
- data/lib/decidim/surveys/admin_engine.rb +46 -7
- data/lib/decidim/surveys/component.rb +24 -19
- data/lib/decidim/surveys/engine.rb +8 -25
- data/lib/decidim/surveys/seeds.rb +42 -42
- data/lib/decidim/surveys/test/factories.rb +3 -3
- data/lib/decidim/surveys/version.rb +1 -1
- data/lib/tasks/surveys/upgrade/decidim_surveys_upgrade_tasks.rake +16 -82
- metadata +36 -29
- data/app/queries/decidim/surveys/metrics/answers_metric_manage.rb +0 -65
- data/app/queries/decidim/surveys/metrics/survey_participants_metric_measure.rb +0 -30
- data/app/views/decidim/surveys/admin/answers/index.html.erb +0 -49
- data/app/views/decidim/surveys/admin/answers/show.html.erb +0 -43
- data/app/views/decidim/surveys/admin/publish_answers/_toggle_button.html.erb +0 -22
- data/app/views/decidim/surveys/admin/surveys/edit_questions.html.erb +0 -47
@@ -2,91 +2,25 @@
|
|
2
2
|
|
3
3
|
namespace :decidim_surveys do
|
4
4
|
namespace :upgrade do
|
5
|
-
desc "Migrates
|
6
|
-
task
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
class AnswerOption < ApplicationRecord
|
16
|
-
self.table_name = :decidim_surveys_survey_answer_options
|
17
|
-
end
|
18
|
-
|
19
|
-
class Question < ApplicationRecord
|
20
|
-
self.table_name = :decidim_surveys_survey_questions
|
21
|
-
end
|
22
|
-
|
23
|
-
unless [Answer, AnswerChoice, AnswerOption, Question].all? { |model| ActiveRecord::Base.connection.table_exists? model.table_name }
|
24
|
-
puts "ERROR: There are not all the necessary surveys tables. Have you already migrated the data?"
|
25
|
-
next
|
5
|
+
desc "Migrates the component permission from answer to respond"
|
6
|
+
task fix_survey_permissions: :environment do
|
7
|
+
Decidim::Component.where(manifest_name: "surveys").find_each do |component|
|
8
|
+
next if component.permissions.nil?
|
9
|
+
|
10
|
+
if component.permissions.is_a?(Hash) && component.permissions.has_key?("answer")
|
11
|
+
component.permissions["respond"] = component.permissions["answer"]
|
12
|
+
component.permissions.delete("answer")
|
13
|
+
component.save!
|
14
|
+
end
|
26
15
|
end
|
27
16
|
|
28
|
-
|
29
|
-
|
30
|
-
puts "Migrating survey #{survey.id}..."
|
31
|
-
|
32
|
-
questionnaire = Decidim::Forms::Questionnaire.create!(
|
33
|
-
questionnaire_for: survey,
|
34
|
-
title: survey.title,
|
35
|
-
description: survey.description,
|
36
|
-
tos: survey.tos,
|
37
|
-
published_at: survey.published_at,
|
38
|
-
created_at: survey.created_at,
|
39
|
-
updated_at: survey.updated_at
|
40
|
-
)
|
41
|
-
|
42
|
-
Question.where(decidim_survey_id: survey.id).find_each do |survey_question|
|
43
|
-
puts "Migrating question #{survey_question.id}..."
|
44
|
-
|
45
|
-
question = Decidim::Forms::Question.create!(
|
46
|
-
questionnaire:,
|
47
|
-
position: survey_question.position,
|
48
|
-
question_type: survey_question.question_type,
|
49
|
-
mandatory: survey_question.mandatory,
|
50
|
-
body: survey_question.body,
|
51
|
-
description: survey_question.description,
|
52
|
-
max_choices: survey_question.max_choices,
|
53
|
-
created_at: survey_question.created_at,
|
54
|
-
updated_at: survey_question.updated_at
|
55
|
-
)
|
56
|
-
|
57
|
-
# A hash with the old answer_option id as key, and the new form answer option as value
|
58
|
-
answer_option_mapping = {}
|
59
|
-
|
60
|
-
AnswerOption.where(decidim_survey_question_id: survey_question.id).find_each do |survey_answer_option|
|
61
|
-
answer_option_mapping[survey_answer_option.id] = Decidim::Forms::AnswerOption.create!(
|
62
|
-
question:,
|
63
|
-
body: survey_answer_option.body,
|
64
|
-
free_text: survey_answer_option.free_text
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
Answer.where(decidim_survey_id: survey.id, decidim_survey_question_id: survey_question.id).find_each do |survey_answer|
|
69
|
-
answer = Decidim::Forms::Answer.new(
|
70
|
-
questionnaire:,
|
71
|
-
question:,
|
72
|
-
decidim_user_id: survey_answer.decidim_user_id,
|
73
|
-
body: survey_answer.body,
|
74
|
-
created_at: survey_answer.created_at,
|
75
|
-
updated_at: survey_answer.updated_at
|
76
|
-
)
|
77
|
-
|
78
|
-
AnswerChoice.where(decidim_survey_answer_id: survey_answer.id).find_each do |survey_answer_choice|
|
79
|
-
answer.choices.build(
|
80
|
-
answer_option: answer_option_mapping[survey_answer_choice.decidim_survey_answer_option_id],
|
81
|
-
body: survey_answer_choice.body,
|
82
|
-
custom_body: survey_answer_choice.custom_body,
|
83
|
-
position: survey_answer_choice.position
|
84
|
-
)
|
85
|
-
end
|
17
|
+
Decidim::ResourcePermission.where(resource_type: "Decidim::Surveys::Survey").find_each do |resource|
|
18
|
+
next if resource.permissions.nil?
|
86
19
|
|
87
|
-
|
88
|
-
|
89
|
-
|
20
|
+
if resource.permissions.is_a?(Hash) && resource.permissions.has_key?("answer")
|
21
|
+
resource.permissions["respond"] = resource.permissions["answer"]
|
22
|
+
resource.permissions.delete("answer")
|
23
|
+
resource.save!
|
90
24
|
end
|
91
25
|
end
|
92
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-surveys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2025-
|
13
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-core
|
@@ -18,84 +18,84 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.31.0.rc1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.31.0.rc1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: decidim-forms
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.31.0.rc1
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.31.0.rc1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: decidim-admin
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - '='
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.31.0.rc1
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - '='
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.31.0.rc1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: decidim-dev
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - '='
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.
|
63
|
+
version: 0.31.0.rc1
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - '='
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0.
|
70
|
+
version: 0.31.0.rc1
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: decidim-participatory_processes
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 0.31.0.rc1
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - '='
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.
|
84
|
+
version: 0.31.0.rc1
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: decidim-templates
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - '='
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.
|
91
|
+
version: 0.31.0.rc1
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - '='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.
|
98
|
+
version: 0.31.0.rc1
|
99
99
|
description: A surveys component for decidim's participatory spaces.
|
100
100
|
email:
|
101
101
|
- josepjaume@gmail.com
|
@@ -116,22 +116,26 @@ files:
|
|
116
116
|
- app/commands/decidim/surveys/admin/publish_survey.rb
|
117
117
|
- app/commands/decidim/surveys/admin/unpublish_survey.rb
|
118
118
|
- app/commands/decidim/surveys/admin/update_survey.rb
|
119
|
-
- app/commands/decidim/surveys/
|
120
|
-
- app/commands/decidim/surveys/
|
119
|
+
- app/commands/decidim/surveys/admin/update_survey_settings.rb
|
120
|
+
- app/commands/decidim/surveys/publish_responses.rb
|
121
|
+
- app/commands/decidim/surveys/unpublish_responses.rb
|
121
122
|
- app/controllers/concerns/decidim/surveys/admin/filterable.rb
|
122
|
-
- app/controllers/decidim/surveys/admin/answers_controller.rb
|
123
123
|
- app/controllers/decidim/surveys/admin/application_controller.rb
|
124
|
-
- app/controllers/decidim/surveys/admin/
|
124
|
+
- app/controllers/decidim/surveys/admin/publish_responses_controller.rb
|
125
|
+
- app/controllers/decidim/surveys/admin/questions/surveys_controller.rb
|
126
|
+
- app/controllers/decidim/surveys/admin/responses_controller.rb
|
127
|
+
- app/controllers/decidim/surveys/admin/settings/surveys_controller.rb
|
125
128
|
- app/controllers/decidim/surveys/admin/surveys_controller.rb
|
126
129
|
- app/controllers/decidim/surveys/application_controller.rb
|
127
130
|
- app/controllers/decidim/surveys/surveys_controller.rb
|
128
131
|
- app/events/decidim/surveys/closed_survey_event.rb
|
129
132
|
- app/events/decidim/surveys/opened_survey_event.rb
|
130
133
|
- app/forms/decidim/surveys/admin/survey_form.rb
|
134
|
+
- app/forms/decidim/surveys/admin/survey_settings_form.rb
|
131
135
|
- app/helpers/decidim/surveys/application_helper.rb
|
132
|
-
- app/helpers/decidim/surveys/
|
136
|
+
- app/helpers/decidim/surveys/publish_responses_helper.rb
|
133
137
|
- app/helpers/decidim/surveys/survey_helper.rb
|
134
|
-
- app/jobs/decidim/surveys/
|
138
|
+
- app/jobs/decidim/surveys/clean_survey_responses_job.rb
|
135
139
|
- app/jobs/decidim/surveys/settings_change_job.rb
|
136
140
|
- app/mailers/decidim/surveys/survey_confirmation_mailer.rb
|
137
141
|
- app/models/decidim/surveys/application_record.rb
|
@@ -139,25 +143,27 @@ files:
|
|
139
143
|
- app/permissions/decidim/surveys/admin/permissions.rb
|
140
144
|
- app/permissions/decidim/surveys/permissions.rb
|
141
145
|
- app/presenters/decidim/surveys/admin_log/survey_presenter.rb
|
142
|
-
- app/queries/decidim/surveys/metrics/answers_metric_manage.rb
|
143
|
-
- app/queries/decidim/surveys/metrics/survey_participants_metric_measure.rb
|
144
146
|
- app/serializers/decidim/surveys/data_importer.rb
|
145
147
|
- app/serializers/decidim/surveys/data_serializer.rb
|
146
|
-
- app/views/decidim/surveys/admin/
|
147
|
-
- app/views/decidim/surveys/admin/
|
148
|
-
- app/views/decidim/surveys/admin/
|
149
|
-
- app/views/decidim/surveys/admin/
|
150
|
-
- app/views/decidim/surveys/admin/
|
148
|
+
- app/views/decidim/surveys/admin/publish_responses/_toggle_button.html.erb
|
149
|
+
- app/views/decidim/surveys/admin/publish_responses/index.html.erb
|
150
|
+
- app/views/decidim/surveys/admin/questions/surveys/edit.html.erb
|
151
|
+
- app/views/decidim/surveys/admin/responses/index.html.erb
|
152
|
+
- app/views/decidim/surveys/admin/responses/show.html.erb
|
153
|
+
- app/views/decidim/surveys/admin/settings/surveys/_form.html.erb
|
154
|
+
- app/views/decidim/surveys/admin/settings/surveys/edit.html.erb
|
155
|
+
- app/views/decidim/surveys/admin/surveys/_tabs_menu.html.erb
|
151
156
|
- app/views/decidim/surveys/admin/surveys/edit.html.erb
|
152
|
-
- app/views/decidim/surveys/admin/surveys/edit_questions.html.erb
|
153
157
|
- app/views/decidim/surveys/admin/surveys/index.html.erb
|
158
|
+
- app/views/decidim/surveys/admin/surveys/new.html.erb
|
154
159
|
- app/views/decidim/surveys/survey_confirmation_mailer/confirmation.html.erb
|
155
|
-
- app/views/decidim/surveys/surveys/
|
160
|
+
- app/views/decidim/surveys/surveys/_published_questions_responses.html.erb
|
156
161
|
- app/views/decidim/surveys/surveys/_surveys.html.erb
|
157
162
|
- app/views/decidim/surveys/surveys/index.html.erb
|
158
163
|
- app/views/decidim/surveys/surveys/index.js.erb
|
159
164
|
- app/views/decidim/surveys/surveys/no_permission.html.erb
|
160
165
|
- app/views/decidim/surveys/surveys/not_allowed.html.erb
|
166
|
+
- app/views/layouts/decidim/admin/surveys.html.erb
|
161
167
|
- config/assets.rb
|
162
168
|
- config/locales/am-ET.yml
|
163
169
|
- config/locales/ar-SA.yml
|
@@ -267,6 +273,7 @@ files:
|
|
267
273
|
- db/migrate/20240828103030_add_deleted_at_to_decidim_surveys_surveys.rb
|
268
274
|
- db/migrate/20240925124312_add_settings_to_decidim_surveys_surveys.rb
|
269
275
|
- db/migrate/20250115193836_add_allow_survey_editing.rb
|
276
|
+
- db/migrate/20250317110501_rename_answer_to_response_in_decidim_surveys.rb
|
270
277
|
- decidim-surveys.gemspec
|
271
278
|
- lib/decidim/api/survey_type.rb
|
272
279
|
- lib/decidim/api/surveys_type.rb
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Surveys
|
5
|
-
module Metrics
|
6
|
-
class AnswersMetricManage < Decidim::MetricManage
|
7
|
-
def metric_name
|
8
|
-
"survey_answers"
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
query.each do |key, results|
|
13
|
-
cumulative_value = results[:cumulative]
|
14
|
-
next if cumulative_value.zero?
|
15
|
-
|
16
|
-
quantity_value = results[:quantity] || 0
|
17
|
-
space_type, space_id, survey_id = key
|
18
|
-
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
19
|
-
organization: @organization, decidim_taxonomy_id: nil,
|
20
|
-
participatory_space_type: space_type, participatory_space_id: space_id,
|
21
|
-
related_object_type: Decidim::Surveys::Survey.name, related_object_id: survey_id)
|
22
|
-
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
23
|
-
record.save!
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def query
|
30
|
-
return @query if @query
|
31
|
-
|
32
|
-
@query = retrieve_surveys.each_with_object({}) do |survey, grouped_answers|
|
33
|
-
answers = Decidim::Forms::Answer.joins(:questionnaire)
|
34
|
-
.where(questionnaire: retrieve_questionnaires(survey))
|
35
|
-
.where(decidim_forms_answers: { created_at: ..end_time })
|
36
|
-
next grouped_answers unless answers
|
37
|
-
|
38
|
-
group_key = generate_group_key(survey)
|
39
|
-
grouped_answers[group_key] ||= { cumulative: 0, quantity: 0 }
|
40
|
-
grouped_answers[group_key][:cumulative] += answers.count
|
41
|
-
grouped_answers[group_key][:quantity] += answers.where(decidim_forms_answers: { created_at: start_time.. }).count
|
42
|
-
end
|
43
|
-
@query
|
44
|
-
end
|
45
|
-
|
46
|
-
def retrieve_surveys
|
47
|
-
Decidim::Surveys::Survey.where(component: visible_components_from_spaces(retrieve_participatory_spaces))
|
48
|
-
end
|
49
|
-
|
50
|
-
def retrieve_questionnaires(survey)
|
51
|
-
Decidim::Forms::Questionnaire.includes(:questionnaire_for)
|
52
|
-
.where(questionnaire_for: survey)
|
53
|
-
end
|
54
|
-
|
55
|
-
def generate_group_key(survey)
|
56
|
-
participatory_space = survey.participatory_space
|
57
|
-
group_key = []
|
58
|
-
group_key += [participatory_space.class.name, participatory_space.id]
|
59
|
-
group_key += [survey.id]
|
60
|
-
group_key
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Surveys
|
5
|
-
module Metrics
|
6
|
-
# Searches for Participants in the following actions
|
7
|
-
# - Answer a survey (Surveys)
|
8
|
-
class SurveyParticipantsMetricMeasure < Decidim::MetricMeasure
|
9
|
-
def valid?
|
10
|
-
super && @resource.is_a?(Decidim::Component)
|
11
|
-
end
|
12
|
-
|
13
|
-
def calculate
|
14
|
-
surveys = Decidim::Surveys::Survey.joins(:component, :questionnaire).where(component: @resource)
|
15
|
-
questionnaires = Decidim::Forms::Questionnaire.includes(:questionnaire_for)
|
16
|
-
.where(questionnaire_for_type: Decidim::Surveys::Survey.name, questionnaire_for_id: surveys.pluck(:id))
|
17
|
-
|
18
|
-
answers = Decidim::Forms::Answer.joins(:questionnaire)
|
19
|
-
.where(questionnaire: questionnaires)
|
20
|
-
.where(decidim_forms_answers: { created_at: ..end_time })
|
21
|
-
|
22
|
-
{
|
23
|
-
cumulative_users: answers.pluck(:decidim_user_id).uniq,
|
24
|
-
quantity_users: answers.where(decidim_forms_answers: { created_at: start_time.. }).pluck(:decidim_user_id).uniq
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -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 class="!text-left"><%= 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 class="!text-left">
|
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,22 +0,0 @@
|
|
1
|
-
<div class="toggle__switch-trigger float-right">
|
2
|
-
<% label = "publish_answer_#{question.id}" %>
|
3
|
-
<label for="<%= label %>" class="toggle__switch-toggle">
|
4
|
-
<span class="toggle__switch-trigger-text">
|
5
|
-
<%= content_tag(:span, class: "label success ml-[-8.5rem] mt-1 #{"hidden" if question.survey_answers_published_at.blank?}") { t("status.published", scope: "decidim.surveys.admin.publish_answers.index") } %>
|
6
|
-
<%= content_tag(:span, class: "label alert -ml-40 mt-1 #{"hidden" if question.survey_answers_published_at.present?}") { t("status.not_published", scope: "decidim.surveys.admin.publish_answers.index") } %>
|
7
|
-
</span>
|
8
|
-
<span>
|
9
|
-
<input
|
10
|
-
<%== %(checked="checked") if question.survey_answers_published_at.present? %>
|
11
|
-
id="<%= label %>"
|
12
|
-
type="checkbox"
|
13
|
-
name="<%= label %>"
|
14
|
-
data-publish-question-answer-action="<%= question.survey_answers_published_at.present? ? "unpublish" : "publish" %>"
|
15
|
-
data-publish-question-answer-question-url="<%= survey_publish_answer_path(params[:survey_id], question) %>">
|
16
|
-
<span class="toggle__switch-toggle-content">
|
17
|
-
</span>
|
18
|
-
<%= icon "check-line", class: "toggle__switch-toggle-icon" %>
|
19
|
-
<%= icon "close-line", class: "toggle__switch-toggle-icon" %>
|
20
|
-
</span>
|
21
|
-
</label>
|
22
|
-
</div>
|
@@ -1,47 +0,0 @@
|
|
1
|
-
<% add_decidim_page_title(t("decidim.forms.admin.questionnaires.edit_questions.title")) %>
|
2
|
-
|
3
|
-
<% if templates_defined? && choose_template? %>
|
4
|
-
<%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title") } %>
|
5
|
-
<% else %>
|
6
|
-
|
7
|
-
<div class="questionnaire-questions">
|
8
|
-
<div class="item_show__header">
|
9
|
-
<h1 class="item_show__header-title">
|
10
|
-
<%= t("decidim.forms.admin.questionnaires.edit_questions.title") %>
|
11
|
-
<% if questionnaire.questions_editable? %>
|
12
|
-
<button class="button button__sm button__secondary add-question"><%= t("add_question", scope: "decidim.forms.admin.questionnaires.edit_questions") %></button>
|
13
|
-
<button class="button button__sm button__secondary add-separator"><%= t("add_separator", scope: "decidim.forms.admin.questionnaires.edit_questions") %></button>
|
14
|
-
<button class="button button__sm button__secondary add-title-and-description"><%= t("add_title_and_description", scope: "decidim.forms.admin.questionnaires.edit_questions") %></button>
|
15
|
-
<% end %>
|
16
|
-
<% if allowed_to? :preview, :questionnaire %>
|
17
|
-
<%= link_to t("preview", scope: "decidim.forms.admin.questionnaires.form"), public_url, class: "button button__sm button__transparent-secondary", target: :_blank, data: { "external-link": false } %>
|
18
|
-
<% end %>
|
19
|
-
<% if questionnaire.answers.any? %>
|
20
|
-
<%= export_dropdown(current_component, questionnaire.id) if allowed_to? :export_answers, :questionnaire %>
|
21
|
-
<% if allowed_to? :show, :questionnaire_answers %>
|
22
|
-
<%= link_to t("actions.show", scope: "decidim.forms.admin.questionnaires"), questionnaire_participants_url, class: "button button__sm button__secondary new whitespace-nowrap" %>
|
23
|
-
<% end %>
|
24
|
-
<% if allowed_to? :index, :questionnaire_publish_answers, survey: @survey %>
|
25
|
-
<%= link_to t("actions.publish_answers", scope: "decidim.forms.admin.questionnaires"), survey_publish_answers_path(survey_id: params[:id]), class: "button button__sm button__secondary new" %>
|
26
|
-
<% end %>
|
27
|
-
<% else %>
|
28
|
-
<button class="button button__sm button__secondary whitespace-nowrap" disabled><%= t("empty", scope: "decidim.forms.admin.questionnaires.answers") %></button>
|
29
|
-
<% end %>
|
30
|
-
</h1>
|
31
|
-
</div>
|
32
|
-
</div>
|
33
|
-
|
34
|
-
<div class="item__edit item__edit-1col">
|
35
|
-
<div class="item__edit-form">
|
36
|
-
<%= decidim_form_for(@form, url: update_questions_survey_path(@survey), method: :patch, html: { class: "form-defaults form edit_questions_survey" }) do |form| %>
|
37
|
-
<%= render partial: "decidim/forms/admin/questionnaires/questions_form", object: form %>
|
38
|
-
<div class="item__edit-sticky">
|
39
|
-
<div class="item__edit-sticky-container">
|
40
|
-
<%= form.submit t("save", scope: "decidim.forms.admin.questionnaires.edit"), class: "button button__sm button__secondary" %>
|
41
|
-
</div>
|
42
|
-
</div>
|
43
|
-
<% end %>
|
44
|
-
</div>
|
45
|
-
</div>
|
46
|
-
|
47
|
-
<% end %>
|