Welcome, Guest
Username: Password: Remember me

TOPIC: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values

Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84144

  • abita1
  • abita1's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 44
  • Thank you received: 1
  • Karma: 0
I am using 1.92+ -- [as modified by Tom S, for excel imports, probably approximating the status of current to build 120726, or so...]

In the online manual, there is a survey sample, derived from a Joy Lane Research survey, with "Cascading Array Filters" that effectively places appropriate relevance strings into the subquestion [answer] records in the database for a multiple choice question [Type M]. This works, when imported into my 192+.

The sample, when loaded, in the QA report, clearly shows relevance values associated with subquestions [the answers to a multiple choice question type]; they include, in the second question there, entries such as:
(( ! is_empty(Q01_A.NAOK)))
Elsewhere, the manual also has this comment: "
Internally, all array_filter and array_filter_exclude commands become sub-question-level relevance" [see: docs.limesurvey.org/Expression+Manager+HowTos].
Try as I may, I have never been able to land values, in the form within the Sample Survey, in the relevance field for a Type M SubQ, in the database.

I have tried:
  • Placing the QCode for the first question, into the second questions' "array filter", just like the Joy Research QA shows;
  • Using the excel survey import, placing values there in the proper column, and;
  • stuffing values in the various fields, in other combinations -- fields such as the "array filter", "array filter exclusion" and "exclusive option" (tried merely to see if anything helpful happens; I report that nothing does...).
From reading other posts, and trolling the whole program, I am aware that the UI does not yet provide a clean system for enter SubQ Relevance values, but obviously Joy Research managed to get the values inside the database. I am also aware that I could create a slew of questions, with their own relevance, as a poor man's approach.

Can anyone provide a clue, outside of a manual SQL command for an SQL insert? Am I missing some other setting that needs attention, beyond merely inserting strings with appropriate values into some fields on the question edit form? I've left the second question's relevance blank, unlike in the sample, as that made sense for my question -- yet, I don't see how that would rationally impact the SubQ relevance entries anyhow.
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84146

  • abita1
  • abita1's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 44
  • Thank you received: 1
  • Karma: 0
Ok....On another manual page, I discovered a problem I caused:

My answers to the second question are not identical to the first -- If I am reading the manual right, this breaks the code somehow.

What perplexes me now, however, is why that trait (the identify of answers) is even considered. Clearly, the LS-code recognizes a way to make the SubQ/Answer disappear, if the the relevance expression evaluates true.

