Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decidim-forms

Package Overview
Dependencies
Maintainers
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decidim-forms

  • 0.29.1
  • Rubygems
  • Socket score

Version published
Maintainers
4
Created
Source

Decidim::Forms

This gem encapsulates the logic to create and manage forms, so it can be reused in other modules, like surveys and meetings.

A Decidim::Forms::Question must be of one of the types:

  • short_answer
  • long_answer
  • single_option
  • multiple_option
  • sorting

Here are the relations between the classes of a Decidim::Questionnaire:

                  1..* +----------+         1..* +--------------+
        +------------->| Question |------------->| AnswerOption |
        |              +-----+----+              +------+-------+
        |                    ^ 1..1                     ^ 1..*
        |                    |                          |
        |                    |                          |
+-------+-------+   1..* +---+----+ 1..*         +------+-------+
| Questionnaire +------->| Answer |<-------------+ AnswerChoice |
+---------------+        +---+----+              +--------------+
                             |
                             |
                             v 1..1
                          +--+---+
                          | User |
                          +------+

Installation

Add this line to your module's gemspec:

s.add_dependency "decidim-forms", Decidim::YourModule.version

And then execute:

bundle

Contributing

See Decidim.

License

See Decidim.

Seeds

Since questionnaires cannot exist without a component we are not including specific seeds for this engine.

Other engines are free to include questionnaires on their seeds like this:

Decidim::Forms::Questionnaire.new(
  title: Decidim::Faker::Localized.paragraph,
  description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
    Decidim::Faker::Localized.paragraph(3)
  end,
  tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
    Decidim::Faker::Localized.paragraph(2)
  end,
)

Decidim::Surveys::Survey.create!(component: component, questionnaire: questionnaire)

%w(short_answer long_answer).each do |text_question_type|
  Decidim::Forms::Question.create!(
    questionnaire: questionnaire,
    body: Decidim::Faker::Localized.paragraph,
    question_type: text_question_type
  )
end

%w(single_option multiple_option).each do |multiple_choice_question_type|
  question = Decidim::Forms::Question.create!(
    questionnaire: questionnaire,
    body: Decidim::Faker::Localized.paragraph,
    question_type: multiple_choice_question_type
  )

  3.times do
    question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
  end
end

FAQs

Package last updated on 02 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc