From: Ben H. <bdv...@us...> - 2010-11-22 23:06:00
|
Update of /cvsroot/stack/stack-dev/lib/CAS In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29766/lib/CAS Modified Files: Tag: question_reporting maximaXMLConnector.php displayCASText.php maximaCLIConnector.php casText.php Log Message: Merging from the current HEAD into question_reporting. Apologies in advance if this all goes horribly wrong. Index: maximaXMLConnector.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/CAS/maximaXMLConnector.php,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -C2 -d -r1.22 -r1.22.2.1 *** maximaXMLConnector.php 27 Aug 2009 16:23:00 -0000 1.22 --- maximaXMLConnector.php 22 Nov 2010 23:05:52 -0000 1.22.2.1 *************** *** 238,242 **** } ! $returnArray; $returnArray['key'] = (string)$this->parser->anstestresult->key; --- 238,242 ---- } ! //$returnArray; $returnArray['key'] = (string)$this->parser->anstestresult->key; Index: maximaCLIConnector.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/CAS/maximaCLIConnector.php,v retrieving revision 1.35 retrieving revision 1.35.2.1 diff -C2 -d -r1.35 -r1.35.2.1 *** maximaCLIConnector.php 27 Aug 2009 16:23:00 -0000 1.35 --- maximaCLIConnector.php 22 Nov 2010 23:05:52 -0000 1.35.2.1 *************** *** 233,238 **** $cs ='cab:block([ RANDOM_SEED'; $cs .= $this->csNames; ! $cs .='], RANDOM_SEED:'; ! $cs .= $this->seed.$this->csVars; $cs .= ", print(\"[TimeStamp= [ $this->seed ], Locals= [ \") "; $cs .= $this->csCmds; --- 233,238 ---- $cs ='cab:block([ RANDOM_SEED'; $cs .= $this->csNames; ! $cs .='], stack_randseed('; ! $cs .= $this->seed.')'.$this->csVars; $cs .= ", print(\"[TimeStamp= [ $this->seed ], Locals= [ \") "; $cs .= $this->csCmds; *************** *** 255,262 **** { ! $cs = "cab:block([ ans1983,ans1984,str{$this->csNames}] {$this->csVars}, "; ! $cs .= " print(\"[ Timestamp = [ $this->seed ], Ans= [ error = [\"), cte(\"ans1983\",errcatch(ans1983:$exp1)),"; ! $cs .= " print(\" TAAns= [ error = [\"), cte(\"ans1984\",errcatch(ans1984:$exp2)),"; ! $cs .= " print(\" AnswerTestError = [ \"), str:$ansTest(ans1983,ans1984), print(\" ], \"), print(str), return(true)); \n"; $this->rawcommand = $cs; return $cs; --- 255,262 ---- { ! $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"; $this->rawcommand = $cs; return $cs; *************** *** 364,368 **** $val = trim($val); ! if (ereg('[A-Za-z0-9].*',substr($strin,$offset,$eqpos-$offset),$regs)) { $var = trim($regs[0]); } else { --- 364,368 ---- $val = trim($val); ! if (preg_match('/[A-Za-z0-9].*/',substr($strin,$offset,$eqpos-$offset),$regs)) { $var = trim($regs[0]); } else { *************** *** 409,413 **** // Now we need to turn the (error,key,value,display) tuple into an array foreach ($locals_raw as $var => $valdval) { ! if (ereg('.*\[.*\].*',$valdval)) { // There are some []'s in the string. $loc = $this->CASParsePreparse($valdval); if ('' == trim($loc['error'])) { --- 409,413 ---- // Now we need to turn the (error,key,value,display) tuple into an array foreach ($locals_raw as $var => $valdval) { ! if (preg_match('/.*\[.*\].*/',$valdval)) { // There are some []'s in the string. $loc = $this->CASParsePreparse($valdval); if ('' == trim($loc['error'])) { *************** *** 469,474 **** //for latex mode, remove the mbox ! $parsedArray[$i]['display'] = str_replace('\mbox{{} <html>', '<html>', $parsedArray[$i]['display']); ! $parsedArray[$i]['display'] = str_replace('</html> {}}', '</html>', $parsedArray[$i]['display']); } $this->maximaAnsArray[] = new maximaAns($parsedArray[$i]['key'], $parsedArray[$i]['value'], $parsedArray[$i]['display'], $error); --- 469,474 ---- //for latex mode, remove the mbox ! // handles forms: \mbox{image} and (earlier?) \mbox{{} {image} {}} ! $parsedArray[$i]['display'] = preg_replace("|\\\mbox{({})? (<html>.+</html>) ({})?}|", "$2", $parsedArray[$i]['display']); } $this->maximaAnsArray[] = new maximaAns($parsedArray[$i]['key'], $parsedArray[$i]['value'], $parsedArray[$i]['display'], $error); *************** *** 490,494 **** $unp = $this->CASParsePreparse($instr); ! // echo "<pre>";print_r($unp);echo "</pre>"; if (array_key_exists('Ans',$unp)) { --- 490,494 ---- $unp = $this->CASParsePreparse($instr); ! //echo "<pre>";print_r($unp);echo "</pre>"; if (array_key_exists('Ans',$unp)) { *************** *** 509,513 **** } - if (''!=$unp['AnswerTestError']) { $unp['error'].=$unp['AnswerTestError']; --- 509,512 ---- *************** *** 515,540 **** unset($unp['AnswerTestError']); ! ! if (array_key_exists('Valid',$unp)) { ! $unp['Valid'] = strtolower($unp['Valid']); } - // Sort out translations of the feedback. - if (array_key_exists('FeedBack',$unp)) { - $strin = str_replace("\n","",$unp['FeedBack'] ); - $strin = str_replace('\\','\\\\',$strin); - $strin = str_replace('$','\$',$strin); - $strin = str_replace("<QUOT>",'"',$strin); - - //echo "STRIN: <pre>$strin</pre><br>"; - - ob_start(); - eval($strin); - $strin = ob_get_contents(); - ob_end_clean(); - - $unp['FeedBack'] = $strin; - } //echo "<pre>";print_r($unp);echo "</pre>"; return $unp; --- 514,539 ---- unset($unp['AnswerTestError']); + //echo "<pre>";print_r($unp);echo "</pre>"; ! /* If the fields are not here, Maxima didn't generate them = problem! */ ! if(!array_key_exists('rawmark',$unp)) { ! $unp['rawmark'] = 0; ! if (array_key_exists('feedback',$unp)) { ! $unp['feedback'] .= ' stack_trans("TEST_FAILED");'; ! } else { ! $unp['feedback'] = ' stack_trans("TEST_FAILED");'; ! } ! if (array_key_exists('answernote',$unp)) { ! $unp['answernote'] .= ' TEST_FAILED '; ! } else { ! $unp['answernote'] = ' TEST_FAILED'; ! } ! if (array_key_exists('error',$unp)) { ! $unp['error'] .= ' TEST_FAILED'; ! } else { ! $unp['error'] = ' TEST_FAILED'; ! } } //echo "<pre>";print_r($unp);echo "</pre>"; return $unp; *************** *** 558,564 **** $trimResult = str_replace('(%o1) true','', $trimResult); - $result = $this->CASAnsTestParse($trimResult); - return $result; } --- 557,561 ---- *************** *** 691,695 **** //of the format [label] -> error ! $returnArray; $noObjects = count($this->maximaAnsArray); --- 688,692 ---- //of the format [label] -> error ! $returnArray = array(); $noObjects = count($this->maximaAnsArray); Index: displayCASText.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/CAS/displayCASText.php,v retrieving revision 1.37 retrieving revision 1.37.4.1 diff -C2 -d -r1.37 -r1.37.4.1 *** displayCASText.php 26 Jun 2009 18:08:36 -0000 1.37 --- displayCASText.php 22 Nov 2010 23:05:52 -0000 1.37.4.1 *************** *** 254,258 **** foreach ($this->feedbackData as $key => $loc) { ! if (substr($key,$this->mathmlString)) { $this->mathmlString=str_replace($key,"<IEfeedback>$loc</IEfeedback>",$this->mathmlString); --- 254,258 ---- foreach ($this->feedbackData as $key => $loc) { ! if (strpos($this->mathmlString, $key) !== false) { $this->mathmlString=str_replace($key,"<IEfeedback>$loc</IEfeedback>",$this->mathmlString); *************** *** 279,283 **** foreach ($this->PRTfeedbackData as $key => $loc) { ! if (substr($key,$this->mathmlString)) { $this->mathmlString=str_replace($key,"<PRTfeedback>$loc</PRTfeedback>",$this->mathmlString); --- 279,283 ---- foreach ($this->PRTfeedbackData as $key => $loc) { ! if (strpos($this->mathmlString, $key) !== false) { $this->mathmlString=str_replace($key,"<PRTfeedback>$loc</PRTfeedback>",$this->mathmlString); *************** *** 316,323 **** foreach ($this->htmlData as $key => $loc) { ! $dummy = $key; ! if (substr($dummy,$this->mathmlString)) { ! $this->mathmlString=str_replace($dummy,$loc,$this->mathmlString); } } --- 316,322 ---- foreach ($this->htmlData as $key => $loc) { ! if (strpos($this->mathmlString, $key) !== false) { ! $this->mathmlString=str_replace($key, $loc, $this->mathmlString); } } Index: casText.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/CAS/casText.php,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -C2 -d -r1.36 -r1.36.2.1 *** casText.php 27 Aug 2009 16:23:00 -0000 1.36 --- casText.php 22 Nov 2010 23:05:52 -0000 1.36.2.1 *************** *** 169,172 **** --- 169,173 ---- function checkValidCASCommands() { + $toReturn = true; foreach($this->cmdArray as $cmd) *************** *** 185,189 **** foreach($this->cmdArray as $cmd) { ! $pat = "|([A-za-z0-9\(\)]+) ([A-za-z0-9\(\)]+)|"; if (preg_match($pat,$cmd)) { --- 186,190 ---- foreach($this->cmdArray as $cmd) { ! $pat = "|([A-Za-z0-9\(\)]+) ([A-Za-z0-9\(\)]+)|"; if (preg_match($pat,$cmd)) { *************** *** 204,208 **** foreach ($found[0] as $match) { ! if((strpos($match, '%e') !== false) || (strpos($match, '%pi') !== false) || (strpos($match, '%i') !== false) || (strpos($match, '%gamma') !== false) || (strpos($match, '%phi') !== false)) { //%e and %pi are allowed. Any other percentages dissallowed. --- 205,209 ---- foreach ($found[0] as $match) { ! if((strpos($match, '%e') !== false) || (strpos($match, '%pi') !== false) || (strpos($match, '%i') !== false) || (strpos($match, '%j') !== false) || (strpos($match, '%gamma') !== false) || (strpos($match, '%phi') !== false)) { //%e and %pi are allowed. Any other percentages dissallowed. *************** *** 266,270 **** } ! //check final character is not / * + - ^ £ # = & ~ | , ? foreach($this->cmdArray as $cmd) --- 267,271 ---- } ! //check final character is not / * + - ^ £ # = & ~ | , ? : ; foreach($this->cmdArray as $cmd) *************** *** 274,278 **** $lastChar = $cmd[($length -1)]; ! $disallowedChars = array('/','+','*','/','-','^','£','#','~','=','?','|',',','_','&','"','`','¬'); if(in_array($lastChar, $disallowedChars)) --- 275,279 ---- $lastChar = $cmd[($length -1)]; ! $disallowedChars = array('/','+','*','/','-','^','£','#','~','=','?',',','_','&','"','`','¬',';',':','$'); if(in_array($lastChar, $disallowedChars)) *************** *** 436,443 **** $i++; - $str = new stringUtil($cmd); - $cmd = $str->trimCommands(); - //$cmd = $this->trimCommands($cmd); - unset($str); $this->cmdArray[$label] = $cmd; } --- 437,440 ---- *************** *** 528,541 **** // We assume f and g are single letter functions. $patterns[] = "|(\))(\()|"; // Simply the pattern ")(". Must be wrong! ! $patterns[] = "|([0-9]+)([A-Za-eh-z])|"; // eg 3x ! $patterns[] = "|([0-9])([A-Za-z]\()|"; // eg 3 x ( ! $patterns[] = "|([0-9]+)(\()|"; // eg 3212 ( ! $patterns[] = "|(\))([0-9A-Za-z])|"; // eg )a if ($this->security == 's') { // Teachers have more options for functions ! $patterns[] = "|(^[A-Za-eh-z])(\()|"; // eg a( , that is a single letter. ! $patterns[] = "|(\*[A-Za-eh-z])(\()|"; } --- 525,538 ---- // We assume f and g are single letter functions. $patterns[] = "|(\))(\()|"; // Simply the pattern ")(". Must be wrong! ! $patterns[] = "|([0-9]+)([A-DF-Za-eh-z])|"; // eg 3x ! $patterns[] = "|([0-9])([A-DF-Za-z]\()|"; // eg 3 x ( ! $patterns[] = "|(\))([0-9A-DF-Za-z])|"; // eg )a if ($this->security == 's') { // Teachers have more options for functions ! $patterns[] = "|([0-9]+)(\()|"; // eg 3212 ( ! $patterns[] = "|(^[A-DF-Za-eh-z])(\()|"; // eg a( , that is a single letter. ! $patterns[] = "|(\*[A-DF-Za-eh-z])(\()|"; } *************** *** 598,612 **** { // We assume f and g are single letter functions. $patterns[] = "|(\))(\()|"; // Simply the pattern ")(". Must be wrong! ! $patterns[] = "|([0-9]+)([A-Za-eh-z])|"; // eg 3x ! $patterns[] = "|([0-9])([A-Za-z]\()|"; // eg 3 x ( ! $patterns[] = "|([0-9]+)(\()|"; // eg 3212 ( ! $patterns[] = "|(\))([0-9A-Za-z])|"; // eg )a if ($this->security == 's') { // Teachers have more options for functions ! $patterns[] = "|(^[A-Za-eh-z])(\()|"; // eg a( , that is a single letter. ! $patterns[] = "|(\*[A-Za-eh-z])(\()|"; } --- 595,610 ---- { // We assume f and g are single letter functions. + // We exclude E (capital eee) to enable 24E+1 to be a floating point number. $patterns[] = "|(\))(\()|"; // Simply the pattern ")(". Must be wrong! ! $patterns[] = "|([0-9]+)([A-DF-Za-eh-z])|"; // eg 3x ! $patterns[] = "|([0-9])([A-DF-Za-z]\()|"; // eg 3 x ( ! $patterns[] = "|(\))([0-9A-DF-Za-z])|"; // eg )a if ($this->security == 's') { // Teachers have more options for functions ! $patterns[] = "|([0-9]+)(\()|"; // eg 3212 ( ! $patterns[] = "|(^[A-DF-Za-eh-z])(\()|"; // eg a( , that is a single letter. ! $patterns[] = "|(\*[A-DF-Za-eh-z])(\()|"; } |