Quantcast
Channel: Topics in Category: Can I do this with LimeSurvey? - LimeSurvey forums
Viewing all 17529 articles
Browse latest View live

Automatically proceed to next question after selecting answer - by: Joffm

$
0
0
Hi, siam,

it is a Javascript snippet.

So you should put it into an Javascript file, here I should say, the "custom.js" of your template is the right place.

Best regards
Joffm

Automatically proceed to next question after selecting answer - by: Siem

$
0
0
Thanks Joff, I put it in the Javascript file, but then I get this error:

Error: Syntax error, unrecognized expression: #question{QID} input[type="radio"]

I tried it with and without the <script> tags:
$(document).ready(function(){ 
	$('#question{QID} input[type="radio"]').on('click', function() {
		$('#ls-button-submit').trigger('click');
	});
});

Automatically proceed to next question after selecting answer - by: Joffm

$
0
0
Hi,

I put it into the question text (source code mode) and it works.

Joffm

HowTo Filter the Columns of an Array (Numbers) - by: Joffm

API: Invite participants to a survey - by: tpartner

$
0
0
Using version 3.13.2, this will create a token defined by $token and send the invitation to that token:

<?php
 
	define( 'LS_BASEURL', 'http://pathTo/limesurvey/');
	define( 'LS_USER', 'admin' );
	define( 'LS_PASSWORD', '****' );
 
	require_once 'relativePathTo/application/libraries/jsonRPCClient.php';
 
	$iSurveyID = 885886;
	$token = 'ABCDE';
	$email = 'example@example.com';
	$LastNameAPI = 'Firstname' ;
	$FirstNameAPI = 'Lastname' ;
 
 
	// Instantiate a new RPC client
	$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' );
 
	// Get a session key
	$sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
	// Define the token params
	$tokenParams = array("email"=>$email,"lastname"=>$LastNameAPI,"firstname"=>$FirstNameAPI,"token"=>$token,"language"=>'en',"emailstatus"=>"OK");
	$aParticipantData=array($tokenParams);
	$bCreateToken = false;
 
	// Create the tokens
	$newToken = $myJSONRPCClient->add_participants( $sSessionKey, $iSurveyID, $aParticipantData, $bCreateToken);
 
	// Print returned results
	echo '<hr><br><h1>Limesurvey</h1><br>New token created in survey '.$iSurveyID.':'
	.'<ul>'
	.'<li>TID - '.$newToken[0]['tid'].'</li>'
	.'<li>Token - '.$newToken[0]['token'].'</li>'
	.'</ul>';
 
	// Send an invitation to the created token
	$tokenIDs = array($newToken[0]['tid']);
	$newMail = $myJSONRPCClient->invite_participants($sSessionKey, $iSurveyID, $tokenIDs, true);
 
	// Print returned results
	if($newMail[$newToken[0]['tid']]['status'] == 'OK') {
		echo 'Invitation sent to:'
		.'<ul>'
		.'<li>Name - '.$newMail[$newToken[0]['tid']]['name'].'</li>'
		.'<li>Email - '.$newMail[$newToken[0]['tid']]['email'].'</li>'
		.'</ul>';
	}
	else {
		echo 'Error - no invitation sent!';
	}
 
	// Release the session key
	$myJSONRPCClient->release_session_key( $sSessionKey );
?>

If you want to generate a random token value instead of defining it, change this:
$bCreateToken = false;

To this:
$bCreateToken = true;

Automatically proceed to next question after selecting answer - by: tpartner

$
0
0
If want it to act on EVERY list-radio question in every survey using that template, add this to your theme custom.js file:

$(document).on('ready pjax:scriptcomplete',function(){ 
	$('.list-radio input[type="radio"]').on('click', function() {
		$('#ls-button-submit').trigger('click');
	});
});

Restrict Limesurvey Admin portal access - by: DenisChenu

Delete attributes from token table to start attribute_ID at "attribute_1" again - by: DenisChenu


Record timing and limit time to answer set of questions - by: tpartner

$
0
0
As I said in your other post, you will need to use a cookie to keep track of the allowed time.

1) Download js.cookie.js and place it in your template directory.
- github.com/js-cookie/js-cookie

