Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Automatically proceed to next question (without clicking "next")

Automatically proceed to next question (without clicking "next") 6 months 23 hours ago #106399

  • dweisser
  • dweisser's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 204
  • Thank you received: 5
  • Karma: 5
I hear what you're saying...
The goal I have is to collect as much data as possible, so I'm not sure redirection is the answer.
Any advice you have to offer is always much appreciated.
David
The administrator has disabled public write access.

Automatically proceed to next question (without clicking "next") 6 months 21 hours ago #106406

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
I can't agree with forcing the browser to submit the form. I my opinion, any form submission should be left entirely up to the user.

However, if you just want to remove the survey from an inactive computer you can add something like this to the end of template.js.

(adjust the first 5 variable as necessary)

This will:
- Start an "alert" timer on page load
- When the "alert" timer expires a dialog is popped up and a "redirect" timer is started
- When the "redirect" timer expires the page is redirected
- Closing the dialog will stop the "redirect" timer and restart the "alert" timer
- Any activity in the form (click, key-up, paste, change) will restart the "alert" timer

$(document).ready(function(){
 
	var txtAlertMessage = 'Anyone there? Do you want to continue?';		
	var txtCloseButton = 'Continue';
	var redirectURL = location.pathname.split('index.php')[0];
	var timeToAlert = 300; // In seconds
	var timeToRedirect = 5; // In seconds
 
	// Page timeout action
	function pageTimeout() {
		window.location = redirectURL;
	}	
 
	// Alert Timer
	var alertTimer;
	function startAlertTimer() {
		alertTimer = setTimeout(function() {
			$('.custom-dialog-1').dialog('open');
		},timeToAlert*1000);
	}		
	function stopAlertTimer() {
		clearTimeout(alertTimer);
	}		
	function restartAlertTimer() {
		clearTimeout(alertTimer);
		startAlertTimer();
	}
	startAlertTimer();
 
	// Redirect Timer
	var redirectTimer;
	function startRedirectTimer() {
		redirectTimer = setTimeout(function() {
			pageTimeout();
		},timeToRedirect*1000);
	}		
	function stopRedirectTimer() {
		clearTimeout(redirectTimer);
	}		
	function restartRedirectTimer() {
		clearTimeout(redirectTimer);
		startRedirectTimer();
	}	
 
	// Insert the alert dialog
	var timeoutDialog = '<div class="custom-dialog-1"> \
							<div class="text">'+txtAlertMessage+'</div> \
							<div class="buttons"> \
								<button class="close" type="button" value="close">'+txtCloseButton+'</button> \
							</div> \
						</div>';
	$(timeoutDialog).dialog({
		autoOpen: false,
		open: function( event, ui ) {
			startRedirectTimer();
			//IE 10 z-index hack
			$('.ui-widget-overlay').css('z-index', Number($('.ui-widget-overlay').css('z-index')) - 2);
		},
		close: function( event, ui ) {
			stopRedirectTimer();
			restartAlertTimer();
		},
		width: 400,
		modal: true,
		resizable: false,
		draggable: false,
		closeOnEscape: true,
		dialogClass: 'timeout-dialog'
	});
	$('.timeout-dialog button').click(function() {
		$('.custom-dialog-1').dialog('close');
	});
 
	// Listener for activity
	$('#limesurvey').on('click keyup paste change' ,function(event){ 
		restartAlertTimer();
	});
});
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.
Last Edit: 6 months 21 hours ago by tpartner.
The administrator has disabled public write access.

Automatically proceed to next question (without clicking "next") 5 months 2 weeks ago #107123

  • dweisser
  • dweisser's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 204
  • Thank you received: 5
  • Karma: 5
For the record,
I'm not auto-submitting surveys. In the end, no body wants that. However, I was working with the code and trying to figure out why this wont work:
// Page timeout action
	function pageTimeout() {
		//window.location = redirectURL;
 
// Find the group index 
    var groupIndex = $('div[id^="group-"]').attr('id').split('group-')[1];
 
        if(groupIndex[0] >= 0) {
        $('#movesubmitbtn').click();
        }    
        else {
        window.location = redirectURL;
        }
    }

There seems to be something wrong with this:
$('#movesubmitbtn').click();
, but I can't figure out what it is. If I simple put this:
$('#movesubmitbtn').click();
in the timer block without a condition - it auto submits. What gives?

Any thoughts would be appreciated.
David
The administrator has disabled public write access.

Automatically proceed to next question (without clicking "next") 5 months 2 weeks ago #107124

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
Hard to say without seeing all of the code but it seems to me that groupIndex is an array item, not an array.

