Welcome to the LimeSurvey Community Forum

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

Keep token linked info (attributes) when changing language in survey

More
3 weeks 1 day ago #272813 by dvilchez
Your LimeSurvey version: 6.15.16
Own server or LimeSurvey hosting: Lime survey Hosting
Survey theme/template: Fruity

Hi there,I’ve built quite a complex survey in LimeSurvey. It’s multilingual and restricted to a specific group of participants. For some conditional questions, I use attributes from the participant table (e.g.,
Code:
TOKEN:ATTRIBUTE_1 = 1
) so the survey doesn’t need to ask for information I already have.The issue is that when I start the survey and switch languages using the top-menu language switcher, the attribute information disappears. Apparently this happens because the URL changes from one that includes the token (e.g.: xxxxxx.limequery.org/376147?token=fuab_202500000a&newtest=Y ) to a generic URL without it ( xxxxxx.limequery.org/376147 ) .I got some JavaScript from an AI chat that was supposed to fix the problem, but it doesn’t. The code is intended to be placed in 
Code:
language_changer_top_menu.twig
.{# Capture all current query parameters #}
{% set q = app.request.query.all %}

{# (Optional) list of parameters you want to explicitly preserve #}
{% set keep = %}

{# When rendering each language option #}
<ul class="dropdown-menu languagechanger">
  {% for langcode, langname in aSurveyInfo.aOtherLanguages %}
    {# Merge current query parameters with the new 'lang' value #}
    {% set q2 = q|merge({'lang': langcode}) %}
    <li>
      <a class="ls-language-link"
         href="{{ app.request.pathInfo }}?{{ q2|url_encode('query') }}">
         {{ langname }}
      </a>
    </li>
  {% endfor %}
</ul>

How can I prevent the problem?
Is in the snippet any mistake?

Thanks!! 

Please Log in to join the conversation.

More
3 weeks 11 hours ago #272827 by holch
Please ignore anything that any AI tool tells you about Limesurvey. So far I need to see one answer related to Limesurvey that makes sense. Seems like none of the major AI tools has any "training" on Limesurvey. So what you usually get from them are hallucinations.

What you experience might actually be connected to this here:
forums.limesurvey.org/forum/installation...d-from-question-html

Ployrich has noticed that there is no hidden input with the token after the first page. I am not a developer, but I assume that this hidden field is used to store the token into the database, but for that you need to click "next" at least once I think.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

More
2 weeks 3 days ago #272849 by dvilchez
First of all, thanks for the advice regarding AI tools and LimeSurvey — I'll keep that in mind!

Secondly, I tested whether the token information is stored after first "next" click. To do so, I enabled the welcome page (which I usually skip to keep surveys as short as possible). Unfortunately, it didn’t work: if I change the language on page two or three of the survey, the same issue occurs.
On the other hand, I noticed that if I change the language on the welcome page —whether using the top-menu language switcher or the specific language switcher on that page—, there's no issue with the token information throughout the rest of the survey. In this case, even though the URL changes (as I pointed out in the opening of the topic) everything works fine when I go on with the survey. So, it seems the suposition I originally made about the URL alteration it has nothing to do with the issue.
Another scenario I tested was going forward, answering some questions, then going back to the welcome page and changing the language. In this case, the issue also occurs. So, it seems the bug is somewhat more complex.
Since I send participants invitation messages with links in all avalaible survey languages, I've hidden the top-menu language switcher as a provisory workaround. (I followed the instructions from official manual "How to hide the language switcher located on the top menu":  [url] www.limesurvey.org/manual/Multilingual_survey/en [/url])

Still, I think there should be a proper arrangement for this issue. Is there any way to prevent the problem while keeping the permission to navigate throught the survey and the language switcher available?

Thanks again!

P.S: I read the other post and it seems to be a connection but I couldn't draw any conclusion... Also, I don't have direct access to the theme code so I couldn't check the lines posted there (another colleague in my company handles that). 

Please Log in to join the conversation.

More
2 weeks 3 days ago #272853 by holch
I would open a bug report. I think the problem is, that the token is written into the hidden field. When you switch the language, the hidden field seems to get lost, and when you then click next, the token can't be written into the database.

Seems like before the hidden token field would be also on the next pages.

I feel like someone changes something and didn't think it completely through and did not anticipate all the potential issues the change could have.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

More
1 week 14 hours ago #272929 by dvilchez
Thanks for the advice!

We'll open a bug report.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose