Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Access from Twig to URL

  • erichn
  • erichn's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #241392 by erichn
Access from Twig to URL was created by erichn
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.3.31
Own server or LimeSurvey hosting: Root server
Survey theme/template: own
==================
Depending on several participant conditions, some questions in a Survey get suppressed. This is controlled by pre-defining answer "CD" via the URL, e.g. adding "?CD=3" to the URL. If CD=3, some questions will be skipped using the "conditions"-feature.

This works fine, but now I learned that the calculation of the progress bar gives seemingly wrong results. The value  "progressValue" is always calculated on the base of the number of ALL questions (aSurveyInfo.progress.total) - whether they will be skipped or not. A correction must be made in the "progress_bar.twig". It's just a multiplication with some factor, but I need to know, what case I have, CD=3 or not. So, now my question:

Is there a variable containing the called URL? If so, could you please name it and, second, how could I have found it myself?

Thank you very much1
Kind regards,
Erich

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241400 by tpartner
Replied by tpartner on topic Access from Twig to URL
If CD is a question code, you can use the processString() function to access the value of the question.

Code:
{{ processString('{CD}') }}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • erichn
  • erichn's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #241405 by erichn
Replied by erichn on topic Access from Twig to URL
No, sorry, doesn't work. I put this into the end of progress_bar.twig:

    </div>
    -aa-
    {{ processString('{CD}') }}
    -bb-
    {{aSurveyInfo }}
    -cc-
     {{ getConfig('sitename') }}
    -dd-
{% endif %}


and I got (jpg looks wrong)

            -aa- [CD] -bb- Array -cc LimeSurvey -dd-

[CD] stands for an orange coloured rectangle with the Letters CD in it. {{aSurveyInfo }} gives the correct output and also {{ getConfig('sitename') }}.

Problem might be, that the question "CD" comes later in the questionnaire.

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241407 by tpartner
Replied by tpartner on topic Access from Twig to URL
Yes, you may need to move CD to the first survey page. I tested with list-radio and short-text types.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, erichn

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241416 by DenisChenu
Replied by DenisChenu on topic Access from Twig to URL

[CD] stands for an orange coloured rectangle with the Letters CD in it.
 
Are you sure of the question code ?
manual.limesurvey.org/Expression_Manager#Syntax_Highlighting
 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • erichn
  • erichn's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #241440 by erichn
Replied by erichn on topic Access from Twig to URL
URL is: some_server.de/q/index.php/695374?newtest=Y&lang=de&CD=3

{{
processString('{CD}') }}

gives "3", but onliy within the group containing question CD

I tried
 

{% set uvw = getQuery('CD') %}

also gives 3, but the query-string is only visible within the first call.

In both cases I need the variable "uvw" to be a global variable, because I must correct the value of the progress bar on every page. So, my remaining problem is, to define the variable "uvw" as global. I tried different places for this (e.g. welcome.twig), but with no success. There are several tips in the web, but the all say "define it outside of any blocks", but I couldn't find the right place for this.

Is it possible to define a global variable within the theme editor? Thanks to everybody..
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241443 by DenisChenu
Replied by DenisChenu on topic Access from Twig to URL

{{ processString('{CD}') }}

gives "3", but onliy within the group containing question CD
 
Before it break ?

A good improvement must be done here …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: erichn

Please Log in to join the conversation.

  • erichn
  • erichn's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #241449 by erichn
Replied by erichn on topic Access from Twig to URL

{{ processString('{CD}') }}

gives "3", but onliy within the group containing question CD

 
Before it break ?

A good improvement must be done here …


Ohhh, just wait a bit... I tried this again with one group before and one group after the group CD (actually CD was in the last group).

Start: CD not seen (empty?)
Group 1: again no CD
Group 2: CD has the value from URL (this is the group containing CD)
Group 3: CD still has the same value

So, if I find no solution with a global variable, I have to shift question CD to the first page. I would like to get around this, because actually CD is located in the group, it controls - better for maintenance in some future.

Anyway, I've got a solution. Thanks to you and also to tpartner for your help!

Kind regards,
Erich


 

Please Log in to join the conversation.

  • erichn
  • erichn's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #241515 by erichn
Replied by erichn on topic Access from Twig to URL
Thank you, as far as I found, this is the only solution. For minimum of change I didn't move question CD, but inserted a new question "PAR" at the start of the survey. PAR is also marked as invisible and gets it's information (here the same, as CD) via URL. The URL now looks like

someserver.de/q/index.php/799?lang=en&CD=3&PAR=3

Only one last problem remains, the new column PAR in the output. This should be easily deleted by the following processing. As the Survey and some Childs are already running, some additional logic will be needed to distinguish old an new output. A nice solution would be, if Limesurvey didn't export the new question PAR. Is it possible to suppress output of a question?

Thank you and kinde regards
Erich


 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241516 by tpartner
Replied by tpartner on topic Access from Twig to URL
Please read the manual. You can select which columns to export - manual.limesurvey.org/Exporting_results/...n_.28Excel.2F.csv.29

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: erichn

Please Log in to join the conversation.

  • erichn
  • erichn's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 1 month ago #241523 by erichn
Replied by erichn on topic Access from Twig to URL
As I'm using RPC2, I looked at the wrong place. But here it is also: "export_responses(...array $aFields = ...)". Nearly everything is there...

Thank you for RTFM
Erich

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose