Skip to content

Commit

Permalink
Dev Speed optimizations when browsing responses
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Dec 12, 2013
1 parent 6a75d8c commit 709ae21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions application/controllers/admin/responses.php
Expand Up @@ -586,6 +586,7 @@ function browse($iSurveyID)
$aData['end'] = $end;
$aData['fncount'] = $fncount;
$aData['fnames'] = $fnames;
$aData['bHasFileUploadQuestion'] = hasFileUploadQuestion($iSurveyID);

$aViewUrls[] = 'browseallheader_view';

Expand Down
11 changes: 4 additions & 7 deletions application/helpers/common_helper.php
Expand Up @@ -2245,13 +2245,13 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi

$sLanguage = sanitize_languagecode($sLanguage);
$surveyid = sanitize_int($surveyid);
$clang = new Limesurvey_lang($sLanguage);

//checks to see if fieldmap has already been built for this page.
if (isset(Yii::app()->session['fieldmap-' . $surveyid . $sLanguage]) && !$force_refresh && $questionid == false) {
return Yii::app()->session['fieldmap-' . $surveyid . $sLanguage];
}

$clang = new Limesurvey_lang($sLanguage);
$fieldmap["id"]=array("fieldname"=>"id", 'sid'=>$surveyid, 'type'=>"id", "gid"=>"", "qid"=>"", "aid"=>"");
if ($style == "full")
{
Expand Down Expand Up @@ -2822,12 +2822,9 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
* @param $surveyid The survey ID
* @return bool
*/
function hasFileUploadQuestion($surveyid) {
$fieldmap = createFieldMap($surveyid,'short',false,false,getBaseLanguageFromSurveyID($surveyid));

foreach ($fieldmap as $field) {
if (isset($field['type']) && $field['type'] === '|') return true;
}
function hasFileUploadQuestion($iSurveyID) {
$iCount = Question::model()->count( "sid=:surveyid AND parent_qid=0 AND type='|'", array(':surveyid' => $iSurveyID));
return $iCount>0 ;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/responses/browseallheader_view.php
Expand Up @@ -105,7 +105,7 @@
<?php if (Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'delete')) { ?>
<img id='imgDeleteMarkedResponses' src='<?php echo $sImageURL; ?>token_delete.png' alt='<?php $clang->eT('Delete marked responses'); ?>' />
<?php } ?>
<?php if (hasFileUploadQuestion($iSurveyId)) { ?>
<?php if ($bHasFileUploadQuestion) { ?>
<img id='imgDownloadMarkedFiles' src='<?php echo $sImageURL; ?>down_all.png' alt='<?php $clang->eT('Download marked files'); ?>' />
<?php } ?>
</td>
Expand Down

0 comments on commit 709ae21

Please sign in to comment.