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
}
}
}
}
<?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
}
}
}
}