Skip to content

Commit

Permalink
Fixed issue #05894: INSERTANS (and qcode.shown) returning wrong value…
Browse files Browse the repository at this point in the history
…s for some question types

Fixed issue Uploaded files fail if target directory does not exist.
  • Loading branch information
TMSWhite committed Mar 10, 2012
1 parent 59a55eb commit df31a28
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
26 changes: 19 additions & 7 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -2161,8 +2161,9 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
break;
case '|': //File Upload
// Only want the use the one that ends in '_filecount'
$goodcode = preg_replace("/^(.*?)(_filecount)?$/","$1",$sgqa);
$jsVarName = $goodcode . '_filecount';
// $goodcode = preg_replace("/^(.*?)(_filecount)?$/","$1",$sgqa);
// $jsVarName = $goodcode . '_filecount';
$jsVarName = $sgqa;
$jsVarName_on = $jsVarName;
break;
case 'P': //Multiple choice with comments checkbox + text
Expand Down Expand Up @@ -6132,6 +6133,10 @@ static function ProcessCurrentResponses()
if (file_exists($tmp . $phparray[$i]->filename))
{
$sDestinationFileName = 'fu_' . sRandomChars(15);
if (!is_dir($LEM->surveyOptions['target']))
{
mkdir($LEM->surveyOptions['target'], 0777, true);
}
if (!rename($tmp . $phparray[$i]->filename, $LEM->surveyOptions['target'] . $sDestinationFileName))
{
echo "Error moving file to target destination";
Expand Down Expand Up @@ -6356,15 +6361,24 @@ private function _GetVarAttribute($name,$attr,$default,$gseq,$qseq)
case 'S': //SHORT FREE TEXT
case 'T': //LONG FREE TEXT
case 'U': //HUGE FREE TEXT
case 'M': //Multiple choice checkbox
case 'P': //Multiple choice with comments checkbox + text
case 'D': //DATE
case '*': //Equation
case 'I': //Language Question
case '|': //File Upload
case 'X': //BOILERPLATE QUESTION
$shown = $code;
break;
case 'M': //Multiple choice checkbox
case 'P': //Multiple choice with comments checkbox + text
if ($code == 'Y' && isset($var['question']))
{
$shown = $var['question'];
}
else
{
$shown = $default;
}
break;
case 'G': //GENDER drop-down list
case 'Y': //YES/NO radio-buttons
case 'C': //ARRAY (YES/UNCERTAIN/NO) radio-buttons
Expand All @@ -6377,9 +6391,7 @@ private function _GetVarAttribute($name,$attr,$default,$gseq,$qseq)
else
{
if (isset($ansArray[$code])) {
$answerInfo = explode('|',$ansArray[$code]);
array_shift($answerInfo);
$answer = join('|',$answerInfo);
$answer = $ansArray[$code];
}
else {
$answer = $default;
Expand Down
31 changes: 24 additions & 7 deletions classes/expressions/em_javascript.js
Expand Up @@ -268,14 +268,19 @@ function LEMval(alias)
case 'H': //ARRAY (Flexible) - Column Format
case 'F': //ARRAY (Flexible) - Row Format
case 'R': //RANKING STYLE
which_ans = '0~' + value;
if (typeof attr.answers[which_ans] === 'undefined') {
if (attr.type == 'O' && varName.match(/comment$/)) {
answer = value;
}
else {
answerParts = attr.answers[which_ans].split('|');
answerParts.shift(); // remove the first element
answer = answerParts.join('|');
which_ans = '0~' + value;
if (typeof attr.answers[which_ans] === 'undefined') {
answer = value;
}
else {
answerParts = attr.answers[which_ans].split('|');
answerParts.shift(); // remove the first element
answer = answerParts.join('|');
}
}
shown = answer;
break;
Expand Down Expand Up @@ -303,15 +308,27 @@ function LEMval(alias)
case 'S': //SHORT FREE TEXT
case 'T': //LONG FREE TEXT
case 'U': //HUGE FREE TEXT
case 'M': //Multiple choice checkbox
case 'P': //Multiple choice with comments checkbox + text
case 'D': //DATE
case '*': //Equation
case 'I': //Language Question
case '|': //File Upload
case 'X': //BOILERPLATE QUESTION
shown = value; // what about "no answer"?
break;
case 'M': //Multiple choice checkbox
case 'P': //Multiple choice with comments checkbox + text
if (typeof attr.question === 'undefined' || value == '') {
shown = '';
}
else {
if (attr.type == 'P' && varName.match(/comment$/)) {
shown = value;
}
else {
shown = htmlspecialchars_decode(attr.question);
}
}
break;
}
}
return htmlspecialchars_decode(shown);
Expand Down

0 comments on commit df31a28

Please sign in to comment.