From: Chris S. <san...@us...> - 2005-08-30 12:20:51
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29496/scripts Modified Files: stackXML.php Log Message: Index: stackXML.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackXML.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** stackXML.php 30 Aug 2005 10:50:32 -0000 1.18 --- stackXML.php 30 Aug 2005 12:20:29 -0000 1.19 *************** *** 62,70 **** * XML document to the calling function * ! * @see stack_xml_create_question_frag_new() * @param array $question A stackQuestion data structure * @return DOMIT_Document The XML document representing the question */ ! function stack_xml_create_question_new($question) { //Validate the question --- 62,70 ---- * XML document to the calling function * ! * @see stack_xml_create_question_frag() * @param array $question A stackQuestion data structure * @return DOMIT_Document The XML document representing the question */ ! function stack_xml_create_question($question) { //Validate the question *************** *** 82,86 **** $xmlDoc->appendChild($xmlDoc->createProcessingInstruction('xml', "version=\"1.0\" encoding=\"utf-8\"")); ! $questionFrag = &stack_xml_create_question_frag_new($question); //questionFrag head node is <assessmentItem>, add namespacing information to it --- 82,86 ---- $xmlDoc->appendChild($xmlDoc->createProcessingInstruction('xml', "version=\"1.0\" encoding=\"utf-8\"")); ! $questionFrag = &stack_xml_create_question_frag($question); //questionFrag head node is <assessmentItem>, add namespacing information to it *************** *** 97,101 **** * @return DOMIT_Element $questionFrag The root assessmentItem node with child question elements */ ! function &stack_xml_create_question_frag_new($question) { global $stackQuestion, $stack_ver, $xmlNamespaces; --- 97,101 ---- * @return DOMIT_Element $questionFrag The root assessmentItem node with child question elements */ ! function &stack_xml_create_question_frag($question) { global $stackQuestion, $stack_ver, $xmlNamespaces; *************** *** 103,107 **** $xmlDoc = &new DOMIT_Document(); //Required for some method calls $questionFrag = &new DOMIT_Element('assessmentItem'); ! //Construct main body of XML file //Iterate through each $stackQuestion field, and check for the presence in the instantiated $question --- 103,107 ---- $xmlDoc = &new DOMIT_Document(); //Required for some method calls $questionFrag = &new DOMIT_Element('assessmentItem'); ! show_array($question); //Construct main body of XML file //Iterate through each $stackQuestion field, and check for the presence in the instantiated $question *************** *** 110,115 **** //1. Write out metadata if ('meta' == $attribs['type'] && array_key_exists($qfield,$question)) { ! ! //Detect the metadata type switch ($attribs['metatype']) { --- 110,115 ---- //1. Write out metadata if ('meta' == $attribs['type'] && array_key_exists($qfield,$question)) { ! ! //Detect the metadata type switch ($attribs['metatype']) { *************** *** 269,273 **** * @return string $xml_file_name The name of the XML file to allow user to download, if the save was successful. Otherwise null */ ! function stack_xml_write_question_new($question,$directory) { //Create question filename --- 269,273 ---- * @return string $xml_file_name The name of the XML file to allow user to download, if the save was successful. Otherwise null */ ! function stack_xml_write_question($question,$directory) { //Create question filename *************** *** 278,282 **** } ! $xmlDoc = stack_xml_create_question_new($question); //Create the assessmentItem XML fragment $success = $xmlDoc->saveXML($directory."/".$xml_file_name,true); //Attempt to save XML file to requested directory --- 278,282 ---- } ! $xmlDoc = stack_xml_create_question($question); //Create the assessmentItem XML fragment $success = $xmlDoc->saveXML($directory."/".$xml_file_name,true); //Attempt to save XML file to requested directory *************** *** 293,301 **** * Returns the containing XML document to the calling function * ! * @see stack_xml_create_quiz_frag_new() * @param array $quiz A stackQuiz data structure * @return DOMIT_Document The XML document representing the quiz */ ! function stack_xml_create_quiz_new($quiz) { $xmlDoc = &new DOMIT_Document(); --- 293,301 ---- * Returns the containing XML document to the calling function * ! * @see stack_xml_create_quiz_frag() * @param array $quiz A stackQuiz data structure * @return DOMIT_Document The XML document representing the quiz */ ! function stack_xml_create_quiz($quiz) { $xmlDoc = &new DOMIT_Document(); *************** *** 309,313 **** //Create the quiz level metadata and options, wrapped in a <mathQuiz> container ! $quizFrag = stack_xml_create_quiz_frag_new($quiz); //<TODO> Does the quiz have any questions attached. If not, is there any point writing out?? --- 309,313 ---- //Create the quiz level metadata and options, wrapped in a <mathQuiz> container ! $quizFrag = stack_xml_create_quiz_frag($quiz); //<TODO> Does the quiz have any questions attached. If not, is there any point writing out?? *************** *** 322,329 **** stack_question_validate($question,$errors); //Validate it stack_xml_remove_question_meta_defaults($question); //Remove any disused fields before writing out - unset($question['questionID']); ! $questionFrag = &stack_xml_create_question_frag_new($question); //Write <assessmentItem> corresponding to this question //Include an order to each question on a question list --- 322,328 ---- stack_question_validate($question,$errors); //Validate it stack_xml_remove_question_meta_defaults($question); //Remove any disused fields before writing out unset($question['questionID']); ! $questionFrag = &stack_xml_create_question_frag($question); //Write <assessmentItem> corresponding to this question //Include an order to each question on a question list *************** *** 356,360 **** * @return DOMIT_Element $quizFrag The root mathQuiz node with child quiz elements */ ! function &stack_xml_create_quiz_frag_new($quiz) { global $stackQuiz, $xmlNamespaces; --- 355,359 ---- * @return DOMIT_Element $quizFrag The root mathQuiz node with child quiz elements */ ! function &stack_xml_create_quiz_frag($quiz) { global $stackQuiz, $xmlNamespaces; *************** *** 450,454 **** * @return string $xml_file_name The name of the XML file to allow user to download, if the save was successful. Otherwise null */ ! function stack_xml_write_quiz_new($quiz,$directory) { //<TODO> How about using Quiz name? --- 449,453 ---- * @return string $xml_file_name The name of the XML file to allow user to download, if the save was successful. Otherwise null */ ! function stack_xml_write_quiz($quiz,$directory) { //<TODO> How about using Quiz name? *************** *** 465,469 **** ! $xmlDoc = stack_xml_create_quiz_new($quiz); $success = $xmlDoc->saveXML($directory."/".$xml_file_name,true); --- 464,468 ---- ! $xmlDoc = stack_xml_create_quiz($quiz); $success = $xmlDoc->saveXML($directory."/".$xml_file_name,true); *************** *** 534,538 **** unset($question['questionID']); ! $questionFrag = &stack_xml_create_question_frag_new($question); //Include an order to each question on a question list --- 533,537 ---- unset($question['questionID']); ! $questionFrag = &stack_xml_create_question_frag($question); //Include an order to each question on a question list *************** *** 582,586 **** * Also adds a version to the head question element, based upon the current release of STACK. * ! * @see stack_xml_create_question_new() * @param DOMIT_Element &$headElement The element to which the namespacing information will be appended to, by reference * @return void --- 581,585 ---- * Also adds a version to the head question element, based upon the current release of STACK. * ! * @see stack_xml_create_question() * @param DOMIT_Element &$headElement The element to which the namespacing information will be appended to, by reference * @return void *************** *** 619,624 **** * Also adds a version to the head quiz element, based upon the current release of STACK. * ! * @see stack_xml_create_quiz_new() ! * @see stack_xml_create_question_list_new() * @param DOMIT_Element &$headElement The element to which the namespacing information will be appended to, by reference * @return void --- 618,623 ---- * Also adds a version to the head quiz element, based upon the current release of STACK. * ! * @see stack_xml_create_quiz() ! * @see stack_xml_create_question_list() * @param DOMIT_Element &$headElement The element to which the namespacing information will be appended to, by reference * @return void *************** *** 656,660 **** * @return string The XML string representing the question */ ! function stack_xml_create_question_frag($question, $depth) { // Takes a $stackQuestion array, and returns and XML string fragment $xml = ''; --- 655,659 ---- * @return string The XML string representing the question */ ! function stack_xml_create_question_frag_old($question, $depth) { // Takes a $stackQuestion array, and returns and XML string fragment $xml = ''; *************** *** 695,699 **** * @return string The XML file name */ ! function stack_xml_write_question_file($question, $directory) { // takes a $stackQuestion array and writes it to an XML file in $directory --- 694,698 ---- * @return string The XML file name */ ! function stack_xml_write_question_file_old($question, $directory) { // takes a $stackQuestion array and writes it to an XML file in $directory *************** *** 958,962 **** if ($node->childNodes[0]->nodeType==3) { ! $array[$nodeName]=$node->getText(); } --- 957,967 ---- if ($node->childNodes[0]->nodeType==3) { ! $val = $node->getText(); ! ! //Only import node if it does actually have any text behind it, in metadata this will assume defaults ! if (!empty($val)) { ! $array[$nodeName]=$val; ! } ! } *************** *** 1056,1060 **** else { ! $array[$nodeName]=$node->getText(); } } --- 1061,1070 ---- else { ! $val = $node->getText(); ! ! //Do not write question field if there is no text behind it ! if (!empty($val)) { ! $array[$nodeName]=$val; ! } } } |