Skip to content

Commit

Permalink
Fixed issue #CR-1230: Deactivate survey - wrong name of the responses…
Browse files Browse the repository at this point in the history
… table (#3347)
  • Loading branch information
mohabmes committed Aug 21, 2023
1 parent 01da4ab commit 2c8ae34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion application/controllers/SurveyAdministrationController.php
Expand Up @@ -1611,9 +1611,15 @@ public function actionDeactivate()
$this->redirect($this->createUrl("surveyAdministration/view/surveyid/{$iSurveyID}"));
}
if (Yii::app()->request->getPost('ok') == '') {
if (!empty(Yii::app()->session->get('sNewSurveyTableName'))) {
Yii::app()->session->remove('sNewSurveyTableName');
}

Yii::app()->session->add('sNewSurveyTableName', Yii::app()->db->tablePrefix . "old_survey_{$iSurveyID}_{$date}");
$aData['surveyid'] = $iSurveyID;
$aData['date'] = $date;
$aData['dbprefix'] = Yii::app()->db->tablePrefix;
$aData['sNewSurveyTableName'] = Yii::app()->session->get('sNewSurveyTableName');
$aData['step1'] = true;
} else {
//See if there is a tokens table for this survey
Expand Down Expand Up @@ -1655,7 +1661,7 @@ public function actionDeactivate()
// IF there are any records in the saved_control table related to this survey, they have to be deleted
SavedControl::model()->deleteSomeRecords(array('sid' => $iSurveyID)); //Yii::app()->db->createCommand($query)->query();
$sOldSurveyTableName = Yii::app()->db->tablePrefix . "survey_{$iSurveyID}";
$sNewSurveyTableName = Yii::app()->db->tablePrefix . "old_survey_{$iSurveyID}_{$date}";
$sNewSurveyTableName = Yii::app()->session->get('sNewSurveyTableName');
$aData['sNewSurveyTableName'] = $sNewSurveyTableName;

$query = "SELECT id FROM " . Yii::app()->db->quoteTableName($sOldSurveyTableName) . " ORDER BY id desc";
Expand Down Expand Up @@ -1715,6 +1721,7 @@ public function actionDeactivate()

//after deactivation redirect to survey overview and show message...
//$this->redirect(['surveyAdministration/view', 'surveyid' => $iSurveyID]);
Yii::app()->session->remove('sNewSurveyTableName');
}

$aData['sidemenu']['state'] = false;
Expand Down
Expand Up @@ -5,7 +5,8 @@
$this->renderPartial('stopSurvey_view', [
'surveyid' => $surveyid,
'dbprefix' => $dbprefix,
'date' => $date
'date' => $date,
'sNewSurveyTableName' => $sNewSurveyTableName ?? null
]);
} elseif (isset($nostep)) { //todo: why no step? at least a message would be nice...?>

Expand Down
5 changes: 3 additions & 2 deletions application/views/surveyAdministration/stopSurvey_view.php
Expand Up @@ -3,6 +3,7 @@
/** @var int $surveyid */
/** @var string $dbprefix */
/** @var string $date */
/** @var string $sNewSurveyTableName */

?>
<div class='side-body stop-survey-body <?php echo getSideBodyClass(false); ?>'>
Expand Down Expand Up @@ -62,8 +63,8 @@ class="btn btn-outline-secondary px-4"
</div>
<div class="card-body px-0 d-flex">
<ul>
<li><?php printf(gT('%sResponses%s are %sno longer accessible%s.%s Your response table will be renamed to: %s%s_old_%d_%s%s'),
'<b>', '</b>', '<b>', '</b>','<br />', '<span class="table-rename">', $dbprefix, $surveyid, $date, '</span>'); ?></li>
<li><?php printf(gT('%sResponses%s are %sno longer accessible%s.%s Your response table will be renamed to: %s%s'),
'<b>', '</b>', '<b>', '</b>','<br />', '<b>', $sNewSurveyTableName, '</b>'); ?></li>

This comment has been minimized.

Copy link
@c-schmitz

c-schmitz Sep 25, 2023

Contributor

@mohabmes This introduced a bug, because the number of placeholder and the number of texts in the string are not matching.

<li><?php printf(gT("All %sparticipant information will be lost%s."), '<b>', '</b>'); ?></li>
<li><?php printf(gT("%sCannot%s be %saccessed%s by %sparticipants%s. A message will be displayed stating that the survey has been closed."),
'<b>', '</b>','<b>', '</b>', '<b>', '</b>'); ?></li>
Expand Down

0 comments on commit 2c8ae34

Please sign in to comment.