Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed #16210: Time limit not working LimeSurvey CE 4.2.1 (#1431)
  • Loading branch information
Jelle-S committed Jun 5, 2020
1 parent 722fd5a commit d83c52e
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 38 deletions.
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -37,7 +37,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -37,7 +37,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -35,7 +35,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -35,7 +35,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -89,7 +89,7 @@ public function render($sCoreClasses = '')
'placeholder' => $placeholder,
), true);

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}
$sLanguage = $this->sLanguage;
Expand Down
Expand Up @@ -216,7 +216,7 @@ public function render($sCoreClasses = '')

$inputnames[] = $this->sSGQA;

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}
$this->registerAssets();
Expand Down
Expand Up @@ -185,7 +185,7 @@ public function render($sCoreClasses = '')
$this->inputnames[] = $this->sSGQA;
$this->sCoreClass .= " ".$sCoreClasses;

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -35,7 +35,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -89,7 +89,7 @@ public function render($sCoreClasses = '')
'placeholder' => $placeholder,
), true);

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -37,7 +37,7 @@ public function render($sCoreClasses = '')
$inputnames = [];
$placeholder = "";

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -120,7 +120,7 @@ public function render($sCoreClasses = '')
$answer = '';

$sCoreClasses = "ls-answers answers-lists select-sortable-lists ".$sCoreClasses;
if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -37,7 +37,7 @@ public function render($sCoreClasses = '')
$inputnames = [];
$placeholder = "";

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
Expand Up @@ -38,7 +38,7 @@ public function render($sCoreClasses = '')
$answer = '';
$inputnames = [];

