Welcome, Guest
Username: Password: Remember me

TOPIC: How can I get the mapping between SGQA and code

How can I get the mapping between SGQA and code 2 years 9 months ago #67188

  • tamacheq
  • tamacheq's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
Hi
To validate the answer to an non mandatory question Q1 in group G1 I have added in the description of question Q2 of group G2, the following code.
<pre>
function validation()
{

if ((!((validateQ1('{INSERTANS:17451X1201X5398}',false))))
{

document.limesurvey.move.value = 'moveprev';
document.limesurvey.submit();
}
}
setTimeout("validation()",250);

</script>
</pre>
I don't want to modify the survey when moving from devel to prod. So I don't want to use SGQA in javascript code, but the field named title in the questions table.
How can I do the mapping between SGQA and code in javascript.
I could use json to do a request in php, but it may be to much doing a json request on each group if I need it only for one group.
Thanks for any suggestion.
AD
The administrator has disabled public write access.

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67218

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4058
  • Thank you received: 741
  • Karma: 341
There is no mapping between the SGQA and the question code in the current version. In 2.0 (to be released later this year), you should be able to use Expression Manager to accomplish your validation.

In the meantime, rather than an AJAX call, I would set a cookie with the value of Q1 or use persistent JavaScript data (pablotron.org/?cid=1557) to store the Q1 value.
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67265

  • tamacheq
  • tamacheq's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
Ok, the cookie is a good solution, in Q1 description I have added
<script type="text/javascript" charset="utf-8">
createCookie('SGQq1', '{SGQ}', 7) ;
validateQ1('{INSERTANS:{SGQ}}');
</script>

and in question Q2
<script>
function validation()
{
var SGQ_q1 = GetCookie ('SGQq1') ;
if (!((validateQ1('{INSERTANS:'+SGQ_q1+'}'))))
{
document.limesurvey.move.value = 'moveprev';
document.limesurvey.submit();
}
}
setTimeout("validation()",250);
</script>

BUT the limesurvey parsing doesn't work
{INSERTANS:'+SGQ_q1+'} is not replaced by the value of the answer of 17654X5430X3424
May be I didn't write it correctly.

May be I could set a cookie containing the value Q1 answer when the submit button is clicked.
But I don't know how to do it.

Thanks anyway for your previous trick.
Anne
The administrator has disabled public write access.

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67314

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4058
  • Thank you received: 741
  • Karma: 341
Here is an example of how to store and retrieve a cookie - www.limesurvey.org/en/forum/advsearch?q=...name=1&childforums=1
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67332

  • tamacheq
  • tamacheq's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
Here is the solution I founded :
in the question Q1 I have added
<script type="text/javascript" charset="utf-8">
createCookie('SGQq1', '{SGQ}', 7) ;
</script>

and in startpage.pstpl
for immediate validation :
var SGQsiret = GetCookie ('SGQsiret') ;
$("#answer"+SGQq1).live('change', function(event) { validateQ1 ($("#answer"+SGQq1).val(), true) });

and also in startpage.pstpl for validation on submit :
if ($("#answer"+SGQq1).length)
{
$("#limesurvey").bind('click', function()
{ return validateQ1 ($("#answer"+SGQq1).val(), true)) ;})
}
AD
The administrator has disabled public write access.

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67333

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5300
  • Thank you received: 291
  • Karma: 247
Can you please add this at the woraround section of our manual so that other users will benefit from your work as well!?

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67347

  • tamacheq
  • tamacheq's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Karma: 0
I didn't copy properly
Please replace var SGQsiret = GetCookie ('SGQsiret') ;
by var SGQq1 = GetCookie ('SGQq1') ;
The administrator has disabled public write access.

Re: How can I get the mapping between SGQA and code 2 years 9 months ago #67358

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5300
  • Thank you received: 291
  • Karma: 247
If you added that to our wiki please correct there, too?

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.128 seconds
Donation Image