Skip to content

Commit

Permalink
Fixed issue #10436: Display the question correctly in question explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Feb 16, 2016
1 parent c8c2ce8 commit 7f87a06
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.
10 changes: 10 additions & 0 deletions application/core/Survey_Common_Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,16 @@ function _surveysidemenu($aData)
foreach($aGroups as $group)
{
$group->aQuestions = Question::model()->findAllByAttributes(array("sid"=>$iSurveyID, "gid"=>$group['gid'],"language"=>$sumresult1->defaultlanguage->surveyls_language), array('order'=>'question_order ASC'));

foreach($group->aQuestions as $question)
{
if(strlen($question->question)>100)
{
$question->question = substr($question->question, 0, 50);
$question->question .= ' <br>...<br> ';
$question->question .= substr($question->question, 0, 50);
}
}
}
}
$aData['aGroups'] = $aGroups;
Expand Down
78 changes: 39 additions & 39 deletions application/helpers/expressions/em_core_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ public function GetPrettyPrintString()
}

if ($this->groupSeq == -1 || $groupSeq == -1 || $questionSeq == -1 || $this->questionSeq == -1) {
$class = 'em-var-static';
$class = 'em-var-static';
}
elseif ($groupSeq > $this->groupSeq) {
$class = 'em-var-before em-var-diffgroup';
Expand Down Expand Up @@ -2556,14 +2556,14 @@ function exprmgr_stripos($haystack , $needle ,$offset=0)
* @param string $haystack : checked string
* @param string $needle : string to find
* @param boolean $before_needle : portion to return
* @return string|false
* @return string|false
*/
function exprmgr_stristr($haystack,$needle,$before_needle=false)
{
return mb_stristr($haystack,$needle,$before_needle,'UTF-8');
}
/**
* Get unicode string length
* Get unicode string length
* @param string $string
* @return int
*/
Expand All @@ -2589,14 +2589,14 @@ function exprmgr_strpos($haystack , $needle ,$offset=0)
* @param string $haystack : checked string
* @param string $needle : string to find
* @param boolean $before_needle : portion to return
* @return string|false
* @return string|false
*/
function exprmgr_strstr($haystack,$needle,$before_needle=false)
{
return mb_strstr($haystack,$needle,$before_needle,'UTF-8');
}
/**
* Make an unicode string lowercase
* Make an unicode string lowercase
* @param string $string
* @return string
*/
Expand All @@ -2605,7 +2605,7 @@ function exprmgr_strtolower($string)
return mb_strtolower ($string,'UTF-8');
}
/**
* Make an unicode string uppercase
* Make an unicode string uppercase
* @param string $string
* @return string
*/
Expand Down Expand Up @@ -2660,48 +2660,48 @@ function exprmgr_sumifop($args)

/**
* Find the closest matching numerical input values in a list an replace it by the
* corresponding value within another list
*
* corresponding value within another list
*
* @author Johannes Weberhofer, 2013
*
* @param numeric $fValueToReplace
* @param numeric $iStrict - 1 for exact matches only otherwise interpolation the
* @param numeric $iStrict - 1 for exact matches only otherwise interpolation the
* closest value should be returned
* @param string $sTranslateFromList - comma seperated list of numeric values to translate from
* @param string $sTranslateToList - comma seperated list of numeric values to translate to
* @return numeric
*/
function exprmgr_convert_value($fValueToReplace, $iStrict, $sTranslateFromList, $sTranslateToList)
function exprmgr_convert_value($fValueToReplace, $iStrict, $sTranslateFromList, $sTranslateToList)
{
if ( (is_numeric($fValueToReplace)) && ($iStrict!=null) && ($sTranslateFromList!=null) && ($sTranslateToList!=null) )
{
$aFromValues = explode( ',', $sTranslateFromList);
$aToValues = explode( ',', $sTranslateToList);
if ( (count($aFromValues) > 0) && (count($aFromValues) == count($aToValues)) )
{
$fMinimumDiff = null;
$iNearestIndex = 0;
for ( $i = 0; $i < count($aFromValues); $i++) {
if ( !is_numeric($aFromValues[$i])) {
// break processing when non-numeric variables are about to be processed
return null;
}
$fCurrentDiff = abs($aFromValues[$i] - $fValueToReplace);
if ($fCurrentDiff === 0) {
return $aToValues[$i];
} else if ($i === 0) {
$fMinimumDiff = $fCurrentDiff;
} else if ( $fMinimumDiff > $fCurrentDiff ) {
$fMinimumDiff = $fCurrentDiff;
$iNearestIndex = $i;
}
}
if ( $iStrict !== 1 ) {
return $aToValues[$iNearestIndex];
}
}
}
return null;
if ( (is_numeric($fValueToReplace)) && ($iStrict!=null) && ($sTranslateFromList!=null) && ($sTranslateToList!=null) )
{
$aFromValues = explode( ',', $sTranslateFromList);
$aToValues = explode( ',', $sTranslateToList);
if ( (count($aFromValues) > 0) && (count($aFromValues) == count($aToValues)) )
{
$fMinimumDiff = null;
$iNearestIndex = 0;
for ( $i = 0; $i < count($aFromValues); $i++) {
if ( !is_numeric($aFromValues[$i])) {
// break processing when non-numeric variables are about to be processed
return null;
}
$fCurrentDiff = abs($aFromValues[$i] - $fValueToReplace);
if ($fCurrentDiff === 0) {
return $aToValues[$i];
} else if ($i === 0) {
$fMinimumDiff = $fCurrentDiff;
} else if ( $fMinimumDiff > $fCurrentDiff ) {
$fMinimumDiff = $fCurrentDiff;
$iNearestIndex = $i;
}
}
if ( $iStrict !== 1 ) {
return $aToValues[$iNearestIndex];
}
}
}
return null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/viewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static function getFieldCode($aField, $aOption=array())

/**
* Return a string with the good separator before and after
*
*
* @param $sString :the string
* @param : string/array : the string to put before of the array (before,after)
*/
Expand All @@ -207,13 +207,13 @@ public static function putSeparator($sString,$separator){
}
/**
* Return a string fixed according to option
*
*
* @param $sString :the string
* @param $bFlat : flattenText or not : completely flat (not like flattenText from common_helper)
* @param $iAbbreviated : max string text (if true : allways flat), 0 or false : don't abbreviated
* @param $sEllipsis if abbreviated : the char to put at end (or middle)
* @param $fPosition if abbreviated position to split (in % : 0 to 1)
*
*
*/
public static function flatEllipsizeText($sString,$bFlat,$iAbbreviated,$sEllipsis='...',$fPosition = 1){
if($bFlat || $iAbbreviated)
Expand Down
6 changes: 2 additions & 4 deletions application/views/admin/super/_question_explorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ class="" href="<?php echo $this->createUrl("/admin/questiongroups/sa/add/surveyi
<br/>
<em>
<?php
templatereplace($question->question, array(),$aReplacementData,'Unspecified', false ,$question->qid);
echo viewHelper::stripTagsEM(LimeExpressionManager::GetLastPrettyPrintExpression());
echo $question->question;
?>
</em>
</span>
Expand All @@ -105,8 +104,7 @@ class="" href="<?php echo $this->createUrl("/admin/questiongroups/sa/add/surveyi
<br/>
<em>
<?php
templatereplace($question->question, array(),$aReplacementData,'Unspecified', false ,$question->qid);
echo viewHelper::stripTagsEM(LimeExpressionManager::GetLastPrettyPrintExpression());
echo $question->question;
?>
</em>
</span>
Expand Down

0 comments on commit 7f87a06

Please sign in to comment.