Check out the LimeSurvey source code on GitHub!

'Session variable', randomizing embedded audio but with fixed questions?

5 years 8 months ago - 5 years 8 months ago #61550 by TWB125
Hello all,

I just asked a question on the IRC channel, but this place is better.

We have one question group that pertains to a particular audio clip (of a large collection of audio clips).

We want to have 179 participants to answer the questions of that question group in relation to the audio clips presented.

We have succeeded in embedding the audio clips with the <embed> HTML-tag.

We want to make sure that the audio clips are never presented more than once. So we thought that we maybe could assign the audio clips based on a unique participant code, by naming the audio clip files correspondingly.

But is there an easy way to set a variable per 'session' (one participant doing the survey)? Embedding JavaScript code will not suffice, as variables defined in there will get lost when the next question in the question group is presented (new HTML-page loaded). So we could use cookies. But that seems a bit of hack. Doesn't LimeSurvey provide some sort of 'session variables' that can be accessed by JavaScript in question HTML-page (requirement, for the randomization of audio clips) and is also stored in the database along with the answers (requirement, we have to know afterwards which audio clips were presented and which participant did the survey).

We are in a hurry, so I hope that any of you can still amaze us with an elegant solution! :)

FYI: the IRC log:
[15:15] <academic> The questions are always the same, but we want to randomize an audio sample that comes along with them
[15:16] <academic> We have the audio sample working with an <embed> tag
[15:16] <academic> We do not want to offer the same audio fragment twice
[15:17] <academic> So we thought maybe we should generate participant IDs for all 179 participants, and assign specific audio samples to each ID beforehand
[15:18] <academic> We are trying to get up and running quickly, I am not so experiences with LS
[15:19] <academic> But we could solve this problem, we think
[15:19] <pmonstad> I guess you need some javascript to get that to work
[15:20] <academic> We just need to know whether it is possible for a questionnaire session (that means: one certain participant doing the survey)
[15:20] <academic> to store variable in
[15:20] <academic> LimeSurvey
[15:20] <academic> So that we could access this variable with JavaScript for eacht question page presented
[15:21] <academic> So we want to store the participant code, that contains all required info, in a variable that is stored along with the survey results
[15:22] <academic> We want to be able to know this unique code so that we can change the audio file referred to in the <embed> tag by means of JavaScript
[15:22] <academic> (know this unique code during the questions session, across pages)
[15:23] <academic> We had this solution in mind: let the user provide their participant code at the beginning of the survey
[15:23] <academic> and store the value in a cookie with JavaScript
[15:24] <academic> At the end read out the cookie and put the value in a hidden answer field, so that LS store that value with the answers in the database
[15:24] <academic> Problem with that is, that it is perhaps fragile
[15:25] <academic> Doesn't LS have simpler and more robust facility to store 'session variables'?
Last Edit: 5 years 8 months ago by TWB125.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form