From: Chris S. <san...@us...> - 2006-01-27 11:42:18
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23566/scripts Modified Files: stackCAS.php stackQuestion.php Log Message: Index: stackCAS.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackCAS.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** stackCAS.php 28 Nov 2005 14:10:01 -0000 1.15 --- stackCAS.php 27 Jan 2006 11:42:10 -0000 1.16 *************** *** 291,294 **** --- 291,295 ---- $cas_cmd .= " simp:false, "; $cas_cmd .= " print(\"[ Timestamp = [ 0 ], Ans= [ error = [\"), cte(\"ans\",errcatch(ans:$exp1)),"; + $cas_cmd .= " print(\" ListOfVariables = [ \"), print(listofvars(ans)), print(\" ], \"),"; $cas_cmd .= " print(\" ValidationError = [ \"), str:stack_validate(ans), print(str),"; $cas_cmd .= " print(\" ], \"), print(str), return(true)); \n"; Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** stackQuestion.php 28 Nov 2005 14:10:01 -0000 1.56 --- stackQuestion.php 27 Jan 2006 11:42:10 -0000 1.57 *************** *** 113,116 **** --- 113,122 ---- $stackOptions['Forbid']['default'] = ''; + // An autogenerated list of implicitly Forbidden strings, such as variable names used in a question; + // There is no user interface to this option. + $stackOptions['Forbid_implicit']['type'] = 'string'; + $stackOptions['Forbid_implicit']['values'] = ''; + $stackOptions['Forbid_implicit']['default'] = ''; + // 'Allowed words'; $stackOptions['Allow']['type'] = 'string'; *************** *** 1315,1319 **** // We do not want the student to be able to type in one of the question variables. ! // Hence we add these to the forbidden strings. // A teacher could always allow these if needed. if ( array_key_exists('questionVarsInst',$questionInst) ) { --- 1321,1325 ---- // We do not want the student to be able to type in one of the question variables. ! // Hence we add these to an option Forbid_implicit. // A teacher could always allow these if needed. if ( array_key_exists('questionVarsInst',$questionInst) ) { *************** *** 1325,1345 **** } ! // (2) Get any pre-existing options ! $forbid = ''; ! if (array_key_exists('questionOptions',$questionInst)) { ! if (array_key_exists('Forbid',$questionInst['questionOptions'])) { ! $forbid = $questionInst['questionOptions']['Forbid']; ! } ! } ! ! // (3) Sort out any comma problems. ! if ('' == $forbid) { // knock off the comma ! $forbid = substr($forbidvars, 1, strlen($forbidvars)-1); ! } else { ! $forbid .= $forbidvars; ! } ! // (4) Insert these ! $questionInst['questionOptions']['Forbid'] = $forbid; } --- 1331,1339 ---- } ! // (2) Sort out any comma problems. ! $forbid = substr($forbidvars, 1, strlen($forbidvars)-1); ! // (3) Insert these ! $questionInst['questionOptions']['Forbid_implicit'] = $forbid; } *************** *** 1672,1675 **** --- 1666,1694 ---- } + // Unpack the ListofVariables. This comes back as a comma separated string list. + if (array_key_exists('Forbid_implicit',$options) AND array_key_exists('ListOfVariables',$this_attempt)) { + // (1) Get any variables in the student's answers. + $LoV = trim($this_attempt['ListOfVariables']); + // Chop off the ['s + $LoV = substr($LoV,1,strlen($LoV)-2); + $LoV = explode(',',$LoV); + // (2) Get an array of variables used in the question. + $forb = explode(',',$options['Forbid_implicit']); + $forb = array_unique(array_map('trim',$forb)); + + // (3) Loop accross the $L0V's (likely to be shorter the $forbs) + foreach ($LoV as $fword) { + if (in_array($fword,$forb)) { + + // Throw an error + $this_attempt['Valid'] = 'false'; + $this_attempt['AnswerNote'] .= ' Implicit_ForbidWord'; + $this_attempt['FeedBack'] .= '<br />'.get_string('ForbidWord','stack',$fword); + } + } // end (3) + + } + + return $this_attempt; *************** *** 1686,1698 **** function stack_question_inst_mark(&$questionInst,$options,$RawAns,&$errors) { global $stackQuestionPotResp,$stackAnswerTest; - $disp = $options['Display']; // (1) Validate the student's attempt $this_attempt = stack_question_validate_sa($RawAns,$options,$errors); ! $RawAns = $this_attempt['RawAns']; ! // (2) Do we have a valid & non-empty attempt? ! $CorrectAns = $questionInst['questionAnsInst']['value']; if ('true' == $this_attempt['Valid'] and '' != trim($RawAns) and '' != $CorrectAns) { --- 1705,1720 ---- function stack_question_inst_mark(&$questionInst,$options,$RawAns,&$errors) { global $stackQuestionPotResp,$stackAnswerTest; $disp = $options['Display']; // (1) Validate the student's attempt $this_attempt = stack_question_validate_sa($RawAns,$options,$errors); ! //show_array($this_attempt); ! // (2) Do any of the variables in the question appear in the student's answer. ! ! ! // (3) Do we have a valid & non-empty attempt? ! $RawAns = $this_attempt['RawAns']; ! $CorrectAns = $questionInst['questionAnsInst']['value']; if ('true' == $this_attempt['Valid'] and '' != trim($RawAns) and '' != $CorrectAns) { |