View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
08348 | Feature requests | Expression Manager | public | 2013-11-07 14:33 | 2016-04-30 19:58 |
Reporter | DenisChenu | Assigned To | |||
Priority | normal | Severity | feature | ||
Status | new | Resolution | open | ||
Summary | 08348: Need some array function in EM | ||||
Description | 1st function : get the value of nth var in an array | ||||
Additional Information | 1st seems helping for me: acces to nth element of array : We can not use [3] in EM. Not find a good name ... 2nd: we already have countifop : but sumifop ? concateifop Better with | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Bug heat | 6 | ||||
Story point estimate | |||||
Users affected % | |||||
related to | 07728 | closed | DenisChenu | Bug reports | Unable to use self.sgqa or this.sgqa |
related to | 08571 | closed | DenisChenu | Feature requests | EM function : array_unique |
related to | 11047 | new | Feature requests | Enable RegEx for Relevance Equations |
Arrays would also be a huge help for sorting issues like this: If you have a survey about health and ask related questions and there is a scoring question for each disease which calculates scores depending on the user's answers it would be very helpful to later sort these X different scores from MAX to MIN using EM to create an output like (disease/score):
|
|
Adding support for formal arrays would be much harder -- and if there was really a need for that, I'd recommend switching away from EM's Recursive Decent Parser and going to using Twig (extending Twig to support the needed EM functionality). Either way, formal arrays is likely to be a very large lift. However, it is very easy to add new functions to EM. Please say more about the features you are trying to add. For example, the list() function is already designed to generate a comma separated list of non-empty answers. array_filter() may not be needed, because the "that.sq_XXX" notation lets you list all variables (or a subset of the variables) within a question. As noted, we already have countifop() and sumifop(). Adding variants like concatenateifop() would be trivial. As an alternate to adding arrays to EM, one option might be to make it easy to create and manipulate JSON from EM. Since JSON is just a string, as far as EM is concerned, someone could add functions to convert the JSON into arrays, hashes, etc. and implement functions like sort(), access the Nth value of an array, etc. Another option is to implement the showAllResponsesExcept( questionList,attributeList,attributeTitleList) or showTheseResponses( questionList,attributeList,attributeTitleList) functions and add a sortBy option. That would solve Mazi's need, which is a very common reporting need. |
|
Aaaaaaaaah !!! Don't know list ..... A great thanks for this ... implode is a bad example then. I search a beter example [nth] , i need it somewhere (think it's for ranking question but maybe it's OK with existing function). For JSON : if i don't make error : it's best to have same functionnality in PHP and in JS ? Maybe i close this one and Add a sort specific. usort/uasort/sort etc ... Maybe you rigth sortBy is the better system. Denis |
|
Thanks for your detailed answer, Tom. Can you explain how to exactly use the list() function? "Return comma-separated list of non-blank values" isn't very clear to me. For what requirements does it makes sense to make use of it? As for the disease example I listed below: A simple sorting function might do the trick. If we use KEY => VALUE notation using question code as KEY and the score as value for sorting, maybe we can find some simple notation to refer to the KEY of a sorted array to be able to use something KEY.question for outputting sorted results within Limesurvey?! |
|
@Mazi : uploade a test survey for list vs implode I don't know if we have to have a Key->value function, think it can be great. Maybe put another FR for sort and [key] ? @Tom : did you think it's more clear if we put 2 new feature request : one for [key] and one for sort with example survey where it can be great ? |
|
@Tom: But we can not use list with javascript actually ? If i do : And i can not have : |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2013-11-07 14:33 | DenisChenu | New Issue | |
2014-01-06 16:26 | Mazi | Note Added: 27726 | |
2014-01-08 06:17 | TMSWhite | Note Added: 27752 | |
2014-01-08 09:25 | DenisChenu | Note Added: 27753 | |
2014-01-08 09:26 | DenisChenu | Relationship added | related to 07728 |
2014-01-08 11:33 | Mazi | Note Added: 27759 | |
2014-01-08 14:00 | DenisChenu | File Added: limesurvey_survey_listimplode.lss | |
2014-01-08 14:02 | DenisChenu | Note Added: 27764 | |
2014-01-08 15:58 | DenisChenu | Note Added: 27767 | |
2014-07-01 09:13 | DenisChenu | Relationship added | related to 08571 |
2016-04-30 19:58 | DenisChenu | Relationship added | related to 11047 |