Skip to content

Commit

Permalink
Merge branch 'master' into 192_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
TMSWhite committed May 15, 2012
2 parents 6b57604 + b76a64b commit bc202a6
Show file tree
Hide file tree
Showing 18 changed files with 36,500 additions and 10,162 deletions.
2 changes: 1 addition & 1 deletion admin/scripts/answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function addinput()
languages=langs.split(';');

sNextCode=getNextCode($(this).parent().parent().find('.code').val());
while ($(this).parent().parent().parent().find('input[value="'+sNextCode+'"]').length>0)
while ($(this).parent().parent().parent().find('input[value="'+sNextCode+'"]').length>0 && sNextCode!=$(this).parent().parent().find('.code').val())
{
sNextCode=getNextCode(sNextCode);
}
Expand Down
2 changes: 1 addition & 1 deletion admin/scripts/subquestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function addinput()
languages=langs.split(';');

nextcode=getNextCode($(this).parent().parent().find('.code').val());
while ($(this).parent().parent().parent().find('input[value="'+nextcode+'"]').length>0)
while ($(this).parent().parent().parent().find('input[value="'+nextcode+'"]').length>0 && nextcode!=$(this).parent().parent().find('.code').val())
{
nextcode=getNextCode(nextcode);
}
Expand Down
9 changes: 8 additions & 1 deletion classes/core/surveytranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,16 @@ function getLanguageData($orderbynative=false) {
$supportedLanguages['es']['dateformat'] = 5;
$supportedLanguages['es']['radixpoint'] = 1;

// Spanish (Chile)
$supportedLanguages['es-CL']['description'] = $clang->gT('Spanish (Mexico)');
$supportedLanguages['es-CL']['nativedescription'] = 'Español chileno';
$supportedLanguages['es-CL']['rtl'] = false;
$supportedLanguages['es-CL']['dateformat'] = 5;
$supportedLanguages['es-CL']['radixpoint'] = 0;

// Spanish (Mexico)
$supportedLanguages['es-MX']['description'] = $clang->gT('Spanish (Mexico)');
$supportedLanguages['es-MX']['nativedescription'] = 'Español Mejicano';
$supportedLanguages['es-MX']['nativedescription'] = 'Español mejicano';
$supportedLanguages['es-MX']['rtl'] = false;
$supportedLanguages['es-MX']['dateformat'] = 5;
$supportedLanguages['es-MX']['radixpoint'] = 0;
Expand Down
151 changes: 112 additions & 39 deletions classes/expressions/LimeExpressionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
}

// exclude_all_others
// If any excluded options are true (and relevant), then disable all other input elements for that question
if (isset($qattr['exclude_all_others']) && trim($qattr['exclude_all_others']) != '')
{
$exclusive_options = explode(';',$qattr['exclude_all_others']);
Expand Down Expand Up @@ -1208,6 +1209,8 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
}

// exclude_all_others_auto
// if (count(this.relevanceStatus) == count(this)) { set exclusive option value to "Y" and call checkconditions() }
// However, note that would need to blank the values, not use relevance, otherwise can't unclick the _auto option without having it re-enable itself
// TODO

// min_answers
Expand Down Expand Up @@ -2236,37 +2239,39 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$order=0;
foreach ($subQrels as $sq)
{
if (isset($rowdivids[$sq['rowdivid']]))
{
$backup = $rowdivids[$sq['rowdivid']];
$rowdivids[$sq['rowdivid']] = array(
'order'=>$backup['order'],
'qid'=>$sq['qid'],
'rowdivid'=>$sq['rowdivid'],
'type'=>$backup['type'] . ';' .$sq['type'],
'qtype'=>$sq['qtype'],
'sgqa'=>$sq['sgqa'],
'eqns' => array_merge($backup['eqns'],array($sq['eqn'])),
);
}
else
{
$rowdivids[$sq['rowdivid']] = array(
'order'=>$order++,
'qid'=>$sq['qid'],
'rowdivid'=>$sq['rowdivid'],
'type'=>$sq['type'],
'qtype'=>$sq['qtype'],
'sgqa'=>$sq['sgqa'],
'eqns'=>array($sq['eqn']),
);
}
$oldeqn = (isset($rowdivids[$sq['rowdivid']]['eqns']) ? $rowdivids[$sq['rowdivid']]['eqns'] : array());
$oldtype = (isset($rowdivids[$sq['rowdivid']]['type']) ? $rowdivids[$sq['rowdivid']]['type'] : '');
$neweqn = (($sq['type'] == 'exclude_all_others') ? array() : array($sq['eqn']));
$oldeo = (isset($rowdivids[$sq['rowdivid']]['exclusive_options']) ? $rowdivids[$sq['rowdivid']]['exclusive_options'] : array());
$neweo = (($sq['type'] == 'exclude_all_others') ? array($sq['eqn']) : array());
$rowdivids[$sq['rowdivid']] = array(
'order'=>$order++,
'qid'=>$sq['qid'],
'rowdivid'=>$sq['rowdivid'],
'type'=>$sq['type'] . ';' . $oldtype,
'qtype'=>$sq['qtype'],
'sgqa'=>$sq['sgqa'],
'eqns'=>array_merge($oldeqn, $neweqn),
'exclusive_options'=>array_merge($oldeo, $neweo),
);
}

