Skip to content

Commit

Permalink
DEV: add boolean getters for all survey Y/N properties (#763)
Browse files Browse the repository at this point in the history
DEV: Kill surveyinfo: remove SurveyLink->getSurveyInfo() (UNUSED)
DEV: add boolean getters for all survey Y/N properties
  • Loading branch information
TonisOrmisson authored and LouisGac committed Jul 11, 2017
1 parent 8bfec7d commit 2ab30cb
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 31 deletions.
142 changes: 141 additions & 1 deletion application/models/Survey.php
Expand Up @@ -97,13 +97,32 @@
* @property string[] $allLanguages
* @property string[] $additionalLanguages Additional survey languages
* @property array $tokenAttributes Additional token attribute names
* @property bool $isActive Whether Survey is active
* @property string $creationDate Creation date formatted according to user format
* @property string $startDateFormatted Start date formatted according to user format
* @property string $expiryDateFormatted Expiry date formatted according to user format
* @property string $tokensTableName Name of survey tokens table
* @property string $hasTokensTable Whether survey has a tokens table or not
* @property string $googleanalyticsapikeysetting Returns the value for the SurveyEdit GoogleAnalytics API-Key UseGlobal Setting
*
* All Y/N columns in the model can be accessed as boolean values:
* @property bool $isActive Whether Survey is active
* @property bool $isAnonymized Whether survey is anonymized or not
* @property bool $isDateStamp Whether respondents' datestamps will be saved
* @property bool $isUseCookie Are cookies used to prevent repeated participation
* @property bool $isAllowRegister Allow public registration
* @property bool $isAallowSave Is participant allowed save and resume later
* @property bool $isAutoRedirect Automatically load URL when survey complete
* @property bool $isAllowPrev Allow backwards navigation
* @property bool $isPrintAnswers Participants may print answers
* @property bool $isIpAddr Whether Participants IP address will be saved
* @property bool $isRefUrl Save referrer URL
* @property bool $isPublicStatistics Public statistics
* @property bool $isPublicGraphs Show graphs in public statistics
* @property bool $isListPublic List survey publicly
* @property bool $isHtmlEmail Use HTML format for token emails
* @property bool $isSendConfirmation Send confirmation emails
* @property bool $isTokenAnswersPersistence Enable token-based response persistence
* @property bool $isAssessments Enable assessment mode
*/
class Survey extends LSActiveRecord
{
Expand Down Expand Up @@ -936,6 +955,127 @@ public function getIsActive()
{
return ($this->active === 'Y');
}
/**
* @return bool
*/
public function getIsAnonymized()
{
return ($this->anonymized === 'Y');
}
/**
* @return bool
*/
public function getIsDateStamp()
{
return ($this->datestamp === 'Y');
}
/**
* @return bool
*/
public function getIsUseCookie()
{
return ($this->usecookie === 'Y');
}

/**
* @return bool
*/
public function getIsAllowRegister()
{
return ($this->allowregister === 'Y');
}
/**
* @return bool
*/
public function getIsAallowSave()
{
return ($this->allowsave === 'Y');
}
/**
* @return bool
*/
public function getIsAutoRedirect()
{
return ($this->autoredirect === 'Y');
}
/**
* @return bool
*/
public function getIsAllowPrev()
{
return ($this->allowprev === 'Y');
}
/**
* @return bool
*/
public function getIsPrintAnswers()
{
return ($this->printanswers === 'Y');
}
/**
* @return bool
*/
public function getIsIpAddr()
{
return ($this->ipaddr === 'Y');
}
/**
* @return bool
*/
public function getIsRrefUrl()
{
return ($this->refurl === 'Y');
}
/**
* @return bool
*/
public function getIsPublicStatistics()
{
return ($this->publicstatistics === 'Y');
}
/**
* @return bool
*/
public function getIsPublicGraphs()
{
return ($this->publicgraphs === 'Y');
}
/**
* @return bool
*/
public function getIsListPublic()
{
return ($this->listpublic === 'Y');
}
/**
* @return bool
*/
public function getIsHtmlEmail()
{
return ($this->htmlemail === 'Y');
}
/**
* @return bool
*/
public function getIsSendConfirmation()
{
return ($this->sendconfirmation === 'Y');
}
/**
* @return bool
*/
public function getIsTokenAnswersPersistence()
{
return ($this->tokenanswerspersistence === 'Y');
}
/**
* @return bool
*/
public function getIsAssessments()
{
return ($this->assessments === 'Y');
}


/**
* @return array|null
Expand Down
8 changes: 0 additions & 8 deletions application/models/SurveyLink.php
Expand Up @@ -24,7 +24,6 @@
*
* @property Participant $participant
* @property Survey $survey
* @property array $surveyInfo
* @property string $dateFormat
* @property string|boolean $isSubmitted
* @property string $checkbox
Expand Down Expand Up @@ -138,13 +137,6 @@ public function getDateFormat()
return $dateFormat['phpdate'];
}

/**
* @return array
*/
public function getSurveyInfo()
{
return $this->survey->surveyinfo;
}

/**
* @return TokenDynamic
Expand Down
26 changes: 14 additions & 12 deletions application/views/admin/emailtemplates/emailtemplates_view.php
@@ -1,9 +1,14 @@
<?php
$surveyinfo = getSurveyInfo($surveyid);
App()->getClientScript()->registerScriptFile( App()->getConfig('adminscripts') . 'emailtemplates.js');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . 'popup-dialog.css');
$count=0;
/**
* General options
* @var AdminController $this
* @var Survey $oSurvey
*/
App()->getClientScript()->registerScriptFile( App()->getConfig('adminscripts') . 'emailtemplates.js');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . 'popup-dialog.css');
$count=0;
?>

<script type='text/javascript'>
var sReplaceTextConfirmation='<?php eT("This will replace the existing text. Continue?","js"); ?>';
var sKCFinderLanguage='<?php echo sTranslateLangCode2CK(App()->language); ?>';
Expand Down Expand Up @@ -36,10 +41,10 @@
<?php echo CHtml::form(array('admin/emailtemplates/sa/update/surveyid/'.$surveyid), 'post', array('name'=>'emailtemplates', 'class'=>'form-horizontal', 'id'=>'emailtemplates'));?>

<ul class="nav nav-tabs">
<?php foreach ($grplangs as $grouplang): ?>
<?php foreach ($oSurvey->allLanguages as $grouplang): ?>
<li role="presentation" class="<?php if($count==0){ echo 'active'; $count++; }?>" >
<a data-toggle="tab" href='#tab-<?php echo $grouplang; ?>'><?php echo getLanguageNameFromCode($grouplang,false); ?>
<?php if ($grouplang == Survey::model()->findByPk($surveyid)->language): ?>
<?php if ($grouplang == $oSurvey->language): ?>
<?php echo ' ('.gT("Base language").')'; ?>
<?php endif; ?>
</a>
Expand All @@ -50,20 +55,17 @@
<?php
$count = 0;
$active = 'active';
foreach ($grplangs as $key => $grouplang)
{
foreach ($oSurvey->allLanguages as $key => $grouplang) {
$bplang = $bplangs[$key];
$esrow = $attrib[$key];
$aDefaultTexts = $defaulttexts[$key];
if ($ishtml == true)
{
if ($ishtml == true) {
$aDefaultTexts['admin_detailed_notification']=$aDefaultTexts['admin_detailed_notification_css'].conditionalNewlineToBreak($aDefaultTexts['admin_detailed_notification'],$ishtml);
}

$this->renderPartial('/admin/emailtemplates/email_language_tab', compact( 'ishtml', 'surveyid', 'grouplang', 'bplang', 'esrow', 'aDefaultTexts', 'active'));

if($count == 0)
{
if($count == 0) {
$count++;
$active = '';
}
Expand Down
24 changes: 14 additions & 10 deletions application/views/admin/expressions/test/survey_logic_file.php
@@ -1,5 +1,11 @@
<?php
$fullPage = (isset($_GET["sid"]))?false:true;
/**
* General options
* @var AdminController $this
* @var Survey $oSurvey
*/

$fullPage = (isset($_GET["sid"]))?false:true;
?>

<?php if(!$fullPage):?>
Expand Down Expand Up @@ -57,16 +63,14 @@
echo $form;
}
else {
$surveyInfo = (array) explode('|', $_REQUEST['sid']);
$surveyid = sanitize_int($surveyInfo[0]);
$thissurvey=getSurveyInfo($surveyid);
if (isset($_REQUEST['assessments']))
{
//TODO This stuff must be in controller!

$temp = (array) explode('|', $_REQUEST['sid']);
$surveyid = sanitize_int($temp[0]);
if (isset($_REQUEST['assessments'])) {
$assessments = ($_REQUEST['assessments'] == 'Y');
}
else
{
$assessments = ($thissurvey['assessments'] == 'Y');
} else {
$assessments = ($oSurvey->assessments == 'Y');
}
$LEMdebugLevel = (
((isset($_REQUEST['LEM_DEBUG_TIMING']) && $_REQUEST['LEM_DEBUG_TIMING'] == 'Y') ? LEM_DEBUG_TIMING : 0) +
Expand Down

0 comments on commit 2ab30cb

Please sign in to comment.