From: pkiddie <pk...@us...> - 2005-07-19 13:31:42
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5086/scripts Modified Files: stackQuiz.php stackXML.php Log Message: Addition of metadata tags to quizzes, and relevant documentation Index: stackQuiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuiz.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stackQuiz.php 14 Jul 2005 18:31:23 -0000 1.3 --- stackQuiz.php 19 Jul 2005 13:31:32 -0000 1.4 *************** *** 11,32 **** --- 11,160 ---- * */ + // 'Unique quiz ID - local mySQL value' $stackQuiz['quizid']['descript'] = 'Quiz ID number'; $stackQuiz['quizid']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; + // 'Quiz name' $stackQuiz['quizName']['descript'] = 'Quiz name'; $stackQuiz['quizName']['mysql'] = 'TINYTEXT'; + // 'Quiz description' $stackQuiz['quizDescription']['descript'] = 'Description'; $stackQuiz['quizDescription']['mysql'] = 'TINYTEXT'; + // 'Quiz options' $stackQuiz['quizOptions']['descript'] = 'Quiz options'; $stackQuiz['quizOptions']['mysql'] = 'TEXT'; + // 'Quiz due date' $stackQuiz['quizDueDate']['descript'] = 'Due date'; $stackQuiz['quizDueDate']['mysql'] = 'int(10)'; + // 'Quiz mode' $stackQuiz['quizMode']['descript'] = 'Mode'; $stackQuiz['quizMode']['mysql'] = 'TINYTEXT'; + //<PDK> Quiz Metadata added - database updated + // 'Globally unique quiz ID'; + $stackQuiz['quizGUID']['type']='meta'; + $stackQuiz['quizGUID']['required']='system'; + $stackQuiz['quizGUID']['mysql']='CHAR(22) UNIQUE KEY'; //GUID's are 32byte characters + $stackQuiz['quizGUID']['metatag']='Identifier'; + + // 'Keywords'; + $stackQuiz['quizKeywords']['type']='meta'; + $stackQuiz['quizKeywords']['required']='optional'; + $stackQuiz['quizKeywords']['mysql']='TINYTEXT'; + $stackQuiz['quizKeywords']['metatag']='Keyword'; + + // 'Last edited by'; + $stackQuiz['quizUserLastEdited']['type']='meta'; + $stackQuiz['quizUserLastEdited']['required']='system'; + $stackQuiz['quizUserLastEdited']['mysql']='INT UNSIGNED'; + $stackQuiz['quizUserLastEdited']['metatag']='Creator'; + + // 'Last edited on'; + $stackQuiz['quizDateLastEdited']['type']='meta'; + $stackQuiz['quizDateLastEdited']['required']='system'; + $stackQuiz['quizDateLastEdited']['mysql']='TIMESTAMP'; + $stackQuiz['quizDateLastEdited']['metatag']='Date'; + + //Publisher + $stackQuiz['quizPublisher']['type']='meta'; + $stackQuiz['quizPublisher']['required']='system'; + $stackQuiz['quizPublisher']['mysql']='TINYTEXT'; + $stackQuiz['quizPublisher']['metatag']='Publisher'; + + //Type: Hidden from user + $stackQuiz['type']['type']='meta'; + $stackQuiz['type']['values']=array('quiz','quiz'); //Default to 'type' enumeration in XSD file + $stackQuiz['type']['required']='optional'; + $stackQuiz['type']['mysql']='TINYTEXT'; + $stackQuiz['type']['metatag']='Type'; + + //Format: Hidden from user, selected by script + $stackQuiz['quizFormat']['type']='meta'; + $stackQuiz['quizFormat']['values']=array('application','audio','image', + 'message','model','text','video', + 'multipart'); + $stackQuiz['quizFormat']['required']='optional'; + $stackQuiz['quizFormat']['mysql']='TINYTEXT'; + $stackQuiz['quizFormat']['metatag']='Format'; + + //Language: Defaulted to current system language, but user definable + $stackQuiz['quizLanguage']['type']='meta'; + $stackQuiz['quizLanguage']['values']=array('en','fr','nl','es','unspecified'); + $stackQuiz['quizLanguage']['required']='optional'; + $stackQuiz['quizLanguage']['mysql']='TINYTEXT'; + $stackQuiz['quizLanguage']['metatag']='Language'; + $stackQuiz['quizLanguage']['default']='unspecified'; + + //Rights + $stackQuiz['quizRights']['type']='meta'; + $stackQuiz['quizRights']['required']='optional'; + $stackQuiz['quizRights']['mysql']='TEXT'; + $stackQuiz['quizRights']['metatag']='Rights'; + $stackQuiz['quizRights']['default']='http://www.gnu.org/copyleft/gpl.html'; + + //Learning context: Defaulted to system context, but user definable + $stackQuiz['quizLearningContext']['type']='meta'; + $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']['metatag']='LearningContext'; + $stackQuiz['quizLearningContext']['default']='unspecified'; + + //Difficulty: Default to null - up to user to specify this + $stackQuiz['quizDifficulty']['type']='meta'; + $stackQuiz['quizDifficulty']['values']=array('Very Easy','Easy','Medium', + 'Difficult','Very Difficult','unspecified'); + $stackQuiz['quizDifficulty']['required']='optional'; + $stackQuiz['quizDifficulty']['mysql']='TINYTEXT'; + $stackQuiz['quizDifficulty']['metatag']='Difficulty'; + $stackQuiz['quizDifficulty']['default']='unspecified'; + + //Competency: Default to solve - then up to user + $stackQuiz['quizCompetency']['type']='meta'; + $stackQuiz['quizCompetency']['values']=array('think','argue','solve', + 'represent','language','communicate', + 'tools','unspecified'); + $stackQuiz['quizCompetency']['required']='optional'; + $stackQuiz['quizCompetency']['mysql']='TINYTEXT'; + $stackQuiz['quizCompetency']['metatag']='Competency'; + $stackQuiz['quizCompetency']['default']='unspecified'; + + //CompetencyLevel: Default to null - then up to user + $stackQuiz['quizCompetencyLevel']['type']='meta'; + $stackQuiz['quizCompetencyLevel']['values']=array('elementary','simpleConceptual','multiStep', + 'complex','unspecified'); + $stackQuiz['quizCompetencyLevel']['required']='optional'; + $stackQuiz['quizCompetencyLevel']['mysql']='TINYTEXT'; + $stackQuiz['quizCompetencyLevel']['metatag']='CompetencyLevel'; + $stackQuiz['quizCompetencyLevel']['default']='unspecified'; + + //Time to allocate: Default to null - then up to user + $stackQuiz['quizTimeAllocated']['type']='meta'; + $stackQuiz['quizTimeAllocated']['required']='optional'; + $stackQuiz['quizTimeAllocated']['mysql']='TIME'; + $stackQuiz['quizTimeAllocated']['metatag']='TypicalLearningTime'; + $stackQuiz['quizTimeAllocated']['default']='0'; + + //Type of quiz: Default to algebraicExpression as that is only type of quiz atm, but provides extensibility + $stackQuiz['quizExcerciseType']['type']='meta'; + $stackQuiz['quizExcerciseType']['values']=array('algebraicExpression','mcqSingleAnswer','mcqMultipleAnswer', + 'fillInBlank','unspecified'); + $stackQuiz['quizExcerciseType']['required']='optional'; + $stackQuiz['quizExcerciseType']['mysql']='TINYTEXT'; + $stackQuiz['quizExcerciseType']['metatag']='ExcerciseType'; + $stackQuiz['quizExcerciseType']['default']='unspecified'; + + //Versioning required to check whether schema is up to date + //Where version number has form M.N where M is major version number + // N is minor version number + $stackQuiz['version']='1.0'; + /** * Displays the student quiz selection screen Index: stackXML.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackXML.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** stackXML.php 18 Jul 2005 16:23:13 -0000 1.11 --- stackXML.php 19 Jul 2005 13:31:32 -0000 1.12 *************** *** 234,245 **** //<PDK> /** ! * Writes an XML schema file of the current metadata tags used in STACK * * XML schema used within STACK to validate questions on import/export, and provide a definition of the metadata document * * @param string $directory The directory to store the XSD file (web server must have permissions) ! * @return the XSD filename representing the schema */ ! function stack_schema_write_metadata($directory) { global $stackQuestion; --- 234,245 ---- //<PDK> /** ! * Writes an XML schema file of the current stackQuestion metadata tags * * XML schema used within STACK to validate questions on import/export, and provide a definition of the metadata document * * @param string $directory The directory to store the XSD file (web server must have permissions) ! * @return the XSD filename representing the schema - only returned if xml was able to be written out */ ! function stack_schema_write_question_metadata($directory) { global $stackQuestion; *************** *** 247,255 **** $schema_file_name='stack_question_metadata-'.$stackQuestion['version'].'.xsd'; //File name of schema has version number of stackQuestion clearly identified //create file used for writing ! $xml_file_handle = fopen($directory.$schema_file_name,"w"); if (!$xml_file_handle) { echo "File could not be opened for writing. Please contact the network administrator."; } --- 247,257 ---- $schema_file_name='stack_question_metadata-'.$stackQuestion['version'].'.xsd'; //File name of schema has version number of stackQuestion clearly identified //create file used for writing ! //<TODO: Check if is compatible!!> ! $xml_file_handle = fopen($directory."\\".$schema_file_name,"w"); if (!$xml_file_handle) { echo "File could not be opened for writing. Please contact the network administrator."; + return ''; } *************** *** 263,267 **** //Create root element 'metadata'. stack_schema_create_root("metadata"). ! stack_schema_create_metadata(). stack_schema_escape_root(). stack_schema_create_enum_types(). --- 265,269 ---- //Create root element 'metadata'. stack_schema_create_root("metadata"). ! stack_schema_create_question_metadata(). stack_schema_escape_root(). stack_schema_create_enum_types(). *************** *** 301,304 **** --- 303,430 ---- '</xs:element>'; } + + function stack_schema_write_quiz_metadata() + { + global $stackQuiz; + + $schema_file_name='stack_quiz_metadata-'.$stackQuiz['version'].'.xsd'; //File name of schema has version number of stackQuiz clearly identified + + //<TODO: Check if is compatible!!> + $xml_file_handle = fopen($directory."\\".$schema_file_name,"w"); + + if (!$xml_file_handle) + { + echo "File could not be opened for writing. Please contact the network administrator."; + return ''; + } + + else + { + //Write the XML schema header - same for all XML schemas - with version number. + //XML metadata files which validate against this schema will also have a version number + $xml = '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="'.$stackQuiz['version'].'">'. + "\n". + '<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>'. + //Create root element 'metadata'. + stack_schema_create_root("metadata"). + stack_schema_create_quiz_metadata(). + stack_schema_escape_root(). + stack_schema_create_enum_types(). + //End of schema + '</xs:schema>'; + + //write out xml string + fputs($xml_file_handle,$xml); + //close xml file + fclose($xml_file_handle); + } + } + + function stack_schema_create_quiz_metadata(); + { + global $sqlToSchemaMapping,$stackQuiz; + + include('../../stackstd.php'); + + $options = stack_options_set(array()); + $filename = stack_lang_filename($options,'doc/en_doc.php'); //Include documentation to document fields if it is available + include($filename); + + $xml = ""; + + //Do not export questionID - internal SQL variable + if (array_key_exists('questionID',$stackQuestion)) { + unset($stackQuestion['questionID']); + } + + //Do not export body - internal SQL variable. + if (array_key_exists('questionBody',$stackQuestion)) { + unset($stackQuestion['questionBody']); + } + + //Create a sequence of metadata tags + $xml.='<xs:sequence>'; + + foreach($stackQuestion as $arrayKey=>$questionField) //Iterate through sub array of each array object + { + //First check there is a type associated with that field and that the stackQuestion field is metadata + if (!empty($questionField['type']) && ($questionField['type']=='meta')) { + + //Check that a metadata tag has been supplied and do not write out if tag has not been supplied + if (empty($questionField['metatag'])) + { + echo'No metadata tag for stackQuestion field: '.$arrayKey.'<br> As a consequence it has not been written to the XML metadata schema<br>'; + } + + else + { + //If metadata is not a selection from a list of specified types + if (empty($questionField['values'])) + { + //Create XML schema fragment + //Documentation available for column + if (!empty($questionField['doc'])) { + $xml.=stack_schema_write_element_document($questionField['metatag'],$questionField['mysql'],$questionField['doc']); + + } + + //Documentation not available for column + else { + //echo "Doucmentation not avilable!"; + $xml.=stack_schema_write_element($questionField['metatag'],$questionField['mysql']); + } + } + + //The values field is not empty + else + { + //Create XML schema fragment, and default possible enumeration simpleTypes to be the lower case + //of the current metadata tag + if (!empty($questionField['doc'])) { + $xml.=stack_schema_write_element_document_enum_type($questionField['metatag'],strtolower($questionField['metatag']),$questionField['doc']); + } + + //Documentation not available for column + else { + $xml.=stack_schema_write_element_enum_type($questionField['metatag'],strtolower($questionField['metatag'])); + } + + //Furthermore, need to create + } + + + } + } + } + + //Terminate a sequence of metadata tags + $xml.='</xs:sequence>'; + + //We must now tag the 'metadata' tag with a version attribute + $xml.= stack_schema_write_attribute('version', true); + + return $xml; + } + /** * Writes the current stackQuestion metadata structure to an XML string *************** *** 312,320 **** * @return the XML string representing the entire metadata schema */ ! function stack_schema_create_metadata() { global $sqlToSchemaMapping,$stackQuestion; //use definitive stackQuestion data structure ! include('../stackstd.php'); $options = stack_options_set(array()); --- 438,446 ---- * @return the XML string representing the entire metadata schema */ ! function stack_schema_create_question_metadata() { global $sqlToSchemaMapping,$stackQuestion; //use definitive stackQuestion data structure ! include('../../stackstd.php'); $options = stack_options_set(array()); |