Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
mod_qbank\task\transfer_question_categories Class Reference
Inheritance diagram for mod_qbank\task\transfer_question_categories:
core\task\adhoc_task core\task\task_base

Public Member Functions

 execute ()
 Do the job.
 
 fix_wrong_parents ()
 Fix the context of child categories whose contextid does not match that of their parents.
 
 get_attempts_available ()
 Get the remaining attempts of the task.
 
 get_categories_in_a_different_context_to_their_parent ()
 Get question categories that are in a different context to their parent.
 
 get_component ()
 Getter for $component.
 
 get_concurrency_limit ()
 Returns effective concurrency limit for this task.
 
 get_cron_lock ()
 Get the current lock for the entire cron.
 
 get_custom_data ()
 Getter for $customdata.
 
 get_custom_data_as_string ()
 Alternate getter for $customdata.
 
 get_fail_delay ()
 Getter for $faildelay.
 
 get_hostname ()
 Getter for $hostname.
 
 get_id ()
 Getter for $id.
 
 get_lock ()
 Get the current lock for this task.
 
 get_name ()
 Provide default implementation of the task name for backward compatibility.
 
 get_next_run_time ()
 Get the next run time for this task.
 
 get_pid ()
 Getter for $pid.
 
 get_runtime ()
 Returns task runtime.
 
 get_runtime_result ()
 Returns if the task has been running for too long.
 
 get_timestarted ()
 Getter for $timestarted.
 
 get_userid ()
 Getter for $userid.
 
replacement is_blocking ()
 
 is_component_enabled ()
 Informs whether the task's component is enabled.
 
 move_category_and_its_children (int $categoryid, int $newcontextid)
 Set the contextid of category $categoryid and all its children to $newcontextid.
 
 release_concurrency_lock ()
 Release the concurrency lock for this task type.
 
 retry_until_success ()
 Used to indicate if the task should be re-run if it fails.
 
 set_attempts_available (int $attemptsavailable)
 Set the remaining attempts of the task.
 
replacement set_blocking ()
 
 set_component ($component)
 Setter for $component.
 
 set_concurrency_lock (\core\lock\lock $lock)
 Sets concurrency task lock.
 
 set_cron_lock (\core\lock\lock $lock)
 Set the current lock for the entire cron process.
 
 set_custom_data ($customdata)
 Setter for $customdata.
 
 set_custom_data_as_string ($customdata)
 Alternate setter for $customdata.
 
 set_fail_delay ($faildelay)
 Setter for $faildelay.
 
 set_hostname ($hostname=null)
 Setter for $hostname.
 
 set_id ($id)
 Setter for $id.
 
 set_lock (\core\lock\lock $lock)
 Set the current lock for this task.
 
 set_next_run_time ($nextruntime)
 Set the next run time for this task.
 
 set_pid ($pid=null)
 Setter for $pid.
 
 set_timestarted ($timestarted=null)
 Setter for $timestarted.
 
 set_userid ($userid)
 Setter for $userid.
 

Public Attributes

replacement : null
 
replacement : null
 
replacement final: true
 
replacement mdl: '<a class="el" href="https: reason: 'Blocking tasks are no longer supported'
 
replacement since: '4.4'
 

Protected Member Functions

 create_course (core_course_category $coursecategory, string $shortname)
 Wrapper for create_course.
 
 get_default_concurrency_limit ()
 Returns default concurrency limit for this task.
 
 get_top_category_id_for_context (int $contextid)
 Find the Top category for a context, if there is one.
 
 move_question_category (stdClass $oldtopcategory, context $newcontext)
 Create a new 'Top' category in our new context and move the old categories descendents beneath it.
 
 question_category_is_empty (int $categoryid)
 Recursively check if a question category or its children contain any questions.
 

Member Function Documentation

◆ create_course()

mod_qbank\task\transfer_question_categories::create_course ( core_course_category $coursecategory,
string $shortname )
protected

Wrapper for create_course.

Parameters
core_course_category$coursecategory
string$shortname
Return values
stdClass

◆ execute()

mod_qbank\task\transfer_question_categories::execute ( )

Do the job.

Throw exceptions on errors (the job will be retried).

