From: pkiddie <pk...@us...> - 2005-07-28 13:49:44
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21577/scripts Modified Files: Tag: development_xmlrqp stackAuthor.php stackQuestion.php Log Message: Clear conflicts and cosmetic changes to stackAuthor Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.29 retrieving revision 1.29.2.1 diff -C2 -d -r1.29 -r1.29.2.1 *** stackAuthor.php 25 Jul 2005 14:11:25 -0000 1.29 --- stackAuthor.php 28 Jul 2005 13:49:33 -0000 1.29.2.1 *************** *** 60,98 **** } - //<PDK> Added new function for stackQuestion fields - /** - * Generates the portion of the HTML question edit form for editing metadata of with an array of fields - * - * Checks that specified field is of type meta and that an array of values is present. If so, draw a list - * box with all the fields. As these fields contain optional data - they default to 'unspecified' - * - * @param string $name The name of the field in the form - * @param string $opt The option key - * @param mixed $optval The currently set value - * @param int $sz The size of the answer boxes - * @return void - */ - //$qfield,$question[$qfield],$errors, qfield = questionLanguage - function stack_question_edit_metadata_form($name,$opt,$optval,$sz=8) { - global $stackQuestion; - - $fields = $stackQuestion[$opt]; - //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) { - if ($vals==$optval) {echo " <option value='$vals' selected>$vals</option>\n";} - else {echo " <option value='$vals'>$vals</option>\n";} - } - - echo " </select>\n"; - } - } - } - /** * Build the form to edit a list of STACK options. --- 60,63 ---- *************** *** 102,118 **** * @param array $options Their current values * @param string $fieldname The name of the field in the form - * @param boolean $fragment Is this a fragment, or a complete table? * @return void */ ! function stack_options_edit_form($options_headings,$options_list,$options,$fieldname,$fragment=TRUE) { global $stackOptions; ! if ($fragment) { ! echo "<table cellpadding='4'><tr> ! <td> <b>".get_string('stackQuestion_questionOptions','stack')."</b> </td> ! <td> <b>".get_string('stackOptions_edit_value','stack')."</b> </td> ! <td> <b>".get_string('stackOptions_edit_default','stack')."</b> </td></tr>"; ! } ! foreach( $options_list as $k => $opt) { $descript = stack_question_edit_dispoptionfield($opt); --- 67,80 ---- * @param array $options Their current values * @param string $fieldname The name of the field in the form * @return void */ ! function stack_options_edit_form($options_headings,$options_list,$options,$fieldname) { global $stackOptions; ! echo "<table cellpadding='4'><tr> ! <td> <b>".get_string('stackQuestion_questionOptions','stack')."</b> </td> ! <td> <b>".get_string('stackOptions_edit_value','stack')."</b> </td> ! <td> <b>".get_string('stackOptions_edit_default','stack')."</b> </td></tr>"; ! foreach( $options_list as $k => $opt) { $descript = stack_question_edit_dispoptionfield($opt); *************** *** 121,125 **** echo "\n<tr>\n"; if ('' != $category) { ! echo " <td> <strong>$category</strong> </td>\n</tr>\n</tr>\n"; } --- 83,87 ---- echo "\n<tr>\n"; if ('' != $category) { ! echo " <td> <strong>$category</strong> </td>\n</tr>\n</tr>\n"; } *************** *** 138,144 **** } ! if ($fragment) { ! echo "\n</table>\n\n\n"; ! } } --- 100,104 ---- } ! echo "\n</table>\n\n\n"; } *************** *** 187,190 **** --- 147,152 ---- global $stack_stand_alone,$stackQuestion,$stackOptions,$debug,$user; + show_array($question); + //<PDK> Now datetime $t=time(); $dts = strftime('%c',$t); // Format the string. *************** *** 214,221 **** <input type='hidden' name='questionGUID' value='".sf($question,'questionGUID')."' />\n <input type='hidden' name='questionDateLastEdited' value='$t' />\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> --- 176,183 ---- <input type='hidden' name='questionGUID' value='".sf($question,'questionGUID')."' />\n <input type='hidden' name='questionDateLastEdited' value='$t' />\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> *************** *** 225,231 **** <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. --- 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. *************** *** 382,447 **** echo "\n<hr />\n"; ! ! //<PDK> Insert user definable metadata here ! $qfield='questionLanguage'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! @stack_question_edit_metadata_form($qfield_name,$qfield,$errors); ! ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! ! $qfield='questionLearningContext'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! @stack_question_edit_metadata_form($qfield_name,$qfield,$errors); ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! ! ! $qfield='questionDifficulty'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! @stack_question_edit_metadata_form($qfield_name,$qfield,$errors); ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! $qfield='questionCompetency'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! @stack_question_edit_metadata_form($qfield_name,$qfield,$errors); ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! $qfield='questionCompetencyLevel'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! @stack_question_edit_metadata_form($qfield_name,$qfield,$errors); ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! $qfield='questionExcerciseType'; ! $qfield_name = "question[{$qfield}]"; ! echo "<br /><b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! @stack_question_edit_metadata_form($qfield_name,$qfield,$errors); ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! $qfield='questionTimeAllocated'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! echo "<input type='input' name='questionTimeAllocated' value='".sf($question,'questionTimeAllocated')."' size='20' />"; ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! ! $qfield='questionRights'; ! $qfield_name = "question[{$qfield}]"; ! echo "<b>".stack_question_edit_dispquestionfield($qfield)."</b>"; ! echo "<input type='input' name='questionRights' value='".sf($question,'questionRights')."' size='20' />"; ! echo"({$stackQuestion[$qfield]['default']})";//</tr>"; ! echo "<br />"; ! echo "\n<hr />\n"; --- 344,353 ---- echo "\n<hr />\n"; ! ! //List of metadata tags ! $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"; *************** *** 763,782 **** } // Timestamp this edit echo "<form name='stackquizeditform' action='$PostTo' method='POST'>\n"; ! // Edit the quiz echo "\n<table>\n"; foreach ($stackQuiz as $key => $fields) { ! $err = ''; ! echo "<tr><td><b>{$fields['descript']}</b></td>\n"; ! if ('quizid' == $key) { ! echo "<td><input type=\"hidden\" name=\"quiz[$key]\" value=\"{$quiz[$key]}\" alt=\"$key\" />{$quiz[$key]}</td><td>".$err.'</td></tr>'; ! } else if ('quizOptions' == $key){ ! echo '</tr>'; ! } else { ! echo "<td><input type=\"text\" name=\"quiz[$key]\" size=\"35\" value=\"".nsf($quiz,$key)."\" alt=\"$key\" /></td><td>".$err.'</td></tr>'; } } echo "\n</table>\n"; --- 669,702 ---- } + //<PDK> Now datetime + $t=time(); + $dts = strftime('%c',$t); // Format the string. + // Timestamp this edit echo "<form name='stackquizeditform' action='$PostTo' method='POST'>\n"; + + //<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"; ! if ('quizid' == $key) { ! echo "<td><input type=\"hidden\" name=\"quiz[$key]\" value=\"{$quiz[$key]}\" alt=\"$key\" />{$quiz[$key]}</td><td>".$err.'</td></tr>'; ! } else if ('quizOptions' == $key){ ! echo '</tr>'; ! } else { ! echo "<td><input type=\"text\" name=\"quiz[$key]\" size=\"35\" value=\"".nsf($quiz,$key)."\" alt=\"$key\" /></td><td>".$err.'</td></tr>'; ! } } } + echo "\n</table>\n"; *************** *** 830,834 **** --- 750,761 ---- stack_options_edit_form($options_headings,$options_list,$quiz_options,$fieldname); + + //Check if quiz has metadata set + // $fieldname = 'quiz' + $metadata_list = array('quizLanguage','quizLearningContext','quizDifficulty','quizCompetency', + 'quizCompetencyLevel','quizTimeAllocated','quizExcerciseType','quizRights'); + stack_quiz_metadata_edit_form($quiz, $metadata_list); + // The end of the form! *************** *** 955,957 **** --- 882,1047 ---- } + //<PDK> Added new function for stackQuestion fields + /** + * Generates a portion of HTML which allows the editing of a particular metadata field. + * + * Checks that specified field is of type meta and that an array of values is present. If so, draw a list + * box with all the fields. As these fields contain optional data - they default to 'unspecified'. + * If an array of values is not present, we default to text box entry. + * + * @param string $name The name of the field in the form + * @param string $opt The option key + * @param mixed $optval The currently set value + * @param int $sz The size of the answer boxes + * @return void + */ + function stack_question_edit_metadata_field($name,$opt,$optval,$sz=8) { + global $stackQuestion; + + $fields = $stackQuestion[$opt]; + //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) { + if ($vals==$optval) {echo " <option value='$vals' selected>$vals</option>\n";} + else {echo " <option value='$vals'>$vals</option>\n";} + } + + echo " </select>\n"; + } + + else { + echo "<input type='text' name='$name' value ='".stack_s($optval)."' size = '$sz' />"; + } + } + } + + /** + * Construct the metadata part of the question edit form + * + * @param string $question The current question being edited + * @param array $metadata_list The list of question metadata to display + * @return void + */ + 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"; + } + + /** + * Generates a portion of HTML which allows the editing of a particular quiz metadata field. + * + * Checks that specified field is of type meta and that an array of values is present. If so, draw a list + * box with all the fields. As these fields contain optional data - they default to 'unspecified'. + * If an array of values is not present, we default to text box entry. + * + * @param string $name The name of the field in the form + * @param string $opt The option key + * @param mixed $optval The currently set value + * @param int $sz The size of the answer boxes + * @return void + */ + function stack_quiz_edit_metadata_field($name,$opt,$optval,$sz=8) { + global $stackQuiz; + + $fields = $stackQuiz[$opt]; + //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) { + if ($vals==$optval) {echo " <option value='$vals' selected>$vals</option>\n";} + else {echo " <option value='$vals'>$vals</option>\n";} + } + + echo " </select>\n"; + } + + else { + echo "<input type='text' name='$name' value ='".stack_s($optval)."' size = '$sz' />"; + } //$fields = $stackQuiz[$opt]; + } + } + + /** + * Constructs the metadata part of the quiz edit form + * + * @param string $question The current quiz being edited + * @param array $metadata_list The list of quiz metadata to display + * @return void + */ + function stack_quiz_metadata_edit_form($quiz, $metadata_list) + { + global $stackQuiz; + + //Create table to put quiz 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_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"; + } + + /** + * Display the name of a quizField, in a link generating a popup window. + * + * @param string $field The field name + * @return string The link to the popup window + */ + function stack_quiz_edit_dispquizfield($field) { + global $stackQuiz; + + $fd='stackQuiz_'.$field; + + $fd=get_string($fd,'stack',''); + $strout = "<a border=\"none\" href=\"javascript:HelpPopup('$field','stackQuiz');\"><img align=\"middle\" border=\"0\" alt=\"$fd\" src=\"pics/help.gif\" /></a> $fd"; + return($strout); + } + ?> Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.30 retrieving revision 1.30.2.1 diff -C2 -d -r1.30 -r1.30.2.1 *** stackQuestion.php 22 Jul 2005 12:47:40 -0000 1.30 --- stackQuestion.php 28 Jul 2005 13:49:33 -0000 1.30.2.1 *************** *** 251,260 **** $stackQuestion['questionUserLastEdited']['metatag']='Creator'; - // 'Last edited on'; - $stackQuestion['questionDateLastEdited']['type']='meta'; - $stackQuestion['questionDateLastEdited']['required']='system'; - $stackQuestion['questionDateLastEdited']['mysql']='TIMESTAMP'; - $stackQuestion['questionDateLastEdited']['metatag']='Date'; - //<PDK> Metadata added - database updated //Publisher --- 251,254 ---- *************** *** 350,353 **** --- 344,353 ---- $stackQuestion['questionExcerciseType']['default']='unspecified'; + // 'Last edited on' - Must be last field, representative of database + $stackQuestion['questionDateLastEdited']['type']='meta'; + $stackQuestion['questionDateLastEdited']['required']='system'; + $stackQuestion['questionDateLastEdited']['mysql']='TIMESTAMP'; + $stackQuestion['questionDateLastEdited']['metatag']='Date'; + //////////////////////////////////// // $stackQuestionInst |