View Issue Details

IDProjectCategoryView StatusLast Update
15876Feature requestsPluginspublic2020-02-19 15:57
ReporterDenisChenu Assigned To 
PrioritynoneSeverityfeature 
Status newResolutionopen 
Summary15876: afterValidateQuestion event to allow error or relevance by plugins
Description[function _ValidateQuestion](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L6261) can be really interesting to extend.
Additional Information1. _ValidateQuestion is used by _ValidateGroup and _ValidateSurvey : then no need to extend the 2 other _validate
2. _ValidateQuestion allow to set default value OR to set relevance or to set hidden or to set valid/invalid (then disable move next or submit survey)
3. It return [qStatus](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7152) : some index in this array can be updatable

My idea was :
1. Add the event ValidateQuestion after qStatus is set https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7183
2. Send to the event : surveyid, qid, qtstaus + [relevant](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7154) + [hidden](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7155) + [validTip](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7162) + [validJS](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7164) + [mandTip](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7174) + [updatedValues](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7176)
3. Allow to uodate in plugins : [relevant](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7154) + [hidden](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7155) + [validTip](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7162) + [validJS](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7164) + [mandTip](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7174) + [updatedValues](https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L7176)
TagsNo tags attached.

Activities

DenisChenu

DenisChenu

2020-02-14 07:25

developer   ~55993

@ollehar : can be accepted without a plugin and a test ?

I think it's needed for plugin since some year ... for specific validation (for example validate a question via an API)

I can use it in place of [15873: setVariableExpressionEnd have lack of system to udate question part](https://bugs.limesurvey.org/view.php?id=15873)
ollehar

ollehar

2020-02-14 11:03

administrator   ~56004

Use-case?
DenisChenu

DenisChenu

2020-02-14 11:20

developer   ~56009

Oups ... sorry

1. Fill value (if null) by an external API ($updatedValues)
2. Set hidden for [organizeSurvey](https://gitlab.com/SondagesPro/coreAndTools/organizeSurvey/-/blob/master/organizeSurvey.php#L93-96)
3. Control validity by a complex method (call API for example) and set valid tue/false (i din't add it, but needed).

Maybe : create an event here : https://github.com/LimeSurvey/LimeSurvey/blob/03840d3441aa0eb6d2d2bf83d754b591798a6803/application/helpers/expressions/em_manager_helper.php#L6278
And allow update partially `$qInfo` ?
DenisChenu

DenisChenu

2020-02-14 11:22

developer   ~56010

My idea is allowing plugin to update some core part :

hidden,
relevance,
validity,
Subquestion relevance

etc ...

Maybe fix 15873: setVariableExpressionEnd have lack of system to udate question part is better ?
DenisChenu

DenisChenu

2020-02-14 11:23

developer   ~56011

PS:

> _ValidateQuestion allow to set default value OR to set relevance or to set hidden or to set valid/invalid (then disable move next or submit survey)

:)
DenisChenu

DenisChenu

2020-02-19 15:57

developer   ~56098

OK :
> allowing plugin to update some core part

See setVariableExpressionEnd (and fix)

> Control validity by a complex method (call API for example)

Think it can be done with Expression manager function. sample` myApiCheckvalidity(self.NAOK)`

There are no way to set hidden/relevance/etc ... more dinamically (must be in setVariableExpressionEnd)

Issue History

Date Modified Username Field Change
2020-02-14 07:23 DenisChenu New Issue
2020-02-14 07:25 DenisChenu Note Added: 55993
2020-02-14 11:03 ollehar Note Added: 56004
2020-02-14 11:20 DenisChenu Note Added: 56009
2020-02-14 11:22 DenisChenu Note Added: 56010
2020-02-14 11:23 DenisChenu Note Added: 56011
2020-02-19 15:57 DenisChenu Note Added: 56098