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 Jun 26, 2012
2 parents 0faeba0 + b670b7a commit d6531bb
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 20 deletions.
1 change: 1 addition & 0 deletions admin/admin_functions.php
Expand Up @@ -339,6 +339,7 @@ function getAdminHeader($meta=false)
$strAdminHeader.= "<script type=\"text/javascript\" src=\"{$homeurl}/scripts/tabpane/js/tabpane.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery-ui.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/jquery.ui.touch-punch.min.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery.qtip.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$rooturl}/scripts/jquery/jquery.notify.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"{$homeurl}/scripts/admin_core.js\"></script>\n";
Expand Down
83 changes: 63 additions & 20 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -614,6 +614,11 @@ class LimeExpressionManager {
* @var type
*/
private $qid2exclusiveAuto = array();
/**
* Array of values to be updated
* @var type
*/
private $updatedValues = array();


/**
Expand Down Expand Up @@ -2897,7 +2902,7 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
}
$this->qid2code[$questionNum] = $codeList;

$readWrite = 'N';
$readWrite = 'Y';

// Set $ansArray
switch($type)
Expand Down Expand Up @@ -3943,6 +3948,7 @@ static function NavigateBackwards()
$LEM =& LimeExpressionManager::singleton();

$LEM->ParseResultCache=array(); // to avoid running same test more than once for a given group
$LEM->updatedValues = array();

switch ($LEM->surveyMode)
{
Expand Down Expand Up @@ -4076,6 +4082,7 @@ static function NavigateForwards($force=false) {
$LEM =& LimeExpressionManager::singleton();

$LEM->ParseResultCache=array(); // to avoid running same test more than once for a given group
$LEM->updatedValues = array();

switch ($LEM->surveyMode)
{
Expand Down Expand Up @@ -4296,6 +4303,9 @@ private function _UpdateValuesInDatabase($updatedValues, $finished=false,$setSub
// Update these values in the database
global $connect;

// TODO - now that using $this->updatedValues, may be able to remove local copies of it (unless needed by other sub-systems)
$updatedValues = $this->updatedValues;

if (!$this->surveyOptions['deletenonvalues'])
{
$nonNullValues = array();
Expand Down Expand Up @@ -4527,6 +4537,7 @@ static function JumpTo($seq,$preview=false,$processPOST=true,$force=false,$chang
}

$LEM->ParseResultCache=array(); // to avoid running same test more than once for a given group
$LEM->updatedValues = array();
--$seq; // convert to 0-based numbering

switch ($LEM->surveyMode)
Expand Down Expand Up @@ -5612,6 +5623,7 @@ function _ValidateQuestion($questionSeq)
{
$_SESSION[$sgqa] = NULL;
$updatedValues[$sgqa] = NULL;
$LEM->updatedValues[$sgqa] = NULL;
}
}
else if ($qInfo['type'] == '*')
Expand All @@ -5621,10 +5633,12 @@ function _ValidateQuestion($questionSeq)
$sgqa = $LEM->qid2code[$qid]; // there will be only one, since Equation
// Store the result of the Equation in the SESSION
$_SESSION[$sgqa] = $result;
$updatedValues[$sgqa] = array(
$_update = array(
'type'=>'*',
'value'=>$result,
);
$updatedValues[$sgqa] = $_update;
$LEM->updatedValues[$sgqa] = $_update;
if (($LEM->debugLevel & LEM_DEBUG_VALIDATION_DETAIL) == LEM_DEBUG_VALIDATION_DETAIL)
{
$prettyPrintEqn = $LEM->em->GetPrettyPrintString();
Expand All @@ -5636,6 +5650,7 @@ function _ValidateQuestion($questionSeq)
// NULL irrelevant sub-questions
$_SESSION[$sq] = NULL;
$updatedValues[$sq] = NULL;
$LEM->updatedValues[$sq]= NULL;
}

// Regardless of whether relevant or hidden, if there is a default value and $_SESSION[$sgqa] is NULL, then use the default value in $_SESSION, but don't write to database
Expand Down Expand Up @@ -6615,7 +6630,7 @@ static function GetRelevanceAndTailoringJavaScript()
{
// TODO - is different type needed for text? Or process value to striphtml?
if ($jsVar == '') continue;
$jsParts[] = "<input type='hidden' id='" . $jsVar . "' name='" . $jsVar . "' value='" . htmlspecialchars($undeclaredVal[$jsVar],ENT_QUOTES) . "'/>\n";
$jsParts[] = "<input type='hidden' id='" . $jsVar . "' name='" . substr($jsVar,4) . "' value='" . htmlspecialchars($undeclaredVal[$jsVar],ENT_QUOTES) . "'/>\n";
}
}
else
Expand Down Expand Up @@ -7321,9 +7336,9 @@ static function ProcessCurrentResponses()
$type = $qinfo['info']['type'];
if ($relevant && $grelevant && $sqrelevant)
{
if ($qinfo['info']['hidden'])
if ($qinfo['info']['hidden'] && !isset($_POST[$sq]))
{
$value = (isset($_SESSION[$sq]) ? $_SESSION[$sq] : ''); // if always hidden, use the default value, if any
$value = (isset($_SESSION[$sq]) ? $_SESSION[$sq] : ''); // if always hidden, use the default value, if any, unless value was changed via POST
}
else
{
Expand Down Expand Up @@ -7393,18 +7408,22 @@ static function ProcessCurrentResponses()
break;
}
$_SESSION[$sq] = $value;
$updatedValues[$sq] = array (
$_update = array (
'type'=>$type,
'value'=>$value,
);
$updatedValues[$sq] = $_update;
$LEM->updatedValues[$sq] = $_update;
}
else { // irrelevant, so database will be NULLed separately
// Must unset the value, rather than setting to '', so that EM can re-use the default value as needed.
unset($_SESSION[$sq]);
$updatedValues[$sq] = array (
$_update = array (
'type'=>$type,
'value'=>NULL,
);
$updatedValues[$sq] = $_update;
$LEM->updatedValues[$sq] = $_update;
}
}
}
Expand Down Expand Up @@ -7729,38 +7748,62 @@ public static function SetVariableValue($op,$name,$value)
$LEM->tempVars[$name]['code'] -= $value;
break;
}
return $LEM->tempVars[$name]['code'];
$_result = $LEM->tempVars[$name]['code'];
$_SESSION[$name] = $_result;
$LEM->updatedValues[$name] = array(
'type'=>'*',
'value'=>$_result,
);
return $_result;
}
else
{
if (isset($LEM->knownVars[$name]))
if (!isset($LEM->knownVars[$name]))
{
$vname = $name;
}
else if (isset($LEM->qcode2sgqa[$name]))
if (isset($LEM->qcode2sgqa[$name]))
{
$name = $LEM->qcode2sgqa[$name];
}
else
{
$vname = $LEM->qcode2sgqa[$name];
return ''; // shouldn't happen
}
}

switch($op)
if (isset($_SESSION[$name]))
{
$_result = $_SESSION[$name];
}
else
{
$_result = (isset($LEM->knownVars[$name]['default']) ? $LEM->knownVars[$name]['default'] : 0);
}

switch($op)
{
case '=':
$LEM->knownVars[$name]['code'] = $value;
$_result = $value;
break;
case '*=':
$LEM->knownVars[$name]['code'] *= $value;
$_result *= $value;
break;
case '/=':
$LEM->knownVars[$name]['code'] /= $value;
$_result /= $value;
break;
case '+=':
$LEM->knownVars[$name]['code'] += $value;
$_result += $value;
break;
case '-=':
$LEM->knownVars[$name]['code'] -= $value;
$_result -= $value;
break;
}
return $LEM->knownVars[$name]['code'];
$_SESSION[$name] = $_result;
$_type = $LEM->knownVars[$name]['type'];
$LEM->updatedValues[$name] = array(
'type'=>$_type,
'value'=>$_result,
);
return $_result;
}
}

Expand Down
1 change: 1 addition & 0 deletions common_functions.php
Expand Up @@ -4278,6 +4278,7 @@ function getHeader($meta = false)
. $css_header
. "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/jquery.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/jquery-ui.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"".$rooturl."/scripts/jquery/jquery.ui.touch-punch.min.js\"></script>\n"
. "<link href=\"".$rooturl."/scripts/jquery/css/start/jquery-ui.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />"
. "<link href=\"".$rooturl."/scripts/jquery/css/start/lime-progress.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />"
. $js_header;
Expand Down
11 changes: 11 additions & 0 deletions scripts/jquery/jquery.ui.touch-punch.min.js
@@ -0,0 +1,11 @@
/*
* jQuery UI Touch Punch 0.2.2
*
* Copyright 2011, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery);

0 comments on commit d6531bb

Please sign in to comment.