Skip to content

Commit

Permalink
New feature: Warn when activating a survey that is expired by config (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson authored and c-schmitz committed Jan 22, 2019
1 parent 4dc6d4f commit a776d94
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
18 changes: 18 additions & 0 deletions application/models/Survey.php
Expand Up @@ -145,6 +145,7 @@
* @property bool $isNoKeyboard Show on-screen keyboard
* @property bool $isAllowEditAfterCompletion Allow multiple responses or update responses with one token
* @property SurveyLanguageSetting $defaultlanguage
* @property boolean $isDateExpired Whether survey is expired depending on the current time and survey configuration status
* @method mixed active()
*/
class Survey extends LSActiveRecord
Expand Down Expand Up @@ -1162,6 +1163,23 @@ public function getState()
}
}

/**
* @return bool
* @throws Exception
*/
public function getIsDateExpired()
{
if (!empty($this->expires)) {
$sNow = date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime(date("Y-m-d H:i:s"))));
$sStop = ($this->expires != '') ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->expires))) : $sNow;

$oNow = new DateTime($sNow);
$oStop = new DateTime($sStop);
return $oStop < $oNow;
}
return false;
}


/**
* @todo Document code, please.
Expand Down
13 changes: 13 additions & 0 deletions application/views/admin/survey/activateSurvey_view.php
@@ -1,3 +1,7 @@
<?php
/** @var Survey $oSurvey */

?>
<?php if ((isset($failedcheck) && $failedcheck) || (isset($failedgroupcheck) && $failedgroupcheck)): ?>
<div class='side-body <?php echo getSideBodyClass(false); ?>'>
<div class="row welcome survey-action">
Expand Down Expand Up @@ -218,6 +222,15 @@ function alertPrivacy()
<p class='col-sm-7 col-sm-offset-2'>
<?php eT("Please note that once responses have collected with this survey and you want to add or remove groups/questions or change one of the settings above, you will need to deactivate this survey, which will move all data that has already been entered into a separate archived table."); ?><br /><br />
</p>
<?php if($oSurvey->getIsDateExpired()):?>
<div class="row">
<div class='col-sm-7 col-sm-offset-2'>

<div class="alert alert-warning"><?= Yii::t('app', 'Note: This survey has a past expiration date configured and is currently not available to participants. Please remember to update/remove the expiration date in the survey settings after activation.')?><div>
</div>

</div>
<?php endif;?>

<div class='col-sm-6 col-sm-offset-4'>
<input type='hidden' name='ok' value='Y' />
Expand Down

0 comments on commit a776d94

Please sign in to comment.