MDL-57487 course: final deprecation external::get_activities_overview

This commit is contained in:
Sara Arjona 2019-06-12 21:14:18 +02:00
parent f65075f10f
commit c128ccc142
6 changed files with 11 additions and 171 deletions

View File

@ -2906,121 +2906,6 @@ class core_course_external extends external_api {
return self::get_course_module_returns();
}
/**
* Returns description of method parameters
*
* @deprecated since 3.3
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
* @return external_function_parameters
* @since Moodle 3.2
*/
public static function get_activities_overview_parameters() {
return new external_function_parameters(
array(
'courseids' => new external_multiple_structure(new external_value(PARAM_INT, 'Course id.')),
)
);
}
/**
* Return activities overview for the given courses.
*
* @deprecated since 3.3
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
* @param array $courseids a list of course ids
* @return array of warnings and the activities overview
* @since Moodle 3.2
* @throws moodle_exception
*/
public static function get_activities_overview($courseids) {
global $USER;
// Parameter validation.
$params = self::validate_parameters(self::get_activities_overview_parameters(), array('courseids' => $courseids));
$courseoverviews = array();
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
if (!empty($courses)) {
// Add lastaccess to each course (required by print_overview function).
// We need the complete user data, the ws server does not load a complete one.
$user = get_complete_user_data('id', $USER->id);
foreach ($courses as $course) {
if (isset($user->lastcourseaccess[$course->id])) {
$course->lastaccess = $user->lastcourseaccess[$course->id];
} else {
$course->lastaccess = 0;
}
}
$overviews = array();
if ($modules = get_plugin_list_with_function('mod', 'print_overview')) {
foreach ($modules as $fname) {
$fname($courses, $overviews);
}
}
// Format output.
foreach ($overviews as $courseid => $modules) {
$courseoverviews[$courseid]['id'] = $courseid;
$courseoverviews[$courseid]['overviews'] = array();
foreach ($modules as $modname => $overviewtext) {
$courseoverviews[$courseid]['overviews'][] = array(
'module' => $modname,
'overviewtext' => $overviewtext // This text doesn't need formatting.
);
}
}
}
$result = array(
'courses' => $courseoverviews,
'warnings' => $warnings
);
return $result;
}
/**
* Returns description of method result value
*
* @deprecated since 3.3
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
* @return external_description
* @since Moodle 3.2
*/
public static function get_activities_overview_returns() {
return new external_single_structure(
array(
'courses' => new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'Course id'),
'overviews' => new external_multiple_structure(
new external_single_structure(
array(
'module' => new external_value(PARAM_PLUGIN, 'Module name'),
'overviewtext' => new external_value(PARAM_RAW, 'Overview text'),
)
)
)
)
), 'List of courses'
),
'warnings' => new external_warnings()
)
);
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_activities_overview_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*

View File

@ -2194,50 +2194,6 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
}
/**
* Test get_activities_overview
*/
public function test_get_activities_overview() {
global $USER;
$this->resetAfterTest();
$course1 = self::getDataGenerator()->create_course();
$course2 = self::getDataGenerator()->create_course();
// Create a viewer user.
$viewer = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
$this->getDataGenerator()->enrol_user($viewer->id, $course1->id);
$this->getDataGenerator()->enrol_user($viewer->id, $course2->id);
// Create two forums - one in each course.
$record = new stdClass();
$record->course = $course1->id;
$forum1 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course1->id));
$forum2 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course2->id));
$this->setAdminUser();
// A standard post in the forum.
$record = new stdClass();
$record->course = $course1->id;
$record->userid = $USER->id;
$record->forum = $forum1->id;
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
$this->setUser($viewer->id);
$courses = array($course1->id , $course2->id);
$result = core_course_external::get_activities_overview($courses);
$this->assertDebuggingCalledCount(8);
$result = external_api::clean_returnvalue(core_course_external::get_activities_overview_returns(), $result);
// There should be one entry for course1, and no others.
$this->assertCount(1, $result['courses']);
$this->assertEquals($course1->id, $result['courses'][0]['id']);
// Check expected overview data for the module.
$this->assertEquals('forum', $result['courses'][0]['overviews'][0]['module']);
$this->assertContains('1 total unread', $result['courses'][0]['overviews'][0]['overviewtext']);
}
/**
* Test get_user_navigation_options
*/

View File

@ -1,6 +1,10 @@
This files describes API changes in /course/*,
information provided here is intended especially for developers.
=== 3.8 ===
* The following functions have been finally deprecated and can not be used any more:
- core_course_external::get_activities_overview
=== 3.7 ===
* The course pattern function in course_summary_exporter::get_course_pattern has been moved to $OUTPUT->get_generated_image_for_id.
@ -10,7 +14,6 @@ information provided here is intended especially for developers.
* External function core_course_external::get_course_contents now returns a new contentsinfo field with summary files information.
* External function core_course_external::get_course_contents now returns an additional field "tags" returning the content tags.
=== 3.6 ===
* External function core_course_external::get_course_public_information now returns the roles and the primary role of course

View File

@ -529,15 +529,6 @@ $functions = array(
'type' => 'write',
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
),
'core_course_get_activities_overview' => array(
'classname' => 'core_course_external',
'methodname' => 'get_activities_overview',
'classpath' => 'course/externallib.php',
'description' => '** DEPRECATED ** Please do not call this function any more.
Return activities overview for the given courses.',
'type' => 'read',
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
),
'core_course_get_user_navigation_options' => array(
'classname' => 'core_course_external',
'methodname' => 'get_user_navigation_options',

View File

@ -1,6 +1,10 @@
This files describes API changes in /mod/* - activity modules,
information provided here is intended especially for developers.
=== 3.8 ===
* The final deprecation of xxx_print_overview() callback means that this function will no longer be called.
=== 3.6 ===
* The final deprecation of xxx_get_types() callback means that this function will no longer be called.
@ -44,7 +48,8 @@ information provided here is intended especially for developers.
- isexternalfile (if is a file reference to a external repository)
- repositorytype (the repository name in case is a external file)
Those fields are VALUE_OPTIONAL for backwards compatibility.
* The block_course_overview has been removed and the related core module *_print_overview functions have been deprecated.
* The block_course_overview has been removed and the related core module
*_print_overview functions have been deprecated.
* The block_myoverview has replaced block_course_overview to provide better information to students. To support this,
actions can now be attached to calendar events. Documentation for the following new API callbacks introduced in
MDL-55611 can be found at https://docs.moodle.org/dev/Calendar_API. The 3 new callbacks are:

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019061400.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019061400.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.