foreach ($rowdivids as $sq)
{
$sq['eqn'] = '(' . implode(' and ', array_unique($sq['eqns'])) . ')'; // without array_unique, get duplicate of filters for question types 1, :, and ;
$result = $this->_ProcessSubQRelevance($sq['eqn'], $sq['qid'], $sq['rowdivid'], $sq['type'], $sq['qtype'], $sq['sgqa']);
$sq['eqn'] = implode(' and ', array_unique(array_merge($sq['eqns'],$sq['exclusive_options']))); // without array_unique, get duplicate of filters for question types 1, :, and ;
$eos = array_unique($sq['exclusive_options']);
$isExclusive = '';
$irrelevantAndExclusive = '';
if (count($eos) > 0)
{
$isExclusive = '!(' . implode(' and ', $eos) . ')';
$noneos = array_unique($sq['eqns']);
if (count($noneos) > 0)
{
$irrelevantAndExclusive = '(' . implode(' and ', $noneos) . ') and ' . $isExclusive;
}
}
$this->_ProcessSubQRelevance($sq['eqn'], $sq['qid'], $sq['rowdivid'], $sq['type'], $sq['qtype'], $sq['sgqa'], $isExclusive, $irrelevantAndExclusive);
}

foreach ($validationEqn as $qid=>$eqns)
Expand Down Expand Up @@ -2701,6 +2706,7 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
case ':': //ARRAY (Multi Flexi) 1 to 10
$onlynum=true;
break;
case '*': // Equation
case ';': //ARRAY (Multi Flexi) Text
case 'Q': //MULTIPLE SHORT TEXT
case 'S': //SHORT FREE TEXT
Expand Down Expand Up @@ -3292,7 +3298,7 @@ private function _ProcessRelevance($eqn,$questionNum=NULL,$gseq=NULL,$jsResultVa
* @param <type> $type - the type of sub-question relevance (e.g. 'array_filter', 'array_filter_exclude')
* @return <type>
*/
private function _ProcessSubQRelevance($eqn,$questionNum=NULL,$rowdivid=NULL, $type=NULL, $qtype=NULL, $sgqa=NULL)
private function _ProcessSubQRelevance($eqn,$questionNum=NULL,$rowdivid=NULL, $type=NULL, $qtype=NULL, $sgqa=NULL, $isExclusive='', $irrelevantAndExclusive='')
{
// These will be called in the order that questions are supposed to be asked
if (!isset($eqn) || trim($eqn=='') || trim($eqn)=='1')
Expand All @@ -3319,6 +3325,20 @@ private function _ProcessSubQRelevance($eqn,$questionNum=NULL,$rowdivid=NULL, $t
$relevanceVars = implode('|',$this->em->GetJSVarsUsed());
$relevanceJS = $this->em->GetJavaScriptEquivalentOfExpression();

$isExclusiveJS='';
$irrelevantAndExclusiveJS='';
// Only need to extract JS, since will already have Vars and error counts from main equation
if ($isExclusive != '')
{
$this->em->ProcessBooleanExpression($isExclusive,$groupSeq, $questionSeq);
$isExclusiveJS = $this->em->GetJavaScriptEquivalentOfExpression();
}
if ($irrelevantAndExclusive != '')
{
$this->em->ProcessBooleanExpression($irrelevantAndExclusive,$groupSeq, $questionSeq);
$irrelevantAndExclusiveJS = $this->em->GetJavaScriptEquivalentOfExpression();
}

if (!isset($this->subQrelInfo[$questionNum])) {
$this->subQrelInfo[$questionNum] = array();
}
Expand All @@ -3335,6 +3355,8 @@ private function _ProcessSubQRelevance($eqn,$questionNum=NULL,$rowdivid=NULL, $t
'qtype'=>$qtype,
'sgqa'=>$sgqa,
'hasErrors'=>$hasErrors,
'isExclusiveJS'=>$isExclusiveJS,
'irrelevantAndExclusiveJS'=>$irrelevantAndExclusiveJS,
);
}
return $result;
Expand Down Expand Up @@ -3879,19 +3901,25 @@ private function _UpdateValuesInDatabase($updatedValues, $finished=false,$setSub
}

$message = '';
$_SESSION['datestamp']=date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
if($this->surveyOptions['datestamp']=='Y')
{
$datestamp=date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
}
else
{
$datestamp=date("Y-m-d H:i:s",mktime(0,0,0,1,1,1980));
}
$_SESSION['datestamp']=$datestamp;
if ($this->surveyOptions['active'] && !isset($_SESSION['srid']))
{
// Create initial insert row for this record
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
$sdata = array(
"datestamp"=>$today,
"datestamp"=>$datestamp,
"ipaddr"=>(($this->surveyOptions['ipaddr']) ? getIPAddress() : ''),
"startlanguage"=>$this->surveyOptions['startlanguage'],
"token"=>($this->surveyOptions['token']),
"datestamp"=>($this->surveyOptions['datestamp'] ? $_SESSION['datestamp'] : NULL),
"refurl"=>(($this->surveyOptions['refurl']) ? getenv("HTTP_REFERER") : NULL),
"startdate"=>($this->surveyOptions['datestamp'] ? $_SESSION['datestamp'] : date("Y-m-d H:i:s",0)),
"startdate"=>$datestamp,
);
//One of the strengths of ADOdb's AutoExecute() is that only valid field names for $table are updated
if ($connect->AutoExecute($this->surveyOptions['tablename'], $sdata,'INSERT')) // Checked
Expand Down Expand Up @@ -4039,7 +4067,7 @@ private function _UpdateValuesInDatabase($updatedValues, $finished=false,$setSub
{
if ($finished) {
$sQuery = 'UPDATE '.$this->surveyOptions['tablename'] . " SET "
.db_quote_id('submitdate') . "=" . db_quoteall($_SESSION['datestamp'])
.db_quote_id('submitdate') . "=" . db_quoteall($datestamp)
." WHERE ID=".$_SESSION['srid'];
$connect->Execute($sQuery); // Checked
}
Expand Down Expand Up @@ -5611,14 +5639,43 @@ static function GetRelevanceAndTailoringJavaScript()
foreach ($subqParts as $sq)
{
$rowdividList[$sq['rowdivid']] = $sq['result'];

$relParts[] = " if ( " . $sq['relevancejs'] . " ) {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').show();\n";
$relParts[] = " if ($('#relevance" . $sq['rowdivid'] . "').val()!='1') { relChange" . $arg['qid'] . "=true; }\n";
if ($sq['isExclusiveJS'] != '')
{
$relParts[] = " if ( " . $sq['isExclusiveJS'] . " ) {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " }\n";
$relParts[] = " else {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
$relParts[] = " }\n";
}
$relParts[] = " relChange" . $arg['qid'] . "=true;\n";
$relParts[] = " $('#relevance" . $sq['rowdivid'] . "').val('1');\n";
$relParts[] = " }\n else {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
$relParts[] = " if ($('#relevance" . $sq['rowdivid'] . "').val()=='1') { relChange" . $arg['qid'] . "=true; }\n";
if ($sq['isExclusiveJS'] != '')
{
if ($sq['irrelevantAndExclusiveJS'] != '')
{
$relParts[] = " if ( " . $sq['irrelevantAndExclusiveJS'] . " ) {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " }\n";
$relParts[] = " else {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
$relParts[] = " }\n";
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
}
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
}
$relParts[] = " relChange" . $arg['qid'] . "=true;\n";
$relParts[] = " $('#relevance" . $sq['rowdivid'] . "').val('');\n";
switch ($sq['qtype'])
{
Expand Down Expand Up @@ -5920,6 +5977,14 @@ static function GetRelevanceAndTailoringJavaScript()
if ($_val==1)
{
$jsParts[] = " LEMrel" . $_qid . "(sgqa);\n";
if (isset($LEM->qattr[$_qid]['exclude_all_others']))
{
foreach (explode(';',trim($LEM->qattr[$_qid]['exclude_all_others'])) as $eo)
{
// then need to call the function twice so that cascading of array filter onto an excluded option works
$jsParts[] = " LEMrel" . $_qid . "(sgqa);\n";
}
}
}
}

Expand All @@ -5937,6 +6002,14 @@ static function GetRelevanceAndTailoringJavaScript()
if ($_val == 1)
{
$jsParts[] = " LEMrel" . $_qid . "(sgqa);\n";
if (isset($LEM->qattr[$_qid]['exclude_all_others']))
{
foreach (explode(';',trim($LEM->qattr[$_qid]['exclude_all_others'])) as $eo)
{
// then need to call the function twice so that cascading of array filter onto an excluded option works
$jsParts[] = " LEMrel" . $_qid . "(sgqa);\n";
}
}
}
}
}
Expand All @@ -5961,7 +6034,7 @@ static function GetRelevanceAndTailoringJavaScript()
$jsParts[] = " $('#relevanceG" . $gr['gseq'] . "').val(0);\n";
$jsParts[] = "}\n";
}

// now make sure any needed variables are accessible
$vars = explode('|',$gr['relevanceVars']);
if (is_array($vars))
Expand Down
2 changes: 1 addition & 1 deletion common_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3659,7 +3659,7 @@ function questionAttributes($returnByName=false)
"caption"=>$clang->gT('Integer only'));

$qattributes["numbers_only"]=array(
"types"=>"Q;S",
"types"=>"Q;S*",
'category'=>$clang->gT('Other'),
'sortorder'=>100,
'inputtype'=>'singleselect',
Expand Down

0 comments on commit bc202a6

Please sign in to comment.