Skip to content

Admin can mark question as mandatory#1386

Merged
oriolgual merged 7 commits intofeature/surveysfrom
feature/surveys-mandatory-questions
May 24, 2017
Merged

Admin can mark question as mandatory#1386
oriolgual merged 7 commits intofeature/surveysfrom
feature/surveys-mandatory-questions

Conversation

@beagleknight
Copy link
Copy Markdown
Contributor

@beagleknight beagleknight commented May 22, 2017

🎩 What? Why?

As an admin I should be able to mark some questions as mandatory so users cannot leave them blank.

I also included some bugfixes and minor refactrors.

📌 Related Issues

📋 Subtasks

  • Admin can mark questions as mandatory from the edit form
  • Users cannot leave mandatory questions blank
  • Refactor javascript template
  • [bug] adding multiple questions and mandatory labels
  • [bug] can't drag and drop new questions

📷 Screenshots (optional)

image
image

👻 GIF

@codecov
Copy link
Copy Markdown

codecov bot commented May 22, 2017

Codecov Report

Merging #1386 into feature/surveys will increase coverage by 0.04%.
The diff coverage is 65%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/surveys    #1386      +/-   ##
===================================================
+ Coverage            94.81%   94.86%   +0.04%     
===================================================
  Files                  444      444              
  Lines                 7546     7554       +8     
