Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
  • Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 37 and 311] [Versions 38 and 311] [Versions 39 and 311]

    Defines various restore steps that will be used by common tasks in restore

    Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
    License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
    File Size: 6139 lines (255 kb)
    Included or required:0 times
    Referenced: 1 time
    Includes or requires: 0 files

    Defines 59 classes

    restore_create_and_clean_temp_stuff:: (1 method):
      define_execution()

    restore_drop_and_clean_temp_stuff:: (1 method):
      define_execution()

    restore_gradebook_structure_step:: (12 methods):
      execute_condition()
      define_structure()
      process_attributes()
      process_grade_item()
      process_grade_grade()
      process_grade_category()
      process_grade_letter()
      process_grade_setting()
      after_execute()
      gradebook_calculation_freeze()
      check_minmaxtouse()
      rewrite_step_backup_file_for_legacy_freeze()

    restore_grade_history_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_grade_grade()

    restore_decode_interlinks:: (1 method):
      define_execution()

    restore_rebuild_course_cache:: (1 method):
      define_execution()

    restore_execute_after_restore:: (1 method):
      define_execution()

    restore_review_pending_block_positions:: (1 method):
      define_execution()

    restore_update_availability:: (1 method):
      define_execution()

    restore_process_course_modules_availability:: (1 method):
      define_execution()

    restore_load_included_inforef_records:: (1 method):
      define_execution()

    restore_load_included_files:: (2 methods):
      define_structure()
      process_file()

    restore_load_and_map_roles:: (1 method):
      define_execution()

    restore_load_included_users:: (1 method):
      define_execution()

    restore_process_included_users:: (1 method):
      define_execution()

    restore_create_included_users:: (1 method):
      define_execution()

    restore_groups_structure_step:: (5 methods):
      define_structure()
      process_group()
      process_grouping()
      process_grouping_group()
      after_execute()

    restore_groups_members_structure_step:: (3 methods):
      define_structure()
      process_group()
      process_member()

    restore_scales_structure_step:: (3 methods):
      define_structure()
      process_scale()
      after_execute()

    restore_outcomes_structure_step:: (3 methods):
      define_structure()
      process_outcome()
      after_execute()

    restore_load_categories_and_questions:: (1 method):
      define_execution()

    restore_process_categories_and_questions:: (1 method):
      define_execution()

    restore_section_structure_step:: (7 methods):
      reset_caches()
      define_structure()
      process_section()
      process_availability()
      process_availability_field()
      process_course_format_options()
      after_execute()

    restore_course_structure_step:: (8 methods):
      define_structure()
      process_course()
      process_category()
      process_tag()
      process_customfield()
      process_course_format_option()
      process_allowed_module()
      after_execute()

    restore_course_legacy_files_step:: (1 method):
      define_execution()

    restore_ras_and_caps_structure_step:: (3 methods):
      define_structure()
      process_assignment()
      process_override()

    restore_default_enrolments_step:: (1 method):
      define_execution()

    restore_enrolments_structure_step:: (4 methods):
      execute_condition()
      define_structure()
      process_enrol()
      process_enrolment()

    restore_fix_restorer_access_step:: (1 method):
      define_execution()

    restore_filters_structure_step:: (3 methods):
      define_structure()
      process_active()
      process_config()

    restore_comments_structure_step:: (2 methods):
      define_structure()
      process_comment()

    restore_badges_structure_step:: (10 methods):
      execute_condition()
      define_structure()
      process_badge()
      process_endorsement()
      process_relatedbadge()
      process_alignment()
      process_criterion()
      process_parameter()
      process_manual_award()
      after_execute()

    restore_calendarevents_structure_step:: (3 methods):
      define_structure()
      process_calendarevents()
      after_execute()

    restore_course_completion_structure_step:: (6 methods):
      execute_condition()
      define_structure()
      process_course_completion_criteria()
      process_course_completion_crit_compl()
      process_course_completions()
      process_course_completion_aggr_methd()

    restore_course_logs_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_log()

    restore_activity_logs_structure_step:: (1 method):
      process_log()

    restore_course_logstores_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_logstore()

    restore_course_loglastaccess_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_lastaccess()

    restore_activity_logstores_structure_step:: (0 methods):

    restore_course_competencies_structure_step:: (5 methods):
      define_structure()
      process_course_competency_settings()
      process_course_competency()
      process_user_competency_course()
      execute_condition()

    restore_activity_competencies_structure_step:: (3 methods):
      define_structure()
      process_course_module_competency()
      execute_condition()

    restore_activity_grading_structure_step:: (6 methods):
      execute_condition()
      define_structure()
      process_grading_area()
      process_grading_definition()
      process_grading_instance()
      after_execute()

    restore_activity_grades_structure_step:: (6 methods):
      execute_condition()
      define_structure()
      process_grade_item()
      process_grade_grade()
      process_grade_letter()
      after_restore()

    restore_activity_grade_history_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_grade_grade()

    restore_contentbankcontent_structure_step:: (3 methods):
      define_structure()
      process_contentbankcontent()
      after_execute()

    restore_block_instance_structure_step:: (2 methods):
      define_structure()
      process_block()

    restore_module_structure_step:: (6 methods):
      define_structure()
      process_module()
      process_tag()
      process_availability()
      process_availability_field()
      after_restore()

    restore_userscompletion_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_completion()

    restore_activity_structure_step:: (3 methods):
      prepare_activity_structure()
      process_activity()
      apply_activity_instance()

    restore_create_categories_and_questions:: (6 methods):
      define_structure()
      process_question_category()
      process_question()
      process_question_hint()
      process_tag()
      after_execute()

    restore_move_module_questions_categories:: (1 method):
      define_execution()

    restore_create_question_files:: (3 methods):
      define_execution()
      send_common_files()
      send_qtype_files()

    restore_process_file_aliases_queue:: (18 methods):
      define_execution()
      choose_repository()
      notify_success()
      notify_failure()
      describe_alias()
      expected_alias_location()
      add_result_item()
      add_question_usages()
      process_question_usage()
      process_question_attempt()
      process_question_attempt_step()
      restore_question_usage_worker()
      restore_question_attempt_worker()
      restore_question_attempt_step_worker()
      questions_recode_response_data()
      questions_recode_layout()
      get_qtype_restorer()
      after_execute()

    restore_questions_activity_structure_step:: (6 methods):
      add_legacy_question_attempt_data()
      get_attempt_upgrader()
      process_legacy_quiz_attempt_data()
      find_question_session_and_states()
      recode_legacy_response_data()
      restore_recode_legacy_answer()

    restore_completion_defaults_structure_step:: (3 methods):
      execute_condition()
      define_structure()
      process_completion_defaults()

    restore_course_search_index:: (1 method):
      define_execution()

    restore_activity_search_index:: (1 method):
      define_execution()

    restore_block_search_index:: (1 method):
      define_execution()

    restore_calendar_action_events:: (1 method):
      define_execution()


    Class: restore_create_and_clean_temp_stuff  - X-Ref

    delete old directories and conditionally create backup_temp_ids table

    define_execution()   X-Ref
    No description

    Class: restore_drop_and_clean_temp_stuff  - X-Ref

    Drop temp ids table and delete the temp dir used by backup/restore (conditionally).

    define_execution()   X-Ref
    No description

    Class: restore_gradebook_structure_step  - X-Ref

    Restore calculated grade items, grade categories etc

    execute_condition()   X-Ref
    To conditionally decide if this step must be executed
    Note the "settings" conditions are evaluated in the
    corresponding task. Here we check for other conditions
    not being restore settings (files, site settings...)


    define_structure()   X-Ref
    No description

    process_attributes($data)   X-Ref
    No description

    process_grade_item($data)   X-Ref
    No description

    process_grade_grade($data)   X-Ref
    No description

    process_grade_category($data)   X-Ref
    No description

    process_grade_letter($data)   X-Ref
    No description

    process_grade_setting($data)   X-Ref
    No description

    after_execute()   X-Ref
    put all activity grade items in the correct grade category and mark all for recalculation


    gradebook_calculation_freeze()   X-Ref
    Freeze gradebook calculation if needed.

    This is similar to various upgrade scripts that check if the freeze is needed.

    check_minmaxtouse()   X-Ref
    Checks what should happen with the course grade setting minmaxtouse.

    This is related to the upgrade step at the time the setting was added.

    return: void

    rewrite_step_backup_file_for_legacy_freeze($filepath)   X-Ref
    Rewrite step definition to handle the legacy freeze attribute.

    In previous backups the calculations_freeze property was stored as an attribute of the
    top level node <gradebook>. The backup API, however, do not process grandparent nodes.
    It only processes definitive children, and their parent attributes.

    We had:

    <gradebook calculations_freeze="20160511">
    <grade_categories>
    <grade_category id="10">
    <depth>1</depth>
    ...
    </grade_category>
    </grade_categories>
    ...
    </gradebook>

    And this method will convert it to:

    <gradebook >
    <attributes>
    <calculations_freeze>20160511</calculations_freeze>
    </attributes>
    <grade_categories>
    <grade_category id="10">
    <depth>1</depth>
    ...
    </grade_category>
    </grade_categories>
    ...
    </gradebook>

    Note that we cannot just load the XML file in memory as it could potentially be huge.
    We can also completely ignore if the node <attributes> is already in the backup
    file as it never existed before.

    param: string $filepath The absolute path to the XML file.
    return: void

    Class: restore_grade_history_structure_step  - X-Ref

    Step in charge of restoring the grade history of a course.

    The execution conditions are itendical to {@link restore_gradebook_structure_step} because
    we do not want to restore the history if the gradebook and its content has not been
    restored. At least for now.
    execute_condition()   X-Ref
    No description

    define_structure()   X-Ref
    No description

    process_grade_grade($data)   X-Ref
    No description

    Class: restore_decode_interlinks  - X-Ref

    decode all the interlinks present in restored content
    relying 100% in the restore_decode_processor that handles
    both the contents to modify and the rules to be applied

    define_execution()   X-Ref
    No description

    Class: restore_rebuild_course_cache  - X-Ref

    first, ensure that we have no gaps in section numbers
    and then, rebuid the course cache

    define_execution()   X-Ref
    No description

    Class: restore_execute_after_restore  - X-Ref

    Review all the tasks having one after_restore method
    executing it to perform some final adjustments of information
    not available when the task was executed.

    define_execution()   X-Ref
    No description

    Class: restore_review_pending_block_positions  - X-Ref

    Review all the (pending) block positions in backup_ids, matching by
    contextid, creating positions as needed. This is executed by the
    final task, once all the contexts have been created

    define_execution()   X-Ref
    No description

    Class: restore_update_availability  - X-Ref

    Updates the availability data for course modules and sections.

    Runs after the restore of all course modules, sections, and grade items has
    completed. This is necessary in order to update IDs that have changed during
    restore.

    define_execution()   X-Ref
    No description

    Class: restore_process_course_modules_availability  - X-Ref

    Process legacy module availability records in backup_ids.

    Matches course modules and grade item id once all them have been already restored.
    Only if all matchings are satisfied the availability condition will be created.
    At the same time, it is required for the site to have that functionality enabled.

    This step is included only to handle legacy backups (2.6 and before). It does not
    do anything for newer backups.

    define_execution()   X-Ref
    No description

    Class: restore_load_included_files  - X-Ref

    define_structure()   X-Ref
    No description

    process_file($data)   X-Ref
    Process one <file> element from files.xml

    param: array $data the element data

    Class: restore_load_and_map_roles  - X-Ref

    Execution step that, *conditionally* (if there isn't preloaded information),
    will load all the needed roles to backup_temp_ids. They will be stored with
    "role" itemname. Also it will perform one automatic mapping to roles existing
    in the target site, based in permissions of the user performing the restore,
    archetypes and other bits. At the end, each original role will have its associated
    target role or 0 if it's going to be skipped. Note we wrap everything over one
    restore_dbops method, as far as the same stuff is going to be also executed
    by restore prechecks

    define_execution()   X-Ref
    No description

    Class: restore_load_included_users  - X-Ref

    Execution step that, *conditionally* (if there isn't preloaded information
    and users have been selected in settings, will load all the needed users
    to backup_temp_ids. They will be stored with "user" itemname and with
    their original contextid as paremitemid

    define_execution()   X-Ref
    No description

    Class: restore_process_included_users  - X-Ref

    Execution step that, *conditionally* (if there isn't preloaded information
    and users have been selected in settings, will process all the needed users
    in order to decide and perform any action with them (create / map / error)
    Note: Any error will cause exception, as far as this is the same processing
    than the one into restore prechecks (that should have stopped process earlier)

    define_execution()   X-Ref
    No description

    Class: restore_create_included_users  - X-Ref

    Execution step that will create all the needed users as calculated
    by @restore_process_included_users (those having newiteind = 0)

    define_execution()   X-Ref
    No description

    Class: restore_groups_structure_step  - X-Ref

    Structure step that will create all the needed groups and groupings
    by loading them from the groups.xml file performing the required matches.
    Note group members only will be added if restoring user info

    define_structure()   X-Ref
    No description

    process_group($data)   X-Ref
    No description

    process_grouping($data)   X-Ref
    No description

    process_grouping_group($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_groups_members_structure_step  - X-Ref

    Structure step that will create all the needed group memberships
    by loading them from the groups.xml file performing the required matches.

    define_structure()   X-Ref
    No description

    process_group($data)   X-Ref
    No description

    process_member($data)   X-Ref
    No description

    Class: restore_scales_structure_step  - X-Ref

    Structure step that will create all the needed scales
    by loading them from the scales.xml

    define_structure()   X-Ref
    No description

    process_scale($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_outcomes_structure_step  - X-Ref

    Structure step that will create all the needed outocomes
    by loading them from the outcomes.xml

    define_structure()   X-Ref
    No description

    process_outcome($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_load_categories_and_questions  - X-Ref

    Execution step that, *conditionally* (if there isn't preloaded information
    will load all the question categories and questions (header info only)
    to backup_temp_ids. They will be stored with "question_category" and
    "question" itemnames and with their original contextid and question category
    id as paremitemids

    define_execution()   X-Ref
    No description

    Class: restore_process_categories_and_questions  - X-Ref

    Execution step that, *conditionally* (if there isn't preloaded information)
    will process all the needed categories and questions
    in order to decide and perform any action with them (create / map / error)
    Note: Any error will cause exception, as far as this is the same processing
    than the one into restore prechecks (that should have stopped process earlier)

    define_execution()   X-Ref
    No description

    Class: restore_section_structure_step  - X-Ref

    Structure step that will read the section.xml creating/updating sections
    as needed, rebuilding course cache and other friends

    reset_caches()   X-Ref
    Resets a static cache of course formats. Required for unit testing.


    define_structure()   X-Ref
    No description

    process_section($data)   X-Ref
    No description

    process_availability($data)   X-Ref
    Process the legacy availability table record. This table does not exist
    in Moodle 2.7+ but we still support restore.

    param: stdClass $data Record data

    process_availability_field($data)   X-Ref
    Process the legacy availability fields table record. This table does not
    exist in Moodle 2.7+ but we still support restore.

    param: stdClass $data Record data

    process_course_format_options($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_course_structure_step  - X-Ref

    Structure step that will read the course.xml file, loading it and performing
    various actions depending of the site/restore settings. Note that target
    course always exist before arriving here so this step will be updating
    the course record (never inserting)

    define_structure()   X-Ref


    process_course($data)   X-Ref
    Processing functions go here

    param: stdClass $data

    process_category($data)   X-Ref
    No description

    process_tag($data)   X-Ref
    No description

    process_customfield($data)   X-Ref
    Process custom fields

    param: array $data

    process_course_format_option(array $data)   X-Ref
    Processes a course format option.

    param: array $data The record being restored.

    process_allowed_module($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_course_legacy_files_step  - X-Ref

    Execution step that will migrate legacy files if present.

    define_execution()   X-Ref
    No description

    Class: restore_ras_and_caps_structure_step  - X-Ref

    define_structure()   X-Ref
    No description

    process_assignment($data)   X-Ref
    Assign roles

    This has to be called after enrolments processing.

    param: mixed $data
    return: void

    process_override($data)   X-Ref
    No description

    Class: restore_default_enrolments_step  - X-Ref

    If no instances yet add default enrol methods the same way as when creating new course in UI.

    define_execution()   X-Ref
    No description

    Class: restore_enrolments_structure_step  - X-Ref

    This structure steps restores the enrol plugins and their underlying
    enrolments, performing all the mappings and/or movements required

    execute_condition()   X-Ref
    Conditionally decide if this step should be executed.

    This function checks the following parameter:

    1. the course/enrolments.xml file exists

    return: bool true is safe to execute, false otherwise

    define_structure()   X-Ref
    No description

    process_enrol($data)   X-Ref
    Create enrolment instances.

    This has to be called after creation of roles
    and before adding of role assignments.

    param: mixed $data
    return: void

    process_enrolment($data)   X-Ref
    Create user enrolments.

    This has to be called after creation of enrolment instances
    and before adding of role assignments.

    Roles are assigned in restore_ras_and_caps_structure_step::process_assignment() processing afterwards.

    param: mixed $data
    return: void

    Class: restore_fix_restorer_access_step  - X-Ref

    Make sure the user restoring the course can actually access it.

    define_execution()   X-Ref
    No description

    Class: restore_filters_structure_step  - X-Ref

    This structure steps restores the filters and their configs

    define_structure()   X-Ref
    No description

    process_active($data)   X-Ref
    No description

    process_config($data)   X-Ref
    No description

    Class: restore_comments_structure_step  - X-Ref

    This structure steps restores the comments
    Note: Cannot use the comments API because defaults to USER->id.
    That should change allowing to pass $userid

    define_structure()   X-Ref
    No description

    process_comment($data)   X-Ref
    No description

    Class: restore_badges_structure_step  - X-Ref

    This structure steps restores the badges and their configs

    execute_condition()   X-Ref
    Conditionally decide if this step should be executed.

    This function checks the following parameters:

    1. Badges and course badges are enabled on the site.
    2. The course/badges.xml file exists.
    3. All modules are restorable.
    4. All modules are marked for restore.

    return: bool True is safe to execute, false otherwise

    define_structure()   X-Ref
    No description

    process_badge($data)   X-Ref
    No description

    process_endorsement($data)   X-Ref
    Create an endorsement for a badge.

    param: mixed $data
    return: void

    process_relatedbadge($data)   X-Ref
    Link to related badges for a badge. This relies on post processing in after_execute().

    param: mixed $data
    return: void

    process_alignment($data)   X-Ref
    Link to an alignment for a badge.

    param: mixed $data
    return: void

    process_criterion($data)   X-Ref
    No description

    process_parameter($data)   X-Ref
    No description

    process_manual_award($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_calendarevents_structure_step  - X-Ref

    This structure steps restores the calendar events

    define_structure()   X-Ref
    No description

    process_calendarevents($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_course_completion_structure_step  - X-Ref

    execute_condition()   X-Ref
    Conditionally decide if this step should be executed.

    This function checks parameters that are not immediate settings to ensure
    that the enviroment is suitable for the restore of course completion info.

    This function checks the following four parameters:

    1. Course completion is enabled on the site
    2. The backup includes course completion information
    3. All modules are restorable
    4. All modules are marked for restore.
    5. No completion criteria already exist for the course.

    return: bool True is safe to execute, false otherwise

    define_structure()   X-Ref
    Define the course completion structure

    return: array Array of restore_path_element

    process_course_completion_criteria($data)   X-Ref
    Process course completion criteria

    param: stdClass $data

    process_course_completion_crit_compl($data)   X-Ref
    Processes course compltion criteria complete records

    param: stdClass $data

    process_course_completions($data)   X-Ref
    Process course completions

    param: stdClass $data

    process_course_completion_aggr_methd($data)   X-Ref
    Process course completion aggregate methods

    param: stdClass $data

    Class: restore_course_logs_structure_step  - X-Ref

    This structure step restores course logs (cmid = 0), delegating
    the hard work to the corresponding {@link restore_logs_processor} passing the
    collection of {@link restore_log_rule} rules to be observed as they are defined
    by the task. Note this is only executed based in the 'logs' setting.

    NOTE: This is executed by final task, to have all the activities already restored

    NOTE: Not all course logs are being restored. For now only 'course' and 'user'
    records are. There are others like 'calendar' and 'upload' that will be handled
    later.

    NOTE: All the missing actions (not able to be restored) are sent to logs for
    debugging purposes
    execute_condition()   X-Ref
    Conditionally decide if this step should be executed.

    This function checks the following parameter:

    1. the course/logs.xml file exists

    return: bool true is safe to execute, false otherwise

    define_structure()   X-Ref
    No description

    process_log($data)   X-Ref
    No description

    Class: restore_activity_logs_structure_step  - X-Ref

    This structure step restores activity logs, extending {@link restore_course_logs_structure_step}
    sharing its same structure but modifying the way records are handled

    process_log($data)   X-Ref
    No description

    Class: restore_course_logstores_structure_step  - X-Ref

    Structure step in charge of restoring the logstores.xml file for the course logs.

    This restore step will rebuild the logs for all the enabled logstore subplugins supporting
    it, for logs belonging to the course level.
    execute_condition()   X-Ref
    Conditionally decide if this step should be executed.

    This function checks the following parameter:

    1. the logstores.xml file exists

    return: bool true is safe to execute, false otherwise

    define_structure()   X-Ref
    Return the elements to be processed on restore of logstores.

    return: restore_path_element[] array of elements to be processed on restore.

    process_logstore($data)   X-Ref
    Process the 'logstore' element,

    Note: This is empty by definition in backup, because stores do not share any
    data between them, so there is nothing to process here.

    param: array $data element data

    Class: restore_course_loglastaccess_structure_step  - X-Ref

    Structure step in charge of restoring the loglastaccess.xml file for the course logs.

    This restore step will rebuild the table for user_lastaccess table.
    execute_condition()   X-Ref
    Conditionally decide if this step should be executed.

    This function checks the following parameter:

    1. the loglastaccess.xml file exists

    return: bool true is safe to execute, false otherwise

    define_structure()   X-Ref
    Return the elements to be processed on restore of loglastaccess.

    return: restore_path_element[] array of elements to be processed on restore.

    process_lastaccess($data)   X-Ref
    Process the 'lastaccess' elements.

    param: array $data element data

    Class: restore_activity_logstores_structure_step  - X-Ref

    Structure step in charge of restoring the logstores.xml file for the activity logs.

    Note: Activity structure is completely equivalent to the course one, so just extend it.

    Class: restore_course_competencies_structure_step  - X-Ref

    Restore course competencies structure step.

    define_structure()   X-Ref
    Returns the structure.

    return: array

    process_course_competency_settings($data)   X-Ref
    Process a course competency settings.

    param: array $data The data.

    process_course_competency($data)   X-Ref
    Process a course competency.

    param: array $data The data.

    process_user_competency_course($data)   X-Ref
    Process the user competency course.

    param: array $data The data.

    execute_condition()   X-Ref
    Execute conditions.

    return: bool

    Class: restore_activity_competencies_structure_step  - X-Ref

    Restore activity competencies structure step.

    define_structure()   X-Ref
    Defines the structure.

    return: array

    process_course_module_competency($data)   X-Ref
    Process a course module competency.

    param: array $data The data.

    execute_condition()   X-Ref
    Execute conditions.

    return: bool

    Class: restore_activity_grading_structure_step  - X-Ref

    Defines the restore step for advanced grading methods attached to the activity module

    execute_condition()   X-Ref
    This step is executed only if the grading file is present


    define_structure()   X-Ref
    Declares paths in the grading.xml file we are interested in


    process_grading_area($data)   X-Ref
    Processes one grading area element

    param: array $data element data

    process_grading_definition($data)   X-Ref
    Processes one grading definition element

    param: array $data element data

    process_grading_instance($data)   X-Ref
    Processes one grading form instance element

    param: array $data element data

    after_execute()   X-Ref
    Final operations when the database records are inserted


    Class: restore_activity_grades_structure_step  - X-Ref

    This structure step restores the grade items associated with one activity
    All the grade items are made child of the "course" grade item but the original
    categoryid is saved as parentitemid in the backup_ids table, so, when restoring
    the complete gradebook (categories and calculations), that information is
    available there

    execute_condition()   X-Ref
    No grades in front page.

    return: bool

    define_structure()   X-Ref
    No description

    process_grade_item($data)   X-Ref
    No description

    process_grade_grade($data)   X-Ref
    No description

    process_grade_letter($data)   X-Ref
    process activity grade_letters. Note that, while these are possible,
    because grade_letters are contextid based, in practice, only course
    context letters can be defined. So we keep here this method knowing
    it won't be executed ever. gradebook restore will restore course letters.


    after_restore()   X-Ref
    No description

    Class: restore_activity_grade_history_structure_step  - X-Ref

    Step in charge of restoring the grade history of an activity.

    This step is added to the task regardless of the setting 'grade_histories'.
    The reason is to allow for a more flexible step in case the logic needs to be
    split accross different settings to control the history of items and/or grades.
    execute_condition()   X-Ref
    This step is executed only if the grade history file is present.


    define_structure()   X-Ref
    No description

    process_grade_grade($data)   X-Ref
    No description

    Class: restore_contentbankcontent_structure_step  - X-Ref

    This structure steps restores the content bank content

    define_structure()   X-Ref
    Define structure for content bank step


    process_contentbankcontent($data)   X-Ref
    Define data processed for content bank

    param: mixed  $data

    after_execute()   X-Ref
    Define data processed after execute for content bank


    Class: restore_block_instance_structure_step  - X-Ref

    This structure steps restores one instance + positions of one block
    Note: Positions corresponding to one existing context are restored
    here, but all the ones having unknown contexts are sent to backup_ids
    for a later chance to be restored at the end (final task)

    define_structure()   X-Ref
    No description

    process_block($data)   X-Ref
    No description

    Class: restore_module_structure_step  - X-Ref

    Structure step to restore common course_module information

    This step will process the module.xml file for one activity, in order to restore
    the corresponding information to the course_modules table, skipping various bits
    of information based on CFG settings (groupings, completion...) in order to fullfill
    all the reqs to be able to create the context to be used by all the rest of steps
    in the activity restore task
    define_structure()   X-Ref
    No description

    process_module($data)   X-Ref
    No description

    process_tag($data)   X-Ref
    Fetch all the existing because tag_set() deletes them
    so everything must be reinserted on each call.

    param: stdClass $data Record data

    process_availability($data)   X-Ref
    Process the legacy availability table record. This table does not exist
    in Moodle 2.7+ but we still support restore.

    param: stdClass $data Record data

    process_availability_field($data)   X-Ref
    Process the legacy availability fields table record. This table does not
    exist in Moodle 2.7+ but we still support restore.

    param: stdClass $data Record data

    after_restore()   X-Ref
    This method will be executed after the rest of the restore has been processed.

    Update old tag instance itemid(s).

    Class: restore_userscompletion_structure_step  - X-Ref

    Structure step that will process the user activity completion
    information if all these conditions are met:
    - Target site has completion enabled ($CFG->enablecompletion)
    - Activity includes completion info (file_exists)

    execute_condition()   X-Ref
    To conditionally decide if this step must be executed
    Note the "settings" conditions are evaluated in the
    corresponding task. Here we check for other conditions
    not being restore settings (files, site settings...)


    define_structure()   X-Ref
    No description

    process_completion($data)   X-Ref
    No description

    Class: restore_activity_structure_step  - X-Ref

    Abstract structure step, parent of all the activity structure steps. Used to support
    the main <activity ...> tag and process it.

    prepare_activity_structure($paths)   X-Ref
    Adds support for the 'activity' path that is common to all the activities
    and will be processed globally here


    process_activity($data)   X-Ref
    Process the activity path, informing the task about various ids, needed later


    apply_activity_instance($newitemid)   X-Ref
    This must be invoked immediately after creating the "module" activity record (forum, choice...)
    and will adjust the new activity id (the instance) in various places


    Class: restore_create_categories_and_questions  - X-Ref

    Structure step in charge of creating/mapping all the qcats and qs
    by parsing the questions.xml file and checking it against the
    results calculated by {@link restore_process_categories_and_questions}
    and stored in backup_ids_temp

    define_structure()   X-Ref
    No description

    process_question_category($data)   X-Ref
    No description

    process_question($data)   X-Ref
    No description

    process_question_hint($data)   X-Ref
    No description

    process_tag($data)   X-Ref
    No description

    after_execute()   X-Ref
    No description

    Class: restore_move_module_questions_categories  - X-Ref

    Execution step that will move all the CONTEXT_MODULE question categories
    created at early stages of restore in course context (because modules weren't
    created yet) to their target module (matching by old-new-contextid mapping)

    define_execution()   X-Ref
    No description

    Class: restore_create_question_files  - X-Ref

    Execution step that will create all the question/answers/qtype-specific files for the restored
    questions. It must be executed after {@link restore_move_module_questions_categories}
    because only then each question is in its final category and only then the
    contexts can be determined.

    define_execution()   X-Ref
    Preform the restore_create_question_files step.


    send_common_files($oldctxid, $newctxid, $progress)   X-Ref
    Send the common question files to a new context.

    param: int             $oldctxid Old context id.
    param: int             $newctxid New context id.
    param: \core\progress  $progress Progress object to use.

    send_qtype_files($qtype, $oldctxid, $newctxid, $progress)   X-Ref
    Send the question type specific files to a new context.

    param: text            $qtype The qtype name to send.
    param: int             $oldctxid Old context id.
    param: int             $newctxid New context id.
    param: \core\progress  $progress Progress object to use.

    Class: restore_process_file_aliases_queue  - X-Ref

    Try to restore aliases and references to external files.

    The queue of these files was prepared for us in {@link restore_dbops::send_files_to_pool()}.
    We expect that all regular (non-alias) files have already been restored. Make sure
    there is no restore step executed after this one that would call send_files_to_pool() again.

    You may notice we have hardcoded support for Server files, Legacy course files
    and user Private files here at the moment. This could be eventually replaced with a set of
    callbacks in the future if needed.

    define_execution()   X-Ref
    What to do when this step is executed.


    choose_repository(stdClass $info)   X-Ref
    Choose the repository instance that should handle the alias.

    At the same site, we can rely on repository instance id and we just
    check it still exists. On other site, try to find matching Server files or
    Legacy course files repository instance. Return null if no matching
    repository instance can be found.

    param: stdClass $info
    return: repository|null

    notify_success(stdClass $info)   X-Ref
    Let the user know that the given alias was successfully restored

    param: stdClass $info

    notify_failure(stdClass $info, $reason = '')   X-Ref
    Let the user know that the given alias can't be restored

    param: stdClass $info
    param: string $reason detailed reason to be logged

    describe_alias(stdClass $info)   X-Ref
    Return a human readable description of the alias file

    param: stdClass $info
    return: string

    expected_alias_location($filerecord)   X-Ref
    Return the expected location of a file

    Please note this may and may not work as a part of URL to pluginfile.php
    (depends on how the given component/filearea deals with the itemid).

    param: stdClass $filerecord
    return: string

    add_result_item($name, $value)   X-Ref
    Append a value to the given resultset

    param: string $name name of the result containing a list of values
    param: mixed $value value to add as another item in that result

    add_question_usages($element, &$paths, $nameprefix = '')   X-Ref
    Attach below $element (usually attempts) the needed restore_path_elements
    to restore question_usages and all they contain.

    If you use the $nameprefix parameter, then you will need to implement some
    extra methods in your class, like

    protected function process_{nameprefix}question_attempt($data) {
    $this->restore_question_usage_worker($data, '{nameprefix}');
    }
    protected function process_{nameprefix}question_attempt($data) {
    $this->restore_question_attempt_worker($data, '{nameprefix}');
    }
    protected function process_{nameprefix}question_attempt_step($data) {
    $this->restore_question_attempt_step_worker($data, '{nameprefix}');
    }

    param: restore_path_element $element the parent element that the usages are stored inside.
    param: array $paths the paths array that is being built.
    param: string $nameprefix should match the prefix passed to the corresponding

    process_question_usage($data)   X-Ref
    Process question_usages


    process_question_attempt($data)   X-Ref
    Process question_attempts


    process_question_attempt_step($data)   X-Ref
    Process question_attempt_steps


    restore_question_usage_worker($data, $nameprefix)   X-Ref
    This method does the actual work for process_question_usage or
    process_{nameprefix}_question_usage.

    param: array $data the data from the XML file.
    param: string $nameprefix the element name prefix.

    restore_question_attempt_worker($data, $nameprefix)   X-Ref
    This method does the actual work for process_question_attempt or
    process_{nameprefix}_question_attempt.

    param: array $data the data from the XML file.
    param: string $nameprefix the element name prefix.

    restore_question_attempt_step_worker($data, $nameprefix)   X-Ref
    This method does the actual work for process_question_attempt_step or
    process_{nameprefix}_question_attempt_step.

    param: array $data the data from the XML file.
    param: string $nameprefix the element name prefix.

    questions_recode_response_data($qtype, $newquestionid, $sequencenumber, array $response)   X-Ref
    Recode the respones data for a particular step of an attempt at at particular question.

    param: string $qtype the question type.
    param: int $newquestionid the question id.
    param: int $sequencenumber the sequence number.
    param: array $response the response data to recode.

    questions_recode_layout($layout)   X-Ref
    Given a list of question->ids, separated by commas, returns the
    recoded list, with all the restore question mappings applied.
    Note: Used by quiz->questions and quiz_attempts->layout
    Note: 0 = page break (unconverted)


    get_qtype_restorer($qtype)   X-Ref
    Get the restore_qtype_plugin subclass for a specific question type.

    param: string $qtype e.g. multichoice.
    return: restore_qtype_plugin instance.

    after_execute()   X-Ref
    No description

    Class: restore_questions_activity_structure_step  - X-Ref

    Abstract structure step to help activities that store question attempt data.

    add_legacy_question_attempt_data($element, &$paths)   X-Ref
    Attach below $element (usually attempts) the needed restore_path_elements
    to restore question attempt data from Moodle 2.0.

    When using this method, the parent element ($element) must be defined with
    $grouped = true. Then, in that elements process method, you must call
    {@link process_legacy_attempt_data()} with the groupded data. See, for
    example, the usage of this method in {@link restore_quiz_activity_structure_step}.
    param: restore_path_element $element the parent element. (E.g. a quiz attempt.)
    param: array $paths the paths array that is being built to describe the

    get_attempt_upgrader()   X-Ref
    No description

    process_legacy_quiz_attempt_data($data, $quiz)   X-Ref
    Process the attempt data defined by {@link add_legacy_question_attempt_data()}.

    param: object $data contains all the grouped attempt data to process.
    param: object $quiz data about the activity the attempts belong to. Required

    find_question_session_and_states($data, $questionid)   X-Ref
    No description

    recode_legacy_response_data($question, $qsession, $qstates)   X-Ref
    Recode any ids in the response data

    param: object $question the question data
    param: object $qsession the question sessions.
    param: array $qstates the question states.

    restore_recode_legacy_answer($state, $qtype)   X-Ref
    Recode the legacy answer field.

    param: object $state the state to recode the answer of.
    param: string $qtype the question type.

    Class: restore_completion_defaults_structure_step  - X-Ref

    Restore completion defaults for each module type

    execute_condition()   X-Ref
    To conditionally decide if this step must be executed.


    define_structure()   X-Ref
    Function that will return the structure to be processed by this restore_step.

    return: restore_path_element[]

    process_completion_defaults($data)   X-Ref
    Processor for path element 'completion_defaults'

    param: stdClass|array $data

    Class: restore_course_search_index  - X-Ref

    Index course after restore.

    define_execution()   X-Ref
    When this step is executed, we add the course context to the queue for reindexing.


    Class: restore_activity_search_index  - X-Ref

    Index activity after restore (when not restoring whole course).

    define_execution()   X-Ref
    When this step is executed, we add the activity context to the queue for reindexing.


    Class: restore_block_search_index  - X-Ref

    Index block after restore (when not restoring whole course).

    define_execution()   X-Ref
    When this step is executed, we add the block context to the queue for reindexing.


    Class: restore_calendar_action_events  - X-Ref

    Restore action events.

    define_execution()   X-Ref
    What to do when this step is executed.