From: Chris S. <san...@us...> - 2005-08-16 09:45:13
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv433/scripts Modified Files: Tag: development_xmlrqp stackAuthor.php stackQuestion.php Log Message: Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.29.2.3 retrieving revision 1.29.2.4 diff -C2 -d -r1.29.2.3 -r1.29.2.4 *** stackAuthor.php 12 Aug 2005 17:16:47 -0000 1.29.2.3 --- stackAuthor.php 16 Aug 2005 09:45:04 -0000 1.29.2.4 *************** *** 104,107 **** --- 104,130 ---- + /** + * Build an array which contains either the values of the options, or the + * string "default" + * + * @param array $options The options array + * @return array $optval The array to be displayed. + */ + function stack_options_formvals_set($options) { + global $stackOptions; + + // Sort out the values of the options. + foreach ($stackOptions as $opt => $fields) { + $optval[$opt] = 'default'; + // Sort out if a value has been set explicitly in the question. + if (array_key_exists($opt,$options)) { + $optval[$opt] = $options[$opt]; + } + } + + return $optval; + } + + //****************************************************** //** Edit question *************** *** 152,171 **** $dts = strftime('%c',$t); // Format the string. ! // Sort out the values of the options. ! foreach ($stackOptions as $opt => $fields) { ! $optval[$opt] = ''; ! // Sort out if a value has been set explicitly in the question. ! if (array_key_exists('questionOptions',$question)) { // option set in question ! if (is_array($question['questionOptions'])) { ! if (array_key_exists($opt,$question['questionOptions'])) { ! $optval[$opt] = $question['questionOptions'][$opt]; ! } ! } ! } ! // In every other case.... ! if (''==$optval[$opt]) { ! $optval[$opt] = 'default'; ! } } // Add all the metadata to the question. --- 175,184 ---- $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. *************** *** 176,183 **** <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='questionType' value='".sf($question,'questionType')."' />\n ! <input type='hidden' name='questionFormat' value='".sf($question,'questionFormat')."' />\n ! <table cellboarder='0' cellpadding='2'> <tr> <td>".get_string('stackQuestion_questionName','stack','').":</td> --- 189,196 ---- <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='questionType' value='".sf($question,'questionType')."' />\n ! <input type='hidden' name='questionFormat' value='".sf($question,'questionFormat')."' />\n ! <table cellboarder='0' cellpadding='2'> <tr> <td>".get_string('stackQuestion_questionName','stack','').":</td> *************** *** 187,193 **** <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. --- 200,206 ---- <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. *************** *** 348,353 **** $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"; --- 361,366 ---- $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"; *************** *** 678,690 **** //<PDK> Hidden metadata echo "<input type='hidden' name='quizDateLastEdited' value='$t' />\n ! <input type='hidden' name='quizPublisher' value='".sf($quiz,'quizPublisher')."' />\n ! <input type='hidden' name='type' value='".sf($quiz,'type')."' />\n ! <input type='hidden' name='quizFormat' value='".sf($quiz,'quizFormat')."' />\n"; // Edit the quiz - dont iterate through metadata tags! echo "\n<table>\n"; foreach ($stackQuiz as $key => $fields) { ! //Check that within current field there is no type tag, otherwise skip ! if (empty($fields['type'])){ $err = ''; echo "<tr><td><b>{$fields['descript']}</b></td>\n"; --- 691,703 ---- //<PDK> Hidden metadata echo "<input type='hidden' name='quizDateLastEdited' value='$t' />\n ! <input type='hidden' name='quizPublisher' value='".sf($quiz,'quizPublisher')."' />\n ! <input type='hidden' name='type' value='".sf($quiz,'type')."' />\n ! <input type='hidden' name='quizFormat' value='".sf($quiz,'quizFormat')."' />\n"; // Edit the quiz - dont iterate through metadata tags! echo "\n<table>\n"; foreach ($stackQuiz as $key => $fields) { ! //Check that within current field there is no type tag, otherwise skip ! if (empty($fields['type'])){ $err = ''; echo "<tr><td><b>{$fields['descript']}</b></td>\n"; *************** *** 750,754 **** stack_options_edit_form($options_headings,$options_list,$quiz_options,$fieldname); ! //Check if quiz has metadata set // $fieldname = 'quiz' --- 763,767 ---- stack_options_edit_form($options_headings,$options_list,$quiz_options,$fieldname); ! //Check if quiz has metadata set // $fieldname = 'quiz' *************** *** 912,919 **** //Must be of type meta if ('meta'==$fields['type']) { ! if (is_array( $fields['values'])) { //Check that there is an array (list type) in the values tag ! echo "\n<select name=\"$name\">\n"; if ('default'==$optval){echo " <option value='default' selected>default</option>\n";} ! else {echo " <option value='default'>default</option>\n";} foreach ($fields['values'] as $vals) { --- 925,932 ---- //Must be of type meta if ('meta'==$fields['type']) { ! if (is_array( $fields['values'])) { //Check that there is an array (list type) in the values tag ! echo "\n<select name=\"$name\">\n"; if ('default'==$optval){echo " <option value='default' selected>default</option>\n";} ! else {echo " <option value='default'>default</option>\n";} foreach ($fields['values'] as $vals) { *************** *** 923,931 **** echo " </select>\n"; ! } ! ! else { ! echo "<input type='text' name='$name' value ='".stack_s($optval)."' size = '$sz' />"; ! } } } --- 936,944 ---- echo " </select>\n"; ! } ! ! else { ! echo "<input type='text' name='$name' value ='".stack_s($optval)."' size = '$sz' />"; ! } } } *************** *** 939,968 **** */ function stack_question_metadata_edit_form($question,$metadata_list) ! { global $stackQuestion; ! //Create table to put metadata on ! echo "<table cellpadding='4'><tr> <td> <b>".get_string('stackQuestion_questionMetadata','stack')."</b> </td> <td> <b>".get_string('stackOptions_edit_value','stack')."</b> </td> <td> <b>".get_string('stackOptions_edit_default','stack')."</b> </td></tr>"; ! ! //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; echo " <td> $descript </td>\n <td>"; ! @stack_question_edit_metadata_field($fieldname,$metadata,$question[$metadata]); //Display correct UI component for field echo "</td>\n"; ! ! $defval = $stackQuestion[$metadata]['default']; //Retrieve the metadata's default value ! ! echo " <td> $defval </td>\n</tr>\n"; } ! ! //print_r($question); ! echo "\n</table>\n\n\n"; } --- 952,981 ---- */ function stack_question_metadata_edit_form($question,$metadata_list) ! { global $stackQuestion; ! //Create table to put metadata on ! echo "<table cellpadding='4'><tr> <td> <b>".get_string('stackQuestion_questionMetadata','stack')."</b> </td> <td> <b>".get_string('stackOptions_edit_value','stack')."</b> </td> <td> <b>".get_string('stackOptions_edit_default','stack')."</b> </td></tr>"; ! ! //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; echo " <td> $descript </td>\n <td>"; ! @stack_question_edit_metadata_field($fieldname,$metadata,$question[$metadata]); //Display correct UI component for field echo "</td>\n"; ! ! $defval = $stackQuestion[$metadata]['default']; //Retrieve the metadata's default value ! ! echo " <td> $defval </td>\n</tr>\n"; } ! ! //print_r($question); ! echo "\n</table>\n\n\n"; } *************** *** 986,993 **** //Must be of type meta if ('meta'==$fields['type']) { ! if (is_array( $fields['values'])) { //Check that there is an array (list type) in the values tag ! echo "\n<select name=\"$name\">\n"; if ('default'==$optval){echo " <option value='default' selected>default</option>\n";} ! else {echo " <option value='default'>default</option>\n";} foreach ($fields['values'] as $vals) { --- 999,1006 ---- //Must be of type meta if ('meta'==$fields['type']) { ! if (is_array( $fields['values'])) { //Check that there is an array (list type) in the values tag ! echo "\n<select name=\"$name\">\n"; if ('default'==$optval){echo " <option value='default' selected>default</option>\n";} ! else {echo " <option value='default'>default</option>\n";} foreach ($fields['values'] as $vals) { *************** *** 997,1005 **** echo " </select>\n"; ! } ! ! else { ! echo "<input type='text' name='$name' value ='".stack_s($optval)."' size = '$sz' />"; ! } //$fields = $stackQuiz[$opt]; } } --- 1010,1018 ---- echo " </select>\n"; ! } ! ! else { ! echo "<input type='text' name='$name' value ='".stack_s($optval)."' size = '$sz' />"; ! } //$fields = $stackQuiz[$opt]; } } *************** *** 1021,1040 **** <td> <b>".get_string('stackOptions_edit_value','stack')."</b> </td> <td> <b>".get_string('stackOptions_edit_default','stack')."</b> </td></tr>"; ! ! //Iterate through each field given in $metadata_list ! foreach( $metadata_list as $k => $metadata) { ! $descript = stack_quiz_edit_dispquizfield($metadata); //Display tag with help $fieldname= 'quiz'.'['.$metadata.']'; echo " <td> $descript </td>\n <td>"; ! @stack_quiz_edit_metadata_field($fieldname,$metadata,$quiz[$metadata]); //Display correct UI component for field echo "</td>\n"; ! ! $defval = $stackQuiz[$metadata]['default']; //Retrieve the metadata's default value ! ! echo " <td> $defval </td>\n</tr>\n"; } ! echo "\n</table>\n\n\n"; } --- 1034,1053 ---- <td> <b>".get_string('stackOptions_edit_value','stack')."</b> </td> <td> <b>".get_string('stackOptions_edit_default','stack')."</b> </td></tr>"; ! ! //Iterate through each field given in $metadata_list ! foreach( $metadata_list as $k => $metadata) { ! $descript = stack_quiz_edit_dispquizfield($metadata); //Display tag with help $fieldname= 'quiz'.'['.$metadata.']'; echo " <td> $descript </td>\n <td>"; ! @stack_quiz_edit_metadata_field($fieldname,$metadata,$quiz[$metadata]); //Display correct UI component for field echo "</td>\n"; ! ! $defval = $stackQuiz[$metadata]['default']; //Retrieve the metadata's default value ! ! echo " <td> $defval </td>\n</tr>\n"; } ! echo "\n</table>\n\n\n"; } Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.30.2.5 retrieving revision 1.30.2.6 diff -C2 -d -r1.30.2.5 -r1.30.2.6 *** stackQuestion.php 12 Aug 2005 17:16:47 -0000 1.30.2.5 --- stackQuestion.php 16 Aug 2005 09:45:04 -0000 1.30.2.6 *************** *** 1,867 **** <?php - - /** - * This file contains most functions which deal with questions. These are the - * everyday functions used by students, and it is rare indeed that this file is not - [...4860 lines suppressed...] - if (is_array($seeds)) { - $seed = end($seeds); - } - - return($seed); - - } - - ?> - --- 1021,2161 ---- |