if (!empty($this->getQuestionAttribute('time_limit', 'value'))) {
if (!empty($this->getQuestionAttribute('time_limit'))) {
$answer .= $this->getTimeSettingRender();
}

Expand Down
34 changes: 17 additions & 17 deletions application/models/QuestionBaseRenderer.php
Expand Up @@ -26,21 +26,21 @@ abstract class QuestionBaseRenderer extends StaticModel
public $bPreview;
public $sCoreClass;
public $checkconditionFunction = "checkconditions";

protected $aFieldArray;
protected $aQuestionAttributes;
protected $aSurveySessionArray;
protected $mSessionValue;
protected $sLanguage;

protected $aSubQuestions = [];
protected $aAnswerOptions = [];

protected $aPackages = [];
protected $aScripts = [];
protected $aScriptFiles = [];
protected $aStyles = [];

public function __construct($aFieldArray, $bRenderDirect = false)
{
$this->aFieldArray = $aFieldArray;
Expand All @@ -51,25 +51,25 @@ public function __construct($aFieldArray, $bRenderDirect = false)
if(!$this->sLanguage) {
$this->sLanguage = $this->oQuestion->survey->language;
}

$this->aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($this->oQuestion->qid);
$this->aSurveySessionArray = @$_SESSION['survey_'.$this->oQuestion->sid];
$this->mSessionValue = @$this->setDefaultIfEmpty($this->aSurveySessionArray[$this->sSGQA], '');

$oQuestionTemplate = QuestionTemplate::getNewInstance($this->oQuestion);
$oQuestionTemplate->registerAssets(); // Register the custom assets of the question template, if needed

if(!empty($this->oQuestion->questionl10ns[$this->sLanguage]->script)){
$sScriptRendered = LimeExpressionManager::ProcessString($this->oQuestion->questionl10ns[$this->sLanguage]->script,$this->oQuestion->qid, ['QID' => $this->oQuestion->qid]);
$this->addScript('QuestionStoredScript-'.$this->oQuestion->qid, $sScriptRendered, LSYii_ClientScript::POS_POSTSCRIPT);
}
}

protected function getTimeSettingRender()
{
$oQuestion = $this->oQuestion;
$oSurvey = $this->oQuestion->survey;

Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts").'coookies.js', CClientScript::POS_BEGIN);
Yii::app()->getClientScript()->registerPackage('timer-addition');

Expand Down Expand Up @@ -104,7 +104,7 @@ protected function getTimeSettingRender()

//Render timer
$timer_html = Yii::app()->twigRenderer->renderQuestion('/survey/questions/question_timer/timer', array('iQid'=>$oQuestion->qid, 'sWarnId'=>''), true);

$time_limit = $oQuestion->questionattributes['time_limit']['value'];
$disable_next = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_disable_next']['value'], 0);
$disable_prev = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_disable_prev']['value'], 0);
Expand All @@ -117,18 +117,18 @@ protected function getTimeSettingRender()
$time_limit_warning_message = str_replace("{TIME}", $timer_html, $time_limit_warning_message);
$time_limit_warning_display_time = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_warning_display_time'], 0);
$time_limit_warning_2_message = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_warning_2_message'], gT("Your time to answer this question has nearly expired. You have {TIME} remaining."));


//Render timer 2
$timer_html = Yii::app()->twigRenderer->renderQuestion(
'/survey/questions/question_timer/timer',
array('iQid'=>$ia[0], 'sWarnId'=>'_Warning_2'),
true
);

$time_limit_message_delay = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_message_delay'], 1000);
$time_limit_warning_2_message = str_replace("{TIME}", $timer_html, $time_limit_warning_2_message);
$time_limit_warning_2_display_time = trim($oQuestion->questionattributes['time_limit_warning_2_display_time'], 0);
$time_limit_warning_2_display_time = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_warning_2_display_time'], 0);
$time_limit_message_style = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_message_style'], '');
$time_limit_message_class = "hidden ls-timer-content ls-timer-message ls-no-js-hidden";
$time_limit_warning_style = $this->setDefaultIfEmpty($oQuestion->questionattributes['time_limit_warning_style'], '');
Expand Down Expand Up @@ -228,7 +228,7 @@ protected function getQuestionAttribute($key1, $key2=null) {

protected function setSubquestions($scale_id = null)
{

$this->aSubQuestions = $this->oQuestion->getOrderedSubQuestions($scale_id);
}

Expand All @@ -249,7 +249,7 @@ protected function getQuestionCount($iScaleId=0)

protected function getFromSurveySession($sIndex, $default="")
{
return isset($_SESSION['survey_'.$this->oQuestion->sid][$sIndex])
return isset($_SESSION['survey_'.$this->oQuestion->sid][$sIndex])
? $_SESSION['survey_'.$this->oQuestion->sid][$sIndex]
: $default;
}
Expand Down Expand Up @@ -331,7 +331,7 @@ public function getCurrentRelevecanceClass($myfname)
}
}
}

// Currently null/0/false=> hidden , 1 : disabled
$filterStyle = !empty($this->aQuestionAttributes['array_filter_style']);
return ($filterStyle) ? "ls-irrelevant ls-disabled" : "ls-irrelevant ls-hidden";
Expand Down Expand Up @@ -359,7 +359,7 @@ public function getLabelInputWidth()
? null
: intval($labelAttributeWidth)
);

if ($attributeInputContainerWidth === null && $attributeLabelWidth === null) {
$sInputContainerWidth = 8;
$sLabelWidth = 4;
Expand Down Expand Up @@ -396,7 +396,7 @@ public function getLabelInputWidth()
public function includeKeypad()
{
Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('third_party')."jquery-keypad/jquery.keypad.alt.css");

$this->aScriptFiles[] = ['path' => Yii::app()->getConfig('third_party').'jquery-keypad/jquery.plugin.min.js', 'position' => LSYii_ClientScript::POS_BEGIN];
$this->aScriptFiles[] = ['path' => Yii::app()->getConfig('third_party').'jquery-keypad/jquery.keypad.min.js', 'position' => LSYii_ClientScript::POS_BEGIN];
$localefile = Yii::app()->getConfig('rootdir').'/third_party/jquery-keypad/jquery.keypad-'.App()->language.'.js';
Expand Down

0 comments on commit d83c52e

Please sign in to comment.