Reimplemented from core\task\task_base.

◆ fix_wrong_parents()

mod_qbank\task\transfer_question_categories::fix_wrong_parents ( )

Fix the context of child categories whose contextid does not match that of their parents.

Fix here means:

  • if the child category's context exists, and has a 'Top' category, we move the child category to be just under that Top category. That is where they would have appeared before, e.g. in the return from question_categorylist().
  • if the child category points to a context that does not exist at all, then we instead change its context to be the same as it's parent's context. This may break things like images in the question text of questions there, but there is no real alternative.

This is necessary because, due to old bugs, for example in backup and restoree code, we know there can be question categories in the databases of old Moodle sites with the wrong context id.

◆ get_attempts_available()

core\task\adhoc_task::get_attempts_available ( )
inherited

Get the remaining attempts of the task.

Return values
intNumber of the remaining attempts of the task.

◆ get_categories_in_a_different_context_to_their_parent()

mod_qbank\task\transfer_question_categories::get_categories_in_a_different_context_to_their_parent ( )

Get question categories that are in a different context to their parent.

Return values
int[]child category id => context id of the child category.

◆ get_component()

core\task\task_base::get_component ( )
inherited

Getter for $component.

Return values
string

◆ get_concurrency_limit()

core\task\adhoc_task::get_concurrency_limit ( )
finalinherited

Returns effective concurrency limit for this task.

Return values
inteffective concurrency limit for this task

◆ get_cron_lock()

core\task\task_base::get_cron_lock ( )
inherited

Get the current lock for the entire cron.

Return values
core\lock\lock

◆ get_custom_data()

core\task\adhoc_task::get_custom_data ( )
inherited

Getter for $customdata.

Return values
mixed(anything that can be handled by json_decode).

◆ get_custom_data_as_string()

core\task\adhoc_task::get_custom_data_as_string ( )
inherited

Alternate getter for $customdata.

Return values
stringthis is the raw json encoded version.

◆ get_default_concurrency_limit()

core\task\adhoc_task::get_default_concurrency_limit ( )
protectedinherited

Returns default concurrency limit for this task.

Return values
intdefault concurrency limit

◆ get_fail_delay()

core\task\task_base::get_fail_delay ( )
inherited

Getter for $faildelay.

Return values
int

◆ get_hostname()

core\task\task_base::get_hostname ( )
inherited

Getter for $hostname.

Return values
string

◆ get_id()

core\task\adhoc_task::get_id ( )
inherited

Getter for $id.

Return values
int|null#$id

◆ get_lock()

core\task\task_base::get_lock ( )
inherited

Get the current lock for this task.

Return values
core\lock\lock

◆ get_name()

core\task\adhoc_task::get_name ( )
inherited

Provide default implementation of the task name for backward compatibility.

Extending classes are expected to implement this method to provide a descriptive name for the task (shown to admins)

Return values
string

Reimplemented from core\task\task_base.

Reimplemented in core\task\badges_adhoc_task, core_reportbuilder\task\send_schedule, and quiz_statistics\task\recalculate.

◆ get_next_run_time()

core\task\task_base::get_next_run_time ( )
inherited

Get the next run time for this task.

Return values
inttimestamp

◆ get_pid()

core\task\task_base::get_pid ( )
inherited

Getter for $pid.

Return values
int

◆ get_runtime()

core\task\task_base::get_runtime ( )
inherited

Returns task runtime.

Return values
int

◆ get_runtime_result()

core\task\task_base::get_runtime_result ( )
inherited

Returns if the task has been running for too long.

Return values
result

◆ get_timestarted()

core\task\task_base::get_timestarted ( )
inherited

Getter for $timestarted.

Return values
int

◆ get_top_category_id_for_context()

mod_qbank\task\transfer_question_categories::get_top_category_id_for_context ( int $contextid)
protected

Find the Top category for a context, if there is one.

Parameters
int$contextidthe id of a context (which might not exist).
Return values
inta Top category id, or 0 if none is found.

◆ get_userid()

core\task\adhoc_task::get_userid ( )
inherited

Getter for $userid.

Return values
int|null#$userid

◆ is_component_enabled()

core\task\task_base::is_component_enabled ( )
inherited