2) Add this to the <head> element in startpage.pstpl after the {TEMPLATEJS} placeholder:
<script type="text/javascript" src="{TEMPLATEURL}js.cookie.js"></script>
3) Run the survey in group-by-group mode (you can place single questions in a group).

4) Enable the survey index in "Full" mode.

5) Place this in template.css to hide the index (this is for a copy of the default template):
.outerframe.withindex {
    margin: 0 !important;
}
 
#index {
	display: none !important;
}

6) Place this in template.js (this is for a copy of the default template):
//@name			| initiateTimer
//@author		| Tony Partner
//@editor		| Tony Partner
//@updated_at	| 21/07/2018 16:00:00
//@description	| A function to initiate a cookie-based timer
 
function initiateTimer(allowedTime) {
	// Set the cookie
	var sid = $('input#fieldnames').val().split('X')[0];
	Cookies.set('ls_g_time_'+sid, allowedTime-1, { expires: 365, path: '/' });
}
 
//@name			| runTimer
//@author		| Tony Partner
//@editor		| Tony Partner
//@updated_at	| 21/07/2018 16:00:00
//@description	| A function to run the timer
 
function runTimer(jumpToGroup) {
 
	// Define some vars
	var timerDisplayText = 'Time remaining in this question set:';	// Text in the active timer display
	var hourText = ' hours: ';		// Text appended to hours
	var minuteText = ' minute: ';	// Text appended to minutes
	var secondText = ' seconds';	// Text appended to seconds
 
	var sid = $('input#fieldnames').val().split('X')[0];
	var gid = $('input#fieldnames').val().split('X')[1];
	var lastGroupID = $('#index ol:eq(0) li:eq('+(jumpToGroup-1)+')').attr('data-gid');
	var currentTime = Cookies.get('ls_g_time_'+sid);
 
	// Insert the timer display element
	$('#progress-wrapper').after('<div class="g-timer-display-wrapper" style="border: 1px solid #BBC6CC; width: 200px; margin: 10px auto;">\
											<div class="g-timer-display-text">'+timerDisplayText+'</div>\
											<div class="g-timer-display-value"></div>\
										</div>');
 
	// A function to update the timer display
	function updateTimerDisplay() {
		var displayTime = parseTime(Cookies.get('ls_g_time_'+sid), true, hourText, minuteText, secondText);
		$('.g-timer-display-value').text(displayTime);
	}
	updateTimerDisplay();
 
	// Interval timer
	var gInterval = setInterval(function(){gTimer()}, 1000);
	function gTimer() {
		if(currentTime != 0) { // Update timer cookie and display
			currentTime--
			Cookies.set('ls_g_time_'+sid, currentTime, { expires: 365, path: '/' });
			updateTimerDisplay();
		}
		if(currentTime == 0) { // Stop interval and advance survey
			gTimerStop();
			$('.g-timer-display-wrapper').removeClass('bg-primary').addClass('bg-warning');
 
			// Click on the index
			if(lastGroupID != gid) {
				$('#index li[data-gid="'+lastGroupID+'"]').trigger('click');
			}
		}
	}	
	function gTimerStop() {
		clearInterval(gInterval);
	} 
}
 
//@name			| parseTime
//@author		| Tony Partner
//@editor		| Tony Partner
//@updated_at	| 21/07/2018 16:00:00
//@description	| A function to parse the remaining time
 
var parseTime = function(totalSeconds, showHours, hourText, minuteText, secondText) {
	var hours   = Math.floor(totalSeconds / 3600);
	var minutes = Math.floor((totalSeconds - (hours * 3600)) / 60);
	var seconds = totalSeconds - (hours * 3600) - (minutes * 60);
 
	// Round seconds
	seconds = Math.round(seconds * 100) / 100
 
	var result = '';
	if(showHours) {
		 result += (hours < 10 ? "0" + hours : hours)+hourText;
	}
	result += (minutes < 10 ? "0" + minutes : minutes)+minuteText;
	result += (seconds  < 10 ? "0" + seconds : seconds)+secondText;
	return result;
}

7) Place this script in the source of a question where you want to initiate and run the timer. In this example, the timer will run for 30 seconds and then jump the survey to group 4.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		// Initiate the timer with allowed time in seconds
		initiateTimer(30);
 
		// Run the timer with the group number to jump to on time expiration
		runTimer(4);
	});
