Skip to content

Commit

Permalink
Fixed issue #T1055: Optimization open/closed-access mode and survey a…
Browse files Browse the repository at this point in the history
…ctivation screens (#2097)
  • Loading branch information
thedirtypanda committed Oct 27, 2021
1 parent 974a09f commit 4f3197a
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 47 deletions.
11 changes: 6 additions & 5 deletions application/controllers/SurveyAdministrationController.php
Expand Up @@ -1746,12 +1746,13 @@ public function actionActivate($iSurveyID)
$noOnclickAction = "window.location.href='" . (Yii::app()->getController()->createUrl("surveyAdministration/view/surveyid/" . $iSurveyID)) . "'";

$activationData = array(
'iSurveyID' => $iSurveyID,
'warning' => $warning,
'allowregister' => $allowregister,
'onclickAction' => $onclickAction,
'iSurveyID' => $iSurveyID,
'survey' => $survey,
'warning' => $warning,
'allowregister' => $allowregister,
'onclickAction' => $onclickAction,
'closedOnclickAction' => $closedOnclickAction,
'noOnclickAction' => $noOnclickAction,
'noOnclickAction' => $noOnclickAction,
);
$this->aData = $aData;
$this->render('_activation_feedback', $activationData);
Expand Down
25 changes: 6 additions & 19 deletions application/controllers/admin/tokens.php
Expand Up @@ -29,7 +29,7 @@ class tokens extends Survey_Common_Action
* @param int $surveyid The survey ID
* @return void
*/
public function index($surveyid)
public function index(int $surveyid)
{
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts') . 'tokens.js', LSYii_ClientScript::POS_BEGIN);
$iSurveyId = $surveyid;
Expand Down Expand Up @@ -2276,7 +2276,7 @@ public function tokenify($iSurveyId)
* @param int $iSurveyId
* @return void
*/
public function kill($iSurveyId)
public function kill(int $iSurveyId)
{
$iSurveyId = (int) $iSurveyId;
$survey = Survey::model()->findByPk($iSurveyId);
Expand Down Expand Up @@ -2307,15 +2307,8 @@ public function kill($iSurveyId)

if (!Yii::app()->request->getQuery('ok')) {
$aData['sidemenu']['state'] = false;
$this->_renderWrappedTemplate('token', array('message' => array(
'title' => gT("Delete survey participants table"),
'message' => gT("If you delete this table access codes will no longer be required to access this survey.") . "<br />" . gT("A backup of this table will be made if you proceed. Your system administrator will be able to access this table.") . "<br />\n"
. sprintf('("%s")<br /><br />', $newtableDisplay)
. "<input class='btn btn-danger' type='submit' value='"
. gT("Delete table") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/kill/surveyid/{$iSurveyId}/ok/Y") . "', '_top')\" />\n"
. "<input class='btn btn-default' type='submit' value='"
. gT("Cancel") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n"
)), $aData);
$aData['backupTableName'] = $newtableDisplay;
$this->_renderWrappedTemplate('token', 'deleteParticipantsTable', $aData);
} else /* The user has confirmed they want to delete the tokens table */
{
Yii::app()->db->createCommand()->renameTable("{{{$oldtable}}}", "{{{$newtable}}}");
Expand All @@ -2334,14 +2327,8 @@ public function kill($iSurveyId)
SurveyLink::model()->deleteLinksBySurvey($iSurveyId);

$aData['sidemenu']['state'] = false;
$this->_renderWrappedTemplate('token', array('message' => array(
'title' => gT("Delete survey participants table"),
'message' => '<br />' . gT("The participant table has now been removed and access codes are no longer required to access this survey.") . "<br /> " . gT("A backup of this table has been made and can be accessed by your system administrator.") . "<br />\n"
. sprintf('("%s")<br /><br />', $newtableDisplay)
. "<input type='submit' class='btn btn-default' value='"
. gT("Main Admin Screen") . "' onclick=\"window.open('" . Yii::app()->getController()->createUrl("surveyAdministration/view/surveyid/" . $iSurveyId) . "', '_top')\" />"
)), $aData);

$aData['backupTableName'] = $newtableDisplay;
$this->_renderWrappedTemplate('token', 'afterDeleteParticipantsTable', $aData);
LimeExpressionManager::SetDirtyFlag(); // so that knows that survey participants tables have changed
}
}
Expand Down
31 changes: 31 additions & 0 deletions application/views/admin/token/afterDeleteParticipantsTable.php
@@ -0,0 +1,31 @@
<?php
/**
* View which will appear, if the particpants table is deleted.
*/
?>
<div class="side-body <?php echo getSideBodyClass(false); ?>">
<div class="row welcom survey-action">
<div class="col-lg-12 content-right">
<div class="jumbotron message-box">
<h3 class="lead"><?php eT('Survey participants table deleted'); ?></h3>
<br /> <br />
<p>
<?php eT('The survey participants table has been deleted and your survey has been switched back to open-access mode. Participants no longer require an access code to access the survey.'); ?>
<br /> <br />
<?php eT('A backup of this table has been made and can be accessed by your administrator.'); ?>
<br />
<?php echo '('. $backupTableName .')'; ?>
<br /> <br />
<?php eT("You can switch back to closed-access mode at any time. Navigate to Settings --> Survey participants and click on the ''Switch to closed-access mode'' button."); ?>
<br /><br />
<input
class="btn btn-default"
type="submit"
value="<?php eT('Main Admin Screen'); ?>"
onclick="window.open(

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt May 11, 2022

Collaborator

Syntax error in the JS here

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt May 11, 2022

Collaborator

And should be anchor button, not submit?

'<?php echo $this->createUrl("surveyAdministration/view/surveyid/{$iSurveyId}"); ?>',
'_top'" />
</div>
</div>
</div>
</div>
39 changes: 39 additions & 0 deletions application/views/admin/token/deleteParticipantsTable.php
@@ -0,0 +1,39 @@
<?php
/**
* Delete Participants Table view
*/
?>
<div class="side-body <?php echo getSideBodyClass(false); ?>">
<div class="row welcom survey-action">
<div class="col-lg-12 content-right">
<div class="jumbotron message-box">
<h3 class="lead"><?php eT('Delete survey participants table'); ?></h3>
<p>
<?php eT('Delete participants table will switch the survey back to open-access mode.'); ?>
<br /> <br />
<?php eT('Access codes will no longer be required to access this survey.'); ?>
<br /> <br />
<?php eT('A backup of this table will be made if you proceed. Your system administrator will be able to access this table.'); ?>
<br />
<?php echo '('. $backupTableName .')'; ?>
<br /> <br />
<?php eT("You can switch back to closed-access mode at any time. Navigate to Settings --> Survey participants and click on the 'Switch to closed-access mode' button."); ?>
<br /> <br />
</p>
<input
class="btn btn-default"
type="submit"
value="<?php eT('Cancel'); ?>"
onclick="window.open(
'<?php echo $this->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}"); ?>',
'_top')" />
<input
class="btn btn-danger"
type='submit'
value="<?php eT('Delete table'); ?>"
onclick="window.open(
'<?php echo $this->createUrl("admin/tokens/sa/kill/surveyid/{$iSurveyId}/ok/Y"); ?>',
'_top')" />

