Hello everyone.
I have a survey with multiple questions that have a time limit. To prevent respondents returning to the same incomplete survey on the same computer, I used the newtest=Y in the URL. It does restart the survey but the timed questions appear out of time if the time elapsed on the previous attempt to answer the survey. How do I change this to have a completely new start without manually erasing cookies?
Thank you in advance!
Timer are in cookies
Solution : make a plugin to reset timer cookies with beforeSurveyPage
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
Thank you for your reply. Is it something I can change myself using the controls of the survey (and if yes - how) or is it in the setup of the LimeSurvey installation (I don't have access to this unfortunately, I'm using the survey through an organization that installed it for its researchers).
DenisChenu wrote: Not included currently in LimeSurvey core .
....
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
public function init() {
$this->subscribe('beforeSurveyPage');
}
public function beforeSurveyPage() {
$oEvent = $this->event;
$iSurveyId=$oEvent->get('surveyId');
if (isset($_COOKIE)) {
unset($_COOKIE);
setcookie('limesurvey_timers', '', time() - 3600, '/'); // empty value and old timestamp
}
}
}
It works. Now I want to restart the timer only for new users on the same computer where a previous user did not submit. That is, I want to prevent users from reloading the page to get more time to answer the timed question. I identify unique users by login=uniquelogin in the URL where login is a hidden short-text question. Is there another event that is triggered by the start of the survey?
Thank you!
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 {
// 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
}
}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.