Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
moodle1_gradebook_handler Class Reference

Handles the conversion of the gradebook structures in the moodle.xml file. More...

Inheritance diagram for moodle1_gradebook_handler:
moodle1_xml_handler moodle1_handler loggable

Public Member Functions

 get_converter ()
 
 get_paths ()
 Registers paths.
 
 log ($message, $level, $a=null, $depth=null, $display=false)
 This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.
 
 on_gradebook_end ()
 Writes the collected information into gradebook.xml.
 
 on_gradebook_grade_item_grades_start ()
 
 on_gradebook_start ()
 Initializes the in-memory structures.
 
 process_gradebook_grade_category (array $data, array $raw)
 Processes one GRADE_CATEGORY data.
 
 process_gradebook_grade_item (array $data, array $raw)
 Processes one GRADE_ITEM data.
 
 process_gradebook_grade_letter (array $data, array $raw)
 Processes one GRADE_LETTER data.
 

Protected Member Functions

 calculate_category_path ($categoryid)
 Calculates the path to the grade_category.
 
 close_xml_writer ()
 Close the XML writer.
 
 has_xml_writer ()
 Checks if the XML writer has been opened by self::open_xml_writer().
 
 make_sure_xml_exists ($filename, $rootelement=false, $content=array())
 Makes sure that a new XML file exists, or creates it itself.
 
 open_xml_writer ($filename)
 Opens the XML writer - after calling, one is free to use $xmlwriter.
 
 process_mod_grade_item (array $data, array $raw)
 Processes one GRADE_ITEM of the type 'mod'.
 
 process_nonmod_grade_item (array $data, array $raw)
 Processes one GRADE_ITEM of te type 'manual' or 'course' or 'category'.
 
 write_grade_categories ()
 Writes grade_categories.
 
 write_grade_items ()
 Writes grade_items.
 
 write_grade_letters ()
 Writes grade_letters.
 
 write_xml ($element, array $data, array $attribs=array(), $parent='/')
 Writes the given XML tree data into the currently opened file.
 

Protected Attributes

array $categoryparent = array()
 of (int)gradecategoryid => (int|null)parentcategoryid
 
moodle1_converter $converter
 
null string $xmlfilename
 the name of file we are writing to
 
null xml_writer $xmlwriter
 

Detailed Description

Handles the conversion of the gradebook structures in the moodle.xml file.

Member Function Documentation

◆ calculate_category_path()

moodle1_gradebook_handler::calculate_category_path ( $categoryid)
protected

Calculates the path to the grade_category.

Moodle 1.9 backup does not store the grade_category's depth and path. This method is used to repopulate this information using the $this->categoryparent values.

Parameters
int$categoryid
Return values
arrayof ids including the categoryid

◆ close_xml_writer()

moodle1_xml_handler::close_xml_writer ( )
protectedinherited

Close the XML writer.

At the moment, the caller must close all tags before calling

Return values
void

Reimplemented in moodle1_qtype_handler.

◆ get_converter()

moodle1_handler::get_converter ( )
inherited
Return values
moodle1_converterthe converter that required this handler

◆ has_xml_writer()

moodle1_xml_handler::has_xml_writer ( )
protectedinherited

Checks if the XML writer has been opened by self::open_xml_writer().

Return values
bool

◆ log()

moodle1_handler::log ( $message,
$level,
$a = null,
$depth = null,
$display = false )
inherited

This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.

Implements loggable.

◆ make_sure_xml_exists()

moodle1_xml_handler::make_sure_xml_exists ( $filename,
$rootelement = false,
$content = array() )
protectedinherited

Makes sure that a new XML file exists, or creates it itself.

This is here so we can check that all XML files that the restore process relies on have been created by an executed handler. If the file is not found, this method can create it using the given $rootelement as an empty root container in the file.

Parameters
string$filenamerelative file name like 'course/course.xml'
string | bool$rootelementroot element to use, false to not create the file
array$contentcontent of the root element
Return values
booltrue is the file existed, false if it did not

◆ on_gradebook_grade_item_grades_start()

moodle1_gradebook_handler::on_gradebook_grade_item_grades_start ( )

◆ on_gradebook_start()

moodle1_gradebook_handler::on_gradebook_start ( )

Initializes the in-memory structures.

This should not be needed actually as the moodle.xml contains just one GRADEBOOK element. But who knows - maybe someone will want to write a mass conversion tool in the future (not me definitely ;-)

◆ open_xml_writer()

moodle1_xml_handler::open_xml_writer ( $filename)
protectedinherited

Opens the XML writer - after calling, one is free to use $xmlwriter.

Parameters
string$filenameXML file name to write into
Return values
void

Reimplemented in moodle1_qtype_handler.

◆ process_gradebook_grade_letter()

moodle1_gradebook_handler::process_gradebook_grade_letter ( array $data,
array $raw )

Processes one GRADE_LETTER data.

In Moodle 1.9, all grade_letters are from course context only. Therefore we put them here.

◆ write_xml()

moodle1_xml_handler::write_xml ( $element,
array $data,
array $attribs = array(),
$parent = '/' )
protectedinherited

Writes the given XML tree data into the currently opened file.

Parameters
string$elementthe name of the root element of the tree
array$datathe associative array of data to write
array$attribslist of additional fields written as attributes instead of nested elements
string$parentused internally during the recursion, do not set yourself

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