Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Jan 14, 2018
1 parent 7213088 commit 9268855
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 67 deletions.
6 changes: 3 additions & 3 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -1589,12 +1589,12 @@ protected function getCAnswersAndCQuestions(array $theserows)
}
} elseif ($rows['type'] != Question::QT_M_MULTIPLE_CHOICE &&
$rows['type'] != Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS &&
$rows['type'] != Question::QT_I_LANGUAGE ) {
$rows['type'] != Question::QT_I_LANGUAGE) {
// For dropdown questions
// optinnaly add the 'Other' answer
if ( ($rows['type'] == Question::QT_L_LIST_DROPDOWN ||
if (($rows['type'] == Question::QT_L_LIST_DROPDOWN ||
$rows['type'] == Question::QT_EXCLAMATION_LIST_DROPDOWN) &&
$rows['other'] == "Y" ) {
$rows['other'] == "Y") {
$canswers[] = array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], "-oth-", gT("Other"));
}

Expand Down
3 changes: 1 addition & 2 deletions application/controllers/admin/questions.php
Expand Up @@ -1489,8 +1489,7 @@ public function setMultipleMandatory()
$oQuestion = Question::model()->findByPk(array("qid"=>$iQid, 'language'=>$sAdditionalLanguage));

// These are the questions types that have no mandatory property - so zap it accordingly
if ($oQuestion->type != Question::QT_X_BOILERPLATE_QUESTION && $oQuestion->type != Question::QT_VERTICAL_FILE_UPLOAD)
{
if ($oQuestion->type != Question::QT_X_BOILERPLATE_QUESTION && $oQuestion->type != Question::QT_VERTICAL_FILE_UPLOAD) {
$oQuestion->mandatory = $bMandatory;
$oQuestion->save();
}
Expand Down
3 changes: 1 addition & 2 deletions application/controllers/admin/statistics.php
Expand Up @@ -671,8 +671,7 @@ public function simpleStatistics($surveyid)
// The questions to display (all question)
foreach ($rows as $row) {
$type = $row['type'];
if ($type == Question::QT_T_LONG_FREE_TEXT || $type == Question::QT_N_NUMERICAL)
{
if ($type == Question::QT_T_LONG_FREE_TEXT || $type == Question::QT_N_NUMERICAL) {
$summary[] = $type.$iSurveyId.'X'.$row['gid'].'X'.$row['qid'];
}
switch ($type) {
Expand Down
5 changes: 3 additions & 2 deletions application/controllers/admin/usergroups.php
Expand Up @@ -318,7 +318,8 @@ public function index($ugid = false, $header = false)
$aData["useradddialog"] = true;

$aUsers = User::model()->findAll(['join'=>"LEFT JOIN (SELECT uid AS id FROM {{user_in_groups}} WHERE ugid = {$ugid}) AS b ON t.uid = b.id", 'condition'=>"id IS NULL"]);
$aNewUserListData = CHtml::listData($aUsers, 'uid', function($user) {
$aNewUserListData = CHtml::listData($aUsers, 'uid', function($user)
{
return \CHtml::encode($user->users_name)." (".\CHtml::encode($user->full_name).')'; });
// Remove group owner because an owner is automatically member of a group
unset($aNewUserListData[$aUserInGroupsResult->owner_id]);
Expand Down Expand Up @@ -393,7 +394,7 @@ function user($ugid, $action = 'add')
}
break;
}
if (!empty($sFlashType) && !empty($sFlashMessage)) {
if (!empty($sFlashType) && !empty($sFlashMessage)) {
Yii::app()->user->setFlash($sFlashType, $sFlashMessage);
}
$this->getController()->redirect(array('admin/usergroups/sa/view/ugid/'.$ugid));
Expand Down
4 changes: 1 addition & 3 deletions application/core/plugins/ExportSTATAxml/STATAxmlWriter.php
Expand Up @@ -245,9 +245,7 @@ function createStataFieldmap($survey, $sLanguage, $oOptions)
'code' => 3,
'answer' => gT('Uncertain')
);
}
elseif ($aQuestion['type'] == Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS)
{
} elseif ($aQuestion['type'] == Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS) {
$aFieldmap['answers'][$aQuestion['qid']]['0']['1'] = array(
'code' => 1,
'answer' => gT('Increase')
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/activate_helper.php
Expand Up @@ -316,7 +316,7 @@ function activateSurvey($iSurveyID, $simulate = false)
case Question::QT_M_MULTIPLE_CHOICE: //Multiple choice
case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS: //Multiple choice with comment
case Question::QT_O_LIST_WITH_COMMENT: //DROPDOWN LIST WITH COMMENT
if ($aRow['aid'] != 'other' && strpos($aRow['aid'],'comment')===false && strpos($aRow['aid'],'othercomment')===false) {
if ($aRow['aid'] != 'other' && strpos($aRow['aid'], 'comment') === false && strpos($aRow['aid'], 'othercomment') === false) {
$aTableDefinition[$aRow['fieldname']] = "string(5)";
} else {
$aTableDefinition[$aRow['fieldname']] = "text";
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/admin/import_helper.php
Expand Up @@ -1009,12 +1009,12 @@ function XMLImportLabelsets($sFullFilePath, $options)

//CHECK FOR DUPLICATE LABELSETS

if ($options['checkforduplicates']=='on') {
if ($options['checkforduplicates'] == 'on') {

$aLabelSetCheckSums = buildLabelSetCheckSumArray();
$aCounts=array_count_values($aLabelSetCheckSums);
$aCounts = array_count_values($aLabelSetCheckSums);
foreach ($aImportedLabelSetIDs as $iLabelSetID) {
if ($aCounts[$aLabelSetCheckSums[$iLabelSetID]]>1) {
if ($aCounts[$aLabelSetCheckSums[$iLabelSetID]] > 1) {
LabelSet::model()->deleteLabelSet($iLabelSetID);
}
}
Expand Down
33 changes: 11 additions & 22 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -1416,13 +1416,11 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
}

//handling for "other" field for list radio or list drowpdown
if ((($qtype == Question::QT_L_LIST_DROPDOWN || $qtype == Question::QT_EXCLAMATION_LIST_DROPDOWN) && $qother == Question::QT_Y_YES_NO_RADIO))
{
if ((($qtype == Question::QT_L_LIST_DROPDOWN || $qtype == Question::QT_EXCLAMATION_LIST_DROPDOWN) && $qother == Question::QT_Y_YES_NO_RADIO)) {
//add "other"
$alist[] = array(gT("Other"), gT("Other"), $fielddata['fieldname'].'other');
}
if ($qtype == Question::QT_O_LIST_WITH_COMMENT)
{
if ($qtype == Question::QT_O_LIST_WITH_COMMENT) {
//add "comment"
$alist[] = array(gT("Comments"), gT("Comments"), $fielddata['fieldname'].'comment', 'is_comment');
}
Expand Down Expand Up @@ -1705,8 +1703,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
}

// For multi question type, we have to check non completed with ALL sub question set to NULL
if (($outputs['qtype'] == Question::QT_M_MULTIPLE_CHOICE) or ($outputs['qtype'] == Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS))
{
if (($outputs['qtype'] == Question::QT_M_MULTIPLE_CHOICE) or ($outputs['qtype'] == Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS)) {
$criteria = new CDbCriteria;
foreach ($outputs['alist'] as $al) {
$criteria->addCondition(Yii::app()->db->quoteColumnName($al[2])." IS NULL");
Expand Down Expand Up @@ -1801,8 +1798,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
//data available
if (($gdata[$i] !== "N/A")) {
//check if data should be aggregated
if (Yii::app()->getConfig('showaggregateddata') == 1 && ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS))
{
if (Yii::app()->getConfig('showaggregateddata') == 1 && ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS)) {
//mark that we have done soemthing special here
$aggregated = true;

Expand Down Expand Up @@ -1905,8 +1901,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
//it's only useful to calculate standard deviation and arithmetic means for question types
//5 = 5 Point Scale
//A = Array (5 Point Choice)
if ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS)
{
if ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS) {
$stddev = 0;
$stddevarray = array_slice($grawdata, 0, 5, true);
$am = 0;
Expand Down Expand Up @@ -2199,10 +2194,8 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
if (isset($al[2]) && $al[2]) {

//handling for "other" option
if ($al[0] == gT("Other"))
{
if ($outputs['qtype'] == Question::QT_EXCLAMATION_LIST_DROPDOWN || $outputs['qtype'] == Question::QT_L_LIST_DROPDOWN)
{
if ($al[0] == gT("Other")) {
if ($outputs['qtype'] == Question::QT_EXCLAMATION_LIST_DROPDOWN || $outputs['qtype'] == Question::QT_L_LIST_DROPDOWN) {
// It is better for single choice question types to filter on the number of '-oth-' entries, than to
// just count the number of 'other' values - that way with failing Javascript the statistics don't get messed up
/* This query selects a count of responses where "other" has been selected */
Expand Down Expand Up @@ -2406,8 +2399,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
//check if aggregated results should be shown
elseif (Yii::app()->getConfig('showaggregateddata') == 1) {
if (!isset($showheadline) || $showheadline != false) {
if ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS)
{
if ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS) {
switch ($outputType) {
case 'xls':
$this->xlsRow++;
Expand Down Expand Up @@ -2678,8 +2670,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
}

// For multi question type, we have to check non completed with ALL sub question set to NULL
if (($outputs['qtype'] == Question::QT_M_MULTIPLE_CHOICE) or ($outputs['qtype'] == Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS))
{
if (($outputs['qtype'] == Question::QT_M_MULTIPLE_CHOICE) or ($outputs['qtype'] == Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS)) {
$criteria = new CDbCriteria;
foreach ($outputs['alist'] as $al) {
$criteria->addCondition(Yii::app()->db->quoteColumnName($al[2])." IS NULL");
Expand Down Expand Up @@ -2830,8 +2821,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
//data available
else {
//check if data should be aggregated
if (Yii::app()->getConfig('showaggregateddata') == 1 && ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS))
{
if (Yii::app()->getConfig('showaggregateddata') == 1 && ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS)) {
//mark that we have done soemthing special here
$aggregated = true;

Expand Down Expand Up @@ -3077,8 +3067,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
//it's only useful to calculate standard deviation and arithmetic means for question types
//5 = 5 Point Scale
//A = Array (5 Point Choice)
if ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS)
{
if ($outputs['qtype'] == Question::QT_5_POINT_CHOICE || $outputs['qtype'] == Question::QT_A_ARRAY_5_CHOICE_QUESTIONS) {
$stddev = 0;
$stddevarray = array_slice($grawdata, 0, 5, true);
$am = 0;
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -1137,9 +1137,9 @@ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $sLanguage)

//Find out the question type
$this_type = $fields['type'];
switch($this_type) {
switch ($this_type) {
case Question::QT_D_DATE:
if (trim($sValue)!='') {
if (trim($sValue) != '') {
$qidattributes = QuestionAttribute::model()->getQuestionAttributes($fields['qid']);
$dateformatdetails = getDateFormatDataForQID($qidattributes, $iSurveyID);
$sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate']);
Expand Down
8 changes: 4 additions & 4 deletions application/helpers/frontend_helper.php
Expand Up @@ -1512,15 +1512,15 @@ function doAssessment($surveyid)
{
if ($_SESSION['survey_'.$surveyid][$field['fieldname']] == "Y")
{
$aAttributes=getQuestionAttributeValues($field['qid']);
$aAttributes = getQuestionAttributeValues($field['qid']);
}
$assessmentValue = (int)$aAttributes['assessment_value'];
$assessmentValue = (int) $aAttributes['assessment_value'];
}
} else {
// Single choice question
$usrow = Answer::findByAttributes(['qid'=>$field['qid'],'code'=>$_SESSION['survey_'.$surveyid][$field['fieldname']]]);
$usrow = Answer::findByAttributes(['qid'=>$field['qid'], 'code'=>$_SESSION['survey_'.$surveyid][$field['fieldname']]]);
if (!empty($usrow)) {
$assessmentValue = $usrow->assessment_value;
$assessmentValue = $usrow->assessment_value;
// $total = $total+$usrow['assessment_value'];
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/questionHelper.php
Expand Up @@ -80,7 +80,7 @@ public static function getAttributesDefinitions()
);

self::$attributes["repeat_headings"] = array(
"types"=>Question::QT_F_ARRAY_FLEXIBLE_ROW . Question::QT_COLON_ARRAY_MULTI_FLEX_NUMBERS . Question::QT_1_ARRAY_MULTISCALE . Question::QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT,
"types"=>Question::QT_F_ARRAY_FLEXIBLE_ROW.Question::QT_COLON_ARRAY_MULTI_FLEX_NUMBERS.Question::QT_1_ARRAY_MULTISCALE.Question::QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT,
'category'=>gT('Display'),
'sortorder'=>100,
'inputtype'=>'integer',
Expand Down

0 comments on commit 9268855

Please sign in to comment.