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

Processor class. More...

Public Member Functions

 __construct (csv_import_reader $cir, array $options, array $defaults=array())
 Constructor.
 
 execute ($tracker=null)
 Execute the process.
 
 get_errors ()
 Return the errors.
 
 preview ($rows=10, $tracker=null)
 Return a preview of the import.
 
 reset ()
 Reset the current process.
 

Public Attributes

const MODE_CREATE_ALL = 2
 Create all courses, appending a suffix to the shortname if the course exists.
 
const MODE_CREATE_NEW = 1
 Create courses that do not exist yet.
 
const MODE_CREATE_OR_UPDATE = 3
 Create courses, and update the ones that already exist.
 
const MODE_UPDATE_ONLY = 4
 Only update existing courses.
 
const UPDATE_ALL_WITH_DATA_ONLY = 1
 During update, only use data passed from the CSV.
 
const UPDATE_ALL_WITH_DATA_OR_DEFAUTLS = 2
 During update, use either data from the CSV, or defaults.
 
const UPDATE_MISSING_WITH_DATA_OR_DEFAUTLS = 3
 During update, update missing values from either data from the CSV, or defaults.
 
const UPDATE_NOTHING = 0
 During update, do not update anything... O_o Huh?!
 

Protected Member Functions

 get_course ($data)
 Return a course import object.
 
 get_restore_content_dir ()
 Get the directory of the object to restore.
 
 log_error ($errors)
 Log errors on the current line.
 
 parse_line ($line)
 Parse a line to return an array(column => value)
 
 validate ()
 Validation.
 

Protected Attributes

bool $allowdeletes = false
 are deletes allowed.
 
bool $allowrenames = false
 are renames allowed.
 
bool $allowresets = false
 are resets allowed.
 
csv_import_reader $cir
 
array $columns = array()
 CSV columns.
 
array $defaults = array()
 default values.
 
array $errors = array()
 of errors where the key is the line number.
 
int $linenb = 0
 line number.
 
int $mode
 processor mode.
 
bool $processstarted = false
 whether the process has been started or not.
 
string $reset
 reset courses after processing them.
 
string $restorefile
 path to a restore file.
 
string $shortnametemplate
 template to generate a course shortname.
 
string $templatecourse
 shortname of the course to be restored.
 
int $updatemode
 upload mode.
 

Detailed Description

Processor class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_uploadcourse_processor::__construct ( csv_import_reader $cir,
array $options,
array $defaults = array() )

Constructor.

Parameters
csv_import_reader$cirimport reader object
array$optionsoptions of the process
array$defaultsdefault data value

Member Function Documentation

◆ execute()

tool_uploadcourse_processor::execute ( $tracker = null)

Execute the process.

Parameters
object$trackerthe output tracker to use.
Return values
void

◆ get_course()

tool_uploadcourse_processor::get_course ( $data)
protected

Return a course import object.

Parameters
array$datadata to import the course with.
Return values
tool_uploadcourse_course

◆ get_errors()

tool_uploadcourse_processor::get_errors ( )

Return the errors.

Return values
array

◆ get_restore_content_dir()

tool_uploadcourse_processor::get_restore_content_dir ( )
protected

Get the directory of the object to restore.

Return values
stringsubdirectory in $CFG->backuptempdir/...

◆ log_error()

tool_uploadcourse_processor::log_error ( $errors)
protected

Log errors on the current line.

Parameters
array$errorsarray of errors
Return values
void

◆ parse_line()

tool_uploadcourse_processor::parse_line ( $line)
protected

Parse a line to return an array(column => value)

Parameters
array$linereturned by csv_import_reader
Return values
array

◆ preview()

tool_uploadcourse_processor::preview ( $rows = 10,
$tracker = null )

Return a preview of the import.

This only returns passed data, along with the errors.

Parameters
integer$rowsnumber of rows to preview.
object$trackerthe output tracker to use.
Return values
arrayof preview data.

◆ reset()

tool_uploadcourse_processor::reset ( )

Reset the current process.

Return values
void.

◆ validate()

tool_uploadcourse_processor::validate ( )
protected

Validation.

Return values
void

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