classes-XMLQuestionImporter

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.
Tags
class

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

version
1.1.000

Table of Contents

$boolval  : mixed
Boolean values.
$current_data  : mixed
Current data value.
$current_element  : mixed
Current data element.
$level  : mixed
Current level: 'module', 'subject', 'question', 'answer'.
$level_data  : mixed
Array to store current level data.
$qtype  : mixed
Type of questions.
$questionhash  : mixed
Store hash values of question descriptions.
$xmlfile  : mixed
XML file.
__construct()  : true
Class constructor.
__destruct()  : mixed
Class destructor;
addAnswer()  : mixed
Add a new answer if not exist.
addModule()  : mixed
Add a new module if not exist.
addQuestion()  : mixed
Add a new question if not exist.
addSubject()  : mixed
Add a new subject if not exist.
endElementHandler()  : mixed
Sets the end element handler function for the XML parser parser.end_element_handler.
segContentHandler()  : mixed
Sets the character data handler function for the XML parser parser.handler.
startElementHandler()  : mixed
Sets the start element handler function for the XML parser parser.start_element_handler.

Properties

$boolval

Boolean values.

private mixed $boolval = array('false' => '0', 'true' => '1')
Tags
private

$level

Current level: 'module', 'subject', 'question', 'answer'.

private mixed $level = ''
Tags
private

$level_data

Array to store current level data.

private mixed $level_data = array()
Tags
private

$qtype

Type of questions.

private mixed $qtype = array('single' => '1', 'multiple' => '2', 'text' => '3', 'ordering' => '4')
Tags
private

$questionhash

Store hash values of question descriptions.

private mixed $questionhash = array()

This is used to avoid the 255 chars limitation for string indexes on MySQL

Tags
private

Methods

__construct()

Class constructor.

public __construct( $xmlfile) : true
Parameters
$xmlfile :

(string) xml (XML) file name

Return values
true

or die for parsing error

addAnswer()

Add a new answer if not exist.

private addAnswer() : mixed
Tags
private
Return values
mixed

addModule()

Add a new module if not exist.

private addModule() : mixed
Tags
private
Return values
mixed

addQuestion()

Add a new question if not exist.

private addQuestion() : mixed
Tags
private
Return values
mixed

addSubject()

Add a new subject if not exist.

private addSubject() : mixed
Tags
private
Return values
mixed

endElementHandler()

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

private endElementHandler( $parser,  $name) : mixed
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.

Tags
private
Return values
mixed

segContentHandler()

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

private segContentHandler( $parser,  $data) : mixed
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.

Tags
private
Return values
mixed

startElementHandler()

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

private startElementHandler( $parser,  $name,  $attribs) : mixed
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.

Tags
private
Return values
mixed
 

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