Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
restore_questions_parser_processor Class Reference

helper implementation of grouped_parser_processor that will load all the categories and questions (header info only) from the questions.xml file to the backup_ids table storing the whole structure there for later processing. More...

Inheritance diagram for restore_questions_parser_processor:
grouped_parser_processor simplified_parser_processor progressive_parser_processor

Public Member Functions

 __construct ($restoreid)
 
 add_path ($path, $grouped=false)
 
 add_path ($path)
 
 after_path ($path)
 The parser fires this each time one path has been parsed.
 
 before_path ($path)
 The parser fires this each time one path is going to be parsed.
 
 debug_info ()
 
 process_cdata ($cdata)
 Provide NULL decoding.
 
 process_chunk ($data)
 Get one chunk of parsed data and make it simpler adding attributes as tags and delegating to dispatch_chunk() the procesing of the resulting chunk.
 
 receive_chunk ($data)
 

Static Public Member Functions

static generate_question_identity_hash (stdClass $questiondata, ?backup_xml_transformer $transformer=null,)
 Given a data structure containing the data for a question, reduce it to a flat array and return a sha1 hash of the data.
 

Protected Member Functions

 add_missing_sub ($grouped, $path, $tags)
 Add non-existing subarray elements.
 
 build_currentdata ($grouped, $data)
 This function will accumulate the chunk into the specified grouped element for later dispatching once it is complete.
 
 dispatch_chunk ($data)
 Get the already simplified chunk and dispatch it.
 
 get_parent_path ($path)
 Get the parent path using a local cache for performance.
 
 grouped_child_exists ($path)
 Function that will look for any grouped child for the given path, returning it if found, false if not.
 
 grouped_parent_exists ($path)
 Function that will look for any grouped parent for the given path, returning it if found, false if not.
 
 notify_path_end ($path)
 Get one selected path and notify about end.
 
 notify_path_start ($path)
 Get one selected path and notify about start.
 
 path_is_grouped ($path)
 
 path_is_selected ($path)
 
 path_is_selected_parent ($path)
 
 postprocess_chunk ($data)
 Override this method so grouping will be happening here also deciding between accumulating/dispatching.
 
 process_pending_startend_notifications ($path, $action)
 Adjust start/end til finding one match start/end path (included)
 
 selected_parent_exists ($path)
 Returns the first selected parent if available or false.
 

Static Protected Member Functions

static get_qtype_restore (string $qtype)
 Load and instantiate the restore class for the given question type.
 

Protected Attributes

 $chunks
 
 $currentdata
 
array $groupedparentprefixtree
 Search tree storing the grouped paths.
 
 $groupedpaths
 
 $inittime
 
int int $lastcatid
 during the restore, this tracks the last category we saw.
 
array $parentcache = array()
 Keep cache of parent directory paths for XML parsing.
 
integer $parentcacheavailablesize = 2048
 Remaining space for parent directory paths.
 
 $parentpaths
 
 $parentsinfo
 
 $paths
 
string string $restoreid
 identifies the current restore.
 
 $startendinfo
 
string const CATEGORY_PATH = '/question_categories/question_category'
 XML path in the questions.xml backup file to question categories.
 
string const HASHDATA_SEPARATOR = '|HASHDATA|'
 String for concatenating data into a string for hashing.
 
string const LEGACY_QUESTION_SUBPATH = '/questions/question'
 XML path in the questions.xml to question elements within question_category (before Moodle 4.0).
 
string const QUESTION_SUBPATH
 XML path in the questions.xml to question elements within question_category (Moodle 4.0+).
 

Detailed Description

helper implementation of grouped_parser_processor that will load all the categories and questions (header info only) from the questions.xml file to the backup_ids table storing the whole structure there for later processing.

Note: only "needed" categories are loaded (must have question_categoryref record in backup_ids) Note: parentitemid will contain the category->contextid for categories Note: parentitemid will contain the category->id for questions

TODO: Complete phpdocs

Member Function Documentation

◆ after_path()

grouped_parser_processor::after_path ( $path)
inherited

The parser fires this each time one path has been parsed.

Parameters
string$pathxml path which parsing has ended

Reimplemented from simplified_parser_processor.

◆ before_path()

grouped_parser_processor::before_path ( $path)
inherited

The parser fires this each time one path is going to be parsed.

Parameters
string$pathxml path which parsing has started

Reimplemented from simplified_parser_processor.

◆ dispatch_chunk()

restore_questions_parser_processor::dispatch_chunk ( $data)
protected

Get the already simplified chunk and dispatch it.

Reimplemented from simplified_parser_processor.

◆ generate_question_identity_hash()

static restore_questions_parser_processor::generate_question_identity_hash ( stdClass $questiondata,
?backup_xml_transformer $transformer = null )
static

Given a data structure containing the data for a question, reduce it to a flat array and return a sha1 hash of the data.

Parameters
stdClass$questiondataAn array containing all the data for a question, including hints and qtype plugin data.
?backup_xml_transformer$transformerIf provided, run the backup transformer process on all text fields. This ensures that values from the database are compared like-for-like with encoded values from the backup.
Return values
stringA sha1 hash of all question data, normalised and concatenated together.

◆ get_parent_path()

grouped_parser_processor::get_parent_path ( $path)
protectedinherited

Get the parent path using a local cache for performance.

Parameters
$pathstring The pathname you wish to obtain the parent name for.
Return values
stringThe parent pathname.

◆ get_qtype_restore()

static restore_questions_parser_processor::get_qtype_restore ( string $qtype)
staticprotected

Load and instantiate the restore class for the given question type.

If there is no restore class, null is returned.

Parameters
string$qtypeThe question type name (no qtype_ prefix)
Return values
?restore_qtype_plugin

◆ notify_path_end()

restore_questions_parser_processor::notify_path_end ( $path)
protected

Get one selected path and notify about end.

Reimplemented from simplified_parser_processor.

◆ notify_path_start()

restore_questions_parser_processor::notify_path_start ( $path)
protected

Get one selected path and notify about start.

Reimplemented from simplified_parser_processor.

◆ postprocess_chunk()

grouped_parser_processor::postprocess_chunk ( $data)
protectedinherited

Override this method so grouping will be happening here also deciding between accumulating/dispatching.

Reimplemented from simplified_parser_processor.

Reimplemented in restore_structure_parser_processor.

◆ process_cdata()

restore_questions_parser_processor::process_cdata ( $cdata)

Provide NULL decoding.

Reimplemented from progressive_parser_processor.

◆ process_chunk()

simplified_parser_processor::process_chunk ( $data)
inherited

Get one chunk of parsed data and make it simpler adding attributes as tags and delegating to dispatch_chunk() the procesing of the resulting chunk.

Reimplemented from progressive_parser_processor.

◆ process_pending_startend_notifications()

simplified_parser_processor::process_pending_startend_notifications ( $path,
$action )
protectedinherited

Adjust start/end til finding one match start/end path (included)

This will trigger all the pending {

See also
notify_path_start} and {
notify_path_end} calls for one given path and action
Parameters
stringpath the path to look for as limit
stringaction the action to look for as limit

Member Data Documentation

◆ $lastcatid

int int restore_questions_parser_processor::$lastcatid
protected

during the restore, this tracks the last category we saw.

Any questions we see will be in here.

◆ QUESTION_SUBPATH

string const restore_questions_parser_processor::QUESTION_SUBPATH
protected
Initial value:
=
'/question_bank_entries/question_bank_entry/question_version/question_versions/questions/question'

XML path in the questions.xml to question elements within question_category (Moodle 4.0+).


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