classXMLQuestionImporter

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.

Public Member Functions

 construct ($xmlfile)
 
 destruct ()
 

Private Member Functions

 startElementHandler ($parser, $name, $attribs)
 
 endElementHandler ($parser, $name)
 
 segContentHandler ($parser, $data)
 
 addModule ()
 
 addSubject ()
 
 addQuestion ()
 
 addAnswer ()
 

Private Attributes

 $xmlfile = 0
 
 $level = “
 
 $level_data = Array()
 
 $current_element = “
 
 $current_data = “
 
 $boolval = Array(‘false’ => ‘0’, ‘true’ => ‘1’)
 
 $qtype = Array(‘single’ => ‘1’, ‘multiple’ => ‘2’, ‘text’ => ‘3’, ‘ordering’ => ‘4’)
 
 $questionhash = array()
 

Detailed Description

This PHP Class imports question data directly from an XML file.

Constructor & Destructor Documentation

XMLQuestionImporter::__construct (   $xmlfile)

Class constructor.

Parameters
$xmlfile(string) xml (XML) file name
Returns
true or die for parsing error

XMLQuestionImporter::__destruct ( )

Class destructor;

Member Function Documentation

XMLQuestionImporter::addAnswer ( )
private

Add a new answer if not exist.

XMLQuestionImporter::addModule ( )
private

Add a new module if not exist.

XMLQuestionImporter::addQuestion ( )
private

Add a new question if not exist.

XMLQuestionImporter::addSubject ( )
private

Add a new subject if not exist.

XMLQuestionImporter::endElementHandler (   $parser,
  $name 
)
private

Sets the end element handler function for the XML parser parser.end_element_handler.

Parameters
$parser(resource) The first parameter, parser, is a reference to the XML parser calling the handler.
$name(string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.

XMLQuestionImporter::segContentHandler (   $parser,
  $data 
)
private

Sets the character data handler function for the XML parser parser.handler.

Parameters
$parser(resource) The first parameter, parser, is a reference to the XML parser calling the handler.
$data(string) The second parameter, data, contains the character data as a string.

XMLQuestionImporter::startElementHandler (   $parser,
  $name,
  $attribs 
)
private

Sets the start element handler function for the XML parser parser.start_element_handler.

Parameters
$parser(resource) The first parameter, parser, is a reference to the XML parser calling the handler.
$name(string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
$attribs(array) The third parameter, attribs, contains an associative array with the element’s attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.

Member Data Documentation

XMLQuestionImporter::$boolval = Array(‘false’ => ‘0’, ‘true’ => ‘1’)
private

Boolean values.

XMLQuestionImporter::$current_data = “
private

Current data value.

XMLQuestionImporter::$current_element = “
private

Current data element.

XMLQuestionImporter::$level = “
private

Current level: ‘module’, ‘subject’, ‘question’, ‘answer’.

XMLQuestionImporter::$level_data = Array()
private

Array to store current level data.

XMLQuestionImporter::$qtype = Array(‘single’ => ‘1’, ‘multiple’ => ‘2’, ‘text’ => ‘3’, ‘ordering’ => ‘4’)
private

Type of questions.

XMLQuestionImporter::$questionhash = array()
private

Store hash values of question descriptions. This is used to avoid the 255 chars limitation for string indexes on MySQL

XMLQuestionImporter::$xmlfile = 0
private

XML file.


The documentation for this class was generated from the following file:

 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy