public static function get_restore_name(\context $context) {
        global $DB;
        $instanceid = $context->instanceid;

        if ($context->contextlevel == CONTEXT_MODULE) {
            // For modules get the course name and module name.
            $cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST);
            $coursename = $DB->get_field('course', 'fullname', array('id' => $cm->course));
            $itemname = $coursename . ' - ' . $cm->name;
        } else {
            $itemname = $DB->get_field('course', 'fullname', array('id' => $context->instanceid));

        }

        return $itemname;
    }
public static function get_restore_name(\context $context) {
        global $DB;
        $instanceid = $context->instanceid;

        if ($context->contextlevel == CONTEXT_MODULE) {
            // For modules get the course name and module name.
            $cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST);
            $coursename = $DB->get_field('course', 'fullname', array('id' => $cm->course));
            $itemname = $coursename . ' - ' . $cm->name;
        } else {
            $itemname = $DB->get_field('course', 'fullname', array('id' => $context->instanceid));

        }

        return $itemname;
    }
public static function get_restore_name ( \ context $ context ) { global $ DB ; $ instanceid = $ context -> instanceid ; if ( $ context -> contextlevel == CONTEXT_MODULE ) { // For modules get the course name and module name. $ cm = get_coursemodule_from_id ( '' , $ context -> instanceid , 0 , false , MUST_EXIST ) ; $ coursename = $ DB -> get_field ( 'course' , 'fullname' , array ( 'id' => $ cm -> course ) ) ; $ itemname = $ coursename . ' - ' . $ cm -> name ; } else { $ itemname = $ DB -> get_field ( 'course' , 'fullname' , array ( 'id' => $ context -> instanceid ) ) ; } return $ itemname ; }
Get the course name of the resource being restored.

@param \context $context The Moodle context for the restores.
@return string $coursename The full name of the course.
Get the course name of the resource being restored .