Informs whether the task's component is enabled.

Return values
booltrue when enabled. false otherwise.

◆ move_category_and_its_children()

mod_qbank\task\transfer_question_categories::move_category_and_its_children ( int $categoryid,
int $newcontextid )

Set the contextid of category $categoryid and all its children to $newcontextid.

Parameters
int$categoryida question_category id.
int$newcontextidthe place to move to.

◆ move_question_category()

mod_qbank\task\transfer_question_categories::move_question_category ( stdClass $oldtopcategory,
context $newcontext )
protected

Create a new 'Top' category in our new context and move the old categories descendents beneath it.

Parameters
stdClass$oldtopcategoryThe old 'Top' category that we are moving.
context$newcontextThe context we are moving our category to.
Return values
void

◆ question_category_is_empty()

mod_qbank\task\transfer_question_categories::question_category_is_empty ( int $categoryid)
protected

Recursively check if a question category or its children contain any questions.

Parameters
int$categoryidThe parent category to check from.
Return values
boolTrue if neither the category nor its children contain any questions.

◆ retry_until_success()

core\task\adhoc_task::retry_until_success ( )
inherited

Used to indicate if the task should be re-run if it fails.

By default, tasks will be retried until they succeed, other tasks can override this method to change this behaviour.

Return values
booltrue if the task should be retried until it succeeds, false otherwise.

Reimplemented in core\task\asynchronous_restore_task, and core_course\task\course_delete_modules.

◆ set_attempts_available()

core\task\adhoc_task::set_attempts_available ( int $attemptsavailable)
inherited

Set the remaining attempts of the task.

Parameters
int$attemptsavailableNumber of the remaining attempts of the task.

◆ set_component()

core\task\task_base::set_component ( $component)
inherited

Setter for $component.

Parameters
string$component

◆ set_concurrency_lock()

core\task\adhoc_task::set_concurrency_lock ( \core\lock\lock $lock)
finalinherited

Sets concurrency task lock.

Parameters
core\lock\lock$lockconcurrency lock to be set

◆ set_cron_lock()

core\task\task_base::set_cron_lock ( \core\lock\lock $lock)
inherited

Set the current lock for the entire cron process.

Parameters
core\lock\lock$lock

◆ set_custom_data()

core\task\adhoc_task::set_custom_data ( $customdata)
inherited

Setter for $customdata.

Parameters
mixed$customdata(anything that can be handled by json_encode)

◆ set_custom_data_as_string()

core\task\adhoc_task::set_custom_data_as_string ( $customdata)
inherited

Alternate setter for $customdata.

Expects the data as a json_encoded string.

Parameters
string$customdatajson_encoded string

◆ set_fail_delay()

core\task\task_base::set_fail_delay ( $faildelay)
inherited

Setter for $faildelay.

Parameters
int$faildelay

◆ set_hostname()

core\task\task_base::set_hostname ( $hostname = null)
inherited

Setter for $hostname.

Parameters
string$hostname

◆ set_id()

core\task\adhoc_task::set_id ( $id)
inherited

Setter for $id.

Parameters
int | null$id

◆ set_lock()

core\task\task_base::set_lock ( \core\lock\lock $lock)
inherited

Set the current lock for this task.

Parameters
core\lock\lock$lock

◆ set_next_run_time()

core\task\task_base::set_next_run_time ( $nextruntime)
inherited

Set the next run time for this task.

Parameters
int$nextruntime

◆ set_pid()

core\task\task_base::set_pid ( $pid = null)
inherited

Setter for $pid.

Parameters
int$pid

◆ set_timestarted()

core\task\task_base::set_timestarted ( $timestarted = null)
inherited

Setter for $timestarted.

Parameters
int$timestarted

◆ set_userid()

core\task\adhoc_task::set_userid ( $userid)
inherited

Setter for $userid.

Parameters
int | null$userid

Member Data Documentation

◆ __pad0__

replacement core\task\task_base::__pad0__
inherited
Deprecated
since Moodle 4.4 See MDL-67667

◆ __pad1__

replacement core\task\task_base::__pad1__
inherited
Deprecated
since Moodle 4.4 See MDL-67667

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