Skip to content
Permalink
Browse files

Fixed issue #16023: all survey group settings could now be safed corr…

…ectly
  • Loading branch information
Patricia Stelling
Patricia Stelling committed Mar 24, 2020
1 parent 01a3111 commit eddb5493b09bb21a604ce4c97b841b6aae32091f
@@ -131,18 +131,34 @@ public function update($id)
public function surveySettings($id)
{
$bRedirect = 0;
/** @var SurveysGroups $model */
$model = $this->loadModel($id);

$aData['model'] = $model;

$sPartial = Yii::app()->request->getParam('partial', '_generaloptions_panel');
/** @var SurveysGroupsettings $oSurvey */
$oSurvey = SurveysGroupsettings::model()->findByPk($model->gsid);
$oSurvey->setOptions();
$oSurvey->setOptions(); //this gets the "values" from the group that inherits to this group ...
$oSurvey->owner_id = $model->owner_id;

if (isset($_POST['template'])) {
//every $_POST checked here is one of the switchers(On|Off|Inherit) names
// Name of sidemenulink => name of input field
// "General settings" => 'template'
// "Presentation" => 'showxquestions'
// "Pariticipant setting" => 'anonymized'
// "Notification & data" => 'datestamp'
// "Publication & access" => 'listpublic'
if(isset($_POST['template']) || isset($_POST['showxquestions']) || isset($_POST['anonymized'])
|| isset($_POST['datestamp']) || isset($_POST['listpublic'])){
$oSurvey->attributes = $_POST;
$oSurvey->usecaptcha = Survey::saveTranscribeCaptchaOptions();

if(isset($_POST['listpublic'])){
//what is usecaptcha used for? see saveTranscribeCaptchaOptions method description ...
// in default group this is set to 'N' ... (this means 'none' no captcha for survey access, regigstration
// and 'save&load'
$oSurvey->usecaptcha = Survey::saveTranscribeCaptchaOptions();
}

if ($oSurvey->save()) {
$bRedirect = 1;
@@ -278,13 +278,25 @@ public function getIsAnonymized()
}

/**
* Recursive function
*
* Gets the real values for a group.
* A group could inherit from a group, this one could inherit from a group ...
* It steps up (see param $iStep) until it has found the real settings ...
*
* @param int $iSurveyGroupId
* @param null $oSurvey
* @param null $instance
* @param int $iStep this is inheritance step (recursive step) (parent, parentParent, parentParentParent ?)
* @param bool $bRealValues
* @return SurveysGroupsettings instance
*/
public static function getInstance($iSurveyGroupId = 0, $oSurvey = null, $instance = null, $iStep = 1, $bRealValues = false){

if ($iSurveyGroupId > 0){
$model = SurveysGroupsettings::model()->with('SurveysGroups')->findByPk($iSurveyGroupId);
} else {
//this is the default group setting with gsid=0 !!!
$model = SurveysGroupsettings::model()->findByPk($iSurveyGroupId);
}

@@ -392,6 +404,13 @@ protected static function translateOptionLabels($instance, $attribute, $value){
}
}

/**
* Gets the "values" from the group that inherits to this group and ...
*
* ... sets the variables (not DB attributes) of "oOptions", "oOptionLabels", "aOptions"
* and "showInherited" (most of them used for frontend i think)
*
*/
public function setOptions()
{
$instance = SurveysGroupsettings::getInstance($this->gsid);

0 comments on commit eddb549

Please sign in to comment.
You can’t perform that action at this time.