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

Restarting timer if survey taken on the same computer - by: Arthemis

$
0
0
Ok, I figured it out. The plugin below resets timers only for those who just loaded the survey and passed the first question (i.e., the new comer, not someone trying to reload the page to get more time). It's also written to be survey-specific (in this case surveyID=9999) and the question id is set to 2 but can be any question at the start of the survey:
<?php
/**
* resetTimersNM Plugin for LimeSurvey
* Reset the timers for each question in a survey.
*
*
*
*/

class resetTimersNM extends \ls\pluginmanager\PluginBase {

static protected $description = 'Reset questions timers';
static protected $name = 'resetTimersNM';

public function init() {
$this->subscribe('beforeQuestionRender');
}

public function beforeQuestionRender() {

// Get Event
$oEvent = $this->event;

// Fetch Parameters
$iSurveyId = $oEvent->get('surveyId');
$qid = $oEvent->get('qid');

// Reset timers cookie for a specific survey and when the user go through
// a specific question.
if($iSurveyId==9999 && $qid==2)
{
if (isset($_COOKIE)) {
unset($_COOKIE);
setcookie('limesurvey_timers', '', time() - 3600, '/'); // empty value and old timestamp
}
}

}


}

Viewing all articles
Browse latest Browse all 17529

Trending Articles



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