Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv976/scripts Modified Files: stackAuthor.php stackDatabase.php stackQuestion.php stackSocketSend.php stackUnix.php stackUtility.php stackWin.php Log Message: Index: stackDatabase.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackDatabase.php,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** stackDatabase.php 8 Jul 2005 16:56:23 -0000 1.30 --- stackDatabase.php 14 Jul 2005 07:27:03 -0000 1.31 *************** *** 104,107 **** --- 104,108 ---- } + /** * List all the questions in the database and allow access to all functions, including editing. Outputs question *************** *** 257,261 **** echo "<tr><td><input type=\"checkbox\" name=\"questionsToAdd[$qID][add]\" value=\"ticked\" /></td>\n"; ! echo "<td>$qID</td><td>$name</td><td>$qkw</td> </tr>\n"; // Descriptions on a new line. --- 258,269 ---- echo "<tr><td><input type=\"checkbox\" name=\"questionsToAdd[$qID][add]\" value=\"ticked\" /></td>\n"; ! echo "<td>$qID</td><td>$name</td><td>$qkw</td> "; ! ! // List any quizzes in which the question is used. ! echo "<td>"; ! echo stack_db_question_quiz_list_printquizname($qID); ! echo "</td>"; ! ! echo " </tr>\n"; // Descriptions on a new line. *************** *** 324,328 **** function stack_db_question_filter_tablehead($action,$filter,$quizid=0) { ! // The following is JAVA script to select all the questions in a quiz. // Note the fix to prevent all check boxes being selected. echo "<script> --- 332,336 ---- function stack_db_question_filter_tablehead($action,$filter,$quizid=0) { ! // The following is JAVAscript to select all the questions in a quiz. // Note the fix to prevent all check boxes being selected. echo "<script> *************** *** 407,415 **** ! echo "<tr>\n<td></td>\n<td><b>ID</b></td><td align='center'><b>Name</b></td> <td align='center'><b>Key words</b></td> <td></td>"; if ('edit'==$action) { ! echo "<td align='center'><b>Last edit</b></td>"; } else { ! echo '<td></td><td></td>'; } --- 415,423 ---- ! echo "<tr>\n<td></td>\n<td><b>ID</b></td><td align='center'><b>Name</b></td> <td align='center'><b>Key words</b></td>"; if ('edit'==$action) { ! echo "<td></td><td align='center'><b>Last edit</b></td>"; } else { ! echo '<td><b>In quiz?</b></td><td></td>'; } *************** *** 508,512 **** * @return int $result the questionID of the question in the database, new or not. */ ! function stack_db_addquestion($question,$newq=FALSE) { // Add a question to the DB. // If a question has an ID number, and $newq = FALSE, then we update the existing question. --- 516,520 ---- * @return int $result the questionID of the question in the database, new or not. */ ! function stack_db_question_add($question,$newq=FALSE) { // Add a question to the DB. // If a question has an ID number, and $newq = FALSE, then we update the existing question. *************** *** 659,685 **** /** - * Confirms a question still exists in the database. - * - * @param int $questionID The questionID of the question. - * @return boolean - */ - function stack_db_confirm_question_exists($questionID) { - - $exists = FALSE; - - if ('' != $questionID ) { - $query = 'SELECT questionDateLastEdited FROM stackQuestion WHERE questionID='.$questionID; - $result= stack_db_query($query); - - if(0 != mysql_num_rows($result)) { - $exists = TRUE; - } - } - - return $exists; - } - - - /** * Returns the question from the database with the given id. * --- 667,670 ---- *************** *** 741,744 **** --- 726,809 ---- /** + * Confirms a question still exists in the database. + * + * @param int $questionID The questionID of the question. + * @return boolean + */ + function stack_db_question_confirm_exists($questionID) { + + $exists = FALSE; + + if ('' != $questionID ) { + $query = 'SELECT questionDateLastEdited FROM stackQuestion WHERE questionID='.$questionID; + $result= stack_db_query($query); + + if(0 != mysql_num_rows($result)) { + $exists = TRUE; + } + } + + return $exists; + } + + /** + * Returns an array of quizID's, indicating in which quizzes a question is used. + * + * @param int $questionID The questionID of the question. + * @return array $quizList + */ + function stack_db_question_quiz_list($questionID) { + + $quizList = array(); + + if ('' != $questionID ) { + $query = 'SELECT quizID FROM quiz_question WHERE questionID='.$questionID; + $result= stack_db_query($query); + + if(0 != mysql_num_rows($result)) { + for ($i = 0; $i < mysql_num_rows($result); $i++) { + $row = mysql_fetch_row($result); + $quizList[] = $row[0]; + } + } + } + + return $quizList; + } + + + /** + * Returns a string in a printable form, giving a comma separated list of quiz names + * in which the question occurs + * + * @param int $questionID The questionID of the question. + * @return array $quizList + */ + function stack_db_question_quiz_list_printquizname($questionID) { + + $quizList = ''; + + if ('' != $questionID ) { + $quiz_used = stack_db_question_quiz_list($questionID); + if (!empty($quiz_used)) { + foreach($quiz_used as $i) { + $quizDetails = stack_db_quiz_get($i); + $quizName = $quizDetails['quizName']; + if (strlen($quizName)>15) { + $quizName = substr($quizName,0,15).'...'; + } + $quizList .= ", (".$i.") ".$quizName; + } + $quizList = substr($quizList,1,strlen($quizList)-1); + } + } + + + + return $quizList; + } + + + /** * Deletes a question from the database with the given id. * *************** *** 746,756 **** * @return string The result from the MySQL database */ ! function stack_db_dropquestion($questionID) { // Deletes a question from the database with this id. global $stackQuestion,$stack_mysql; $query='DELETE FROM stackQuestion WHERE questionID='.$questionID; $result= stack_db_query($query); return $result; } --- 811,826 ---- * @return string The result from the MySQL database */ ! function stack_db_question_drop($questionID) { // Deletes a question from the database with this id. global $stackQuestion,$stack_mysql; + // (0) delete the question itself $query='DELETE FROM stackQuestion WHERE questionID='.$questionID; $result= stack_db_query($query); + // (1) Delete question from any quizzes in which it is in. + $query = "DELETE FROM quiz_question WHERE questionID = '$questionID'"; + $result = stack_db_query($query); + return $result; } *************** *** 1280,1286 **** if ('' != $quizid ) { $query = "DELETE FROM stackQuiz WHERE quizid = '$quizid'"; ! $result= stack_db_query($query); ! } } --- 1350,1363 ---- if ('' != $quizid ) { + // (0) Delete the quiz itself $query = "DELETE FROM stackQuiz WHERE quizid = '$quizid'"; ! $result = stack_db_query($query); ! ! // (1) Delete all questions attached to the quiz ! $query = "DELETE FROM quiz_question WHERE quizID = '$quizid'"; ! $result = stack_db_query($query); ! ! } ! } Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** stackAuthor.php 21 Jun 2005 14:52:25 -0000 1.25 --- stackAuthor.php 14 Jul 2005 07:27:03 -0000 1.26 *************** *** 680,684 **** $qo = nsf($qu,'order'); // Get the question with the body encoded. ! $qID_exists_in_DB = stack_db_confirm_question_exists($qID); if ($qID_exists_in_DB) { $question = stack_db_getquestion($qID,TRUE); --- 680,684 ---- $qo = nsf($qu,'order'); // Get the question with the body encoded. ! $qID_exists_in_DB = stack_db_question_confirm_exists($qID); if ($qID_exists_in_DB) { $question = stack_db_getquestion($qID,TRUE); *************** *** 827,831 **** // HACK need a regular expression to confirm $quID is a number only! ! if (stack_db_confirm_question_exists($quID)) { stack_db_quiz_add_question($quizid,$quID); $quiz['questions'][] = array('questionID'=>$quID); --- 827,831 ---- // HACK need a regular expression to confirm $quID is a number only! ! if (stack_db_question_confirm_exists($quID)) { stack_db_quiz_add_question($quizid,$quID); $quiz['questions'][] = array('questionID'=>$quID); Index: stackUtility.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUtility.php,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** stackUtility.php 27 Jun 2005 08:26:40 -0000 1.24 --- stackUtility.php 14 Jul 2005 07:27:04 -0000 1.25 *************** *** 10,13 **** --- 10,17 ---- // HACK these should go in stackstd.php. They are in stackstd.php.dist // but old installs will break. Remove in next release. + // + // Also in the new release. + // (1) remove stackData.php - and its reference in stackstd.php + // (2) remove stackSocketSend.php - and its reference in stackstd.php if ($stack_stand_alone) { require_once("{$stack_root}/scripts/moodlelib.php"); *************** *** 17,20 **** --- 21,26 ---- require_once("{$stack_root}/frontend_general/frontend_util.php"); + + /** * Displays the contents of an array for HTML display. Index: stackSocketSend.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackSocketSend.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** stackSocketSend.php 31 Mar 2005 09:39:49 -0000 1.5 --- stackSocketSend.php 14 Jul 2005 07:27:04 -0000 1.6 *************** *** 1,8 **** <?php /** ! * Important utility functions for connecting to sockets and other ! * external progammes. The functions in this file are needed by the ! * stand alone installs, the rqp servers but should not be needed by the ! * Moodle quiz module via the rqp client. * * @package scripts --- 1,5 ---- <?php /** ! * This file is no longer needed. It should be removed at the next major update. * * @package scripts *************** *** 10,238 **** */ - /** - * Instantiate a list of local variables through the CAS. - * - * This function performs the following tasks: - * 1. Checks each local for a PHP error - * 2. If no errors, sends them to the CAS - * 3. Checks for CAS errors - * - * @param array $locals List of local variables to instantiate. - * @param int $seed The random number seed to use - * @param array $options STACK options - * @param array &$err Repository for errors. - * @return array List of instantiated local variables. - */ - function stack_process_vars($locals,$seed,$options,&$err) { - global $stack_os; - - // Make sure ?'s are replaced by qmchar's - if (is_array($locals)) { - foreach ($locals as $key=> $val) { - $locals[$key] = str_replace('?','qmchar',$val); - } - } - - if ('unix' == $stack_os) { - - $locals_inst = stack_process_vars_unix($locals,$seed,$options,$err); - - } else if ('win' == $stack_os) { - - $locals_inst = stack_process_vars_win($locals,$seed,$options,$err); - //show_array($locals_inst); - - } else if ('unix-pool' == $stack_os) { - - if (isset($errors['ProcessVars'])) { - unset($errors['ProcessVars']); - } - - // generate a StackRequest and send it - $webRequest = new StackRequest('PROCESSVARS'); - $webRequest->crData = array('locals' => $locals, 'display' => $options['Display'], 'randseed' => $seed ); - $webResponse = stack_socket_send($webRequest); - - // acknowledge the received StackResponse - $ackRequest = new StackRequest('FINISH'); - $ackRequest->crPID = $webResponse->crPID; - stack_socket_send($ackRequest); - - if (FALSE === $webResponse->crError) { - $locals_inst = $webResponse->crReturn; - } else { - // We have some socket generated error! - // (1) Give back the locals un-instantiated. - $locals_inst = $locals; - $err['stack_process_vars'] = $webResponse->crError; - } - - } else { - echo "\n\n Warning! Could not determing which operating system you are using.\n Given ($stack_os)"; - } - - //show_array($locals_inst); - return($locals_inst); - } - - - // ************************************************************* - // ** LaTeX to HTML - // ************************************************************* - - /** - * Use an external program to convert a LaTeX string to HTML - * - * @see TexProcess - * @param string $tex_string The LaTeX string - * @return string|boolean The converted HTML string or FALSE if there was an error. - */ - function stack_latex_to_html($tex_string) { - global $stack_os,$stack_web_root,$stack_web_services; - - // Takes a pure LaTeX string and returns HTML. - $tex_string = str_replace('\sp', "^", $tex_string); - $tex_string = str_replace('qmchar', '?', $tex_string); - - // create StackRequest object - $request = new StackRequest('TEXCOMMAND'); - $request->crData = $tex_string; - - if ('unix' == $stack_os) { - - $html_string = stack_latex_to_html_unix($tex_string); - - } else if ('win' == $stack_os) { - - $html_string = stack_latex_to_html_win($tex_string); - - } else { - // create a new TeX process - $texProcess = new TexProcess(); - $texReady = $texProcess->CPInitialise(); - - //print_r($texReady); - //echo "<pre>$tex_string</pre>"; - if ($texReady) { - $response = $texProcess->CPSend($request); - $html_string = $response->crData; - $texProcess->CPClose(); - } else { - // process could not be initialised, return an error - return FALSE; - } - } - - return $html_string; - } - - - // ************************************************************* - // ** Connect to CAS: processing vars and connect to socket - // ************************************************************* - - /** - * Connect to a socket to send and receive information. - * - * @see StackSocket - * @see StackRequest - * @see StackResponse - * @param StackRequest $socketRequest - * @return StackResponse - */ - function stack_socket_send($socketRequest) { - - // get the socket parameters from stacksettings.inc - global $stack_socket; - $socketResponse=''; - - // if the port is not set, set it to send to the parent stack socket - if (!is_int($socketRequest->crPort)) { - $socketRequest->crPort = $stack_socket['port']; - } - - // serialize the request for transmission - $request = serialize($socketRequest); - - // open a socket connection - $fp = fsockopen($stack_socket['host'], $socketRequest->crPort, $errno, $errstr); - - // return error immediately if no socket connection can be made - if(!$fp) { - $socketResponse = new StackResponse(); - $socketResponse->crError['SOCKET-CONNECT'] = TRUE; - $socketResponse->crReturn = "Error: $errstr"; - } else { - //send command - fputs($fp, $stack_socket['inputStartTag'].$request.$stack_socket['inputEndTag']); - - //wait for output - $response = ''; - - while (!feof($fp)) { - $response .= fgets($fp, 512); - } - - // close communication socket - fclose($fp); - - // check for start and end tags - $start = strpos($response, $stack_socket['inputStartTag']); - $end = strpos ($response, $stack_socket['inputEndTag']); - - // if start and end tags found, strip them off - if ($start !== FALSE && $end !== FALSE) { - - //strip off outer tags - $startCmd = strpos($response, $stack_socket['inputStartTag']) + strlen($stack_socket['inputStartTag']); - $endCmd = strpos($response, $stack_socket['inputEndTag']); - $command = substr($response, $startCmd, $endCmd-$startCmd); - - $socketResponse = unserialize($command); - } - } - - // result is a StackResponse object - return $socketResponse; - } - - /** - * Similar to stack_socket_send, but don't wait for a response - * - * @see stack_socket_send() - * @param StackRequest $socketRequest - * @return boolean True if message sent, false if no connection could be made. - */ - function stack_socket_send_noresp($socketRequest) { - - // get the socket parameters from stacksettings.inc - global $stack_socket; - - // if the port is not set, set it to send to the parent stack socket - if (!is_int($socketRequest->crPort)) { - $socketRequest->crPort = $stack_socket['port']; - } - - // serialize the request for transmission - $request = serialize($socketRequest); - - // open a socket connection - $fp = fsockopen($stack_socket['host'], $socketRequest->crPort, $errno, $errstr); - - // return error immediately if no socket connection can be made - if(!$fp) { - return FALSE; - } else { - //send command - fputs($fp, $stack_socket['inputStartTag'].$request.$stack_socket['inputEndTag']); - - // close communication socket - fclose($fp); - - return TRUE; - } - } - - - ?> --- 7,9 ---- Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** stackQuestion.php 21 Jun 2005 14:52:26 -0000 1.21 --- stackQuestion.php 14 Jul 2005 07:27:03 -0000 1.22 *************** *** 118,238 **** $stackOptions['ShowSol']['default']='On request'; - /** - * Validates options, removing any blank or default values. - * This should also eventually validate the value of each option. - * - * @param array The options array - * @return void - */ - function stack_options_validate(&$options) { - global $stackOptions; - - // Do we have an array of options? - if (is_array($options)) { - - foreach ($stackOptions as $opt => $fields) { - if (array_key_exists($opt,$options)) { - // Option is set in the $options - if (''==trim($options[$opt]) or 'default'==trim($options[$opt])) { - // But, the option has no value, or is specified 'default' - unset($options[$opt]); // Get rid of this from the question. - } - } - } // end foreach - // Do we have anything left? - if (NULL == array_keys($options)) { - $options=NULL; - } - } - - } - - - /** - * Sets the cascading options, first taking the defaults, then using the subject - * quiz, and finally question values. - * - * @param array &$question The STACK question, required - * @param array &$quiz_options The STACK quiz options array *NOT* the whole quiz, optional - * @param array &$subject The STACK subject options array *NOT* the whole quiz, optional - * @return array The list of options - */ - function stack_options_set($question,$quiz_options=NULL,$subject=NULL) { - global $stackOptions; - - $options = array(); - - //(0) Set the default options. - foreach ($stackOptions as $opnam => $fields) { - $options[$opnam] = $fields['default']; - } - - //(1) Now look in the $question. - if (is_array($question)) { - if (array_key_exists('questionOptions',$question)) { - $qOpt = $question['questionOptions']; - - // Do we have any set options? - if (is_array($qOpt)){ - foreach ($stackOptions as $opt => $fields) { - if (array_key_exists($opt,$qOpt)) { - // Actually take the option which is set, and use it! - $options[$opt] = $qOpt[$opt]; - } - } // end foreach - } - } - } - - //(2) Now look in the $quiz_options - if (is_array($quiz_options)) { - foreach ($stackOptions as $opt => $fields) { - if (array_key_exists($opt,$quiz_options)) { - // Actually take the option which is set, and use it! - $options[$opt] = $quiz_options[$opt]; - } - } // end foreach - } - - return($options); - } - - /** - * Build an array of forbidden strings - * - * @param array $options The STACK option settings - * @return array The list of forbidden words - */ - function stack_options_forbidden($options) { - // Build an array of forbidden strings. - // The fields 'Forbid' and 'Allow' should be in the $options, - // Even if empty strings. - - if (''!= trim($options['Forbid']) ) { // There is at least one forbidden word - $forb = explode(',',$options['Forbid']); - $forb = array_unique(array_map('trim',$forb)); - } else { - $forb = ''; - } - - if (''!= trim($options['Allow']) ) { // There is at least one allowed word - $allow = explode(',',$options['Allow']); - $allow = array_unique(array_map('trim',$allow)); - } else { - $allow = ''; - } - - if (is_array($forb)) { // There are some forbidden words - if (is_array($allow)) {// There are some allowed words - $forbid = array_diff($forb,$allow); // Take out the allowed ones. - } else { - $forbid = $forb; - } - } else { - $forbid = ''; - } // No forbidden words - - return($forbid); - } --- 118,121 ---- *************** *** 533,536 **** --- 416,544 ---- $stackOptions['AnsTest']['values'] = $ats; + /** + * Validates options, removing any blank or default values. + * This should also eventually validate the value of each option. + * + * @param array The options array + * @return void + */ + function stack_options_validate(&$options) { + global $stackOptions; + + // Do we have an array of options? + if (is_array($options)) { + + foreach ($stackOptions as $opt => $fields) { + if (array_key_exists($opt,$options)) { + // Option is set in the $options + if (''==trim($options[$opt]) or 'default'==trim($options[$opt])) { + // But, the option has no value, or is specified 'default' + unset($options[$opt]); // Get rid of this from the question. + } + } + } // end foreach + // Do we have anything left? + if (NULL == array_keys($options)) { + $options=NULL; + } + } + + } + + + /** + * Sets the cascading options, first taking the defaults, then using the subject + * quiz, and finally question values. + * + * @param array &$question The STACK question, required + * @param array &$quiz_options The STACK quiz options array *NOT* the whole quiz, optional + * @param array &$subject The STACK subject options array *NOT* the whole quiz, optional + * @return array The list of options + */ + function stack_options_set($question,$quiz_opts=NULL,$subject_opts=NULL) { + global $stackOptions; + + $options = array(); + $question_opts = NULL; + + //(0) Set the default options. + foreach ($stackOptions as $opnam => $fields) { + $options[$opnam] = $fields['default']; + } + + //(1) Now look in the $question. + if (is_array($question)) { + if (array_key_exists('questionOptions',$question)) { + $question_opts = $question['questionOptions']; + + } + } + + // (2) Set the options - in the reverse order. + stack_options_set_onepass($options,$subject_opts); + stack_options_set_onepass($options,$quiz_opts); + stack_options_set_onepass($options,$question_opts); + + return($options); + } + + + /** + * One pass at adding an array of options to an existing options array. + * + * @param array $opt_toset The options to be set. + * @param array &$options The array holding the existing option. + * @return NULL + */ + function stack_options_set_onepass(&$options,$opt_toset) { + global $stackOptions; + + if (is_array($opt_toset)) { + foreach ($stackOptions as $opt => $fields) { + if (array_key_exists($opt,$opt_toset)) { + $options[$opt] = $opt_toset[$opt]; + } + } + } + } + + /** + * Build an array of forbidden strings + * + * @param array $options The STACK option settings + * @return array The list of forbidden words + */ + function stack_options_forbidden($options) { + // Build an array of forbidden strings. + // The fields 'Forbid' and 'Allow' should be in the $options, + // Even if empty strings. + + if (''!= trim($options['Forbid']) ) { // There is at least one forbidden word + $forb = explode(',',$options['Forbid']); + $forb = array_unique(array_map('trim',$forb)); + } else { + $forb = ''; + } + + if (''!= trim($options['Allow']) ) { // There is at least one allowed word + $allow = explode(',',$options['Allow']); + $allow = array_unique(array_map('trim',$allow)); + } else { + $allow = ''; + } + + if (is_array($forb)) { // There are some forbidden words + if (is_array($allow)) {// There are some allowed words + $forbid = array_diff($forb,$allow); // Take out the allowed ones. + } else { + $forbid = $forb; + } + } else { + $forbid = ''; + } // No forbidden words + + return($forbid); + } + //****************************************************** *************** *** 1055,1077 **** * Apply an Answer Test. * ! * Currently supported answer tests include: ! * - AlgEquiv : algebraic equivalence check (CAS required) ! * - FacForm : factored form check (CAS required) ! * - Num_tol_relative : Numerical Tolerance Relative (CAS required) ! * - Num_tol_absolute : Numerical Tolerance Absolute (CAS required) ! * - SA_True : Use of a CAS function with a boolean result (CAS required) ! * - String : strict string comparison (case-sensitive) ! * - StringSloppy : loose string comparison (case and whitespace ignored) ! * - RegExp : regular expression match ! * - True : Result is always true ! * For the full list, refer to the stackData.php file, in which these are documented. ! * ! * @param string $sa The student's answer ! * @param string $ta The teacher's answer ! * @param string $atest The name of the answer test ! * @param array $atest_ops The answer test optons ! * @param string $disp The display option ! * @param array &$errors Repository for errors ! * @return array A $stackQuestionAttempt data structure containing the information for this attempt */ function stack_apply_answertest($sa,$ta,$atest,$atest_ops,$disp,&$errors) { --- 1063,1073 ---- * Apply an Answer Test. * ! * @param string $sa The student's answer ! * @param string $ta The teacher's answer ! * @param string $atest The name of the answer test ! * @param array $atest_ops The answer test options ! * @param string $disp The display option ! * @param array &$errors Repository for errors ! * @return array $stackQuestionAttempt data structure containing the information for this attempt. */ function stack_apply_answertest($sa,$ta,$atest,$atest_ops,$disp,&$errors) { *************** *** 1132,1173 **** } ! // For the windows demonstration file.... ! if ('unix' == $stack_os) { ! ! $sa = $webRequest->crData['exp1']; ! $ta = $webRequest->crData['exp2']; ! ! $this_attempt = CPProcessAnsTest_unix($sa,$ta,$atest,$disp,$errors); ! ! } else if ('win' == $stack_os) { ! ! $sa = $webRequest->crData['exp1']; ! $ta = $webRequest->crData['exp2']; ! ! $this_attempt = CPProcessAnsTest_win($sa,$ta,$atest,$disp,$errors); ! ! } else { ! $webResponse = stack_socket_send($webRequest); ! ! $ackRequest = new StackRequest('FINISH'); ! $ackRequest->crPID = $webResponse->crPID; ! stack_socket_send($ackRequest); ! ! if ($webResponse->crError !== FALSE) { ! $errors[$atest] = $webResponse->crReturn; ! ! $this_attempt['Valid'] = 'false'; ! $this_attempt['Ans']['key'] = 'ans'; ! $this_attempt['Ans']['value'] = $sa; ! $this_attempt['Ans']['display'] = $sa; ! foreach ($webResponse->crError as $key => $val) { ! $this_attempt['AnswerNote'] .= $key.' '; ! } ! $this_attempt['FeedBack'] = 'There was an error (Specifically: '. $this_attempt['AnswerNote'] .') during the attempt to process your answer. \\ Please contact your teacher. \par For diagnostic purposes, the error was: '. $webResponse->crReturn; ! ! } else { ! $this_attempt = $webResponse->crReturn; ! } ! } // Clean up the CAS dependent scripts here --- 1128,1134 ---- } ! $sa = $webRequest->crData['exp1']; ! $ta = $webRequest->crData['exp2']; ! $this_attempt = CPProcessAnsTest($sa,$ta,$atest,$disp,$errors); // Clean up the CAS dependent scripts here Index: stackUnix.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUnix.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** stackUnix.php 12 Jun 2005 16:10:00 -0000 1.11 --- stackUnix.php 14 Jul 2005 07:27:04 -0000 1.12 *************** *** 19,25 **** * @return string|boolean The converted HTML string or FALSE if there was an error. */ ! function stack_latex_to_html_unix($strin) { global $stack_logfiles,$stack_latex,$stack_root; ! $ret = FALSE; $descriptors = array( --- 19,29 ---- * @return string|boolean The converted HTML string or FALSE if there was an error. */ ! function stack_latex_to_html($strin) { global $stack_logfiles,$stack_latex,$stack_root; ! ! $strin = str_replace('\sp', "^", $strin); ! $strin = str_replace('qmchar', '?', $strin); ! ! $ret = FALSE; $ret = FALSE; $descriptors = array( *************** *** 52,56 **** /** ! * Connect dorectly to the CAS, and return the raw string result. * This does not use sockets, but calls a new CAS session each time. * Hence, this is not likely to be efficient. --- 56,60 ---- /** ! * Connect directly to the CAS, and return the raw string result. * This does not use sockets, but calls a new CAS session each time. * Hence, this is not likely to be efficient. *************** *** 153,157 **** * @param array &$err Repository for errors. * @return array List of instantiated local variables. ! */ function stack_process_vars_unix($locals,$seed,$options,&$err) { $errors = ''; --- 157,161 ---- * @param array &$err Repository for errors. * @return array List of instantiated local variables. ! */ function stack_process_vars($locals,$seed,$options,&$err) { $errors = ''; *************** *** 241,248 **** * @return array $parsed An array structure, which is used to build the student's attempt. */ ! function CPProcessAnsTest_unix($exp1,$exp2,$test,$disp,&$err) { // create a StackResponse object $varResponse = new StackResponse(); ! $cpCAS = new Maxima(); $t = time(); --- 245,252 ---- * @return array $parsed An array structure, which is used to build the student's attempt. */ ! function CPProcessAnsTest($exp1,$exp2,$test,$disp,&$err) { // create a StackResponse object $varResponse = new StackResponse(); ! $cpCAS = new Maxima(); $t = time(); Index: stackWin.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackWin.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stackWin.php 20 Jun 2005 15:42:55 -0000 1.3 --- stackWin.php 14 Jul 2005 07:27:04 -0000 1.4 *************** *** 19,26 **** * @return string|boolean The converted HTML string or FALSE if there was an error. */ ! function stack_latex_to_html_win($strin) { ! // A Windows version, which uses files and direct execution. Not sockets. ! global $stack_logfiles,$stack_latex,$stack_root; $ret = FALSE; --- 19,28 ---- * @return string|boolean The converted HTML string or FALSE if there was an error. */ ! function stack_latex_to_html($strin) { global $stack_logfiles,$stack_latex,$stack_root; + + $strin = str_replace('\sp', "^", $strin); + $strin = str_replace('qmchar', '?', $strin); + $ret = FALSE; *************** *** 56,60 **** /** ! * Connect dorectly to the CAS, and return the raw string result. * This does not use sockets, but calls a new CAS session each time. * Hence, this is not likely to be efficient. --- 58,62 ---- /** ! * Connect directly to the CAS, and return the raw string result. * This does not use sockets, but calls a new CAS session each time. * Hence, this is not likely to be efficient. *************** *** 142,146 **** * @param array &$err Repository for errors. * @return array List of instantiated local variables. ! */ function stack_process_vars_win($locals,$seed,$options,&$err) { // Make sure ?'s are replaced by qmchar's --- 144,148 ---- * @param array &$err Repository for errors. * @return array List of instantiated local variables. ! */ function stack_process_vars($locals,$seed,$options,&$err) { // Make sure ?'s are replaced by qmchar's *************** *** 159,163 **** $winRequest->crData = array('locals' => $locals, 'display' => $options['Display'], 'randseed' => $seed ); ! $locals_inst = CPProcessVars_win($winRequest); --- 161,165 ---- $winRequest->crData = array('locals' => $locals, 'display' => $options['Display'], 'randseed' => $seed ); ! $locals_inst = CPProcessVars($winRequest); *************** *** 178,185 **** * @return StackResponse $varResponse $crReturn contains the instantiated values */ ! function CPProcessVars_win($varRequest) { // create a StackResponse object $varResponse = new StackResponse(); ! $cpCAS = new Maxima(); // local variables to be processed will be stored in --- 180,187 ---- * @return StackResponse $varResponse $crReturn contains the instantiated values */ ! function CPProcessVars($varRequest) { // create a StackResponse object $varResponse = new StackResponse(); ! $cpCAS = new Maxima(); // local variables to be processed will be stored in *************** *** 264,277 **** } - //$errors = ''; - //$seed = time(); - //$options['Display']='LaTeX'; - - //$locals[] = array('key' => 'p', 'value' =>'diff(x/(1+x^2),x)'); - //$locals[] = array('key' => 'p', 'value' =>'diff(x/(1+x^4),x)'); - //$locals[] = array('key' => 'p', 'value' =>'(fc(n):=sum(cos(k*x)/k!,k,0,n), p:makelist(fc(n),n,0,6), plot(p,[x,-2*%Pi,2*%Pi]))'); - - //$varInst = stack_process_vars_win($locals,$seed,$options,$errors); - /** --- 266,269 ---- *************** *** 284,288 **** * @return array $this_attempt An array structure, which is used to build the student's attempt. */ ! function CPProcessAnsTest_win($exp1,$exp2,$test,$disp,&$err) { // create a StackResponse object $varResponse = new StackResponse(); --- 276,280 ---- * @return array $this_attempt An array structure, which is used to build the student's attempt. */ ! function CPProcessAnsTest($exp1,$exp2,$test,$disp,&$err) { // create a StackResponse object $varResponse = new StackResponse(); |