Difference between revisions of "AfterSurveyQuestionAssessment"
From LimeSurvey Manual
Gabrieljenik (talk | contribs) (Created page with "{{FeatureStarting|2.62.0}} NB: Version 2.60.0 is not the same version as 2.6. 2.6 is the new name for 2.06. '''When''' This event is fired after the assessement value for...") |
Gabrieljenik (talk | contribs) |
||
Line 46: | Line 46: | ||
'''Example''' | '''Example''' | ||
+ | One of the use cases could be on open text questions where it could be assessed if a response matches a specific "answer". | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
public function afterSurveyQuestionAssessment() | public function afterSurveyQuestionAssessment() | ||
{ | { | ||
− | + | // Get Event | |
+ | $event = $this->event; | ||
+ | |||
+ | // Fetch Parameters | ||
+ | $surveyId = $event->get('surveyId'); | ||
+ | $lang = $event->get('lang'); | ||
+ | $qid = $event->get('qid'); | ||
+ | $response = $event->get('response'); | ||
+ | |||
+ | if ( strtolower($response) == 'limesurvey') | ||
+ | { | ||
+ | $event->set('assessmentValue', 2); | ||
+ | } | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Plugins events]] | [[Category:Plugins events]] |
Revision as of 17:49, 7 February 2017
NB: Version 2.60.0 is not the same version as 2.6. 2.6 is the new name for 2.06.
When
This event is fired after the assessement value for a question has been calculated.
Input
The event receives the following information:
Name | Type | Description |
---|---|---|
surveyId | int | surveyId for the assessed survey. |
lang | str | language currently being used. |
gid | int | the id of the current group. |
qid | int | the id of the current question. |
sqid | int | the id of the current subquestion (if any). |
aid | string | answer Id (sqga). |
assessmentValue | int | assessment value calculated by default (if any). |
response | int or string | response given by participant |
Possible output
The following information can be set in the event:
Name | Type | Description |
---|---|---|
assessmentValue | int | The new assessment value, overriding the default one |
Example
One of the use cases could be on open text questions where it could be assessed if a response matches a specific "answer".
public function afterSurveyQuestionAssessment()
{
// Get Event
$event = $this->event;
// Fetch Parameters
$surveyId = $event->get('surveyId');
$lang = $event->get('lang');
$qid = $event->get('qid');
$response = $event->get('response');
if ( strtolower($response) == 'limesurvey')
{
$event->set('assessmentValue', 2);
}
}