I understand it makes sense, perhaps, in the context of using the "array" field as a tool to use LS code to construct a set of SubQ relevance strings -- though I could imagine other ways to expand a question reference [say, by example, of requiring the same NUMBER of subQ's, rather than the same number AND the same IDENTITY of contents in series. Especially since the SubQCodes are different...

So . . . I wonder . . . If I manage to make a manual insert in the SQL database for an SubQ relevance string, would the program work?

Or, easier...If I amended the excel import code at import_functions.php, at lines 1885 et seq., to retrieve the values from the excel file in the relevance column, and insert relevance-strings into the database . . .

Would the program behave, and NOT display a SubQ when the relevance expression evaluated FALSE ???
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84181

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
It is possible to use different sets of sub-questions identifiers across sets of questions and still have array_filter work.

Simply adding relevance to a sub-question in the database will not work. Here is a description of the work that would be needed to get sub-question level relevance (and/or validation and/or mandatory) working.
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84183

  • abita1
  • abita1's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 44
  • Thank you received: 1
  • Karma: 0
Thanks, Tom. I was thinking about this topic, this morning, and reformulated a mindset -- realizing that cascading [across >=3 questions] requires internal logic to be established -- as opposed to the simple case where a subQ reaches only one question back.

And now, reading through the URL you provide [the description...], I am still perplexed, regarding the extended needs. Do you mean to note that there is a working barrier to making reaching back to 1-question, too?

And...to work cascades...the normalized state is not "Checked", rather, the states: "Present" and "Checked" -- which is what I assume the code accomplishes to make cascading work. "Answered" is a state that is provided via EM, but, I wonder, is there an EM variable for "Present" [as in..."displayed"...?]
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84191

  • abita1
  • abita1's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 44
  • Thank you received: 1
  • Karma: 0
Tom: I notice/infer that

1. question_attributes is the only place that stores the existence of a cascade, with the value in array_field. No derived value for the intended relevance is stored in the question table, for the SubQ relevance field.
2. The QA report for relevance fields' values for cascaded question is not derived from that field, rather it is calculated
3. Every time a participant runs a survey, the array_field is reexploded.

Do I have that right? Why those choices?

In a cascade of n>=2 questions, the display of Q2-SubQm depends on two normalized traits: First, that Q1-SubQm is both answered
(( ! is_empty(Q01_A.NAOK)))
and second, it is displayed. Is there an EM function, such as "isDisplayed". If there was, one could merely store
(( ! is_empty(Q01_A.NAOK)) and (isDisplayed(Q01_A)))
in the Q2-SubQm relevance field in the database.

Then, the rule would simply be, if you entered an array_field, it would overwrite any manual entry in the SubQ relevance.

I am curious: Which JS code/file in the participants generated page is executing the CSS toggle of "display: none"? Which PHP file is generating that JS code? [I assume it is there that the array_field is again blown up, rather than looking towards the database?
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84199

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
abita1 wrote:
Thanks, Tom. I was thinking about this topic, this morning, and reformulated a mindset -- realizing that cascading [across >=3 questions] requires internal logic to be established -- as opposed to the simple case where a subQ reaches only one question back.

EM does support cascading across multiple questions. If Q3 depends upon Q2 which depends upon Q1, then for each sub-question in Q3, EM checks whether that sub-question exists in Q2 and/or Q1. So, you can have a Q3 (or Qn) that depends on several other questions. Here is a working example that asks for favorite colors (q1) and animals (q2), then has you rate those pooled favorites from 1-5 (also requiring that you only use each rating once).

File Attachment:

File Name: limesurvey_survey_24865.lss
File Size: 34 KB


combined_array_filter.jpg

abita1 wrote:
is there an EM variable for "Present" [as in..."displayed"...?]

Yes,
qcode.relevanceStatus
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84200

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
abita1 wrote:
Tom: I notice/infer that

1. question_attributes is the only place that stores the existence of a cascade, with the value in array_field. No derived value for the intended relevance is stored in the question table, for the SubQ relevance field.
2. The QA report for relevance fields' values for cascaded question is not derived from that field, rather it is calculated
3. Every time a participant runs a survey, the array_field is reexploded.

Do I have that right? Why those choices?

That is essentially correct.
1. Cascading information is stored in the question_attributes table, fields 'array_filter', 'array_filter_exclude', 'exclusive_option', and 'exclude_all_others_auto'.
2. The relevance equations relating to those cascading choices are re-computed/exploded each time the survey is run. The QA (Show Logic File) button shows the generated equation. 3. That generated equation is intentionally NOT stored in the sub-question relevance field for several reasons:
(a) That way we can use the sub-question relevance field separately and AND together anything entered there with the contents of the generated cascaded information.
(b) The generated cascading logic depends upon the source and target question types, and thus can be hard to read and maintain. Similarly, those computed relevance fields would need to be updated each time an author changes a question type.
(c) LimeSurvey doesn't currently read the contents of the sub-question relevance field into fieldMap, so even if that field were populated, LimeSurvey would not be able to use it.

So, by auto-generating the cascading logic, we're giving more future flexibility with the plans to let people enter additional sub-question relevance criteria and still array-filter those sub-questions too (without needing to worry that the array-filter code would corrupt any manually entered sub-question relevance criteria.
abita1 wrote:
In a cascade of n>=2 questions, the display of Q2-SubQm depends on two normalized traits: First, that Q1-SubQm is both answered
(( ! is_empty(Q01_A.NAOK)))
and second, it is displayed. Is there an EM function, such as "isDisplayed". If there was, one could merely store
(( ! is_empty(Q01_A.NAOK)) and (isDisplayed(Q01_A)))
in the Q2-SubQm relevance field in the database.

There is no isDisplayed() function, however, you get the same answer from the following, since 'relevanceStatus' determines whether a question is displayed:
Q01_A.relevanceStatus
abita1 wrote:
Then, the rule would simply be, if you entered an array_field, it would overwrite any manual entry in the SubQ relevance.

When we do have a GUI for entering manual sub-question relevance, this sounds like a nice idea. Alternatively, if you use a different sub-question code (one that can not be array-filtered), then you don't have to worry about a conflict between what is filtered and your hand-entered equations.
abita1 wrote:
I am curious: Which JS code/file in the participants generated page is executing the CSS toggle of "display: none"? Which PHP file is generating that JS code? I assume it is there that the array_field is again blown up, rather than looking towards the database?

All of the cascading logic is generated by LimeExpressionManager.php. The CreateRelevanceAndTailoringJavaScript() function generates the JavaScript ExprMgr_process_relevance_and_tailoring() function that controls all of the dynamic features.
Last Edit: 2 years 3 months ago by TMSWhite.
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84202

  • abita1
  • abita1's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 44
  • Thank you received: 1
  • Karma: 0
Alternatively, if you use a different sub-question code (one that can not be array-filtered), then you don't have to worry about a conflict between what is filtered and your hand-entered equations.
Do you mean: A different SubQ field in the database? But that implies that array_field is coded as ANDed with that field.? I like this idea. Some of these issues go away with a normalized DB, filled with the designers' rules, and the code merely acts; now, the code does both.
Similarly, those computed relevance fields would need to be updated each time an author changes a question type.
I didn't see that as a problem. LS spends a zillion cycles regenerating them for each participant anyway, right? Plus...if someone wanted to, they could code the array directly for cascading with complex values. Then...a new DB column for array_field relevance values solves -that-....!

[quotewithout needing to worry that the array-filter code would corrupt any manually entered sub-question relevance criteria.[/quote]
Expanding the DB with another field, for Code Generated EM (say, for cascades) solves that problem, provided you want to always AND that code with the manual relevance. Yes?

Worth repeating, here: I like the idea of using code, directed by commands at the DesignerUI, to generate survey DB fields. It reduces the complexity of coding, by simply using the code to generate status. If someone wants to make a plug in that quickly fills in blanks, it becomes simple.

There would be, then, three effective parts: a) a JS/HTML code generating engine that b) relies on a DB for all designed elements' retrieval c) with data put in the DB by a Designer UI front end.

If someone, now, wanted to make a routine that generated a survey skeleton from a user entry [or a simple excel input], or to create the DB entries for a cascade of questions, -those- type of encodings become entangled because a) b) and c) are entangled.

