Skip to content

Commit

Permalink
Dev Improved error logging by EM
Browse files Browse the repository at this point in the history
Dev Created expression_errors table
Dev Tools section of admin survey bar has "Show log of syntax errors" and "Delete log of syntax errors" options.
Dev These categorize EM errors by whether they are part of "relevance", "text" (general), or an extra question attribute (e.g. "array_filter")
Dev TODO - add hyperlink to edit the question directly
Dev TODO - syntax-highlight the name of the source question (show shows more details)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11234 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Oct 21, 2011
1 parent d00430a commit e04e0c6
Show file tree
Hide file tree
Showing 14 changed files with 437 additions and 33 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$config['versionnumber'] = "2.0alpha";
$config['dbversionnumber'] = 152;
$config['dbversionnumber'] = 153;
$config['buildnumber'] = '';

?>
4 changes: 2 additions & 2 deletions application/controllers/admin/questiongroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,10 @@ function organize($iSurveyID)
$qs = array();
$junk=array();
foreach ($oQuestionData->result_array() as $q) {
$question = '[{' . $q['relevance'] . '}] ' . $q['question'];
$relevance = (trim($q['relevance'])=='') ? 1 : $q['relevance'];
$question = '[{' . $relevance . '}] ' . $q['question'];
LimeExpressionManager::ProcessString($question,$q['qid'],$junk,false,1,1);
$q['question'] = LimeExpressionManager::GetLastPrettyPrintExpression();
// log_message('debug',$q['question']);
$qs[] = $q;
}
$aGrouplist[$iGID]['questions']=$qs;
Expand Down
59 changes: 59 additions & 0 deletions application/controllers/admin/survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,65 @@ function _tempdir($dir, $prefix='', $mode=0700)
return $path;
}

function showsyntaxerrors($surveyid)
{
$surveyid=(int)$surveyid;
if (is_null($surveyid) || !$surveyid)
{
die();
}

if(!bHasSurveyPermission($surveyid,'surveysettings','read') && !bHasGlobalPermission('USER_RIGHT_CREATE_SURVEY'))
{
die();
}

self::_js_admin_includes($this->config->item('generalscripts').'admin/surveysettings.js');
self::_js_admin_includes($this->config->item('generalscripts').'jquery/jqGrid/js/i18n/grid.locale-en.js');
self::_js_admin_includes($this->config->item('generalscripts').'jquery/jqGrid/js/jquery.jqGrid.min.js');
self::_js_admin_includes($this->config->item('generalscripts').'jquery/jquery.json.min.js');
self::_css_admin_includes($this->config->item('styleurl')."admin/default/superfish.css");
self::_css_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/css/ui.jqgrid.css");
self::_getAdminHeader();
self::_showadminmenu($surveyid);;
self::_surveybar($surveyid);

$data['errors'] = LimeExpressionManager::GetSyntaxErrors();

$this->load->view('admin/survey/showSyntaxErrors_view',$data);
self::_loadEndScripts();
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
}

function resetsyntaxerrorlog($surveyid)
{
$surveyid=(int)$surveyid;
if (is_null($surveyid) || !$surveyid)
{
die();
}

if(!bHasSurveyPermission($surveyid,'surveysettings','read') && !bHasGlobalPermission('USER_RIGHT_CREATE_SURVEY'))
{
die();
}

self::_js_admin_includes($this->config->item('generalscripts').'admin/surveysettings.js');
self::_js_admin_includes($this->config->item('generalscripts').'jquery/jqGrid/js/i18n/grid.locale-en.js');
self::_js_admin_includes($this->config->item('generalscripts').'jquery/jqGrid/js/jquery.jqGrid.min.js');
self::_js_admin_includes($this->config->item('generalscripts').'jquery/jquery.json.min.js');
self::_css_admin_includes($this->config->item('styleurl')."admin/default/superfish.css");
self::_css_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/css/ui.jqgrid.css");
self::_getAdminHeader();
self::_showadminmenu($surveyid);;
self::_surveybar($surveyid);

LimeExpressionManager::ResetSyntaxErrorLog();

$this->load->view('admin/survey/resetSyntaxErrorLog_view');
self::_loadEndScripts();
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
}

/**
* survey::view()
Expand Down
3 changes: 3 additions & 0 deletions application/helpers/expressions/em_core_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ public function sProcessStringContainingExpressionsHelper($src, $questionNum)

$resolvedParts = array();
$prettyPrintParts = array();
$allErrors=array();

foreach ($stringParts as $stringPart)
{
Expand All @@ -1669,6 +1670,7 @@ public function sProcessStringContainingExpressionsHelper($src, $questionNum)
{
// show original and errors in-line
$resolvedPart = $this->GetPrettyPrintString();
$allErrors[] = $this->GetErrors();
}
$jsVarsUsed = $this->GetJsVarsUsed();
$prettyPrintParts[] = $this->GetPrettyPrintString();
Expand Down Expand Up @@ -1699,6 +1701,7 @@ public function sProcessStringContainingExpressionsHelper($src, $questionNum)
}
$result = implode('',$this->flatten_array($resolvedParts));
$this->prettyPrintSource = implode('',$this->flatten_array($prettyPrintParts));
$this->errs = $allErrors; // so that has all errors from this string
return $result; // recurse in case there are nested ones, avoiding infinite loops?
}

Expand Down

0 comments on commit e04e0c6

Please sign in to comment.