Skip to content

Commit

Permalink
DEV: small changes after psalm check
Browse files Browse the repository at this point in the history
  • Loading branch information
Trischi80 committed Jun 2, 2020
1 parent 6b6097d commit 436d0fc
Show file tree
Hide file tree
Showing 7 changed files with 2,058 additions and 14 deletions.
22 changes: 13 additions & 9 deletions application/controllers/QuestionEditorController.php
Expand Up @@ -45,19 +45,27 @@ protected function beforeRender($view)
}

/**
* Renders the main view for questioneditor.
* Main view function prepares the necessary global js parts and renders the HTML for the question editor
*
* @param integer $surveyid
* @param integer $gid
* @param integer $qid
* @param string $landOnSideMenuTab Name of the side menu tab. Default behavior is to land on structure tab.
*
* @return void
*
* @throws CException
* @throws CHttpException
*/
public function actionView($surveyid, $gid = null, $qid = null, $landOnSideMenuTab = 'structure'){
$aData = array();
$iSurveyID = (int) $surveyid;
$oSurvey = Survey::model()->findByPk($iSurveyID);

if($oSurvey === null){
throw new CHttpException(500, "Survey not found $iSurveyID");
}

$gid = $gid ?? $oSurvey->groups[0]->gid;
$oQuestion = $this->getQuestionObject($qid, null, $gid);
App()->getClientScript()->registerPackage('questioneditor');
Expand Down Expand Up @@ -249,8 +257,6 @@ public function actionSaveQuestionData($sid)
}

$questionData = App()->request->getPost('questionData', []);
// TODO: Unused variable
$isNewQuestion = false;
$questionCopy = (boolean) App()->request->getPost('questionCopy');
$questionCopySettings = App()->request->getPost('copySettings', []);
$questionCopySettings = array_map( function($value) {return !!$value;}, $questionCopySettings);
Expand All @@ -259,8 +265,6 @@ public function actionSaveQuestionData($sid)
$oQuestion = Question::model()->findByPk($questionData['question']['qid']);
if ($oQuestion == null || $questionCopy == true) {
$oQuestion = $this->storeNewQuestionData($questionData['question']);
// TODO: Unused variable
$isNewQuestion = true;
} else {
$oQuestion = $this->updateQuestionData($oQuestion, $questionData['question']);
}
Expand Down Expand Up @@ -301,7 +305,7 @@ public function actionSaveQuestionData($sid)
);
} elseif (array_key_exists('clear_default', $questionData['generalSettings'])
&& $questionData['generalSettings']['clear_default']['formElementValue'] == 'Y') {
SettingsUser::deleteUserSetting('question_default_values_' . $questionData['question']['type'], '');
SettingsUser::deleteUserSetting('question_default_values_' . $questionData['question']['type']);
}

// If set, store subquestions
Expand Down Expand Up @@ -342,7 +346,7 @@ public function actionSaveQuestionData($sid)
$aCompiledQuestionData = $this->getCompiledQuestionData($oNewQuestion);
$aQuestionAttributeData = QuestionAttribute::model()->getQuestionAttributes($oQuestion->qid);
$aQuestionGeneralOptions = $this->getGeneralOptions($oQuestion->qid, null, $oQuestion->gid, $aQuestionAttributeData['question_template']);
$aAdvancedOptions = $this->getAdvancedOptions($oQuestion->qid, null, true);
$aAdvancedOptions = $this->getAdvancedOptions($oQuestion->qid, null);

// Return a JSON document with the newly stored question data
$this->renderJSON(
Expand Down Expand Up @@ -745,8 +749,8 @@ private function getCompiledQuestionData(&$oQuestion)
/**
* It returns a preformatted array of advanced settings.
*
* @param null $iQuestionId
* @param null $sQuestionType
* @param int $iQuestionId
* @param string $sQuestionType
* @param string $question_template
* @return array
* @throws CException
Expand Down
3 changes: 1 addition & 2 deletions application/models/SettingsUser.php
Expand Up @@ -107,14 +107,13 @@ public static function setUserSetting($stg_name, $stg_value, $uid = null, $entit
* Deletes user setting
*
* @param string $stg_name
* @param integer $stg_value
* @param integer $uid | Can be omitted to just take the currently logged in users id
* @param string $entity | optional defaults to 'null'
* @param integer $entity_id | optional defaults to 'null'
* @return boolean Deleting success/failure
*/

public static function deleteUserSetting($stg_name, $stg_value, $uid = null, $entity = null, $entity_id = null)
public static function deleteUserSetting($stg_name, $uid = null, $entity = null, $entity_id = null)
{
if ($uid === null) { $uid = Yii::app()->user->getId(); }

Expand Down

0 comments on commit 436d0fc

Please sign in to comment.