From: Simon H. <sim...@us...> - 2010-11-09 16:51:48
|
Update of /cvsroot/stack/stack-dev/server In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv25193/server Modified Files: Tag: item_state_separation maximaXMLTranslator.php Log Message: Brought back up to date with big HEAD merge. Index: maximaXMLTranslator.php =================================================================== RCS file: /cvsroot/stack/stack-dev/server/maximaXMLTranslator.php,v retrieving revision 1.8 retrieving revision 1.8.18.1 diff -C2 -d -r1.8 -r1.8.18.1 *** maximaXMLTranslator.php 27 Sep 2007 11:24:18 -0000 1.8 --- maximaXMLTranslator.php 9 Nov 2010 16:51:40 -0000 1.8.18.1 *************** *** 30,38 **** private $xmlIn; //xml coming in ! private $message; //simplexml parser object private $cmdType; //answer test or caschat? private $seed; //timestamp seed ! private $csNames; private $csVars; --- 30,38 ---- private $xmlIn; //xml coming in ! private $message; //simplexml parser object private $cmdType; //answer test or caschat? private $seed; //timestamp seed ! private $csNames; private $csVars; *************** *** 46,52 **** { $this->xmlIn = $xml; ! echo 'XML in: '.$xml; ! try { --- 46,52 ---- { $this->xmlIn = $xml; ! echo 'XML in: '.$xml; ! try { *************** *** 56,71 **** echo 'XML parser failed: '.$e; } ! $this->security = $this->message->security; $this->cmdType = $this->message->cmdtype; $this->seed = $this->message->seed; //$this->seed = time(); ! $this->csNames = ''; $this->csVars = ''; $this->csCmds = ''; ! ! } ! function securityCheck() { --- 56,71 ---- echo 'XML parser failed: '.$e; } ! $this->security = $this->message->security; $this->cmdType = $this->message->cmdtype; $this->seed = $this->message->seed; //$this->seed = time(); ! $this->csNames = ''; $this->csVars = ''; $this->csCmds = ''; ! ! } ! function securityCheck() { *************** *** 74,78 **** $checkArray[] = $this->message->anstest->student; $checkArray[] = $this->message->anstest->teacher; ! return $this->securityCheckCommands($checkArray); } --- 74,78 ---- $checkArray[] = $this->message->anstest->student; $checkArray[] = $this->message->anstest->teacher; ! return $this->securityCheckCommands($checkArray); } *************** *** 84,91 **** } return $this->securityCheckCommands($checkArray); ! } } ! ! /** * Gets just the keywords used in the raw cas string. Gives unique keywords only --- 84,91 ---- } return $this->securityCheckCommands($checkArray); ! } } ! ! /** * Gets just the keywords used in the raw cas string. Gives unique keywords only *************** *** 99,126 **** if(count($checkArray) > 0) { ! foreach($checkArray as $cmd) { $pat = "|[\?_A-Za-z0-9]+|"; preg_match_all($pat,$cmd,$out,PREG_PATTERN_ORDER); ! // Filter out some of these matches. ! ! foreach($out[0] as $key) { // Do we have only numbers, or only 2 characters? // These strings are fine. preg_match("|[0-9]+|",$key,$justnum); ! ! if (empty($justnum) and strlen($key)>2) { //echo "Keyword found: $key <br />"; $upKey = strtoupper($key); ! array_push($strin_keywords, $upKey); ! } } } ! $this->keywords = array_unique($strin_keywords); //var_dump($strin_keywords); if (count($this->keywords) > 0) --- 99,126 ---- if(count($checkArray) > 0) { ! foreach($checkArray as $cmd) { $pat = "|[\?_A-Za-z0-9]+|"; preg_match_all($pat,$cmd,$out,PREG_PATTERN_ORDER); ! // Filter out some of these matches. ! ! foreach($out[0] as $key) { // Do we have only numbers, or only 2 characters? // These strings are fine. preg_match("|[0-9]+|",$key,$justnum); ! ! if (empty($justnum) and strlen($key)>2) { //echo "Keyword found: $key <br />"; $upKey = strtoupper($key); ! array_push($strin_keywords, $upKey); ! } } } ! $this->keywords = array_unique($strin_keywords); //var_dump($strin_keywords); if (count($this->keywords) > 0) *************** *** 138,142 **** } } ! /** * Check security of commands --- 138,142 ---- } } ! /** * Check security of commands *************** *** 148,152 **** $toReturn = true; $problem = ''; ! global $stack_cas; $globalForbid[] = $stack_cas['globalForbid']; --- 148,152 ---- $toReturn = true; $problem = ''; ! global $stack_cas; $globalForbid[] = $stack_cas['globalForbid']; *************** *** 154,158 **** $studentAllow = $stack_cas['studentAllow']; ! if($this->getCommandKeywords($checkArray) === true) { --- 154,158 ---- $studentAllow = $stack_cas['studentAllow']; ! if($this->getCommandKeywords($checkArray) === true) { *************** *** 160,164 **** foreach($this->keywords as $key) { ! if($this->in_array_caseless($key, $globalForbid)) { --- 160,164 ---- foreach($this->keywords as $key) { ! if($this->in_array_caseless($key, $globalForbid)) { *************** *** 183,187 **** //echo "$key is not in teacher forbid.<br>"; } ! } else --- 183,187 ---- //echo "$key is not in teacher forbid.<br>"; } ! } else *************** *** 192,196 **** $toReturn = false; $problem .= "Unknown function: $key"; ! } else --- 192,196 ---- $toReturn = false; $problem .= "Unknown function: $key"; ! } else *************** *** 202,206 **** }//foreach //echo $problem; ! if(!$toReturn) { --- 202,206 ---- }//foreach //echo $problem; ! if(!$toReturn) { *************** *** 215,220 **** return $toReturn; } ! ! function in_array_caseless($search, &$array) { $search = strtolower($search); --- 215,220 ---- return $toReturn; } ! ! function in_array_caseless($search, &$array) { $search = strtolower($search); *************** *** 231,235 **** } } ! function buildMaximaString() { --- 231,235 ---- } } ! function buildMaximaString() { *************** *** 244,265 **** echo 'Creating cas chat'.$this->cmdType; return $this->buildCaschatString(); ! } } ! function buildCaschatString() { ! //sort out maxima commands $i = 0; foreach($this->message->commands->caschat as $cmd) { ! $this->cmd = str_replace('?', 'qmchar', $cmd); // replace any ?'s that slipped through $this->csNames .= ", $cmd->label"; $this->csCmds .= ", print(\"$i=[ error= [\"), cte(\"$cmd->label\",errcatch($cmd->label:$cmd->cmd)) "; $i++; ! } ! $cs ='cab:block([ RANDOM_SEED'; $cs .= $this->csNames; --- 244,265 ---- echo 'Creating cas chat'.$this->cmdType; return $this->buildCaschatString(); ! } } ! function buildCaschatString() { ! //sort out maxima commands $i = 0; foreach($this->message->commands->caschat as $cmd) { ! $this->cmd = str_replace('?', 'qmchar', $cmd); // replace any ?'s that slipped through $this->csNames .= ", $cmd->label"; $this->csCmds .= ", print(\"$i=[ error= [\"), cte(\"$cmd->label\",errcatch($cmd->label:$cmd->cmd)) "; $i++; ! } ! $cs ='cab:block([ RANDOM_SEED'; $cs .= $this->csNames; *************** *** 269,276 **** $cs .= $this->csCmds; $cs .= ", print(\"] ]\") , return(true) ); \n "; ! return $cs; } ! function buildAnsTest() { --- 269,276 ---- $cs .= $this->csCmds; $cs .= ", print(\"] ]\") , return(true) ); \n "; ! return $cs; } ! function buildAnsTest() { *************** *** 278,293 **** $exp2 = $this->message->anstest->teacher; $ansTest = $this->message->anstest->anstesttype; ! ! $cs = "cab:block([ ans1983,str{$this->csNames}] {$this->csVars}, "; ! $cs .= " print(\"[ Timestamp = [ $this->seed ], Ans= [ error = [\"), cte(\"ans1983\",errcatch(ans1983:$exp1)),"; ! $cs .= " print(\" AnswerTestError = [ \"), str:$ansTest(ans1983,$exp2), print(\" ], \"), print(str), return(true)); \n"; ! return $cs; } ! function buildVariables() { ! foreach($this->message->maximavar->mstring as $string) { --- 278,294 ---- $exp2 = $this->message->anstest->teacher; $ansTest = $this->message->anstest->anstesttype; ! ! $cs = "cab:block([ STACK_SA,STACK_TA,str{$this->csNames}] {$this->csVars}, "; ! $cs .= " print(\"[ Timestamp = [ $this->seed ], Ans= [ error = [\"), STACK_SA:cte(\"STACK_SA\",errcatch($exp1)),"; ! $cs .= " print(\" TAAns= [ error = [\"), STACK_TA:cte(\"STACK_TA\",errcatch(STACK_TA:$exp2)),"; ! $cs .= " print(\" AnswerTestError = [ \"), str:$ansTest(STACK_SA,STACK_TA), print(\" ], \"), print(str), return(true)); \n"; ! return $cs; } ! function buildVariables() { ! foreach($this->message->maximavar->mstring as $string) { *************** *** 295,299 **** $this->csVars .= ', '.$string->key.':"'.$string->value.'"'; } ! foreach($this->message->maximavar->mexp as $exp) { --- 296,300 ---- $this->csVars .= ', '.$string->key.':"'.$string->value.'"'; } ! foreach($this->message->maximavar->mexp as $exp) { *************** *** 301,310 **** $this->csVars .= ', '.$exp->key.':'.$exp->value; } ! foreach($this->message->maximavar->mfunc as $func) { $this->csVars .= ', '.$func->key.'('.$func->value.')'; } ! } --- 302,311 ---- $this->csVars .= ', '.$exp->key.':'.$exp->value; } ! foreach($this->message->maximavar->mfunc as $func) { $this->csVars .= ', '.$func->key.'('.$func->value.')'; } ! } |