Welcome to the LimeSurvey Community Forum

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

insert game (code) from URL before questions appear

  • baszek
  • baszek's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago #103165 by baszek
Hello
I have such a game enterid001.nazwa.pl/cyberball/index.html?mode=INC and I would like to know is it possible to insert some way this game before questions appear (in the middle of a test).

I was trying to put this page in a iframe but it's not working - page appear but when you press play (in my language"GRAJ") it shows only blank page. Maybe be it's some security issue with iframe and my link which contains java script. You can see result here --> barbazylia.com/ankieta/enterid001.nazwa.pl/cyberball/test1.html

Anyway If iframe is not working, I wonder is it possible to copy code from enterid001.nazwa.pl/cyberball/index.html?mode=INC stright to lime survey and then add some code when then game is over to show next questions ? I saw that there is some option to hide question, so if it will be posible to copy game code, I may add some code to show previosly hidden question.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 2 months ago #103205 by tpartner
I'm not sure what the game is supposed to do but when loaded in the iframe it creates a JavaScript error:


If the game is controlled with JavaScript, you can place it's code and script in a text display question in it's own group. When the game is over, just submit that group:
Code:
document.limesurvey.move.value = 'movenext';
document.limesurvey.submit();

.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • baszek
  • baszek's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago - 10 years 2 months ago #103224 by baszek
I have already manage to make my game working with survey in iframe, but going to next queastion groupe from code is not working.

Sth with your code, which you gave me is probably wrong. I have created test survey with a first groupe question with a code:
Code:
<script>
document.limesurvey.move.value = 'movenext';
document.limesurvey.submit();
</script>
and after that groupe, there is one more question groupe with one question. As you can see at my link, survey just show some "survey list" and next question groupe does not appear.
LINK to test survey: barbazylia.com/ankieta/index.php/533859/lang-en

I have also problem with disable / hide next button - It should be hidden till the game ends.
I have found such a code but it does not work at my survey too:
Code:
<script type='text/javascript'>
$(document).ready(function() {
   /* Hi There */
   /* Changing button text */
   $("table.navigator-table").hide();
});
</script>
Last edit: 10 years 2 months ago by baszek.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 2 months ago #103225 by tpartner

Sth with your code, which you gave me is probably wrong

This code is not wrong, it is just used incorrectly. It simply moves to the next survey page so should only be fired when the game is finished and only be used if there are following survey pages (groups).

Note that if you are running the game in an iframe you will need to apply the "submit" code to the top frame. So, if fired from within the iframe, something like this:
Code:
window.parent.document.limesurvey.move.value = 'movenext';
window.parent.document.limesurvey.submit();

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • baszek
  • baszek's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago - 10 years 2 months ago #103226 by baszek
But I have made test survey only with that code (without iframe and game):
Code:
<script>
document.limesurvey.move.value = 'movenext';
document.limesurvey.submit();
</script>
So there is first question group with that code and after that there is second question group with a one queastion.
You can see it at barbazylia.com/ankieta/index.php/533859/lang-en
As you can see it does not show that second groupe (following).

By they way in my survey with a game I am using "movenext" code localy not from iframe. Javascript send message from iframe and survey is receving. If survey recevied massage its doing above code to go to next page.
Last edit: 10 years 2 months ago by baszek.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 2 months ago #103230 by tpartner
Don't fire the code until the entire document is loaded:
Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function(){
 
    document.limesurvey.move.value = 'movenext';
    document.limesurvey.submit();
 
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • baszek
  • baszek's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago - 10 years 2 months ago #103231 by baszek
I have used now your code and it worked some how once, but now every time I open my survey its refreshing constantly and It's still not going to next question.
Look barbazylia.com/ankieta/index.php/533859/lang-en
Last edit: 10 years 2 months ago by baszek. Reason: now not know
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 2 months ago #103239 by tpartner
Here is a sample survey with a button in a text-display question in the first group that uses that code to advance to the next group.

File Attachment:

File Name: limesurvey...4557.lss
File Size:14 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • baszek
  • baszek's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago - 10 years 2 months ago #103241 by baszek

tpartner wrote: Here is a sample survey with a button in a text-display question in the first group that uses that code to advance to the next group.

File Attachment:

File Name: limesurvey...4557.lss
File Size:14 KB

I have imported your survey and it's still not working - but I have saw that its not working only at my server because I have made the same thing at your Stable v2.00+ Demo - and it was working ! The same code from my server !

I HAVE A SOLUTION - I DID not turn off XSS filter !
Last edit: 10 years 2 months ago by baszek. Reason: I have a solution
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 2 months ago #103242 by tpartner
Ah, my code is for 2.0. In 2.05, you can use something like this:
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
    $('#movenextbtn').click();
  });
</script>

Here is a survey you can try in 2.05:

File Attachment:

File Name: limesurvey...6655.lss
File Size:14 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • baszek
  • baszek's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago - 10 years 2 months ago #103244 by baszek

tpartner wrote: Ah, my code is for 2.0. In 2.05, you can use something like this:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
    $('#movenextbtn').click();
  });
</script>

Here is a survey you can try in 2.05:

File Attachment:

File Name: limesurvey...6655.lss
File Size:14 KB

This code works perfect! Thx a lot !
Last edit: 10 years 2 months ago by baszek. Reason: some changes
The topic has been locked.
More
9 years 4 months ago #114282 by tomscher
Sorry for bumping up that old thread, but I have a similar problem:
I embed an external game in Limesurvey which should trigger the 'submit' function at the end. For that purpose, I do the following:

a) embed the game using iframe (no probs here)
b) hide the 'next' button of LS to avoid premature submissions (no probs here)
c) at the end of the game, I want to submit the LS-question group and go to the next question group (problem is here).

I have tried the following JS lines at the appropriate places (i.e. within a function that is called at the end of the game within the frame):

document.limesurvey.move.value = 'movenext';
document.limesurvey.submit();

Also not working: defining a function with the proposed "click"-Code from below in LS and calling this function (nextLSpage) from the frame using window.opener.nextLSpage();

Possibly it's a simple solution - I am just completely stuck and help is highly appreciated.

I use LS 2.05 and my first solution did work in previous versions (up from at least 1.92) - so what would be the new equivalent to automatically submit question groups from another frame?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose