Skip to content

Commit

Permalink
Fixed #7097: View response details only appears once survey fully com…
Browse files Browse the repository at this point in the history
…pleted even when token persistence set

dev: needed to make action column a little wide to make it fit
  • Loading branch information
mennodekker committed Jan 15, 2013
1 parent 0fe9810 commit 1228f6d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
6 changes: 5 additions & 1 deletion application/controllers/admin/responses.php
Expand Up @@ -326,7 +326,7 @@ function browse($iSurveyID)
$aViewUrls = array();
$oBrowseLanguage = new Limesurvey_lang($aData['language']);


$tokenRequest = Yii::app()->request->getParam('token', null);

//Delete Individual answer using inrow delete buttons/links - checked
if (Yii::app()->request->getPost('deleteanswer') && Yii::app()->request->getPost('deleteanswer') != '' && Yii::app()->request->getPost('deleteanswer') != 'marked' && hasSurveyPermission($iSurveyID, 'responses', 'delete'))
Expand Down Expand Up @@ -513,6 +513,10 @@ function browse($iSurveyID)
//NOW LETS SHOW THE DATA
if (Yii::app()->request->getPost('sql') && stripcslashes(Yii::app()->request->getPost('sql')) !== "" && Yii::app()->request->getPost('sql') != "NULL")
$oCriteria->addCondition(stripcslashes(Yii::app()->request->getPost('sql')));

if (!is_null($tokenRequest)) {
$oCriteria->addCondition('t.token = ' . Yii::app()->db->quoteValue($tokenRequest));
}

$oCriteria->order = 'id ' . (Yii::app()->request->getParam('order') == 'desc' ? 'desc' : 'asc');
$oCriteria->offset = $start;
Expand Down
30 changes: 22 additions & 8 deletions application/controllers/admin/tokens.php
Expand Up @@ -427,6 +427,18 @@ function getTokens_json($iSurveyId, $search = null)

$aSurveyInfo = Survey::model()->findByPk($iSurveyId)->getAttributes(); //Get survey settings
$attributes = getAttributeFieldNames($iSurveyId);

// Now find all responses for the visible tokens
$visibleTokens = array();
$answeredTokens = array();
foreach ($tokens as $token) {
$visibleTokens[] = $token['token'];
}
$answers = Survey_dynamic::model($iSurveyId)->findAllByAttributes(array('token'=>$visibleTokens));
foreach($answers as $answer) {
$answeredTokens[$answer['token']] = $answer['token'];
}

foreach ($tokens as $token)
{
$aRowToAdd = array();
Expand All @@ -445,16 +457,18 @@ function getTokens_json($iSurveyId, $search = null)

$action="";
$action .= "<div class='inputbuttons'>"; // so we can hide this when edit is clicked
// Check is we have an answer
if (in_array($token['token'], $answeredTokens)) {
// @@TODO change link
$url = $this->getController()->createUrl("admin/responses/sa/browse/surveyid/{$iSurveyId}", array('token'=>$token['token']));
$title = $clang->gT("View response details");
$action .= CHtml::link(CHtml::image(Yii::app()->getConfig('adminimageurl') . 'token_viewanswer.png', $title, array('title'=>$title)), $url, array('class'=>'imagelink'));
} else {
$action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
}
// Check if the token can be taken
if ($token['token'] != "" && ($token['completed'] == "N" || $token['completed'] == "")) {
$action .= viewHelper::getImageLink('do_16.png', "survey/index/sid/{$iSurveyId}/token/{$token['token']}/newtest/Y", $clang->gT("Do survey"), '_blank');
} elseif ($token['completed'] != "N" && $token['completed'] != "" && $aSurveyInfo['anonymized'] == "N") {
//Get the survey response id of the matching entry
$id = Survey_dynamic::model($iSurveyId)->findAllByAttributes(array('token' => $token['token']));
if (count($id) > 0) {
$action .= viewHelper::getImageLink('token_viewanswer.png', "admin/responses/sa/view/surveyid/{$iSurveyId}/id/{$id[0]['id']}", $clang->gT("View response details"), '_top');
} else {
$action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
}
} else {
$action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
}
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/token/browse.php
Expand Up @@ -87,7 +87,7 @@
var colNames = ["ID","<?php $clang->eT("Action") ?>","<?php $clang->eT("First name") ?>","<?php $clang->eT("Last name") ?>","<?php $clang->eT("Email address") ?>","<?php $clang->eT("Email status") ?>","<?php $clang->eT("Token") ?>","<?php $clang->eT("Language") ?>","<?php $clang->eT("Invitation sent?") ?>","<?php $clang->eT("Reminder sent?") ?>","<?php $clang->eT("Reminder count") ?>","<?php $clang->eT("Completed?") ?>","<?php $clang->eT("Uses left") ?>","<?php $clang->eT("Valid from") ?>","<?php $clang->eT("Valid until") ?>"<?php if (count($columnNames)) echo ','.$columnNames; ?>];
var colModels = [
{ "name":"tid", "index":"tid", "width":30, "align":"center", "sorttype":"int", "sortable": true, "editable":false, "hidden":false},
{ "name":"action", "index":"action", "sorttype":"string", "sortable": false, "width":100, "align":"center", "editable":false},
{ "name":"action", "index":"action", "sorttype":"string", "sortable": false, "width":120, "align":"center", "editable":false},
{ "name":"firstname", "index":"firstname", "sorttype":"string", "sortable": true, "width":100, "align":"center", "editable":true},
{ "name":"lastname", "index":"lastname", "sorttype":"string", "sortable": true,"width":100, "align":"center", "editable":true},
{ "name":"email", "index":"email","align":"center","width":170, "sorttype":"string", "sortable": true, "editable":true},
Expand Down

0 comments on commit 1228f6d

Please sign in to comment.