Redirect/change expired-inactive survey message

More
1 year 6 months ago #153503 by FaLifeTime
FaLifeTime created the topic: Redirect/change expired-inactive survey message
Hi: i need some help. I’m trying to change either the expired survey message or the deactivated survey message. I created one enrollment survey per course in the institution where I work and I want to show users another message if they try to access any survey link while is closed or expired; something like “The enrollment survey is closed, please check out …”. It could be a better solution also to redirect to a specific Scholl web page section giving a special message or some choices.

I read this thread without success.

Thanks,

4aLifeTime[/color][/color]

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #153516 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
You have linked to another (old) thread but not explained what you have tried and how it failed. Also what is your LimeSurvey version?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: FaLifeTime

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #153524 by FaLifeTime
FaLifeTime replied the topic: Redirect/change expired-inactive survey message
Hi tpartner,

thanks for your quick reply. Im using "Versión 2.05+ Build 150520". Concerning the thread i particularly tried your suggestion (below) adapting the messages into my default language: Spanish. It didnt work out, but i insist, my code knowledge is limited. Do i have any chance to redirect users if surveys are inactivated or expired?

Thanks!
4aLifeTime

$(document).ready(function() {

if($('p#tokenmessage').length > 0 && $('#tokenform').length == 0) {
var stringIndex = $('p#tokenmessage').text().indexOf('Diese Umfrage ist beendet und steht nicht mehr zur Verfügung);
if(stringIndex >= 0) {
$('p#tokenmessage').html('This survey is CLOSED!<br /><br />Go away!');
}
}

});

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #153529 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
I see a bug (a missing closing quote) in that code so it should be:
$(document).ready(function() {
	if($('p#tokenmessage').length > 0 && $('#tokenform').length == 0) {
		var stringIndex = $('p#tokenmessage').text().indexOf('Diese Umfrage ist beendet und steht nicht mehr zur Verfügung');
		if(stringIndex >= 0) {
			$('p#tokenmessage').html('This survey is CLOSED!<br /><br />Go away!');
		}
	}
});

However, if using Spanish, you will need to replace the German string with whatever you see in Spanish. Probably this:
$(document).ready(function() {
	if($('p#tokenmessage').length > 0 && $('#tokenform').length == 0) {
		var stringIndex = $('p#tokenmessage').text().indexOf('Esta encuesta ya no está disponible');
		if(stringIndex >= 0) {
			$('p#tokenmessage').html('This survey is CLOSED!<br /><br />Go away!');
		}
	}
});

Having said that, if you want to redirect when the survey is closed instead of showing a custom message, try something like this (for Spanish):
$(document).ready(function() {
	if($('p#tokenmessage').length > 0 && $('#tokenform').length == 0) {
		var stringIndex = $('p#tokenmessage').text().indexOf('Esta encuesta ya no está disponible');
		if(stringIndex >= 0) {
			window.location = "http://google.com";
			$('p#tokenmessage').html('This survey is CLOSED!<br /><br />You are being redirected to our website.');
		}
	}
});

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #153530 by FaLifeTime
FaLifeTime replied the topic: Redirect/change expired-inactive survey message
Thanks tpartner. It works perfectly!

Cheers,
4aLifeTime

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago - 5 months 1 week ago #169542 by SCHEP23
SCHEP23 replied the topic: Redirect/change expired-inactive survey message
Hi this workaround works also in version 3? Where I have to put the instruction?

Thanks
Laura
Last Edit: 5 months 1 week ago by SCHEP23.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169570 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
The code would be placed in custom.js.

Which workaround? There are two given above.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: SCHEP23

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169575 by SCHEP23
SCHEP23 replied the topic: Redirect/change expired-inactive survey message
I copy-paste the following in the custom.js of my theme:

$(document).ready(function() {
if($('p#tokenmessage').length > 0 && $('#tokenform').length === 0) {
var stringIndex = $('p#tokenmessage').text().indexOf('We are sorry but the survey is expired and no longer available');
if(stringIndex >= 0) {
window.location = " google.com ";
$('p#tokenmessage').html('This survey is CLOSED!<br /><br />You are being redirected to our website.');
}
}
});

And nothing happened in error message. I'm using english and Limesurvey 3.7.2.

Thanks a lot for any suggestion
Laura

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169630 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
Place something like this is custom.js:

$(document).on('ready pjax:scriptcomplete',function(){
 
	var lsText = 'We are sorry but the survey is expired and no longer available.';
	var newText = 'This survey is CLOSED!<br /><br />You are being redirected to our website.';
 
	if($('p.message-0').length == 1 && $('p.message-0:first').text() == lsText) {			
		$('p.message-0:first').text(newText);
		window.location = "http://google.com";
	}
});

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago - 5 months 1 week ago #169695 by SCHEP23
SCHEP23 replied the topic: Redirect/change expired-inactive survey message
Thanks, i paste this script in theme custom.js but nothing happened.
It's the right place?
Laura
Last Edit: 5 months 1 week ago by SCHEP23.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169700 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
Can you activate a test survey and give a link here?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169723 by SCHEP23
SCHEP23 replied the topic: Redirect/change expired-inactive survey message
Sorry, i cannot do that.
I'm not sure I putted the script in the right form: i did the following:
Configuration-->Advanced-->Themes
I choose the extended one i'm using for the survey and select Theme editor. Than I copied-pasted the script you provide me in the custom.js.
As I said before my expire message is always the same..
Hope this clarify a little
Thanks Laura

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169725 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
It may be a caching issue. Completely clear you cache before testing.

Try placing this simple alert in custom.js:

$(document).on('ready pjax:scriptcomplete',function(){
	alert('Page loaded.');
});

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169760 by SCHEP23
SCHEP23 replied the topic: Redirect/change expired-inactive survey message
I cleared the cache and putted the alert in custom.js and I see the alert.
But the error custom message script is still not working
Laura

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #169763 by tpartner
tpartner replied the topic: Redirect/change expired-inactive survey message
The workaround works for me. Unfortunately, I cannot debug your problem without seeing a test survey.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: LouisGac

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!