So, this:
if(groupIndex[0] >= 0) {

Should be this:
if(groupIndex >= 0) {
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.

Automatically proceed to next question (without clicking "next") 5 months 1 week ago #107144

  • dweisser
  • dweisser's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 204
  • Thank you received: 5
  • Karma: 5
I had tried that, T. And everything else. HEre is the whole code block.
It just won't work inside the condition - and its making me crazy!
$(document).ready(function(){
 
    var txtAlertMessage = 'Anyone there? Do you want to continue?';		
	var txtCloseButton = 'Continue';
	var redirectURL = location.pathname.split('index.php')[0];
	var timeToAlert = 2; // In seconds
	var timeToRedirect = 2; // In seconds
 
	// Page timeout action
	function pageTimeout() {
// Find the group index - 
    var groupIndex = $('div[id^="group-"]').attr('id').split('group-')[1];
 
        if(groupIndex >= 0) {
        $('#movesubmitbtn').click();
        }    
        else {
        window.location = redirectURL;
        }
    }	
 
 
 
	// Alert Timer
	var alertTimer;
	function startAlertTimer() {
		alertTimer = setTimeout(function() {
			$('.custom-dialog-1').dialog('open');
		},timeToAlert*1000);
	}		
	function stopAlertTimer() {
		clearTimeout(alertTimer);
	}		
	function restartAlertTimer() {
		clearTimeout(alertTimer);
		startAlertTimer();
	}
	startAlertTimer();
 
	// Redirect Timer
	var redirectTimer;
	function startRedirectTimer() {
		redirectTimer = setTimeout(function() {
			pageTimeout();
		},timeToRedirect*1000);
	}		
	function stopRedirectTimer() {
		clearTimeout(redirectTimer);
	}		
	function restartRedirectTimer() {
		clearTimeout(redirectTimer);
		startRedirectTimer();
	}	
 
	// Insert the alert dialog
var timeoutDialog = '<div class="custom-dialog-1">							<div class="text">'+txtAlertMessage+'</div>
<div class="buttons">
<button class="close" type="button" value="close">'+txtCloseButton+'</button> 							</div>
</div>';
	$(timeoutDialog).dialog({
		autoOpen: false,
		open: function( event, ui ) {
			startRedirectTimer();
			//IE 10 z-index hack
			$('.ui-widget-overlay').css('z-index', Number($('.ui-widget-overlay').css('z-index')) - 2);
		},
		close: function( event, ui ) {
			stopRedirectTimer();
			restartAlertTimer();
		},
		width: 400,
		modal: true,
		resizable: false,
		draggable: true,
		closeOnEscape: true,
		dialogClass: 'timeout-dialog'
	});
	$('.timeout-dialog button').click(function() {
		$('.custom-dialog-1').dialog('close');
	});
 
	// Listener for activity
	$('#limesurvey').on('click keyup paste change' ,function(event){ 
		restartAlertTimer();
	});
});
Last Edit: 5 months 1 week ago by dweisser.
The administrator has disabled public write access.

Automatically proceed to next question (without clicking "next") 5 months 1 week ago #107145

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
You have some syntax problems where inserting the timeoutDialog - it all needs to be on one line or escaped properly - see below.

Having said that, I just don't get what you are trying to do with the IF statement.
- You say if groupIndex is greater than or equal to 0, click Submit, otherwise redirect the page.
- Well, groupIndex will always be greater than or equal to 0 so the redirect will never happen.
- The #movesubmitbtn element only exists on the last page of the survey, so, unless you are there, nothing will ever happen.

	$(document).ready(function(){
 
		var txtAlertMessage = 'Anyone there? Do you want to continue?';		
		var txtCloseButton = 'Continue';
		var redirectURL = location.pathname.split('index.php')[0];
		var timeToAlert = 2; // In seconds
		var timeToRedirect = 2; // In seconds
 
		// Page timeout action
		function pageTimeout() {
			// Find the group index - 
			var groupIndex = $('div[id^="group-"]').attr('id').split('group-')[1];
 
			if(groupIndex >= 0) {
				$('#movesubmitbtn').click();
			}	
			else {
				window.location = redirectURL;
			}
		}	
 
		// Alert Timer
		var alertTimer;
		function startAlertTimer() {
			alertTimer = setTimeout(function() {
				$('.custom-dialog-1').dialog('open');
			},timeToAlert*1000);
		}		
		function stopAlertTimer() {
			clearTimeout(alertTimer);
		}		
		function restartAlertTimer() {
			clearTimeout(alertTimer);
			startAlertTimer();
		}
		startAlertTimer();
 
		// Redirect Timer
		var redirectTimer;
		function startRedirectTimer() {
			redirectTimer = setTimeout(function() {
				pageTimeout();
			},timeToRedirect*1000);
		}		
		function stopRedirectTimer() {
			clearTimeout(redirectTimer);
		}		
		function restartRedirectTimer() {
			clearTimeout(redirectTimer);
			startRedirectTimer();
		}	
 
		// Insert the alert dialog
		var timeoutDialog = '<div class="custom-dialog-1">\
								<div class="text">'+txtAlertMessage+'</div>\
								<div class="buttons">\
									<button class="close" type="button" value="close">'+txtCloseButton+'</button>\
								</div>\
							</div>';
		$(timeoutDialog).dialog({
			autoOpen: false,
			open: function( event, ui ) {
				startRedirectTimer();
				//IE 10 z-index hack
				$('.ui-widget-overlay').css('z-index', Number($('.ui-widget-overlay').css('z-index')) - 2);
			},
			close: function( event, ui ) {
				stopRedirectTimer();
				restartAlertTimer();
			},
			width: 400,
			modal: true,
			resizable: false,
			draggable: true,
			closeOnEscape: true,
			dialogClass: 'timeout-dialog'
		});
		$('.timeout-dialog button').click(function() {
			$('.custom-dialog-1').dialog('close');
		});
 
		// Listener for activity
		$('#limesurvey').on('click keyup paste change' ,function(event){ 
			restartAlertTimer();
		});
	});
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.
Last Edit: 5 months 1 week ago by tpartner.
The administrator has disabled public write access.

Automatically proceed to next question (without clicking "next") 5 months 1 week ago #107152

  • dweisser
  • dweisser's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 204
  • Thank you received: 5
  • Karma: 5
Ahh, thank you. It makes sense now.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.363 seconds
Donation Image