From: pkiddie <pk...@us...> - 2005-08-30 10:28:13
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2590/scripts Modified Files: stackAuthor.php stackQuestion.php stackXML.php Log Message: Resolving conflicts between rqp branch and head branch Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** stackAuthor.php 29 Aug 2005 16:52:33 -0000 1.32 --- stackAuthor.php 30 Aug 2005 10:28:01 -0000 1.33 *************** *** 16,31 **** /** * Display the name of a option field, in a link generating a popup window. * * @param string $field The field name * @return string The link to the popup window */ ! function stack_question_edit_dispoptionfield($field) { global $stackOptions; $fd='stackOptions_'.$field; $fd=get_string($fd,'stack',''); ! $strout = "<a href=\"javascript:HelpPopup('$field','stackOptions');\">$fd</a>"; ! $strout = "<a border=\"none\" href=\"javascript:HelpPopup('$field','stackOptions');\"><img align=\"middle\" border=\"0\" alt=\"$fd\" src=\"pics/help.gif\" /></a> $fd"; ! return($strout); } --- 16,40 ---- /** * Display the name of a option field, in a link generating a popup window. + * Added $remoteCaller, which if not specified defaults to false. This prevents the display of the help * * @param string $field The field name * @return string The link to the popup window */ ! function stack_question_edit_dispoptionfield($field,$remoteCaller=FALSE) { global $stackOptions; $fd='stackOptions_'.$field; $fd=get_string($fd,'stack',''); ! ! if (!$remoteCaller) ! { ! $strout = "<a href=\"javascript:HelpPopup('$field','stackOptions');\">$fd</a>"; ! $strout = "<a border=\"none\" href=\"javascript:HelpPopup('$field','stackOptions');\"><img align=\"middle\" border=\"0\" alt=\"$fd\" src=\"pics/help.gif\" /></a> $fd"; ! return($strout); ! } ! ! else if ($remoteCaller) { ! return($fd); ! } } *************** *** 71,75 **** * @return void */ ! function stack_options_edit_form($options_headings,$options_list,$options,$fieldname) { global $stackOptions; --- 80,84 ---- * @return void */ ! function stack_options_edit_form($options_headings,$options_list,$options,$fieldname,$remoteCaller=FALSE) { global $stackOptions; *************** *** 80,84 **** foreach( $options_list as $k => $opt) { ! $descript = stack_question_edit_dispoptionfield($opt); $name = $fieldname.'['.$opt.']'; $category = $options_headings[$k]; --- 89,93 ---- foreach( $options_list as $k => $opt) { ! $descript = stack_question_edit_dispoptionfield($opt,$remoteCaller); $name = $fieldname.'['.$opt.']'; $category = $options_headings[$k]; *************** *** 143,147 **** function stack_question_edit_form($question,&$errors,$PostTo = '') { global $_PHP_SELF; - //show_array($question); if (empty($PostTo)) { --- 152,155 ---- *************** *** 160,185 **** } - function stack_question_edit_form_rqp($question,&$errors,$PostTo = '') { - global $_PHP_SELF; - - $html = ''; - //show_array($question); - - if (empty($PostTo)) { - $PostTo=$_PHP_SELF; - } - - // Timestamp this edit - $html .= "<form name='stackeditqform' action='$PostTo' method='POST'>\n"; - - $html .=stack_question_edit_form_substance_rqp($question,$errors); - - $html .= "<input type='hidden' name='action' value='' />\n"; - $html .= "<submit name='dummy' value=''>"; - $html .= "</form>\n\n\n"; // form in which questions are edited. - - return $html; - } - /** * Build the substance of the form to edit a STACK question. --- 168,171 ---- *************** *** 188,199 **** * @param array $question The STACK question * @param array &$errors Repository for errors * @return void */ ! function stack_question_edit_form_substance_rqp($question,&$errors) { ! global $stack_stand_alone,$stackQuestion,$stackOptions,$debug,$user; $t=time(); $dts = strftime('%c',$t); // Format the string. - $html = ''; if (array_key_exists('questionOptions',$question)) { // option set in question --- 174,185 ---- * @param array $question The STACK question * @param array &$errors Repository for errors + * @param string $prefix The string which to prefix all input fields * @return void */ ! function stack_question_edit_form_substance($question,&$errors, $prefix='', $remoteCaller=FALSE) { ! global $stackQuestion,$stackOptions,$debug,$user; $t=time(); $dts = strftime('%c',$t); // Format the string. if (array_key_exists('questionOptions',$question)) { // option set in question *************** *** 203,416 **** } $optval = stack_options_formvals_set($question_options); - - // Add all the metadata to the question ! // hidden metadata ! $html .= "\n<hr />\n ! <input type='hidden' name='questionID' value='".sf($question,'questionID')."' />\n ! <input type='hidden' name='questionGUID' value='".sf($question,'questionGUID')."' />\n ! <input type='hidden' name='questionDateLastEdited' value='$t' />\n ! <input type='hidden' name='questionUserLastEdited' value='".sf($question,'questionUserLastEdited')."' />\n ! <input type='hidden' name='questionPublisher' value='".sf($question,'questionPublisher')."' />\n ! <input type='hidden' name='type' value='".sf($question,'type')."' />\n ! <input type='hidden' name='questionFormat' value='".sf($question,'questionFormat')."' />\n ! ! <table cellboarder='0' cellpadding='2'> ! <tr> <td>".get_string('stackQuestion_questionName','stack','').":</td> ! <td><input type='input' name='questionName' value='".sf($question,'questionName')."' size='25' /> (ID: ".sf($question,'questionID').") </td> </tr> ! <tr> <td>".get_string('stackQuestion_questionDescription','stack','').":</td> ! <td><input type='input' name='questionDescription' value='".sf($question,'questionDescription')."' size='60' /></tr> ! <tr> <td>".get_string('stackQuestion_questionKeywords','stack','').":</td> ! <td><input type='input' name='questionKeywords' value='".sf($question,'questionKeywords')."' size='60' /></tr> ! ! </table> "; ! ! // HACK: the field type in the database does not ! // allow these to be edited yet. ! // <tr> <td> Last edited by: </td> ! // <td> <input type='input' name='questionUserLastEdited' value='".stack_s($question['questionUserLastEdited'])."' size='40' /> on $dts.</td> ! // </tr> ! ! $html .= "\n<hr />\n"; ! ! // Buttons to go somewhere next ! if ($stack_stand_alone) { ! $html .= "<a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; ! if (''==$errors) { ! $html .= "<a href=\"javascript:EditQ('preview')\">Try question</a> \n"; ! $html .= "<a href=\"javascript:EditQ('export_xml')\">Export as XML</a> \n"; ! if ('admin'==$user['username']) { ! $html .= "<a href=\"javascript:EditQ('save')\">Store question</a>\n ! <a href=\"javascript:EditQ('save_as')\">Store as a new question </a>\n"; ! } ! } ! $html .= "</p>"; ! } ! ! // Add the meat of the question. ! $qfield='questionVarsRaw'; ! $html .= "<b>".stack_question_edit_dispquestionfield($qfield)."</b><br />"; ! ! // Replace all \n's with ;'s ! if (array_key_exists($qfield,$question)) { ! $strout = str_replace(";","\n",$question[$qfield]); ! } else { $strout = ''; } ! stack_question_edit_form_field($qfield,$strout,$errors); ! $html .= "\n\n<br />\n"; ! ! $qfield='questionStem'; ! $html .= "<b>".stack_question_edit_dispquestionfield($qfield)."</b><br />"; ! @stack_question_edit_form_field($qfield,$question[$qfield],$errors); ! ! $html .= "<p><table align=top><tr align=top>\n"; ! if (array_key_exists('questionPotResp',$question)) { ! $html .= " <td><b>".stack_question_edit_dispquestionfield('questionAns')."</b></td>\n"; ! $html .= "<td> </td></tr>\n\n<tr align=top>\n <td align=top>"; ! $qfield='questionAns'; ! @stack_question_edit_form_field($qfield,$question[$qfield],$errors); ! $html .= "</td>\n <td> </td></tr>"; ! } else { ! // The questionAns and associated fields ! ! $html .= " <td><b>".stack_question_edit_dispquestionfield('questionAns')."</b></td>\n"; ! $html .= " <td><b>".stack_question_edit_dispoptionfield('AnsTest')."</b></td>\n"; ! $html .= " <td><b>".stack_question_edit_dispoptionfield('AnsTestOpt')."</b></td>\n"; ! $html .= "</tr>\n\n<tr align=top>\n <td align=top>"; ! ! $qfield='questionAns'; ! @stack_question_edit_form_field($qfield,$question[$qfield],$errors); ! $html .= "</td>\n <td align=top>\n"; ! ! $opt = 'AnsTest'; ! $opt_name = "questionOptions[{$opt}]"; ! @stack_question_edit_option_form($opt_name,$opt,$optval[$opt]); ! $html .= "</td>\n <td align=top>\n"; ! ! $opt = 'AnsTestOpt'; ! $opt_name = "questionOptions[{$opt}]"; ! @stack_question_edit_option_form($opt_name,$opt,$optval[$opt],20); ! $html .= "</td>\n</tr>"; ! ! $html .= "<tr align=top><td></td> ! <td>({$stackOptions['AnsTest']['default']})</td> ! <td>{$stackOptions['AnsTestOpt']['default']}</td></tr>"; ! } ! ! $html .= "<tr align=top>\n"; ! $html .= " <td> <b>".stack_question_edit_dispoptionfield('QuVal')."</b></td>\n"; ! $html .= " <td> <b>".stack_question_edit_dispoptionfield('Penalty')."</b></td>\n"; ! $html .= "<td></td><td></td></tr>\n<tr>\n <td>"; ! ! $opt = 'QuVal'; ! $opt_name = "questionOptions[{$opt}]"; ! @stack_question_edit_option_form($opt_name,$opt,$optval[$opt]); ! $html .= " ({$stackOptions[$opt]['default']})</td>\n <td>\n"; ! ! $opt = 'Penalty'; ! $opt_name = "questionOptions[{$opt}]"; ! @stack_question_edit_option_form($opt_name,$opt,$optval[$opt]); ! $html .= " ({$stackOptions[$opt]['default']})</td>\n <td>\n"; ! ! $html .= "</table></p>\n\n"; ! ! // Potential responses ! $html .= "<br /><a href=\"javascript:EditQ('edit')\">Edit</a> and add \n"; ! $html .= '<input type="input" name="questionPotResp[add]" value="0" size="3" />'; ! $html .= " potential responses<a href=\"javascript:HelpPopup('all','author_potresp');\"><img align=\"middle\" border=\"0\" height=\"17\" width=\"17\" src=\"pics/help.gif\" /></a> (distractors etc).<br />"; ! ! if (array_key_exists('questionPotResp',$question)) { ! if (array_key_exists('0',$question['questionPotResp'])) { ! // Add the AnsKey field ! $qfield='questionAnsKey'; ! $html .= '<p><b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; ! @stack_question_edit_form_field($qfield,$question[$qfield],$errors); ! $html .= '</p>'; ! ! // Add the AnsVars field, isnce this may now be used. ! $qfield='questionAnsVarsRaw'; ! $html .= '<b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; ! $strout = ''; ! if (array_key_exists($qfield,$question)) { ! $strout = str_replace(";","\n",$question[$qfield]); ! } ! @stack_question_edit_form_field($qfield,$strout,$errors); ! $html .= "\n\n<br />\n"; ! ! $html .= '<p>'; ! $npr = count($question['questionPotResp']); ! foreach ($question['questionPotResp'] as $key => $potresp) { ! $potresp['order']=$key; ! @stack_question_edit_potresp($key,$potresp,$npr,$errors); ! } ! $html .= '</p>'; ! ! } // end questionPotResp ! } else { // This needs its default, non-empty value. ! $html .= "<input type='hidden' name='questionAnsKey' value='".stack_s($question['questionAnsKey'])."' />\n"; ! } ! ! $qfield='questionSol'; ! $html .= '<b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; ! @stack_question_edit_form_field($qfield,$question[$qfield],$errors); ! $html .= "\n\n<br />\n"; ! ! $qfield='questionNote'; ! $html .= '<b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; ! @stack_question_edit_form_field($qfield,$question[$qfield],$errors); ! $html .= "\n\n<br />\n"; ! ! // Buttons to go somewhere next ! if ($stack_stand_alone) { ! $html .= "<p><a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; ! if (''==$errors) { ! $html .= "<a href=\"javascript:EditQ('preview')\">Try question</a> \n"; ! $html .= "<a href=\"javascript:EditQ('export_xml')\">Export as XML</a> \n"; ! if ('admin'==$user['username']) { ! $html .= "<a href=\"javascript:EditQ('save')\">Store question</a>\n ! <a href=\"javascript:EditQ('save_as')\">Store as a new question</a>\n"; ! } ! } ! $html .= "</p>"; ! } ! ! $options_headings = array(get_string('stackOptions_edit_inmeth','stack'),'','','',get_string('stackOptions_edit_resppro','stack'),'','','','','',get_string('stackOptions_edit_out','stack')); ! $options_list = array('InsertStars','InformalSyntax','AllowInputTool','SyntaxHint','Forbid','Allow','MarkModMethod','FeedBackGenericCorrect','FeedBackGenericPCorrect','FeedBackGenericIncorrect','Display'); ! ! stack_options_edit_form($options_headings,$options_list,$optval,'questionOptions'); ! ! $html .= "\n<hr />\n"; ! ! //List of metadata to display ! $metadata_list = array('questionLanguage','questionLearningContext','questionDifficulty','questionCompetency', ! 'questionCompetencyLevel','questionTimeAllocated','questionExcerciseType','questionRights'); ! stack_question_metadata_edit_form($question,$metadata_list); //Create all metadata fields on question form ! ! $html .= "\n<hr />\n"; ! ! return $html; ! } // end of edit_form_table ! ! /** ! * Build the substance of the form to edit a STACK question. ! * This needs to be wrapped in a <form> </form> structure. ! * ! * @param array $question The STACK question ! * @param array &$errors Repository for errors ! * @return void ! */ ! function stack_question_edit_form_substance($question,&$errors) { ! global $stack_stand_alone,$stackQuestion,$stackOptions,$debug,$user; ! ! $t=time(); ! $dts = strftime('%c',$t); // Format the string. ! ! if (array_key_exists('questionOptions',$question)) { // option set in question ! $question_options = $question['questionOptions']; ! } else { ! $question_options = array(); ! } ! $optval = stack_options_formvals_set($question_options); ! ! // Add all the metadata to the question // hidden metadata --- 189,195 ---- } $optval = stack_options_formvals_set($question_options); ! //For use by RQP - buffer these echo's ! ob_start(); // hidden metadata *************** *** 443,447 **** // Buttons to go somewhere next ! if ($stack_stand_alone) { echo "<a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { --- 222,226 ---- // Buttons to go somewhere next ! if (!$remoteCaller) { echo "<a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { *************** *** 458,462 **** // Add the meat of the question. $qfield='questionVarsRaw'; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b><br />"; // Replace all \n's with ;'s --- 237,241 ---- // Add the meat of the question. $qfield='questionVarsRaw'; ! echo "<b>".stack_question_edit_dispquestionfield($qfield,$remoteCaller)."</b><br />"; // Replace all \n's with ;'s *************** *** 468,477 **** $qfield='questionStem'; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b><br />"; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo "<p><table align=top><tr align=top>\n"; if (array_key_exists('questionPotResp',$question)) { ! echo " <td><b>".stack_question_edit_dispquestionfield('questionAns')."</b></td>\n"; echo "<td> </td></tr>\n\n<tr align=top>\n <td align=top>"; $qfield='questionAns'; --- 247,256 ---- $qfield='questionStem'; ! echo "<b>".stack_question_edit_dispquestionfield($qfield,$remoteCaller)."</b><br />"; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo "<p><table align=top><tr align=top>\n"; if (array_key_exists('questionPotResp',$question)) { ! echo " <td><b>".stack_question_edit_dispquestionfield('questionAns',$remoteCaller)."</b></td>\n"; echo "<td> </td></tr>\n\n<tr align=top>\n <td align=top>"; $qfield='questionAns'; *************** *** 481,487 **** // The questionAns and associated fields ! echo " <td><b>".stack_question_edit_dispquestionfield('questionAns')."</b></td>\n"; ! echo " <td><b>".stack_question_edit_dispoptionfield('AnsTest')."</b></td>\n"; ! echo " <td><b>".stack_question_edit_dispoptionfield('AnsTestOpt')."</b></td>\n"; echo "</tr>\n\n<tr align=top>\n <td align=top>"; --- 260,266 ---- // The questionAns and associated fields ! echo " <td><b>".stack_question_edit_dispquestionfield('questionAns',$remoteCaller)."</b></td>\n"; ! echo " <td><b>".stack_question_edit_dispoptionfield('AnsTest',$remoteCaller)."</b></td>\n"; ! echo " <td><b>".stack_question_edit_dispoptionfield('AnsTestOpt',$remoteCaller)."</b></td>\n"; echo "</tr>\n\n<tr align=top>\n <td align=top>"; *************** *** 506,511 **** echo "<tr align=top>\n"; ! echo " <td> <b>".stack_question_edit_dispoptionfield('QuVal')."</b></td>\n"; ! echo " <td> <b>".stack_question_edit_dispoptionfield('Penalty')."</b></td>\n"; echo "<td></td><td></td></tr>\n<tr>\n <td>"; --- 285,290 ---- echo "<tr align=top>\n"; ! echo " <td> <b>".stack_question_edit_dispoptionfield('QuVal',$remoteCaller)."</b></td>\n"; ! echo " <td> <b>".stack_question_edit_dispoptionfield('Penalty',$remoteCaller)."</b></td>\n"; echo "<td></td><td></td></tr>\n<tr>\n <td>"; *************** *** 531,535 **** // Add the AnsKey field $qfield='questionAnsKey'; ! echo '<p><b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo '</p>'; --- 310,314 ---- // Add the AnsKey field $qfield='questionAnsKey'; ! echo '<p><b>'.stack_question_edit_dispquestionfield($qfield,$remoteCaller).'</b><br />'; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo '</p>'; *************** *** 537,541 **** // Add the AnsVars field, isnce this may now be used. $qfield='questionAnsVarsRaw'; ! echo '<b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; $strout = ''; if (array_key_exists($qfield,$question)) { --- 316,320 ---- // Add the AnsVars field, isnce this may now be used. $qfield='questionAnsVarsRaw'; ! echo '<b>'.stack_question_edit_dispquestionfield($qfield,$remoteCaller).'</b><br />'; $strout = ''; if (array_key_exists($qfield,$question)) { *************** *** 559,573 **** $qfield='questionSol'; ! echo '<b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo "\n\n<br />\n"; $qfield='questionNote'; ! echo '<b>'.stack_question_edit_dispquestionfield($qfield).'</b><br />'; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo "\n\n<br />\n"; // Buttons to go somewhere next ! if ($stack_stand_alone) { echo "<p><a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { --- 338,352 ---- $qfield='questionSol'; ! echo '<b>'.stack_question_edit_dispquestionfield($qfield,$remoteCaller).'</b><br />'; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo "\n\n<br />\n"; $qfield='questionNote'; ! echo '<b>'.stack_question_edit_dispquestionfield($qfield,$remoteCaller).'</b><br />'; @stack_question_edit_form_field($qfield,$question[$qfield],$errors); echo "\n\n<br />\n"; // Buttons to go somewhere next ! if (!$remoteCaller) { echo "<p><a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { *************** *** 585,589 **** $options_list = array('InsertStars','InformalSyntax','AllowInputTool','SyntaxHint','Forbid','Allow','MarkModMethod','FeedBackGenericCorrect','FeedBackGenericPCorrect','FeedBackGenericIncorrect','Display'); ! stack_options_edit_form($options_headings,$options_list,$optval,'questionOptions'); echo "\n<hr />\n"; --- 364,368 ---- $options_list = array('InsertStars','InformalSyntax','AllowInputTool','SyntaxHint','Forbid','Allow','MarkModMethod','FeedBackGenericCorrect','FeedBackGenericPCorrect','FeedBackGenericIncorrect','Display'); ! stack_options_edit_form($options_headings,$options_list,$optval,'questionOptions',$remoteCaller); echo "\n<hr />\n"; *************** *** 592,598 **** $metadata_list = array('questionLanguage','questionLearningContext','questionDifficulty','questionCompetency', 'questionCompetencyLevel','questionTimeAllocated','questionExcerciseType','questionRights'); ! stack_question_metadata_edit_form($question,$metadata_list); //Create all metadata fields on question form echo "\n<hr />\n"; } // end of edit_form_table --- 371,390 ---- $metadata_list = array('questionLanguage','questionLearningContext','questionDifficulty','questionCompetency', 'questionCompetencyLevel','questionTimeAllocated','questionExcerciseType','questionRights'); ! stack_question_metadata_edit_form($question,$metadata_list,$remoteCaller); //Create all metadata fields on question form echo "\n<hr />\n"; + + $html = ob_get_contents(); + + if (!$remoteCaller) { + ob_end_flush(); + } + + //Do not ask server to display options, waste of processor power + else { + ob_end_clean(); + } + + return $html; } // end of edit_form_table *************** *** 649,664 **** /** ! * Display the name of a questionField, in a link generating a popup window. * * @param string $field The field name * @return string The link to the popup window */ ! function stack_question_edit_dispquestionfield($field) { global $stackQuestion; $fd='stackQuestion_'.$field; $fd=get_string($fd,'stack',''); ! $strout = "<a border=\"none\" href=\"javascript:HelpPopup('$field','stackQuestion');\"><img align=\"middle\" border=\"0\" alt=\"$fd\" src=\"pics/help.gif\" /></a> $fd"; ! return($strout); } --- 441,467 ---- /** ! * Display the name of a questionField. Behaviour depends on whether remoteCaller is set ! * If remoteCaller=false, generate help for field with popup link ! * If remoteCaller=true, generate just the question string * * @param string $field The field name * @return string The link to the popup window */ ! function stack_question_edit_dispquestionfield($field,$remoteCaller=false) { global $stackQuestion; $fd='stackQuestion_'.$field; $fd=get_string($fd,'stack',''); ! ! if(!$remoteCaller) ! { ! $strout = "<a border=\"none\" href=\"javascript:HelpPopup('$field','stackQuestion');\"><img align=\"middle\" border=\"0\" alt=\"$fd\" src=\"pics/help.gif\" /></a> $fd"; ! return($strout); ! } ! ! else ! { ! return($fd); ! } } *************** *** 1198,1202 **** * @return void */ ! function stack_question_metadata_edit_form($question,$metadata_list) { global $stackQuestion; --- 1001,1005 ---- * @return void */ ! function stack_question_metadata_edit_form($question,$metadata_list,$remoteCaller=FALSE) { global $stackQuestion; *************** *** 1210,1214 **** //Iterate through each field given in $metadata_list foreach( $metadata_list as $k => $metadata) { ! $descript = stack_question_edit_dispquestionfield($metadata); //Display tag with help $fieldname= $metadata; --- 1013,1017 ---- //Iterate through each field given in $metadata_list foreach( $metadata_list as $k => $metadata) { ! $descript = stack_question_edit_dispquestionfield($metadata,$remoteCaller); //Display tag with help $fieldname= $metadata; Index: stackXML.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackXML.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** stackXML.php 29 Aug 2005 19:08:04 -0000 1.16 --- stackXML.php 30 Aug 2005 10:28:01 -0000 1.17 *************** *** 1743,1746 **** --- 1743,1837 ---- $schemaSequence->appendChild($schemaField); + + if (!empty($optionField['type'])) + { + switch($optionField['type']) + { + case('list'): + { + //List type takes the lower case of the field + if (!empty($optionField['minoccurs']) && (!empty($optionField['maxoccurs']))) + { + $schemaField = &stack_xml_create_schema_field($arrayKey, FALSE, strtolower($arrayKey), + $optionField['minoccurs'], $optionField['maxocurrs']); + } + + else + { + $schemaField = &stack_xml_create_schema_field($arrayKey, FALSE, strtolower($arrayKey)); + } + + //<TODO>If of list type we should also output the list of possible values into the schema root + $schemaSimpleType = &stack_xml_create_schema_vocabulary(strtolower($arrayKey),$optionField['values']); + + $schemaElem->appendChild($schemaSimpleType); + + break; + } + + case('number'): + { + //Output of type xs:float + if (!empty($optionField['minoccurs']) && (!empty($optionField['maxoccurs']))) + { + $schemaField = &stack_xml_create_schema_field($arrayKey, TRUE, 'FLOAT', + $optionField['minoccurs'], $optionField['maxocurrs']); + } + + else + { + $schemaField = &stack_xml_create_schema_field($arrayKey, TRUE, 'FLOAT'); + } + + break; + } + + case('html' || 'string' ): + { + //Output type xs:string + if (!empty($optionField['minoccurs']) && (!empty($optionField['maxoccurs']))) + { + $schemaField = &stack_xml_create_schema_field($arrayKey, TRUE, 'TEXT', + $optionField['minoccurs'], $optionField['maxocurrs']); + } + + else + { + $schemaField = &stack_xml_create_schema_field($arrayKey, TRUE, 'TEXT'); + } + + break; + } + + default: + { + if (!empty($optionField['minoccurs']) && (!empty($optionField['maxoccurs']))) + { + $schemaField = &stack_xml_create_schema_field($arrayKey, TRUE, 'TEXT', + $optionField['minoccurs'], $optionField['maxocurrs']); + } + + else + { + $schemaField = &stack_xml_create_schema_field($arrayKey, TRUE, 'TEXT'); + } + + break; + } + } + + //Now add any documentation to the field + if (!empty($optionField['doc'])) + { + stack_xml_create_field_documentation($schemaField,$optionField['doc']); + } + } + + else + { + echo("<b>Developer notice:</b>The field $optionField does not have a type associated with it and will not be written out<br>"); + } + + $schemaSequence->appendChild($schemaField); } Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** stackQuestion.php 25 Aug 2005 16:15:07 -0000 1.32 --- stackQuestion.php 30 Aug 2005 10:28:01 -0000 1.33 *************** *** 2161,2163 **** --- 2161,2198 ---- } + /** + * Creates a new question with the mimimum fields + * + * @param void + * @return array $question Question with the mimimum fields + */ + function stack_question_new($remoteUser='') + { + global $user, $stack_web_url; + + $question=''; + + $question['questionID'] = '0'; + $question['questionAnsKey'] = 'ans1'; + $question['questionGUID'] = stack_generate_guid($stack_web_url); + $question['questionFormat'] = 'text/xml; charset="utf-8"'; + $question['questionPublisher'] = $stack_web_url; + $question['type'] = 'question'; + + if (empty($remoteUser)) { + $question['questionUserLastEdited'] = $user['firstname']." ".$user['lastname']; + + if ($user['email']!='') { //<TODO: need to somehow retrieve the RQP user who is making new question + $question['questionUserLastEdited'].=' <'.$user['email'].'>'; + } + } + + else + { + $question['questionUserLastEdited'] = $remoteUser; + } + + return $question; + } + ?> |