mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-65974 course: move format_base to core_course\course_format
This commit is contained in:
parent
96b49ddc97
commit
1c839f9072
@ -58,7 +58,7 @@ class core_backup_moodle2_course_format_testcase extends advanced_testcase {
|
||||
'enablecompletion' => COMPLETION_ENABLED),
|
||||
array('createsections' => true));
|
||||
|
||||
$courseobject = format_base::instance($course->id);
|
||||
$courseobject = core_course\course_format::instance($course->id);
|
||||
$section = $DB->get_record('course_sections',
|
||||
array('course' => $course->id, 'section' => 1), '*', MUST_EXIST);
|
||||
$data = array('id' => $section->id,
|
||||
@ -91,7 +91,7 @@ class core_backup_moodle2_course_format_testcase extends advanced_testcase {
|
||||
'enablecompletion' => COMPLETION_ENABLED),
|
||||
array('createsections' => true));
|
||||
|
||||
$courseobject = format_base::instance($course->id);
|
||||
$courseobject = core_course\course_format::instance($course->id);
|
||||
$section = $DB->get_record('course_sections',
|
||||
array('course' => $course->id, 'section' => 1), '*', MUST_EXIST);
|
||||
$data = array('id' => $section->id,
|
||||
@ -134,7 +134,7 @@ class core_backup_moodle2_course_format_testcase extends advanced_testcase {
|
||||
array('createsections' => true));
|
||||
|
||||
// Set section 2 to have both options, and a name.
|
||||
$courseobject = format_base::instance($course->id);
|
||||
$courseobject = core_course\course_format::instance($course->id);
|
||||
$section = $DB->get_record('course_sections',
|
||||
array('course' => $course->id, 'section' => 2), '*', MUST_EXIST);
|
||||
$data = array('id' => $section->id,
|
||||
@ -151,7 +151,7 @@ class core_backup_moodle2_course_format_testcase extends advanced_testcase {
|
||||
// Check that the section contains the options suitable for the new
|
||||
// format and that even the one with the same name as from the old format
|
||||
// has NOT been set.
|
||||
$newcourseobject = format_base::instance($newcourse->id);
|
||||
$newcourseobject = core_course\course_format::instance($newcourse->id);
|
||||
$sectionoptions = $newcourseobject->get_format_options(2);
|
||||
$this->assertArrayHasKey('numdaystocomplete', $sectionoptions);
|
||||
$this->assertArrayNotHasKey('secondparameter', $sectionoptions);
|
||||
|
1416
course/classes/course_format.php
Normal file
1416
course/classes/course_format.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die;
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_legacy extends format_base {
|
||||
class format_legacy extends core_course\course_format {
|
||||
|
||||
/**
|
||||
* Returns true if this course format uses sections
|
||||
|
@ -32,7 +32,7 @@ require_once($CFG->dirroot. '/course/format/lib.php');
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_singleactivity extends format_base {
|
||||
class format_singleactivity extends core_course\course_format {
|
||||
/** @var cm_info the current activity. Use get_activity() to retrieve it. */
|
||||
private $activity = false;
|
||||
|
||||
|
@ -33,7 +33,7 @@ require_once($CFG->dirroot. '/course/format/lib.php');
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_social extends format_base {
|
||||
class format_social extends core_course\course_format {
|
||||
|
||||
/**
|
||||
* The URL to use for the specified course
|
||||
|
@ -34,7 +34,7 @@ require_once($CFG->dirroot. '/course/lib.php');
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_weeks extends format_base {
|
||||
class format_weeks extends core_course\course_format {
|
||||
|
||||
/**
|
||||
* Returns true if this course format uses sections
|
||||
|
@ -592,9 +592,7 @@ function course_set_marker($courseid, $marker) {
|
||||
if ($COURSE && $COURSE->id == $courseid) {
|
||||
$COURSE->marker = $marker;
|
||||
}
|
||||
if (class_exists('format_base')) {
|
||||
format_base::reset_course_cache($courseid);
|
||||
}
|
||||
core_course\course_format::reset_course_cache($courseid);
|
||||
course_modinfo::clear_instance_cache($courseid);
|
||||
}
|
||||
|
||||
@ -2149,7 +2147,7 @@ function move_courses($courseids, $categoryid) {
|
||||
* Returns the display name of the given section that the course prefers
|
||||
*
|
||||
* Implementation of this function is provided by course format
|
||||
* @see format_base::get_section_name()
|
||||
* @see core_course\course_format::get_section_name()
|
||||
*
|
||||
* @param int|stdClass $courseorid The course to get the section name for (object or just course id)
|
||||
* @param int|stdClass $section Section object from database or just field course_sections.section
|
||||
|
@ -210,7 +210,7 @@ class core_course_courseformat_testcase extends advanced_testcase {
|
||||
* @copyright 2016 Jun Pataleta <jun@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_testformat extends format_base {
|
||||
class format_testformat extends core_course\course_format {
|
||||
/**
|
||||
* Returns the list of blocks to be automatically added for the newly created course.
|
||||
*
|
||||
@ -232,7 +232,7 @@ class format_testformat extends format_base {
|
||||
* @copyright 2016 Jun Pataleta <jun@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_testlegacy extends format_base {
|
||||
class format_testlegacy extends core_course\course_format {
|
||||
/**
|
||||
* Returns the list of blocks to be automatically added for the newly created course.
|
||||
*
|
||||
|
@ -4479,7 +4479,7 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
|
||||
if ($SITE->id == $COURSE->id) {
|
||||
$COURSE = $SITE;
|
||||
}
|
||||
format_base::reset_course_cache($SITE->id);
|
||||
core_course\course_format::reset_course_cache($SITE->id);
|
||||
|
||||
return '';
|
||||
|
||||
@ -4690,7 +4690,7 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
|
||||
if ($SITE->id == $COURSE->id) {
|
||||
$COURSE = $SITE;
|
||||
}
|
||||
format_base::reset_course_cache($SITE->id);
|
||||
core_course\course_format::reset_course_cache($SITE->id);
|
||||
|
||||
return '';
|
||||
}
|
||||
@ -4772,7 +4772,7 @@ class admin_setting_sitesettext extends admin_setting_configtext {
|
||||
if ($SITE->id == $COURSE->id) {
|
||||
$COURSE = $SITE;
|
||||
}
|
||||
format_base::reset_course_cache($SITE->id);
|
||||
core_course\course_format::reset_course_cache($SITE->id);
|
||||
|
||||
return '';
|
||||
}
|
||||
@ -4824,7 +4824,7 @@ class admin_setting_special_frontpagedesc extends admin_setting_confightmleditor
|
||||
if ($SITE->id == $COURSE->id) {
|
||||
$COURSE = $SITE;
|
||||
}
|
||||
format_base::reset_course_cache($SITE->id);
|
||||
core_course\course_format::reset_course_cache($SITE->id);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
@ -411,10 +411,7 @@ class behat_util extends testing_util {
|
||||
filter_manager::reset_caches();
|
||||
|
||||
// Reset course and module caches.
|
||||
if (class_exists('format_base')) {
|
||||
// If file containing class is not loaded, there is no cache there anyway.
|
||||
format_base::reset_course_cache(0);
|
||||
}
|
||||
core_course\course_format::reset_course_cache(0);
|
||||
get_fast_modinfo(0, 0, true);
|
||||
|
||||
// Inform data generator.
|
||||
|
@ -42,4 +42,5 @@ $renamedclasses = array(
|
||||
'core\\analytics\\target\\course_completion' => 'core_course\\analytics\\target\\course_completion',
|
||||
'core\\analytics\\target\\course_gradetopass' => 'core_course\\analytics\\target\\course_gradetopass',
|
||||
'core\\analytics\\target\\no_teaching' => 'core_course\\analytics\\target\\no_teaching',
|
||||
'format_base' => 'core_course\\course_format',
|
||||
);
|
||||
|
@ -918,7 +918,8 @@ function textlib_get_instance() {
|
||||
* @deprecated since 2.4
|
||||
*/
|
||||
function get_generic_section_name() {
|
||||
throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base');
|
||||
throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality '
|
||||
.'from class core_course\\course_format');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2357,10 +2357,7 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
|
||||
// Destroy navigation caches
|
||||
navigation_cache::destroy_volatile_caches();
|
||||
|
||||
if (class_exists('format_base')) {
|
||||
// if file containing class is not loaded, there is no cache there anyway
|
||||
format_base::reset_course_cache($courseid);
|
||||
}
|
||||
core_course\course_format::reset_course_cache($courseid);
|
||||
|
||||
$cachecoursemodinfo = cache::make('core', 'coursemodinfo');
|
||||
if (empty($courseid)) {
|
||||
|
@ -5179,9 +5179,7 @@ function delete_course($courseorid, $showfeedback = true) {
|
||||
$DB->delete_records("course_format_options", array("courseid" => $courseid));
|
||||
|
||||
// Reset all course related caches here.
|
||||
if (class_exists('format_base', false)) {
|
||||
format_base::reset_course_cache($courseid);
|
||||
}
|
||||
core_course\course_format::reset_course_cache($courseid);
|
||||
|
||||
// Tell search that we have deleted the course so it can delete course data from the index.
|
||||
\core_search\manager::course_deleting_finish($courseid);
|
||||
|
@ -2005,7 +2005,7 @@ class global_navigation extends navigation_node {
|
||||
* Loads all of the courses section into the navigation.
|
||||
*
|
||||
* This function calls method from current course format, see
|
||||
* {@link format_base::extend_course_navigation()}
|
||||
* {@link core_course\course_format::extend_course_navigation()}
|
||||
* If course module ($cm) is specified but course format failed to create the node,
|
||||
* the activity node is created anyway.
|
||||
*
|
||||
|
@ -240,10 +240,7 @@ class phpunit_util extends testing_util {
|
||||
//TODO MDL-25290: add more resets here and probably refactor them to new core function
|
||||
|
||||
// Reset course and module caches.
|
||||
if (class_exists('format_base')) {
|
||||
// If file containing class is not loaded, there is no cache there anyway.
|
||||
format_base::reset_course_cache(0);
|
||||
}
|
||||
core_course\course_format::reset_course_cache(0);
|
||||
get_fast_modinfo(0, 0, true);
|
||||
|
||||
// Reset other singletons.
|
||||
|
Loading…
x
Reference in New Issue
Block a user