From: Chris S. <san...@us...> - 2005-06-13 16:34:30
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20553/scripts Modified Files: Tag: frontend_dev stackUtility.php Log Message: Index: stackUtility.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUtility.php,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -C2 -d -r1.22 -r1.22.2.1 *** stackUtility.php 12 Jun 2005 16:10:01 -0000 1.22 --- stackUtility.php 13 Jun 2005 16:34:21 -0000 1.22.2.1 *************** *** 355,359 **** } ! // (3) Check for missing *'s // hack: This needs some careful thought. // We can't simply check for adjcent letters. For example sin(x) is ok, xsin(x) is not! --- 355,410 ---- } ! // (3) We should only allow certain strings in student's answers. ! // These are kept in $stack_cas['studentAllow'], and are generated on the fly from ! // the CAS docs. ! ! if ($stack_cas['strict']) { ! // Match more then one occurance ! $pat = "|[\?_A-Za-z0-9]+|"; ! preg_match_all($pat,$strout,$out,PREG_PATTERN_ORDER); ! ! ! // Filter out some of these matches. ! $strin_keywords=''; ! 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) { ! $strin_keywords[] = $key; ! } ! } ! ! // Students are only allowed certain strings. ! if ('t' != $seclevel) { ! // Make sure each one is really an allowed keyword ! if (is_array($strin_keywords)) { ! foreach ($strin_keywords as $strinkey) { ! ! if (!in_array(strtoupper($strinkey),$stack_cas['studentAllow'])) { ! // We are in trouble! ! $a = array('key' => stack_s($strinkey)); ! $ret.='<br />'.get_string('UnknownFun','stack',$a); ! } ! } ! } ! } else { // End of keyword checks for students ! // Make sure a teacher has not entered an unsupported function. ! if (is_array($strin_keywords)) { ! foreach ($strin_keywords as $strinkey) { ! ! if (in_array(strtoupper($strinkey),$stack_cas['teacherNotAllow'])) { ! // We are in trouble! ! $a = array('key' => stack_s($strinkey)); ! $ret.='<br />'.get_string('NotSupported','stack',$a); ! } ! } ! } ! ! } ! } ! ! // (4) Check for missing *'s // hack: This needs some careful thought. // We can't simply check for adjcent letters. For example sin(x) is ok, xsin(x) is not! *************** *** 411,464 **** } - // (5) We should only allow certain strings in student's answers. - // These are kept in $stack_cas['studentAllow'], and are generated on the fly from - // the CAS docs. - - if ($stack_cas['strict']) { - // Match more then one occurance - $pat = "|[\?_A-Za-z0-9]+|"; - preg_match_all($pat,$strout,$out,PREG_PATTERN_ORDER); - - - // Filter out some of these matches. - $strin_keywords=''; - 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) { - $strin_keywords[] = $key; - } - } - - // Students are only allowed certain strings. - if ('t' != $seclevel) { - // Make sure each one is really an allowed keyword - if (is_array($strin_keywords)) { - foreach ($strin_keywords as $strinkey) { - - if (!in_array(strtoupper($strinkey),$stack_cas['studentAllow'])) { - // We are in trouble! - $a = array('key' => stack_s($strinkey)); - $ret.='<br />'.get_string('UnknownFun','stack',$a); - } - } - } - } else { // End of keyword checks for students - // Make sure a teacher has not entered an unsupported function. - if (is_array($strin_keywords)) { - foreach ($strin_keywords as $strinkey) { - - if (in_array(strtoupper($strinkey),$stack_cas['teacherNotAllow'])) { - // We are in trouble! - $a = array('key' => stack_s($strinkey)); - $ret.='<br />'.get_string('NotSupported','stack',$a); - } - } - } - - } - } // Knock off first "<br />", (6 chars) --- 462,465 ---- |