From: Chris S. <san...@us...> - 2005-10-09 16:19:58
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19871/scripts Modified Files: stackCAS.php stackUtility.php Log Message: Index: stackCAS.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackCAS.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** stackCAS.php 13 Sep 2005 08:35:04 -0000 1.4 --- stackCAS.php 9 Oct 2005 16:19:44 -0000 1.5 *************** *** 276,280 **** return NULL; } - $t = time(); --- 276,279 ---- *************** *** 292,345 **** $parsed = CASParseCASOutput($varResponse); ! //show_array($parsed); // Get the CAS's values of the locals into an array. ! // Get the CAS's values of the locals into an array. foreach ($locals as $lk => $locvar) { ! if (array_key_exists($lk,$parsed['questionVarsInst'])) { ! $locals_inst[$lk] = $locals[$lk]; ! $locals_inst[$lk]['display'] = ''; ! foreach ($parsed['questionVarsInst'][$lk] as $lkk => $lvv) { ! $locals_inst[$lk][$lkk] = $lvv; ! } ! } else { ! $locals_inst[$lk] = $locals[$lk]; ! $locals_inst[$lk]['error'] = 'CAS-error (no output)'; ! $locals_inst[$lk]['display'] = ''; ! } ! // Maxima typesets strings with a & at the front. This breaks TeX, so we ! // need to get rid of it..... ! if (array_key_exists('display',$locals_inst[$lk])) { ! if ( '&' == substr($locals_inst[$lk]['display'],0,1)) { ! $locals_inst[$lk]['display'] = substr($locals_inst[$lk]['display'],1); ! } ! } ! if (isset($locals_inst[$lk]['error'])) { // There is a CAS error! ! // Get the command that went in. ! $val = $locvar['value']; ! if ('' == $locals_inst[$lk]['display']) { ! // This must be a genuine error, since nothing is displayed. ! $locals_inst[$lk]['value'] = $val; // Restore the un-CASed value ! $locals_inst[$lk]['display'] = $val; // Restore the un-CASed value ! } else if (strstr($locals_inst[$lk]['error'],'Plot error')) { ! // This must be a genuine error, since we created it! ! $locals_inst[$lk]['value'] = $val; // Restore the un-CASed value ! } else if (FALSE != strstr($val,'plot')) { ! // We asked for a plot, these always generate an error! (HACK) ! unset($locals_inst[$lk]['error']); ! $locals_inst[$lk]['display'] = $locals_inst[$lk]['value']; ! } else { ! // This must also be a genuine error, but keep the display, since we have it. ! $locals_inst[$lk]['value'] = $val; // Restore the un-CASed value ! } ! } } } ! //show_array($locals_inst); return $locals_inst; - } --- 291,348 ---- $parsed = CASParseCASOutput($varResponse); ! show_array($parsed); // Get the CAS's values of the locals into an array. ! $locals_inst = array(); foreach ($locals as $lk => $locvar) { ! $locals_inst[$lk] = $locals[$lk]; ! $locals_inst[$lk]['error'] = 'CAS-error (no output)'; ! $locals_inst[$lk]['display'] = ''; ! } ! if (is_array($parsed)) { ! if (array_key_exists('questionVarsInst',$parsed)) { ! foreach ($locals as $lk => $locvar) { ! if (array_key_exists($lk,$parsed['questionVarsInst'])) { ! unset($locals_inst[$lk]['error']); ! foreach ($parsed['questionVarsInst'][$lk] as $lkk => $lvv) { ! $locals_inst[$lk][$lkk] = $lvv; ! } ! } ! // Maxima typesets strings with a & at the front. This breaks TeX, so we ! // need to get rid of it..... ! if (array_key_exists('display',$locals_inst[$lk])) { ! if ( '&' == substr($locals_inst[$lk]['display'],0,1)) { ! $locals_inst[$lk]['display'] = substr($locals_inst[$lk]['display'],1); ! } ! } ! ! if (isset($locals_inst[$lk]['error'])) { // There is a CAS error! ! // Get the command that went in. ! $val = $locvar['value']; ! if ('' == $locals_inst[$lk]['display']) { ! // This must be a genuine error, since nothing is displayed. ! $locals_inst[$lk]['value'] = $val; // Restore the un-CASed value ! $locals_inst[$lk]['display'] = $val; // Restore the un-CASed value ! } else if (strstr($locals_inst[$lk]['error'],'Plot error')) { ! // This must be a genuine error, since we created it! ! $locals_inst[$lk]['value'] = $val; // Restore the un-CASed value ! } else if (FALSE != strstr($val,'plot')) { ! // We asked for a plot, these always generate an error! (HACK) ! unset($locals_inst[$lk]['error']); ! $locals_inst[$lk]['display'] = $locals_inst[$lk]['value']; ! } else { ! // This must also be a genuine error, but keep the display, since we have it. ! $locals_inst[$lk]['value'] = $val; // Restore the un-CASed value ! } ! } ! } ! } } } ! show_array($locals_inst); return $locals_inst; } Index: stackUtility.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUtility.php,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** stackUtility.php 1 Sep 2005 08:13:57 -0000 1.33 --- stackUtility.php 9 Oct 2005 16:19:44 -0000 1.34 *************** *** 669,673 **** $errs = TRUE; // Hack: should do something more useful here! ! } // (2) Now put the implicit question variables back into the castext strings. --- 669,673 ---- $errs = TRUE; // Hack: should do something more useful here! ! } // (2) Now put the implicit question variables back into the castext strings. *************** *** 719,722 **** --- 719,724 ---- global $stack_web_url; + $errs = ''; + // (1) Looks for the name of each $local as such a dummy string if (is_array($locals)) { *************** *** 724,732 **** foreach ($locals as $key => $loc) { $locname = $loc['key']; if (array_key_exists('display', $loc)) { $locdisplay = $loc['display']; ! } else { ! $locdisplay = ''; ! } $dummy = '@'.$locname.'@'; --- 726,733 ---- foreach ($locals as $key => $loc) { $locname = $loc['key']; + $locdisplay = ''; if (array_key_exists('display', $loc)) { $locdisplay = $loc['display']; ! } $dummy = '@'.$locname.'@'; *************** *** 735,742 **** if (array_key_exists('error',$loc)) { if (array_key_exists('value',$loc)) { $a = array('key' => $loc['value']); $errs .= '<br />'.get_string('ErrorCASString','stack',$a).'<br />'.$loc['error']; } else { ! $displayed = ' \verb$'.$dummy.'$ '; // Otherwise just use its name $a = array('key' => $displayed); $errs .= '<br />'.get_string('ErrorCASString','stack',$a).'<br />'.$loc['error']; --- 736,744 ---- if (array_key_exists('error',$loc)) { if (array_key_exists('value',$loc)) { + $displayed = ' {\color{red} \verb$'.$loc['value'].'$} '; $a = array('key' => $loc['value']); $errs .= '<br />'.get_string('ErrorCASString','stack',$a).'<br />'.$loc['error']; } else { ! $displayed = ' {\color{red} \verb$'.$dummy.'$} '; // Otherwise just use its name $a = array('key' => $displayed); $errs .= '<br />'.get_string('ErrorCASString','stack',$a).'<br />'.$loc['error']; |