- Posts: 24
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Access from Twig to URL
1 week 4 days 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
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.
1 week 3 days ago #241400
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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.
1 week 3 days 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.
</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.
1 week 3 days ago #241407
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 12892
- Thank you received: 2371
1 week 3 days ago #241416
by DenisChenu
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.
Replied by DenisChenu on topic Access from Twig to URL
Are you sure of the question code ?[CD] stands for an orange coloured rectangle with the Letters CD in it.
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.
1 week 2 days 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..
{{ 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.