Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
tool_uploadcourse_course Class Reference

Course class. More...

Public Member Functions

 __construct ($mode, $updatemode, $rawdata, $defaults=array(), $importoptions=array())
 Constructor. More...
 
 can_create ()
 Does the mode allow for course creation? More...
 
 can_delete ()
 Does the mode allow for course deletion? More...
 
 can_only_create ()
 Does the mode only allow for course creation? More...
 
 can_rename ()
 Does the mode allow for course rename? More...
 
 can_reset ()
 Does the mode allow for course reset? More...
 
 can_update ()
 Does the mode allow for course update? More...
 
 can_use_defaults ()
 Can we use default values? More...
 
 get_data ()
 Return the data that will be used upon saving. More...
 
 get_errors ()
 Return the errors found during preparation. More...
 
 get_id ()
 Return the ID of the processed course. More...
 
 get_statuses ()
 Return the errors found during preparation. More...
 
 has_errors ()
 Return whether there were errors with this course. More...
 
 prepare ()
 Validates and prepares the data. More...
 
 proceed ()
 Proceed with the import of the course. More...
 

Public Attributes

const DO_CREATE = 1
 Outcome of the process: creating the course.
 
const DO_DELETE = 3
 Outcome of the process: deleting the course.
 
const DO_UPDATE = 2
 Outcome of the process: updating the course.
 

Protected Member Functions

 delete ()
 Delete the current course. More...
 
 error ($code, lang_string $message)
 Log an error. More...
 
 exists ($shortname=null)
 Return whether the course exists or not. More...
 
 get_final_create_data ($data)
 Assemble the course data based on defaults. More...
 
 get_final_update_data ($data, $usedefaults=false, $missingonly=false)
 Assemble the course data based on defaults. More...
 
 get_restore_content_dir ()
 Get the directory of the object to restore. More...
 
 get_valid_fields ()
 Return array of valid fields for default values. More...
 
 process_enrolment_data ($course)
 Add the enrolment data for the course. More...
 
 reset ($course)
 Reset the current course. More...
 
 status ($code, lang_string $message)
 Log a status. More...
 

Protected Attributes

array $data = array()
 final import data.
 
array $defaults = array()
 default values.
 
int $do
 constant value of self::DO_*, what to do with that course
 
array $enrolmentdata
 enrolment data.
 
array $errors = array()
 errors.
 
int $id
 the ID of the course that had been processed.
 
array $importoptions = array()
 containing options passed from the processor.
 
int $mode
 import mode. More...
 
array $options = array()
 course import options.
 
bool $prepared = false
 set to true once we have prepared the course
 
bool $processstarted = false
 set to true once we have started the process of the course
 
array $rawdata = array()
 course import data.
 
array $restoredata
 restore directory.
 
string $shortname
 course shortname.
 
array $statuses = array()
 errors.
 
int $updatemode
 update mode. More...
 

Static Protected Attributes

static array $importoptionsdefaults
 options determining what can or cannot be done at an import level. More...
 
static array $mandatoryfields = array('fullname', 'category')
 fields required on course creation.
 
static array $optionfields
 fields which are considered as options. More...
 
static array $validfields
 fields allowed as course data. More...
 

Detailed Description

Course class.

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

Constructor & Destructor Documentation

◆ __construct()

tool_uploadcourse_course::__construct (   $mode,
  $updatemode,
  $rawdata,
  $defaults = array(),
  $importoptions = array() 
)

Constructor.

Parameters
int$modeimport mode, constant matching tool_uploadcourse_processor::MODE_*
int$updatemodeupdate mode, constant matching tool_uploadcourse_processor::UPDATE_*
array$rawdataraw course data.
array$defaultsdefault course data.
array$importoptionsimport options.

Member Function Documentation

◆ can_create()

tool_uploadcourse_course::can_create ( )

Does the mode allow for course creation?

Return values
bool

◆ can_delete()

tool_uploadcourse_course::can_delete ( )

Does the mode allow for course deletion?

Return values
bool

◆ can_only_create()

tool_uploadcourse_course::can_only_create ( )

Does the mode only allow for course creation?

Return values
bool

◆ can_rename()

tool_uploadcourse_course::can_rename ( )

Does the mode allow for course rename?

Return values
bool

◆ can_reset()

tool_uploadcourse_course::can_reset ( )

Does the mode allow for course reset?

Return values
bool

◆ can_update()

tool_uploadcourse_course::can_update ( )

Does the mode allow for course update?

Return values
bool