</script>

8) Place this script in the source of every other question where simply want to run the timer. In this example, the survey will jump to group 4 when the allowed time expires.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		// Run the timer with the group number to jump to on time expiration
		runTimer(4);
	});
</script>

Sample survey and template attached (install the template before importing the question:

File Attachment:

File Name: limesurvey_survey_937384_2018-07-21.lss
File Size: 27 KB

File Attachment:

File Name: test_cookie_timer.zip
File Size: 94 KB

Reset timers cookie on last page - by: PauloReis

$
0
0
Hello Matiasko,

I don't know if this solve your problem but solved mine. I did a survey with time limit option enable and after reload the survey at the same computer the timers are not reset. After some search I found this solution.

<script type="text/javascript" charset="utf-8">
  // clear limesurvey_timers_time_question_XXX for all questions
  localStorage.clear();
</script>

I put the code in the first question. Works great for me! :)


I use LimeSurvey Version 3.13.2.


Cheers,
Paulo Reis

Edit respondent table via API / R/Limer (Add/edit respondents and/or variables) - by: socius

$
0
0
Hi again,

I just saw an error in my last/above message:


It is ...
tok <- call_limer(method = "list_participants", 
           params = list(iSurveyID = sid))
str(tok)

that returns a data frame with tid, token, firstname, lastname, email - but no other attributes, and not "usesleft" which I'd like to change.


The above mentioned ...

tok <- call_limer(method = "get_participant_properties", 
           params = list(iSurveyID = sid))
str(tok)

returns NULL.

How would I have to change the latter code to get other/all the attributes in the token table?

Sorry for that mistake!

Best,
G

Pre-filling Responses to Survey Questions - by: holch

$
0
0
How about using tokens and custom attributes to read in this information?

Can I transfer the answers from one survey to another? - by: jma6610

$
0
0
Okay, I now see what you mean and I have a test working. My prior post was just an example. In reality I'll have 60 to 200 records to use with about 20 or more variables/answers to transfer - so it will be worth it. I think this will work well since I can create the .cvs file using SPSS code from the answers from the first survey.

Thanks very much,

Jeff

Record timing and limit time to answer set of questions - by: tpartner

$
0
0
The solution is for LimeSurvey 2.05 as this is the version you said you are using. Solutions such as this are version-specific.

This took quite a bit of time to develop so I don't know when I'll be able to provide a 3.x version.

API: export_responses_by_token - how to add token attributes - by: mfiora

$
0
0
Hello,
i'm using API to export to PDF all the completed responses.
I would like to add token attributes in the beginning of each response.

As you know if i specify the token attributes $aFields i only get the ones specified.
On the other hand i don't know how to get the whole list of "question identifiers" to rebuild the response (just like if $aFields is null).

Could you please help me in one way or the other? Is there a workaround?

Thanks,

Regards,

send individual feedback to respondent - by: tammo

$
0
0
Hi,

as far as I know, it is only possible that you send the results from the survey itself, not an interpretation of the results, to the user. Using Expression Manager you could sort of set up a report in an email to the user, but this would be quite a challenge.

If you want a real report, you will have to write your own module, plugin, software for that.

We did that for the Dutch Workers Union: toolsforresearch.com/project/dutch-decent-work-survey

At the time we wrote this, we used PHP and JQuery for it. I guess if we would have to set this up now, we would use R.

Tammo

Have the assessment done externally and imported into Survey - by: tammo

Assesment Mode - Is it possible to change just a single response? - by: josoroma

$
0
0
Hi Hackers!

I was wondering... is it possible to change just a single response to a completed survey (on Assessment Mode)?

If so, what happens to previous user Answers and Results, are they easily accessible via API or admin interfaces?

Thanks!

Decimal places in answer - by: jimdavies

$
0
0
Do I need to add some advanced settings? When I preview the survey it allows me to put in anything, it doesn't force 2 decimals.

Pre-filling Responses to Survey Questions - by: nh905

$
0
0
I have a look at Expression Manager but am none the wiser. Tokens seem to be associated with users - I have no control over who will do the survey.

Thanks, Norbert
Viewing all 17529 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>