</div>
</div>
22 changes: 8 additions & 14 deletions application/views/admin/token/tokenwarning.php
Expand Up @@ -16,23 +16,17 @@
<p>

<?php
if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'surveysettings', 'update') || Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens','create')){
eT("If you initialise a survey participants table for this survey then this survey will only be accessible to users who provide an access code either manually or by URL.");
?><br /><br />

<?php
if ($oSurvey->isAnonymized) {
eT("Note: If you turn on the -Anonymized responses- option for this survey then LimeSurvey will mark participants who complete the survey only with a 'Y' instead of date/time to ensure the anonymity of your participants.");
?><br /><br />
<?php
}
eT("Do you want to create a survey participant table for this survey?");
?>
if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'surveysettings', 'update') || Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens','create')) {
/** eT("If you initialise a survey participants table for this survey then this survey will only be accessible to users who provide an access code either manually or by URL."); **/
eT("If you switch to closed-access mode then this survey will only be accessible to users who provide an access code either manually or by URL."); ?>
<br /> <br />
<?php eT("You can switch back to open-access mode at any time. Navigate to Settings --> Survey participants and click on the red 'Delete participants table' button from the top bar."); ?>
<?php ?><br /><br />
<br /><br />

<?php echo CHtml::form(array("admin/tokens/sa/index/surveyid/{$oSurvey->sid}"), 'post'); ?>
<button type="submit" class="btn btn-default btn-lg" name="createtable" value="Y"><?php eT("Initialise participant table"); ?></button>
<a href="<?php echo $this->createUrl("surveyAdministration/view/surveyid/$oSurvey->sid"); ?>" class="btn btn-default btn-lg"><?php eT("No, thanks."); ?></a>
<button type="submit" class="btn btn-default btn-lg" name="createtable" value="Y"><?php eT("Switch to closed-access mode"); ?></button>
<a href="<?php echo $this->createUrl("surveyAdministration/view/surveyid/$oSurvey->sid"); ?>" class="btn btn-default btn-lg"><?php eT("Continue in open-access mode"); ?></a>
<?php echo CHtml::endForm() ?>


