Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: insert game (code) from URL before questions appear

insert game (code) from URL before questions appear 2 years 11 months ago #103165

  • baszek
  • baszek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 11
  • Karma: 0
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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103205

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
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:
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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103224

  • baszek
  • baszek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 11
  • Karma: 0
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:
<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:
<script type='text/javascript'>
$(document).ready(function() {
   /* Hi There */
   /* Changing button text */
   $("table.navigator-table").hide();
});
</script>
Last Edit: 2 years 11 months ago by baszek.
The administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103225

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
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:
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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103226

  • baszek
  • baszek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 11
  • Karma: 0
But I have made test survey only with that code (without iframe and game):
<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: 2 years 11 months ago by baszek.
The administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103230

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
Don't fire the code until the entire document is loaded:
<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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103231

  • baszek
  • baszek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 11
  • Karma: 0
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: 2 years 11 months ago by baszek. Reason: now not know
The administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103239

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103241

  • baszek
  • baszek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 11
  • Karma: 0
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: 2 years 11 months ago by baszek. Reason: I have a solution
The administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103242

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
Ah, my code is for 2.0. In 2.05, you can use something like this:
<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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 11 months ago #103244

  • baszek
  • baszek's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 11
  • Karma: 0
tpartner wrote:
Ah, my code is for 2.0. In 2.05, you can use something like this:
<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: 2 years 11 months ago by baszek. Reason: some changes
The administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 4 weeks ago #114282

  • tomscher
  • tomscher's Avatar
  • Offline
  • Junior Lime
  • Posts: 34
  • Thank you received: 7
  • Karma: 2
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 administrator has disabled public write access.

insert game (code) from URL before questions appear 2 years 4 weeks ago #114284

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6574
  • Thank you received: 1477
  • Karma: 579
Try this in the iframe:

$('#movenextbtn', window.top.document).click();


This sets the scope in which to search for "#movenextbtn" to the top window.



.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 2 years 4 weeks ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: tomscher

insert game (code) from URL before questions appear 2 years 4 weeks ago #114288

  • tomscher
  • tomscher's Avatar
  • Offline
  • Junior Lime
  • Posts: 34
  • Thank you received: 7
  • Karma: 2
Thank you! Works like a charm! :)
The administrator has disabled public write access.
Time to create page: 0.311 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form