Download the PHP package sst/survey-lib-bundle without Composer
On this page you can find all versions of the php package sst/survey-lib-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sst/survey-lib-bundle
More information about sst/survey-lib-bundle
Files in sst/survey-lib-bundle
Informations about the package survey-lib-bundle
SST Survey Library Bundle
This bundle provides a library of survey-related Entities and Services for Symfony projects.
License
This bundle is developed by SST Software, see LICENSE for more details.
Installation
- Run
composer require sst/survey-lib-bundle
- Create Entities, based on the interfaces in
Interfaces/Entity
(see below)
Contents
Entities
This bundle provides interfaces and traits to fulfill these, for a general Survey application.
The bundle assumes that these entities are stored in the App\Entity\Survey
namespace, if this is not the case, you can change this in the configuration (see below).
Available Entities with their Traits and Interfaces are:
- Survey: The basis of a survey, contains a list of containers
- Trait:
Sst\SurveyLibBundle\Entity\Traits\SurveyTrait
- Interface:
Sst\SurveyLibBundle\Interfaces\Entity\SurveyInterface
- Trait:
- Container: A container for one or more element-usages or one or more child-containers (use either one, combinations of child-containers and element-usages are not allowed)
- Trait:
Sst\SurveyLibBundle\Entity\Traits\ContainerTrait
- Interface:
Sst\SurveyLibBundle\Interfaces\Entity\ContainerInterface
- Trait:
- Element: The basis of a survey-element, which can be e.g. a question, or a piece of text.
- Trait:
Sst\SurveyLibBundle\Entity\Traits\ElementTrait
- Interface:
Sst\SurveyLibBundle\Interfaces\Entity\ElementInterface
- Trait:
- ElementUsage: An element-usage is a reference to an element, which can be used in a container.
- Trait:
Sst\SurveyLibBundle\Entity\Traits\ElementUsageTrait
- Interface:
Sst\SurveyLibBundle\Interfaces\Entity\ElementUsageInterface
- Trait:
- SurveyResponse: A group of answers, which is the result of a survey being filled in.
- Trait:
Sst\SurveyLibBundle\Entity\Traits\SurveyResponseTrait
- Interface:
Sst\SurveyLibBundle\Interfaces\Entity\SurveyResponseInterface
- Trait:
- Answer: Contains the given answer to an ElementUsage
- Trait:
Sst\SurveyLibBundle\Entity\Traits\AnswerTrait
- Interface:
Sst\SurveyLibBundle\Interfaces\Entity\AnswerInterface
- Trait:
Datamodel
The Element entity and ElementData
The Element entity has a parameter elementData
, in which all data regarding the element can be stored.
ElementData matches the type
of the Element, so make sure you set a valid combination of type
and ElementData
when creating an Element
This bundle provides several default ElementData types:
ElementType | ElementData | Description |
---|---|---|
TEXT | TextQuestionElementDataInterface | Question which can be answered with a text |
NUMBER | NumberQuestionElementDataInterface | Question which can be answered with a number |
DATETIME | DateTimeQuestionElementDataInterface | Question which can be answered with a date or datetime |
MULTIPLE_CHOICE | MultipleChoiceQuestionElementDataInterface | Multiple choice question |
MULTIPLE_CHOICE_GRID | MultipleChoiceGridQuestionElementDataInterface | Question providing a grid of multiple multiple-choice-questions |
SCALE | ScaleQuestionElementDataInterface | Question that can be shown as scale |
INFO | ElementDataInterface | Info-text, to be shown during a survey |
CUSTOM | CustomElementDataInterface | Custom ElementData, to allow for project-specific implementations |
You can extend or overwrite these, as long as your ElementData implements the correct interface, matching the type
of the Element.
Display conditions
This bundle provides a service to check if a given ElementUsage should be displayed, based on a given SurveyResponse.
To identify elements, it uses the code
parameter of the ElementUsage.
The provided displayConditionService
assumes that ElementUsage->display_condition
contains a valid expression, see Symfony Expression Language.
So make sure, this code is unique in the set you are checking, usually this means, that it should be unique in the related survey.
Services
This bundle contains several services to use in your survey-project. These are injected automatically when using their interfaces. This can be overridden by providing a configuration file (see below).
createSurveyResponseService
: Creates a new SurveyResponse, linked to the given survey, with stored start-date and shuffled element-order (if applicable)displayConditionService
: Checks if the given ElementUsage should be displayed, based on a given SurveyResponse, also provided functions to get the condition as php or as javascriptastToJavascriptService
: Converts an AST to javascriptnextElementService
: Gets the next ElementUsage to display for a SurveyResponse, can also be used to get the previous item, by setting$reverse
to trueaddAnswerService
: Adds one or more answers to a SurveyResponse, based on the given ElementUsage and the given rawAnswervalidateAnswerService
: Validates the given answer for a given ElementUsage
Customization
You can customize which class implements which interface by providing a configuration file in your project.
If you want to do so, create a file config/packages/sst_survey_lib.yaml
with the following contents:
These are the default values, if these are the values you need, you don't need to create the file. If you need to change this, copy (parts of) above code into this file.
Events
This bundle provides a few events, which you can listen to.
SurveyResponseCreate::PRE_CREATE
is dispatched before a survey-response is created-
SurveyResponseCreate::POST_CREATE
is dispatched after a survey-response is created AnswerCreate::PRE_CREATE
is dispatched before an answer is createdAnswerCreate::POST_CREATE
is dispatched after an answer is createdAnswerCreate::PRE_UPDATE
is dispatched before an answer is updatedAnswerCreate::POST_UPDATE
is dispatched after an answer is updatedAnswerCreate::PRE_VALIDATE
is dispatched before an answer is validatedAnswerCreate::POST_VALIDATE
is dispatched after an answer is validated
All versions of survey-lib-bundle with dependencies
symfony/http-kernel Version ^6.4 || ^7.0
doctrine/orm Version ^2.14 || ^3.3
symfony/config Version ^6.4 || ^7.0
symfony/dependency-injection Version ^6.4 || ^7.0
doctrine/collections Version ^2.1
symfony/event-dispatcher Version ^6.4 || ^7.0
symfony/expression-language Version ^6.4 || ^7.0
symfony/serializer Version ^6.4 || ^7.0
symfony/property-access Version ^6.4 || ^7.0
stof/doctrine-extensions-bundle Version ^1.7
symfony/validator Version ^6.4 || ^7.0