Expand Down
24 changes: 15 additions & 9 deletions application/views/surveyAdministration/_activation_feedback.php
Expand Up @@ -16,9 +16,11 @@
<div class="row welcome survey-action">
<div class="col-lg-12 content-right">
<div class='jumbotron message-box'>
<h3><?php eT("Activate Survey");?> (<?php echo $iSurveyID; ?>)</h3>
<h3>
<?php eT('Activate Survey'); ?> (<?php echo $survey->currentLanguageSettings->surveyls_title; ?>)
</h3>
<p class='lead'>
<?php eT("Survey has been activated. Results table has been successfully created."); ?>
<?php eT("Your survey has been activated and the responses and statistics section is now available."); ?>
</p>

<?php if($warning):?>
Expand All @@ -41,15 +43,19 @@ class="btn btn-default btn-lg limebutton"
</p>
<?php else:?>
<p>
<?php eT("This survey is now active, and responses can be recorded."); ?>
<br />
<br />
<?php if(!tableExists('tokens_'.$iSurveyID)):?>

<strong><?php eT("Open-access mode:");?></strong>
<?php eT("No invitation code is needed to complete the survey."); ?>
<!-- Open Access Mode -->
<?php eT("By default, surveys are activated in open-access mode. Participants do not need an invitation (access code)"); ?>
<?php eT(" to complete the survey. You can share your survey via URL, QR code or social media. Navigate to Settings --> Overview --> Share your survey."); ?>
<br />
<br />
<!-- Closed Access Mode -->
<?php eT("To exit open-access mode, please click Switch to closed-access mode below. In closed-access mode, only those who are invited (and have an access code) can access the survey."); ?>

<br />
<br />
<?php eT("You can switch to the closed-access mode by initialising a survey participants table by using the button below."); ?>
<?php eT("You can switch back to open-access mode at any time. Navigate to Settings --> Survey participants and click on the red 'Delete participants table' button from the top bar.");?>
<br />
<br />
<input
Expand All @@ -62,7 +68,7 @@ class='btn btn-default'
type='submit'
class='btn btn-default'
id='activateTokenTable__selector--no'
value='<?php eT("No, thanks."); ?>'
value='<?php eT("Continue in open-access mode"); ?>'
/>
<?php else:?>
<input
Expand Down

0 comments on commit 4f3197a

Please sign in to comment.