In fairness...I realize I'm new to the code base, here. But: normalizing DB and variable definitions; code commenting; segregating functional layers of code -- all that makes for better openSource effort....?
Last Edit: 2 years 3 months ago by abita1.
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84203

  • abita1
  • abita1's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 44
  • Thank you received: 1
  • Karma: 0
More learning curve questions:

What code file contains the effort that makes a "field map" not recover the SubQ relevence column?

Am I thinking this through: a simple solution to a quickKill for providing a SubQ relevance:
1) Amending that file, above, to recover the data from the survey DB on participant execution [that's what the field mapping does?].
2) Amending the LimeExpressionManager.php to recognize the SubQ relevance value and act on it, if present, by allowing for a display toggle of the SubQ.
2a) Telling Designers that they can do only one or the other - SubQ relevance or array cascading - on any given question....at least until a new column is created in the DB, and all cascade info is placed and recovered from there.
3) Amending the ExcelSurvey import to read in the data to the DB
Last Edit: 2 years 3 months ago by abita1.
The administrator has disabled public write access.

Re: Subquestion Relevance - Cascading Arrary Filtering -- how to insert values 2 years 3 months ago #84204

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
abita1-

I appreciate the thoughts. It isn't quite as simple as you say, otherwise I would have already done this myself. However, it isn't rocket science, and should only take a few days/weeks of programming effort depending upon the quality and experience (with LimeSurvey) of the developer.

I'm going to cease being available to do Expression Manager enhancements in 2-3 weeks due to other commitments. So, if you are a developer and want to add that functionality yourself, please fork LimeSurvey on GitHub and I (and hopefully other developer too) can guide you through what needs to be done. Alternatively, if you want to pay someone to make those enhancements, please send a private message to see if you can come to a mutually agreeable arrangement.

/Tom
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.646 seconds
Donation Image