◆ can_use_defaults()

tool_uploadcourse_course::can_use_defaults ( )

Can we use default values?

Return values
bool

◆ delete()

tool_uploadcourse_course::delete ( )
protected

Delete the current course.

Return values
bool

◆ error()

tool_uploadcourse_course::error (   $code,
lang_string  $message 
)
protected

Log an error.

Parameters
string$codeerror code.
lang_string$messageerror message.
Return values
void

◆ exists()

tool_uploadcourse_course::exists (   $shortname = null)
protected

Return whether the course exists or not.

Parameters
string$shortnamethe shortname to use to check if the course exists. Falls back on $this->shortname if empty.
Return values
bool

◆ get_data()

tool_uploadcourse_course::get_data ( )

Return the data that will be used upon saving.

Return values
null|array

◆ get_errors()

tool_uploadcourse_course::get_errors ( )

Return the errors found during preparation.

Return values
array

◆ get_final_create_data()

tool_uploadcourse_course::get_final_create_data (   $data)
protected

Assemble the course data based on defaults.

This returns the final data to be passed to create_course().

Parameters
array$datacurrent data.
Return values
array

◆ get_final_update_data()

tool_uploadcourse_course::get_final_update_data (   $data,
  $usedefaults = false,
  $missingonly = false 
)
protected

Assemble the course data based on defaults.

This returns the final data to be passed to update_course().

Parameters
array$datacurrent data.
bool$usedefaultsare defaults allowed?
bool$missingonlyignore fields which are already set.
Return values
array

◆ get_id()

tool_uploadcourse_course::get_id ( )

Return the ID of the processed course.

Return values
int|null

◆ get_restore_content_dir()

tool_uploadcourse_course::get_restore_content_dir ( )
protected

Get the directory of the object to restore.

Return values
string|false|nullsubdirectory in $CFG->backuptempdir/..., false when an error occured and null when there is simply nothing.

◆ get_statuses()

tool_uploadcourse_course::get_statuses ( )

Return the errors found during preparation.

Return values
array

◆ get_valid_fields()

tool_uploadcourse_course::get_valid_fields ( )
protected

Return array of valid fields for default values.

Return values
array

◆ has_errors()

tool_uploadcourse_course::has_errors ( )

Return whether there were errors with this course.

Return values
boolean

◆ prepare()

tool_uploadcourse_course::prepare ( )

Validates and prepares the data.

Return values
boolfalse is any error occured.

◆ proceed()

tool_uploadcourse_course::proceed ( )

Proceed with the import of the course.

Return values
void

◆ process_enrolment_data()

tool_uploadcourse_course::process_enrolment_data (   $course)
protected

Add the enrolment data for the course.

Parameters
object$coursecourse record.
Return values
void

◆ reset()

tool_uploadcourse_course::reset (   $course)
protected

Reset the current course.

This does not reset any of the content of the activities.

Parameters
stdClass$coursethe course object of the course to reset.
Return values
arraystatus array of array component, item, error.

◆ status()

tool_uploadcourse_course::status (   $code,
lang_string  $message 
)
protected

Log a status.

Parameters
string$codestatus code.
lang_string$messagestatus message.
Return values
void

Member Data Documentation

◆ $importoptionsdefaults

array tool_uploadcourse_course::$importoptionsdefaults
staticprotected
Initial value:
= array('canrename' => false, 'candelete' => false, 'canreset' => false,
'reset' => false, 'restoredir' => null, 'shortnametemplate' => null)

options determining what can or cannot be done at an import level.

◆ $mode

int tool_uploadcourse_course::$mode
protected

import mode.

Matches tool_uploadcourse_processor::MODE_*

◆ $optionfields

array tool_uploadcourse_course::$optionfields
staticprotected
Initial value:
= array('delete' => false, 'rename' => null, 'backupfile' => null,
'templatecourse' => null, 'reset' => false)

fields which are considered as options.

◆ $updatemode

int tool_uploadcourse_course::$updatemode
protected

update mode.

Matches tool_uploadcourse_processor::UPDATE_*

◆ $validfields

array tool_uploadcourse_course::$validfields
staticprotected
Initial value:
= array('fullname', 'shortname', 'idnumber', 'category', 'visible', 'startdate', 'enddate',
'summary', 'format', 'theme', 'lang', 'newsitems', 'showgrades', 'showreports', 'legacyfiles', 'maxbytes',
'groupmode', 'groupmodeforce', 'enablecompletion')

fields allowed as course data.


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