Welcome to the LimeSurvey Community Forum

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

"Calculate" SGQA

  • Speakerator
  • Speakerator's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #136325 by Speakerator
"Calculate" SGQA was created by Speakerator
Hi @ all,

I'm rather new to Limesurvey and spent the past few days reading through this forums and various guides and manuals. Currently, I'm looking for a way to dynamically "calculate" the SGQA identifier, since I need to access multiple fields to give some kind of custom analyses right after the survey is completed. That means, instead of accessing each field manually by doing

var answerX= "{INSERTANS:1234X1X1}";
var answerY = "{INSERTANS:1234X1X2}";
etc.

I'd rather loop over multiple fields and concatenate the SGQA identifier, similar to
var SID = 1234
var GID = 1
var QID = 1
var SGQA = "{INSERTANS:" + SID +"X"+GID+ "X" + QID}

(braces would need to be escaped of course, but you get the idea)

I tried multiple variations, but it seems that Limesurvey only fetches the values if a complete string term of "{INSERTANS:[...]}" is provided.
Am I missing out on something? Is there another (possibly better :lol: ) way?

Best regards
Chris
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136333 by holch
Replied by holch on topic "Calculate" SGQA
why not using the answer code? You can create it the way you want.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • Speakerator
  • Speakerator's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #136345 by Speakerator
Replied by Speakerator on topic "Calculate" SGQA

holch wrote: why not using the answer code? You can create it the way you want.


Thanks for the input. Could you go in somer more detail about that? I know that I can access the answer object via JQuery $('#answer1234X1X1), but it's a huge object and kind of hard to traverse if you don't know exactly what you're looking for). I read the manual regarding the expression manager and how to access variables( Expression_Manager#Access to Variables ), but since I am not defining expressions in the manager itself, but in JavaScript, there's still some missing link. Unfortunately, all the examples I found simply use a static "{INSERTANS:XXX}"
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136349 by DenisChenu
Replied by DenisChenu on topic "Calculate" SGQA
Hi,

{SGQ} replaced by the SGQA of the question

$('#answer1{SGQ}), and $('#answer1{SGQ}SQ1) for subquestions

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 topic has been locked.
  • Speakerator
  • Speakerator's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #136429 by Speakerator
Replied by Speakerator on topic "Calculate" SGQA

DenisChenu wrote: Hi,

{SGQ} replaced by the SGQA of the question

$('#answer1{SGQ}), and $('#answer1{SGQ}SQ1) for subquestions



Alright, thanks for the input. But that still means, that I have to hardcode the SGQ, doesn't it? I'd like to have something like
var sSGQ = XYZ;
var sAnswer = { sSGQ };

I currently got it working using 'hardcoded' identifiers, but is it possible to use JS-variables within the expresssions. It seems like all the expressions are immediately parsed at runtime.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136457 by DenisChenu
Replied by DenisChenu on topic "Calculate" SGQA
If answer are in same page : yes : you need to update the part when answer is updated.

I don't know what you want to do exactly ....

You can use too :
$('#answer{that.qcode.sgq}') to get the actual value of the answer qcode.

See : api.jquery.com/ for some usage
Denis

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: Speakerator
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose