From: pkiddie <pk...@us...> - 2005-09-01 13:50:26
|
Update of /cvsroot/stack/stack-1-0/scripts/rqp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16848/scripts/rqp Modified Files: RQPv1p0Server.php nb_soapfuncs.php stackDetails.php Added Files: stackRQP.php Log Message: Latest iteration of HTTP 1.1 code to ensure IIS compatibility Echo'ing of authoring form to buffer if accessing function remotely new stackRQP library, parses form fields returned from RQP client Index: stackDetails.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/stackDetails.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stackDetails.php 25 Aug 2005 16:06:18 -0000 1.2 --- stackDetails.php 1 Sep 2005 13:50:18 -0000 1.3 *************** *** 10,14 **** * - version of STACK in use */ ! require('../../stackstd.php'); echo '<html> --- 10,15 ---- * - version of STACK in use */ ! require('../../stackConfig.php'); ! require('../../stackLib.php'); echo '<html> Index: RQPv1p0Server.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/RQPv1p0Server.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RQPv1p0Server.php 30 Aug 2005 16:34:57 -0000 1.4 --- RQPv1p0Server.php 1 Sep 2005 13:50:18 -0000 1.5 *************** *** 2,9 **** include("nb_easyxml_lite.php"); include("nb_soapfuncs.php"); - //include("../../stackstd.php"); //include("rqp_util.php"); //Stack/RQP utility function. include("../../stackConfig.php"); include("../../stackLib.php"); /********* Data structures used by this web service ********* --- 2,9 ---- include("nb_easyxml_lite.php"); include("nb_soapfuncs.php"); //include("rqp_util.php"); //Stack/RQP utility function. include("../../stackConfig.php"); include("../../stackLib.php"); + include("stackRQP.php"); /********* Data structures used by this web service ********* *************** *** 59,64 **** $stack_web_url = 'http://'.$stack_host.'/'.$stack_basepath.'/'; ! $stack_ver['release'] = '1.0'; ! $stack_ver['cvsmodule'] = 'stack-1-0'; $stack_web_services_provide = TRUE; --- 59,64 ---- $stack_web_url = 'http://'.$stack_host.'/'.$stack_basepath.'/'; ! //$stack_ver['release'] = '1.0'; ! //$stack_ver['cvsmodule'] = 'stack-1-0'; $stack_web_services_provide = TRUE; *************** *** 336,340 **** } ! require("../../stackstd.php"); //Reqd for version info for STACK //require("../moodlelib.php"); require_once('../stackAuthor.php'); --- 336,340 ---- } ! //require("../../stackstd.php"); //Reqd for version info for STACK //require("../moodlelib.php"); require_once('../stackAuthor.php'); *************** *** 358,364 **** if (empty($source)) { $question = stack_question_new('Paul Kiddie'); //Create question with mim fields. Todo, how do we get admin name from Moodle - show_array($question); $persistentData = ''; $outcomeVars = array('completion' => 'unknown', --- 358,370 ---- if (empty($source)) { + //Is this a new NEW question, or are we in an existing authoring session + if (empty($inputData)) { // if empty input array - we are starting afresh $question = stack_question_new('Paul Kiddie'); //Create question with mim fields. Todo, how do we get admin name from Moodle + } + + else { //parse these input fields + $question = stack_rqp_question_get($inputData); + } $persistentData = ''; $outcomeVars = array('completion' => 'unknown', *************** *** 394,401 **** 'response' => '', 'answer' => '', ! 'solution' => ''); ! ! $mimetype = 'text/html'; ! $files = array(); } --- 400,404 ---- 'response' => '', 'answer' => '', ! 'solution' => ''); } *************** *** 404,411 **** --- 407,439 ---- //Use existing source to fill in fields within authoring form //Import source XML and display question editing form + if('adminOptions'==$source) { + $options_headings = array(get_string('stackOptions_edit_out','stack'),''); + $options_list = array('Display','Language'); + + $fieldname = 'quiz'.'[quizOptions]'; + + $output = array('title' => '', //initially question will have no title + //remoteCaller = true + 'body' => stack_options_edit_form($options_headings,$options_list,$optval,$fieldname,$namePrefix, TRUE), + 'stem' => '', + 'feedback' => '', + 'response' => '', + 'answer' => '', + 'solution' => ''); + } + + else if ('teacherOptions'==$source) { + } + + else if ('userOptions'==$source) { + } } } + //Variables the same no matter what context render called in + $mimetype = 'text/html'; + $files = array(); + //Construct RenderType Index: nb_soapfuncs.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/nb_soapfuncs.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** nb_soapfuncs.php 30 Aug 2005 16:34:57 -0000 1.4 --- nb_soapfuncs.php 1 Sep 2005 13:50:18 -0000 1.5 *************** *** 73,77 **** stream_set_timeout($sock, 2); stream_set_blocking($sock, false); ! echo "<pre>".htmlentities($request)."</pre>"; // Uncomment this for debugging if($sock == false) --- 73,77 ---- stream_set_timeout($sock, 2); stream_set_blocking($sock, false); ! //echo "<pre>".htmlentities($request)."</pre>"; // Uncomment this for debugging if($sock == false) *************** *** 89,94 **** while ((!feof($sock))&&(!$pageComplete)) { - $cl = strlen($contents); $contents .= fread($sock, 8192); if(!$headersComplete) { --- 89,94 ---- while ((!feof($sock))&&(!$pageComplete)) { $contents .= fread($sock, 8192); + $cl = strlen($contents); if(!$headersComplete) { *************** *** 97,100 **** --- 97,101 ---- while(($headerEnd != false)&&(!$headersComplete)) { + //echo "<p><i><b>Hdrend</b><br/><pre>[" . htmlentities($contents) . "]</pre></i></p>"; $fle = strpos($contents,"\r\n"); // first line end $line = substr($contents, 0, $fle); *************** *** 109,116 **** { $headersComplete = true; $clp = strpos($contents,"Content-Length:"); ! $cle = strpos($contents,"\r\n",$clp); ! $contentLength = intval(trim(substr($contents, $clp+15, $cle-$clp-15))); ! $headerLength = $cle+4; } else --- 110,130 ---- { $headersComplete = true; + // check for chunked encoding + $clp = strpos($contents,"Transfer-Encoding:"); + + // check for content length $clp = strpos($contents,"Content-Length:"); ! if($clp != false) ! { ! $cle = strpos($contents,"\r\n",$clp); ! $contentLength = intval(trim(substr($contents, $clp+15, $cle-$clp-15))); ! $headerLength = $cle+4; ! } ! else // no content length ! { ! // should really check that it is either chunked or CloseConnection ! // and through an exception if not... ! $contentLength = -1; ! } } else *************** *** 124,128 **** if($headersComplete) // not an else because I want it done if headersComplete just set { ! if(strlen($contents)>=$contentLength+$headerLength) $pageComplete = true; } --- 138,142 ---- if($headersComplete) // not an else because I want it done if headersComplete just set { ! if(($contentLength!=-1)&&(strlen($contents)>=$contentLength+$headerLength)) $pageComplete = true; } *************** *** 139,143 **** fclose($sock); } ! echo "<pre>" . htmlentities($contents) . "</pre>"; // Uncomment this for debugging return $contents; } --- 153,157 ---- fclose($sock); } ! //echo "<pre>" . htmlentities($contents) . "</pre>"; // Uncomment this for debugging return $contents; } --- NEW FILE: stackRQP.php --- <?php require_once('../../stackLib.php'); /** * Gets the question instance that has been stored within the RQP inputData fields * @param array $inputData inputData key/val array * @return array $question The question */ function stack_rqp_question_get($inputData) { global $stackQuestion; $question = NULL; foreach ($stackQuestion as $qfield => $attribs) { for ($i=0;$i<(count($inputData));$i++) { //show_array($inputData[$i]); //show_array($qfield); //show_array($inputData[$i]['key']); if ($qfield==$inputData[$i]['key']) { if ($qfield == 'questionOptions') { //This is two step - first we decode, then deserialise $question[$qfield] = unserialize(html_entity_decode($inputData[$i]['val'])); break; } else if ($qfield == 'questionPotResp') { $question[$qfield] = unserialize(html_entity_decode($inputData[$i]['val'])); break; } else { //Need to work out what we do with options and potential responses - can't have arrays within val! $question[$qfield] = $inputData[$i]['val']; break; } } } } show_array($question); /*foreach($stackQuestion as $qfield => $attribs) { if (array_key_exists($qfield,$_POST) ) { if ('questionOptions' == $qfield) { $question[$qfield] = $_POST[$qfield]; } else if ('questionPotResp' == $qfield ) { $question[$qfield] = $_POST[$qfield]; } else if ( '' !=trim($_POST[$qfield]) ) { // We need this: all fields on form will be present in $_POST. $question[$qfield] = $_POST[$qfield]; } } }*/ return $question; } ?> |