From: pkiddie <pk...@us...> - 2005-08-17 16:48:56
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31977/scripts Modified Files: Tag: development_xmlrqp stackAuthor.php stackDatabase.php stackQuiz.php stackXML.php Log Message: Moved question validation for an exported file into stackXML Ensure all metadata is being written out into database for questions and quizzes Ensure all 'default' metadata is removed from XML when exported, but reinstated whe imported Index: stackQuiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuiz.php,v retrieving revision 1.5.2.5 retrieving revision 1.5.2.6 diff -C2 -d -r1.5.2.5 -r1.5.2.6 *** stackQuiz.php 17 Aug 2005 11:24:06 -0000 1.5.2.5 --- stackQuiz.php 17 Aug 2005 16:48:46 -0000 1.5.2.6 *************** *** 1,226 **** ! <?php ! ! /** ! * This file contains most functions which deal with quizzes. ! * ! * @package scripts ! * @subpackage Stack ! */ ! ! /** ! * ! */ ! // 'Unique quiz ID - local mySQL value' ! $stackQuiz['quizid']['descript'] = 'Quiz ID number'; ! $stackQuiz['quizid']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; ! $stackQuiz['quizid']['type'] = 'meta'; ! ! // 'Quiz name' ! $stackQuiz['quizName']['descript'] = 'Quiz name'; ! $stackQuiz['quizName']['mysql'] = 'TINYTEXT'; ! $stackQuiz['quizName']['type'] = 'meta'; ! $stackQuiz['quizName']['metatag'] = 'title'; //dc:title ! $stackQuiz['quizName']['metatype'] = 'dublincore'; ! ! // 'Quiz description' ! $stackQuiz['quizDescription']['descript'] = 'Description'; ! $stackQuiz['quizDescription']['mysql'] = 'TINYTEXT'; ! $stackQuiz['quizDescription']['type'] = 'meta'; ! $stackQuiz['quizDescription']['metatag'] = 'description'; //dc:description ! $stackQuiz['quizDescription']['metatype'] = 'dublincore'; ! ! // 'Quiz options' ! $stackQuiz['quizOptions']['descript'] = 'Quiz options'; ! $stackQuiz['quizOptions']['mysql'] = 'TEXT'; ! $stackQuiz['quizOptions']['type'] = 'other'; ! ! // 'Quiz due date' ! $stackQuiz['quizDueDate']['descript'] = 'Due date'; ! $stackQuiz['quizDueDate']['mysql'] = 'int(10)'; ! $stackQuiz['quizDueDate']['type'] = 'date'; ! ! // 'Quiz mode' ! $stackQuiz['quizMode']['descript'] = 'Mode'; ! $stackQuiz['quizMode']['mysql'] = 'TINYTEXT'; ! $stackQuiz['quizMode']['type'] = 'string'; ! ! //<PDK> Quiz Metadata added - database updated ! // 'Globally unique quiz ID'; ! $stackQuiz['quizGUID']['required'] = 'system'; ! $stackQuiz['quizGUID']['mysql'] = 'CHAR(22) UNIQUE KEY'; //GUID's are 32byte characters ! $stackQuiz['quizGUID']['type'] = 'meta'; ! $stackQuiz['quizGUID']['metatag'] = 'identifier'; ! $stackQuiz['quizGUID']['metatype'] = 'dublincore'; ! ! // 'Keywords'; ! $stackQuiz['quizKeywords']['required'] = 'optional'; ! $stackQuiz['quizKeywords']['mysql'] = 'TINYTEXT'; ! $stackQuiz['quizKeywords']['type'] = 'meta'; ! $stackQuiz['quizKeywords']['metatag'] = 'keyword'; //lom:keyword ! $stackQuiz['quizKeywords']['metatype'] = 'lom'; ! ! // 'Last edited by'; ! $stackQuiz['quizUserLastEdited']['required']='system'; ! $stackQuiz['quizUserLastEdited']['mysql']='INT UNSIGNED'; ! $stackQuiz['quizUserLastEdited']['type']='meta'; ! $stackQuiz['quizUserLastEdited']['metatag']='creator'; //dc:creator ! $stackQuiz['quizUserLastEdited']['metatype']='dublincore'; ! ! // 'Last edited on'; ! $stackQuiz['quizDateLastEdited']['required']='system'; ! $stackQuiz['quizDateLastEdited']['mysql']='TIMESTAMP'; ! $stackQuiz['quizDateLastEdited']['type']='meta'; ! $stackQuiz['quizDateLastEdited']['metatag']='date'; //dc:date ! $stackQuiz['quizDateLastEdited']['metatype']='dublincore'; ! ! //Publisher ! $stackQuiz['quizPublisher']['required']='system'; ! $stackQuiz['quizPublisher']['mysql']='TINYTEXT'; ! $stackQuiz['quizPublisher']['type']='meta'; ! $stackQuiz['quizPublisher']['metatag']='publisher'; //dc:publisher ! $stackQuiz['quizPublisher']['metatype']='dublincore'; ! ! //Type: Hidden from user ! $stackQuiz['type']['values']=array('quiz','quiz'); //Default to 'type' enumeration in XSD file ! $stackQuiz['type']['required']='optional'; ! $stackQuiz['type']['mysql']='TINYTEXT'; ! $stackQuiz['type']['type']='meta'; ! $stackQuiz['type']['metatag']='type'; //dc:type ! $stackQuiz['type']['metatype']='dublincore'; ! ! //Format: Hidden from user, selected by script ! $stackQuiz['quizFormat']['values']=array('application','audio','image', ! 'message','model','text','video', ! 'multipart'); ! $stackQuiz['quizFormat']['required']='optional'; ! $stackQuiz['quizFormat']['mysql']='TINYTEXT'; ! $stackQuiz['quizFormat']['type']='meta'; //dc:format ! $stackQuiz['quizFormat']['metatag']='format'; ! $stackQuiz['quizFormat']['metatype']='dublincore'; ! ! //Language: Defaulted to current system language, but user definable ! $stackQuiz['quizLanguage']['values']=array('en','fr','nl','es','unspecified'); ! $stackQuiz['quizLanguage']['required']='optional'; ! $stackQuiz['quizLanguage']['mysql']='TINYTEXT'; ! $stackQuiz['quizLanguage']['type']='meta'; ! $stackQuiz['quizLanguage']['metatag']='language'; //dc:language ! $stackQuiz['quizLanguage']['metatype']='dublincore'; ! $stackQuiz['quizLanguage']['default']=$stack_defaultlang; //take the default language; ! ! //Rights ! $stackQuiz['quizRights']['required']='optional'; ! $stackQuiz['quizRights']['mysql']='TEXT'; ! $stackQuiz['quizRights']['type']='meta'; ! $stackQuiz['quizRights']['metatag']='rights'; //dc:rights ! $stackQuiz['quizRights']['metatype']='dublincore'; ! $stackQuiz['quizRights']['default']='http://www.gnu.org/copyleft/gpl.html'; ! ! //Learning context: Defaulted to system context, but user definable ! $stackQuiz['quizLearningContext']['values']=array('Primary Education','Secondary Education','Higher Education', ! 'University First Cycle','University Second Cycle','University Post Grade', ! 'Technical School First Cycle','Technical School Second Cycle','Professional Formation', ! 'Continuous Formation','Vocational Training','unspecified'); ! $stackQuiz['quizLearningContext']['required']='optional'; ! $stackQuiz['quizLearningContext']['mysql']='TINYTEXT'; ! $stackQuiz['quizLearningContext']['type']='meta'; ! $stackQuiz['quizLearningContext']['metatag']='context'; //lom:context ! $stackQuiz['quizLearningContext']['metatype']='lom'; ! $stackQuiz['quizLearningContext']['default']='unspecified'; ! ! //Difficulty: Default to null - up to user to specify this ! $stackQuiz['quizDifficulty']['values']=array('Very Easy','Easy','Medium', ! 'Difficult','Very Difficult','unspecified'); ! $stackQuiz['quizDifficulty']['required']='optional'; ! $stackQuiz['quizDifficulty']['mysql']='TINYTEXT'; ! $stackQuiz['quizDifficulty']['type']='meta'; ! $stackQuiz['quizDifficulty']['metatag']='difficulty'; //lom:difficulty ! $stackQuiz['quizDifficulty']['metatype']='lom'; ! $stackQuiz['quizDifficulty']['default']='unspecified'; ! ! //Competency: Default to solve - then up to user ! $stackQuiz['quizCompetency']['values']=array('think','argue','solve', ! 'represent','language','communicate', ! 'tools','unspecified'); ! $stackQuiz['quizCompetency']['required']='optional'; ! $stackQuiz['quizCompetency']['mysql']='TINYTEXT'; ! $stackQuiz['quizCompetency']['type']='meta'; ! $stackQuiz['quizCompetency']['metatag']='competency'; ! $stackQuiz['quizCompetency']['metatype']='stack'; //competency ! $stackQuiz['quizCompetency']['default']='unspecified'; ! ! //CompetencyLevel: Default to null - then up to user ! $stackQuiz['quizCompetencyLevel']['values']=array('elementary','simpleConceptual','multiStep', ! 'complex','unspecified'); ! $stackQuiz['quizCompetencyLevel']['required']='optional'; ! $stackQuiz['quizCompetencyLevel']['mysql']='TINYTEXT'; ! $stackQuiz['quizCompetencyLevel']['type']='meta'; ! $stackQuiz['quizCompetencyLevel']['metatag']='competencylevel'; //competencylevel ! $stackQuiz['quizCompetencyLevel']['metatype']='stack'; ! $stackQuiz['quizCompetencyLevel']['default']='unspecified'; ! ! //Time to allocate: Default to null - then up to user ! $stackQuiz['quizTimeAllocated']['required']='optional'; ! $stackQuiz['quizTimeAllocated']['mysql']='TIME'; ! $stackQuiz['quizTimeAllocated']['type']='meta'; ! $stackQuiz['quizTimeAllocated']['metatag']='typicallearningtime'; //lom:typicallearningtime ! $stackQuiz['quizTimeAllocated']['metatype']='lom'; ! $stackQuiz['quizTimeAllocated']['default']="00:00:00"; ! ! //Type of quiz: Default to algebraicExpression as that is only type of quiz atm, but provides extensibility ! $stackQuiz['quizExcerciseType']['values']=array('algebraicExpression','mcqSingleAnswer','mcqMultipleAnswer', ! 'fillInBlank','unspecified'); ! $stackQuiz['quizExcerciseType']['required']='optional'; ! $stackQuiz['quizExcerciseType']['mysql']='TINYTEXT'; ! $stackQuiz['quizExcerciseType']['type']='meta'; ! $stackQuiz['quizExcerciseType']['metatag']='excercisetype'; //excercisetype ! $stackQuiz['quizExcerciseType']['metatype']='stack'; ! $stackQuiz['quizExcerciseType']['default']='unspecified'; ! ! /** ! * Displays the student quiz selection screen ! * @param array $quize_store The list of quizzes ! * @param $user ! * @return void ! */ ! function stack_quiz_student_select($quiz_store, $user) { ! global $stack_root; ! ! require_once("{$stack_root}/html/quizjava.html"); ! echo "<h1>Please choose a quiz to try</h1>"; ! global $stackQuiz; ! if (is_array($quiz_store)) { ! echo "<p>\n<form name='quizform' action='quiz.php' method='POST'> ! <input type='hidden' name='quizid' value='-1'> ! <input type='hidden' name='action' value='continue_quiz'>"; ! echo "\n<table cellpadding='2'>\n"; ! echo "\n<tr><th>{$stackQuiz['quizName']['descript']}</th><th>{$stackQuiz['quizDescription']['descript']}</th><th>Last mark (%)</th><th>{$stackQuiz['quizDueDate']['descript']}</th></tr>"; ! foreach ($quiz_store as $qs => $quiz) { ! $qname = $quiz['quizName']; ! $qID = $quiz['quizid']; ! $mark = '-'; ! if (is_array($user)) { ! if (array_key_exists('id',$user)) { ! $userinfo = stack_db_quiz_quizattempt_getlast($qID,$user['id']); ! if (is_array($userinfo)) { ! if (NULL != $userinfo['mark']) { ! $mark = round(100*$userinfo['mark']/$userinfo['maxmark'],2); ! } ! } ! } ! } ! ! echo "<tr><td><a href=\"javascript:takeaction('continue_quiz','$qID');\">{$qname}</a></td>\n"; ! echo "<td>".$quiz['quizDescription']."</td><td align='center'>$mark</td>\n"; ! if ('' != $quiz['quizDueDate']) { ! echo "<td>".stack_time_display($quiz['quizDueDate'])."</td>"; ! } ! echo "</tr>\n"; ! } ! echo "\n</table>\n</form>\n</p>"; ! } else { ! echo "<p>You have no quizzes available to try.</p>"; ! } ! } ! ! ! ?> --- 1,454 ---- ! <?php ! ! ! ! /** ! ! * This file contains most functions which deal with quizzes. ! ! * ! ! * @package scripts ! ! * @subpackage Stack ! ! */ ! ! ! ! /** ! ! * ! ! */ ! ! // 'Unique quiz ID - local mySQL value' ! ! $stackQuiz['quizid']['descript'] = 'Quiz ID number'; ! ! $stackQuiz['quizid']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; ! ! $stackQuiz['quizid']['type'] = 'meta'; ! ! ! ! // 'Quiz name' ! ! $stackQuiz['quizName']['descript'] = 'Quiz name'; ! ! $stackQuiz['quizName']['mysql'] = 'TINYTEXT'; ! ! $stackQuiz['quizName']['type'] = 'meta'; ! ! $stackQuiz['quizName']['metatag'] = 'title'; //dc:title ! ! $stackQuiz['quizName']['metatype'] = 'dublincore'; ! ! ! ! // 'Quiz description' ! ! $stackQuiz['quizDescription']['descript'] = 'Description'; ! ! $stackQuiz['quizDescription']['mysql'] = 'TINYTEXT'; ! ! $stackQuiz['quizDescription']['type'] = 'meta'; ! ! $stackQuiz['quizDescription']['metatag'] = 'description'; //dc:description ! ! $stackQuiz['quizDescription']['metatype'] = 'dublincore'; ! ! ! ! // 'Quiz options' ! ! $stackQuiz['quizOptions']['descript'] = 'Quiz options'; ! ! $stackQuiz['quizOptions']['mysql'] = 'TEXT'; ! ! $stackQuiz['quizOptions']['type'] = 'other'; ! ! ! ! // 'Quiz due date' ! ! $stackQuiz['quizDueDate']['descript'] = 'Due date'; ! ! $stackQuiz['quizDueDate']['mysql'] = 'int(10)'; ! ! $stackQuiz['quizDueDate']['type'] = 'date'; ! ! ! ! // 'Quiz mode' ! ! $stackQuiz['quizMode']['descript'] = 'Mode'; ! ! $stackQuiz['quizMode']['mysql'] = 'TINYTEXT'; ! ! $stackQuiz['quizMode']['type'] = 'string'; ! ! ! ! //<PDK> Quiz Metadata added - database updated ! ! // 'Globally unique quiz ID'; ! ! $stackQuiz['quizGUID']['required'] = 'system'; ! ! $stackQuiz['quizGUID']['mysql'] = 'CHAR(22) UNIQUE KEY'; //GUID's are 32byte characters ! ! $stackQuiz['quizGUID']['type'] = 'meta'; ! ! $stackQuiz['quizGUID']['metatag'] = 'identifier'; ! ! $stackQuiz['quizGUID']['metatype'] = 'dublincore'; ! ! ! ! // 'Keywords'; ! ! $stackQuiz['quizKeywords']['required'] = 'optional'; ! ! $stackQuiz['quizKeywords']['mysql'] = 'TINYTEXT'; ! ! $stackQuiz['quizKeywords']['type'] = 'meta'; ! ! $stackQuiz['quizKeywords']['metatag'] = 'keyword'; //lom:keyword ! ! $stackQuiz['quizKeywords']['metatype'] = 'lom'; ! ! $stackQuiz['quizKeywords']['descript'] = 'Keywords'; //<PDK>Need for display purposes ! ! ! ! // 'Last edited by'; ! ! $stackQuiz['quizUserLastEdited']['required']='system'; ! ! $stackQuiz['quizUserLastEdited']['mysql']='INT UNSIGNED'; ! ! $stackQuiz['quizUserLastEdited']['type']='meta'; ! ! $stackQuiz['quizUserLastEdited']['metatag']='creator'; //dc:creator ! ! $stackQuiz['quizUserLastEdited']['metatype']='dublincore'; ! ! ! ! // 'Last edited on'; ! ! $stackQuiz['quizDateLastEdited']['required']='system'; ! ! $stackQuiz['quizDateLastEdited']['mysql']='TIMESTAMP'; ! ! $stackQuiz['quizDateLastEdited']['type']='meta'; ! ! $stackQuiz['quizDateLastEdited']['metatag']='date'; //dc:date ! ! $stackQuiz['quizDateLastEdited']['metatype']='dublincore'; ! ! ! ! //Publisher ! ! $stackQuiz['quizPublisher']['required']='system'; ! ! $stackQuiz['quizPublisher']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizPublisher']['type']='meta'; ! ! $stackQuiz['quizPublisher']['metatag']='publisher'; //dc:publisher ! ! $stackQuiz['quizPublisher']['metatype']='dublincore'; ! ! ! ! //Type: Hidden from user ! ! $stackQuiz['type']['values']=array('quiz','quiz'); //Default to 'type' enumeration in XSD file ! ! $stackQuiz['type']['required']='optional'; ! ! $stackQuiz['type']['mysql']='TINYTEXT'; ! ! $stackQuiz['type']['type']='meta'; ! ! $stackQuiz['type']['metatag']='type'; //dc:type ! ! $stackQuiz['type']['metatype']='dublincore'; ! ! ! ! //Format: Hidden from user, selected by script ! ! $stackQuiz['quizFormat']['values']=array('application','audio','image', ! ! 'message','model','text','video', ! ! 'multipart'); ! ! $stackQuiz['quizFormat']['required']='optional'; ! ! $stackQuiz['quizFormat']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizFormat']['type']='meta'; //dc:format ! ! $stackQuiz['quizFormat']['metatag']='format'; ! ! $stackQuiz['quizFormat']['metatype']='dublincore'; ! ! ! ! //Language: Defaulted to current system language, but user definable ! ! $stackQuiz['quizLanguage']['values']=array('en','fr','nl','es','unspecified'); ! ! $stackQuiz['quizLanguage']['required']='optional'; ! ! $stackQuiz['quizLanguage']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizLanguage']['type']='meta'; ! ! $stackQuiz['quizLanguage']['metatag']='language'; //dc:language ! ! $stackQuiz['quizLanguage']['metatype']='dublincore'; ! ! $stackQuiz['quizLanguage']['default']=$stack_defaultlang; //take the default language; ! ! ! ! //Rights ! ! $stackQuiz['quizRights']['required']='optional'; ! ! $stackQuiz['quizRights']['mysql']='TEXT'; ! ! $stackQuiz['quizRights']['type']='meta'; ! ! $stackQuiz['quizRights']['metatag']='rights'; //dc:rights ! ! $stackQuiz['quizRights']['metatype']='dublincore'; ! ! $stackQuiz['quizRights']['default']='http://www.gnu.org/copyleft/gpl.html'; ! ! ! ! //Learning context: Defaulted to system context, but user definable ! ! $stackQuiz['quizLearningContext']['values']=array('Primary Education','Secondary Education','Higher Education', ! ! 'University First Cycle','University Second Cycle','University Post Grade', ! ! 'Technical School First Cycle','Technical School Second Cycle','Professional Formation', ! ! 'Continuous Formation','Vocational Training','unspecified'); ! ! $stackQuiz['quizLearningContext']['required']='optional'; ! ! $stackQuiz['quizLearningContext']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizLearningContext']['type']='meta'; ! ! $stackQuiz['quizLearningContext']['metatag']='context'; //lom:context ! ! $stackQuiz['quizLearningContext']['metatype']='lom'; ! ! $stackQuiz['quizLearningContext']['default']='unspecified'; ! ! ! ! //Difficulty: Default to null - up to user to specify this ! ! $stackQuiz['quizDifficulty']['values']=array('Very Easy','Easy','Medium', ! ! 'Difficult','Very Difficult','unspecified'); ! ! $stackQuiz['quizDifficulty']['required']='optional'; ! ! $stackQuiz['quizDifficulty']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizDifficulty']['type']='meta'; ! ! $stackQuiz['quizDifficulty']['metatag']='difficulty'; //lom:difficulty ! ! $stackQuiz['quizDifficulty']['metatype']='lom'; ! ! $stackQuiz['quizDifficulty']['default']='unspecified'; ! ! ! ! //Competency: Default to solve - then up to user ! ! $stackQuiz['quizCompetency']['values']=array('think','argue','solve', ! ! 'represent','language','communicate', ! ! 'tools','unspecified'); ! ! $stackQuiz['quizCompetency']['required']='optional'; ! ! $stackQuiz['quizCompetency']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizCompetency']['type']='meta'; ! ! $stackQuiz['quizCompetency']['metatag']='competency'; ! ! $stackQuiz['quizCompetency']['metatype']='stack'; //competency ! ! $stackQuiz['quizCompetency']['default']='unspecified'; ! ! ! ! //CompetencyLevel: Default to null - then up to user ! ! $stackQuiz['quizCompetencyLevel']['values']=array('elementary','simpleConceptual','multiStep', ! ! 'complex','unspecified'); ! ! $stackQuiz['quizCompetencyLevel']['required']='optional'; ! ! $stackQuiz['quizCompetencyLevel']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizCompetencyLevel']['type']='meta'; ! ! $stackQuiz['quizCompetencyLevel']['metatag']='competencylevel'; //competencylevel ! ! $stackQuiz['quizCompetencyLevel']['metatype']='stack'; ! ! $stackQuiz['quizCompetencyLevel']['default']='unspecified'; ! ! ! ! //Time to allocate: Default to null - then up to user ! ! $stackQuiz['quizTimeAllocated']['required']='optional'; ! ! $stackQuiz['quizTimeAllocated']['mysql']='TIME'; ! ! $stackQuiz['quizTimeAllocated']['type']='meta'; ! ! $stackQuiz['quizTimeAllocated']['metatag']='typicallearningtime'; //lom:typicallearningtime ! ! $stackQuiz['quizTimeAllocated']['metatype']='lom'; ! ! $stackQuiz['quizTimeAllocated']['default']="00:00:00"; ! ! ! ! //Type of quiz: Default to algebraicExpression as that is only type of quiz atm, but provides extensibility ! ! $stackQuiz['quizExcerciseType']['values']=array('algebraicExpression','mcqSingleAnswer','mcqMultipleAnswer', ! ! 'fillInBlank','unspecified'); ! ! $stackQuiz['quizExcerciseType']['required']='optional'; ! ! $stackQuiz['quizExcerciseType']['mysql']='TINYTEXT'; ! ! $stackQuiz['quizExcerciseType']['type']='meta'; ! ! $stackQuiz['quizExcerciseType']['metatag']='excercisetype'; //excercisetype ! ! $stackQuiz['quizExcerciseType']['metatype']='stack'; ! ! $stackQuiz['quizExcerciseType']['default']='unspecified'; ! ! ! ! /** ! ! * Displays the student quiz selection screen ! ! * @param array $quize_store The list of quizzes ! ! * @param $user ! ! * @return void ! ! */ ! ! function stack_quiz_student_select($quiz_store, $user) { ! ! global $stack_root; ! ! ! ! require_once("{$stack_root}/html/quizjava.html"); ! ! echo "<h1>Please choose a quiz to try</h1>"; ! ! global $stackQuiz; ! ! if (is_array($quiz_store)) { ! ! echo "<p>\n<form name='quizform' action='quiz.php' method='POST'> ! ! <input type='hidden' name='quizid' value='-1'> ! ! <input type='hidden' name='action' value='continue_quiz'>"; ! ! echo "\n<table cellpadding='2'>\n"; ! ! echo "\n<tr><th>{$stackQuiz['quizName']['descript']}</th><th>{$stackQuiz['quizDescription']['descript']}</th><th>Last mark (%)</th><th>{$stackQuiz['quizDueDate']['descript']}</th></tr>"; ! ! foreach ($quiz_store as $qs => $quiz) { ! ! $qname = $quiz['quizName']; ! ! $qID = $quiz['quizid']; ! ! $mark = '-'; ! ! if (is_array($user)) { ! ! if (array_key_exists('id',$user)) { ! ! $userinfo = stack_db_quiz_quizattempt_getlast($qID,$user['id']); ! ! if (is_array($userinfo)) { ! ! if (NULL != $userinfo['mark']) { ! ! $mark = round(100*$userinfo['mark']/$userinfo['maxmark'],2); ! ! } ! ! } ! ! } ! ! } ! ! ! ! echo "<tr><td><a href=\"javascript:takeaction('continue_quiz','$qID');\">{$qname}</a></td>\n"; ! ! echo "<td>".$quiz['quizDescription']."</td><td align='center'>$mark</td>\n"; ! ! if ('' != $quiz['quizDueDate']) { ! ! echo "<td>".stack_time_display($quiz['quizDueDate'])."</td>"; ! ! } ! ! echo "</tr>\n"; ! ! } ! ! echo "\n</table>\n</form>\n</p>"; ! ! } else { ! ! echo "<p>You have no quizzes available to try.</p>"; ! ! } ! ! } ! ! ! ! ! ! ?> ! Index: stackXML.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackXML.php,v retrieving revision 1.13.2.16 retrieving revision 1.13.2.17 diff -C2 -d -r1.13.2.16 -r1.13.2.17 *** stackXML.php 16 Aug 2005 22:43:29 -0000 1.13.2.16 --- stackXML.php 17 Aug 2005 16:48:46 -0000 1.13.2.17 *************** *** 99,108 **** function stack_xml_create_question_new($question) { // Don't export questionID if (array_key_exists('questionID',$question)) { unset($question['questionID']); } - // Make sure the question is validated. - stack_question_validate($question,$errors); $xmlDoc = &new DOMIT_Document(); --- 99,110 ---- function stack_xml_create_question_new($question) { + //Validate the question + stack_question_validate($question,$errors); + stack_xml_remove_question_meta_defaults($question); //Remove any disused fields before writing out + // Don't export questionID if (array_key_exists('questionID',$question)) { unset($question['questionID']); } $xmlDoc = &new DOMIT_Document(); *************** *** 351,355 **** $question = stack_db_getquestion($question['questionID']); //Get the questionId from the question data structure stack_question_validate($question,$errors); //Validate it ! unset($question['questionID']); --- 353,358 ---- $question = stack_db_getquestion($question['questionID']); //Get the questionId from the question data structure stack_question_validate($question,$errors); //Validate it ! stack_xml_remove_question_meta_defaults($question); //Remove any disused fields before writing out ! unset($question['questionID']); *************** *** 551,555 **** { $question = stack_db_getquestion($questionID); //Get the questionId from the question ! stack_question_validate($question,$errors); //Validate it unset($question['questionID']); --- 554,560 ---- { $question = stack_db_getquestion($questionID); //Get the questionId from the question ! stack_question_validate($question,$errors); //Validate it ! ! stack_xml_remove_question_meta_defaults($question); //Remove any unused metadata fields from each $question unset($question['questionID']); *************** *** 917,920 **** --- 922,928 ---- } } + + //If unsuccessful at resolving + return $element->nodeName; } *************** *** 933,941 **** $nodeName = $node->nodeName; ! //Is this node the member of a metadata namespace? If so, map it onto the equivalent question field ! if (!empty($node->namespaceURI)) ! { ! $nodeName = stack_xml_map_element_ns($node,$arrayType); ! } //We will have a nodeName at this point, whether the actual element or resolved from namespace //If node has children --- 941,948 ---- $nodeName = $node->nodeName; ! //Check whether node is metadata and if so resolve to equivalent question field ! $nodeName = stack_xml_map_element_ns($node,$arrayType); ! ! //} //We will have a nodeName at this point, whether the actual element or resolved from namespace //If node has children *************** *** 960,972 **** //Get the item $item = $nodeList->item($j); ! //print_r("List item: ".$item->parentNode->nodeName); ! //print_r("<br>"); ! //print_r("Parent node: ".$node->parentNode->nodeName); ! //print_r("<br>"); ! if ($item->parentNode->nodeName!=$node->parentNode->nodeName) { $length=1; ! } ! } --- 967,975 ---- //Get the item $item = $nodeList->item($j); ! ! if ($item->parentNode->nodeName!=$node->parentNode->nodeName) //where they are not { $length=1; ! } } *************** *** 980,986 **** - //print_r($length); - //show_array($nodeList); - //If there are multiple elements of the same name //Deal with arrays of values: for example potential responses and questionVar/answerVar --- 983,986 ---- *************** *** 2423,2426 **** --- 2423,2542 ---- } + /** + * This function iterates through the specified array and removes metadata whose value is the system default + * + * @see stack_xml_create_question_schema() + * @param array $&array The array to search, by reference + * @param string $value The value to search for in that array + * @return bool True if the value being searched for exists, False otherwise + */ + function stack_xml_remove_question_meta_defaults(&$question) + { + global $stackQuestion; + + foreach ($question as $arrayKey=>$quField) //Iterate through the question fields + { + if (array_key_exists($arrayKey,$stackQuestion)) //Where that field exists in the stackQuestion data structure + { + if(!empty($stackQuestion[$arrayKey]['type']) && ($stackQuestion[$arrayKey]['type']=='meta')) + { + //Check stackQuestion data structure has a default for it, and if so, that the value is equal to that default + if(!empty($stackQuestion[$arrayKey]['default']) && $quField==$stackQuestion[$arrayKey]['default']) { + unset($question[$arrayKey]); + } + + //If the field has a default value but the field is blank - dont write out + else if (!empty($stackQuestion[$arrayKey]['default']) && empty($quField)) + { + print_r($arrayKey); + unset($question[$arrayKey]); + } + } + + //Else we just ignore it and write out + } + } + } + + function stack_xml_reinstate_question_meta_defaults(&$question) + { + global $stackQuestion; + + foreach ($stackQuestion as $arrayKey=>$quField) //Iterate through the master stackQuestion fields + { + if (!array_key_exists($arrayKey,$question)) //Where the field ocurrs in stackQuestion, but not the imported question + { //and is metadata + if(!empty($quField['type']) && ($quField['type']=='meta')) + { + //If metadata field has defaults + if(!empty($quField['default'])) + { + //Set the field in $question to the default metadata + $question[$arrayKey]=$quField['default']; + } + + } + } + } + } + + /** + * This function iterates through the specified array and removes metadata whose value is the system default + * + * @see stack_xml_create_question_schema() + * @param array $&array The array to search, by reference + * @param string $value The value to search for in that array + * @return bool True if the value being searched for exists, False otherwise + */ + function stack_xml_remove_quiz_meta_defaults(&$quiz) + { + global $stackQuiz; + + foreach ($quiz as $arrayKey=>$quizField) //Iterate through the question fields + { + if (array_key_exists($arrayKey,$stackQuiz)) //Where that field exists in the stackQuiz data structure + { + if(!empty($stackQuiz[$arrayKey]['type']) && ($stackQuiz[$arrayKey]['type']=='meta')) + { + //Check stackQuestion data structure has a default for it, and if so, that the value is equal to that default + if(!empty($stackQuiz[$arrayKey]['default']) && $quizField==$stackQuiz[$arrayKey]['default']) { + unset($quiz[$arrayKey]); + } + + //If the field has a default value but the field is blank - dont write out + else if (!empty($stackQuiz[$arrayKey]['default']) && empty($quizField)) + { + print_r($arrayKey); + unset($quiz[$arrayKey]); + } + } + + //Else we just ignore it and write out + } + } + } + + function stack_xml_reinstate_quiz_meta_defaults(&$quiz) + { + global $stackQuiz; + + foreach ($stackQuiz as $arrayKey=>$quizField) //Iterate through the master stackQuestion fields + { + if (!array_key_exists($arrayKey,$quiz)) //Where the field ocurrs in stackQuestion, but not the imported question + { //and is metadata + if(!empty($quizField['type']) && ($quizField['type']=='meta')) + { + //If metadata field has defaults + if(!empty($quizField['default'])) + { + //Set the field in $question to the default metadata + $quiz[$arrayKey]==$quizField['default']; + } + + } + } + } + } + if (!stack_xml_check_schema_version("{$stack_root}/schemas/")) { Index: stackDatabase.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackDatabase.php,v retrieving revision 1.34.2.5 retrieving revision 1.34.2.6 diff -C2 -d -r1.34.2.5 -r1.34.2.6 *** stackDatabase.php 17 Aug 2005 11:24:06 -0000 1.34.2.5 --- stackDatabase.php 17 Aug 2005 16:48:46 -0000 1.34.2.6 *************** *** 1453,1456 **** --- 1453,1459 ---- $quiz_fields = array_keys($stackQuiz); + + show_array("In db function:"); + show_array($quiz); $quizid = ''; *************** *** 1466,1469 **** --- 1469,1477 ---- } + // Let SQL add the "last edit", like the question + if (array_key_exists('quizDateLastEdited',$quiz)) { + unset($quiz['quizDateLastEdited']); + } + if ($new_quiz) { $qu = ''; *************** *** 1486,1489 **** --- 1494,1499 ---- $query = "INSERT INTO stackQuiz ($qu) VALUES ($quv)"; $result = stack_db_query($query); + + show_array($query); // GET the last quizid *************** *** 1510,1513 **** --- 1520,1525 ---- $query = "UPDATE stackQuiz SET $qu WHERE quizid = '$quizid'"; $result = stack_db_query($query); + + show_array($query); } Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.29.2.9 retrieving revision 1.29.2.10 diff -C2 -d -r1.29.2.9 -r1.29.2.10 *** stackAuthor.php 17 Aug 2005 11:24:06 -0000 1.29.2.9 --- stackAuthor.php 17 Aug 2005 16:48:46 -0000 1.29.2.10 *************** *** 1,1094 **** ! <?php ! /** ! * Functions which deal with authoring questions and quizzes. These only need to be ! * loaded when an edit page needs to be generated. ! * ! * @package scripts ! * @subpackage Stack ! */ ! ! //****************************************************** [...3256 lines suppressed...] ! 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); ! ! } ! ! ! ! ?> ! |