===================================================
+ Hits                  7155     7166      +11     
+ Misses                 391      388       -3
Impacted Files Coverage Δ
...veys/app/commands/decidim/surveys/answer_survey.rb 100% <ø> (ø) ⬆️
...im-core/app/helpers/decidim/decidim_form_helper.rb 22.22% <0%> (+0.48%) ⬆️
...urveys/app/models/decidim/surveys/survey_answer.rb 100% <100%> (ø) ⬆️
...m-surveys/app/forms/decidim/surveys/survey_form.rb 100% <100%> (ø) ⬆️
...orms/decidim/surveys/admin/survey_question_form.rb 100% <100%> (ø) ⬆️
...ys/app/forms/decidim/surveys/survey_answer_form.rb 100% <100%> (ø) ⬆️
...pp/commands/decidim/surveys/admin/update_survey.rb 100% <100%> (ø) ⬆️
.../controllers/decidim/surveys/surveys_controller.rb 100% <0%> (+10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e44b7a...d937840. Read the comment docs.

within ".alert.flash" do
expect(page).to have_content("error")
end
expect(page).to have_content("can't be blank")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

within ".alert.flash" do
expect(page).to have_content("error")
end
expect(page).to have_content("can't be blank")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

tabs_id = "#{object_name}-#{name}-tabs"
tabs_id = "#{options[:tabs_prefix]}-#{tabs_id}" if options[:tabs_prefix].present?
tabs_id = options[:tabs_id] || "#{object_name}-#{name}-tabs"
enabled_tabs = options[:enable_tabs] == nil ? true : options[:enable_tabs]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer the use of the nil? predicate.

@mention-bot
Copy link
Copy Markdown

@beagleknight, thanks for your PR! By analyzing the history of the files in this pull request, we identified @oriolgual to be a potential reviewer.

mrcasals
mrcasals previously approved these changes May 24, 2017
validates :body, presence: true, if: -> { question.mandatory? }

def question
@question ||= SurveyQuestion.find(question_id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we scope this to the current feature or organization?

# value - A hash containing the value for each locale.
# options - An optional hash of options.
# * tabs_prefix: A prefix to identify the Foundation tabs element.
# * tabs_id: The id to identify the Foundation tabs element.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing docs for enable_tabs

described_class.from_model(survey)
described_class.from_model(survey).with_context({
current_feature: survey.feature
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indent the right brace the same as the first position after the preceding left parenthesis.

subject do
described_class.from_model(survey)
described_class.from_model(survey).with_context({
current_feature: survey.feature
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.


subject do
described_class.from_model(survey)
described_class.from_model(survey).with_context({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundant curly braces around a hash parameter.

subject do
described_class.from_model(survey_answer).with_context({
current_feature: survey.feature
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indent the right brace the same as the first position after the preceding left parenthesis.


subject do
described_class.from_model(survey_answer).with_context({
current_feature: survey.feature
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.

let!(:survey_answer) { create(:survey_answer, user: user, survey: survey, question: survey_question) }

subject do
described_class.from_model(survey_answer).with_context({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundant curly braces around a hash parameter.

@beagleknight beagleknight mentioned this pull request May 24, 2017
8 tasks
@oriolgual oriolgual merged commit d660080 into feature/surveys May 24, 2017
@oriolgual oriolgual deleted the feature/surveys-mandatory-questions branch May 24, 2017 11:03
beagleknight added a commit that referenced this pull request May 31, 2017
* Admin can mark question as mandatory

* Users must respond mandatory questions

* Fix problems with poltergeist

* Fix rubocop complains

* Fix i18n-issues

* Add feedback

* Fix rubocop complains
beagleknight added a commit that referenced this pull request May 31, 2017
* Add custom styles

* Change from toc to tos

* Fix broken tests

* Fix typo

* Fix spec

* Fix rubocop issues

* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Admin can mark question as mandatory (#1386)

* Admin can mark question as mandatory

* Users must respond mandatory questions

* Fix problems with poltergeist

* Fix rubocop complains

* Fix i18n-issues

* Add feedback

* Fix rubocop complains

* Huge refactor templates

* Fix rubocop issues

* Admins can select question type

* Factor out auto label position code

* Moar refactor

* Huge JS refactor

* Add dynamic answer options for a question

* Admin survey form working with dynamic answer options

* Single and multiple options working

* Fixed rubocop issues

* Fix i18n problems

* Ignore unused i18n

* Add ignore unused

* Add answer option default value

* Fix rectify problem

* Fix minor issues

* Fix a few bad merges

* Fix broken specs
beagleknight added a commit that referenced this pull request Jun 2, 2017
* Add custom styles

* Change from toc to tos

* Fix broken tests

* Fix typo

* Fix spec

* Fix rubocop issues

* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Admin can mark question as mandatory (#1386)

* Admin can mark question as mandatory

* Users must respond mandatory questions

* Fix problems with poltergeist

* Fix rubocop complains

* Fix i18n-issues

* Add feedback

* Fix rubocop complains

* Huge refactor templates

* Fix rubocop issues

* Admins can select question type

* Factor out auto label position code

* Moar refactor

* Huge JS refactor

* Add dynamic answer options for a question

* Admin survey form working with dynamic answer options

* Single and multiple options working

* Fixed rubocop issues

* Fix i18n problems

* Ignore unused i18n

* Add ignore unused

* Add answer option default value

* Fix rectify problem

* Fix minor issues

* Fix a few bad merges

* Fix broken specs
beagleknight added a commit that referenced this pull request Jun 5, 2017
* Add custom styles

* Change from toc to tos

* Fix broken tests

* Fix typo

* Fix spec

* Fix rubocop issues

* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Admin can mark question as mandatory (#1386)

* Admin can mark question as mandatory

* Users must respond mandatory questions

* Fix problems with poltergeist

* Fix rubocop complains

* Fix i18n-issues

* Add feedback

* Fix rubocop complains

* Huge refactor templates

* Fix rubocop issues

* Admins can select question type

* Factor out auto label position code

* Moar refactor

* Huge JS refactor

* Add dynamic answer options for a question

* Admin survey form working with dynamic answer options

* Single and multiple options working

* Fixed rubocop issues

* Fix i18n problems

* Ignore unused i18n

* Add ignore unused

* Add answer option default value

* Fix rectify problem

* Fix minor issues

* Fix a few bad merges

* Fix broken specs
josepjaume pushed a commit that referenced this pull request Jun 6, 2017
* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Survey questions can be sorted using drag and drop (#1373)

* Add basic drag and drop features

* Refactor JS and minor adjustments

* Add missing documentation

* Minor label adjustments

* Fix rubocop complains

* Add missing index

* Add missing feature test

* Fix rubocop issues

* Fix lint errors

* Fix broken specs

* Admin can mark question as mandatory

* Restore missing PRs in feature/surveys (#1421)

* Add custom styles

* Change from toc to tos

* Fix broken tests

* Fix typo

* Fix spec

* Fix rubocop issues

* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Admin can mark question as mandatory (#1386)

* Admin can mark question as mandatory

* Users must respond mandatory questions

* Fix problems with poltergeist

* Fix rubocop complains

* Fix i18n-issues

* Add feedback

* Fix rubocop complains

* Huge refactor templates

* Fix rubocop issues

* Admins can select question type

* Factor out auto label position code

* Moar refactor

* Huge JS refactor

* Add dynamic answer options for a question

* Admin survey form working with dynamic answer options

* Single and multiple options working

* Fixed rubocop issues

* Fix i18n problems

* Ignore unused i18n

* Add ignore unused

* Add answer option default value

* Fix rectify problem

* Fix minor issues

* Fix a few bad merges

* Fix broken specs

* Add survey exports (#1417)

* Add user answers serializer

* Finish export and serializer

* Add admin feature specs

* Fix rubocop issues

* Add allow_answers step setting (#1430)

* Admin cannot modify questions if already answered

* Add step setting to allow/disallow answers

* Fix rubocop issues

* Replace answered? with questions_editable?

* Use available_locales instead of Decidim locales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants