MDL-57434 core: deprecated xxx_print_overview() and related functions

Part of MDL-55611 epic.
This commit is contained in:
Mark Nelson 2016-12-21 16:51:41 +08:00 committed by Damyon Wiese
parent 4c5cde3134
commit e9dfeec94e
13 changed files with 76 additions and 2 deletions

View File

@ -2654,6 +2654,8 @@ class core_course_external extends external_api {
/**
* Returns description of method parameters
*
* @deprecated since 3.3
*
* @return external_function_parameters
* @since Moodle 3.2
*/
@ -2668,6 +2670,8 @@ class core_course_external extends external_api {
/**
* Return activities overview for the given courses.
*
* @deprecated since 3.3
*
* @param array $courseids a list of course ids
* @return array of warnings and the activities overview
* @since Moodle 3.2
@ -2725,6 +2729,8 @@ class core_course_external extends external_api {
/**
* Returns description of method result value
*
* @deprecated since 3.3
*
* @return external_description
* @since Moodle 3.2
*/
@ -2751,6 +2757,15 @@ class core_course_external extends external_api {
);
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_activities_overview_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*

View File

@ -1823,6 +1823,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$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.

View File

@ -330,7 +330,8 @@ $functions = array(
'classname' => 'core_course_external',
'methodname' => 'get_activities_overview',
'classpath' => 'course/externallib.php',
'description' => 'Return activities overview for the given courses.',
'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),
),

View File

@ -68,6 +68,7 @@ information provided here is intended especially for developers.
* New adhoc task refresh_mod_calendar_events_task that updates existing calendar events of modules.
* New 'priority' column for the event table to determine which event to show in case of events with user and group overrides.
* Webservices core_course_search_courses and core_course_get_courses_by_field will always return the sortorder field.
* core_course_external::get_activities_overview has been deprecated. Please do not call this function any more.
=== 3.2 ===

View File

@ -484,14 +484,17 @@ function assign_page_type_list($pagetype, $parentcontext, $currentcontext) {
* Print an overview of all assignments
* for the courses.
*
* @deprecated since 3.3
*
* @param mixed $courses The list of courses to print the overview for
* @param array $htmlarray The array of html to return
*
* @return true
*/
function assign_print_overview($courses, &$htmlarray) {
global $CFG, $DB;
debugging('The function assign_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return true;
}
@ -624,6 +627,8 @@ function assign_print_overview($courses, &$htmlarray) {
* This api generates html to be displayed to students in print overview section, related to their submission status of the given
* assignment.
*
* @deprecated since 3.3
*
* @param array $mysubmissions list of submissions of current user indexed by assignment id.
* @param string $sqlassignmentids sql clause used to filter open assignments.
* @param array $assignmentidparams sql params used to filter open assignments.
@ -636,6 +641,8 @@ function assign_get_mysubmission_details_for_print_overview(&$mysubmissions, $sq
$assignment) {
global $USER, $DB;
debugging('The function assign_get_mysubmission_details_for_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if ($assignment->nosubmissions) {
// Offline assignment. No need to display alerts for offline assignments.
return false;
@ -710,6 +717,8 @@ function assign_get_mysubmission_details_for_print_overview(&$mysubmissions, $sq
* This api generates html to be displayed to teachers in print overview section, related to the grading status of the given
* assignment's submissions.
*
* @deprecated since 3.3
*
* @param array $unmarkedsubmissions list of submissions of that are currently unmarked indexed by assignment id.
* @param string $sqlassignmentids sql clause used to filter open assignments.
* @param array $assignmentidparams sql params used to filter open assignments.
@ -722,6 +731,9 @@ function assign_get_mysubmission_details_for_print_overview(&$mysubmissions, $sq
function assign_get_grade_details_for_print_overview(&$unmarkedsubmissions, $sqlassignmentids, $assignmentidparams,
$assignment, $context) {
global $DB;
debugging('The function assign_get_grade_details_for_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (!isset($unmarkedsubmissions)) {
// Build up and array of unmarked submissions indexed by assignment id/ userid
// for use where the user has grading rights on assignment.

View File

@ -125,6 +125,7 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$this->setUser($this->students[0]);
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
$this->assertEquals(1, count($overview));
$this->assertRegExp('/.*Assignment 4.*/', $overview[$this->course->id]['assign']); // No valid submission.
$this->assertNotRegExp('/.*Assignment 1.*/', $overview[$this->course->id]['assign']); // Has valid submission.
@ -135,11 +136,13 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
$this->assertEquals(0, count($overview));
$this->setUser($this->teachers[0]);
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
$this->assertEquals(1, count($overview));
// Submissions without a grade.
$this->assertRegExp('/.*Assignment 4.*/', $overview[$this->course->id]['assign']);
@ -148,6 +151,7 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$this->setUser($this->editingteachers[0]);
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
$this->assertEquals(1, count($overview));
// Submissions without a grade.
$this->assertRegExp('/.*Assignment 4.*/', $overview[$this->course->id]['assign']);
@ -167,6 +171,7 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
$this->assertEquals(1, count($overview));
// Now assignment 4 should not show up.
$this->assertNotRegExp('/.*Assignment 4.*/', $overview[$this->course->id]['assign']);
@ -175,6 +180,7 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$this->setUser($this->editingteachers[0]);
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
$this->assertEquals(1, count($overview));
// Now assignment 4 should not show up.
$this->assertNotRegExp('/.*Assignment 4.*/', $overview[$this->course->id]['assign']);
@ -186,6 +192,7 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$this->setUser($this->students[0]);
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(4);
$this->assertEquals(0, count($overview));
}

View File

@ -1119,6 +1119,8 @@ function chat_get_post_actions() {
}
/**
* @deprecated since 3.3
*
* @global object
* @global object
* @param array $courses
@ -1127,6 +1129,8 @@ function chat_get_post_actions() {
function chat_print_overview($courses, &$htmlarray) {
global $USER, $CFG;
debugging('The function chat_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();
}

View File

@ -918,6 +918,9 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) {
* Prints choice name, due date and attempt information on
* choice activities that have a deadline that has not already passed
* and it is available for completing.
*
* @deprecated since 3.3
*
* @uses CONTEXT_MODULE
* @param array $courses An array of course objects to get choice instances from.
* @param array $htmlarray Store overview output array( course ID => 'choice' => HTML output )
@ -925,6 +928,8 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) {
function choice_print_overview($courses, &$htmlarray) {
global $USER, $DB, $OUTPUT;
debugging('The function choice_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return;
}

View File

@ -1323,12 +1323,16 @@ function forum_user_complete($course, $user, $mod, $forum) {
/**
* Filters the forum discussions according to groups membership and config.
*
* @deprecated since 3.3
*
* @since Moodle 2.8, 2.7.1, 2.6.4
* @param array $discussions Discussions with new posts array
* @return array Forums with the number of new posts
*/
function forum_filter_user_groups_discussions($discussions) {
debugging('The function forum_filter_user_groups_discussions() is now deprecated.', DEBUG_DEVELOPER);
// Group the remaining discussions posts by their forumid.
$filteredforums = array();
@ -1384,6 +1388,8 @@ function forum_is_user_group_discussion(cm_info $cm, $discussiongroupid) {
}
/**
* @deprecated since 3.3
*
* @global object
* @global object
* @global object
@ -1393,6 +1399,8 @@ function forum_is_user_group_discussion(cm_info $cm, $discussiongroupid) {
function forum_print_overview($courses,&$htmlarray) {
global $USER, $CFG, $DB, $SESSION;
debugging('The function forum_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();
}

View File

@ -2448,6 +2448,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
}
$results = array();
forum_print_overview($courses, $results);
$this->assertDebuggingCalledCount(2);
// There should be one entry for course1, and no others.
$this->assertCount(1, $results);
@ -2499,6 +2500,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->setUser($viewer1->id);
$results = array();
forum_print_overview($courses, $results);
$this->assertDebuggingCalledCount(2);
// There should be one entry for course1.
$this->assertCount(1, $results);
@ -2510,6 +2512,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->setUser($viewer2->id);
$results = array();
forum_print_overview($courses, $results);
$this->assertDebuggingCalledCount(2);
// There should be one entry for course1.
$this->assertCount(0, $results);
@ -2555,6 +2558,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->setUser($viewer->id);
$results = array();
forum_print_overview($courses, $results);
$this->assertDebuggingCalledCount(2);
if ($hasresult) {
// There should be one entry for course1.
@ -2620,6 +2624,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->setUser($viewer1->id);
$results = array();
forum_print_overview($courses, $results);
$this->assertDebuggingCalledCount(2);
if ($hasresult) {
// There should be one entry for course1.
@ -2636,6 +2641,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->setUser($viewer2->id);
$results = array();
forum_print_overview($courses, $results);
$this->assertDebuggingCalledCount(2);
// There should be one entry for course1.
$this->assertCount(0, $results);

View File

@ -527,6 +527,8 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
* lessons that have a deadline that has not already passed
* and it is available for taking.
*
* @deprecated since 3.3
*
* @global object
* @global stdClass
* @global object
@ -538,6 +540,8 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
function lesson_print_overview($courses, &$htmlarray) {
global $USER, $CFG, $DB, $OUTPUT;
debugging('The function lesson_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (!$lessons = get_all_instances_in_courses('lesson', $courses)) {
return;
}

View File

@ -1543,11 +1543,17 @@ function quiz_reset_userdata($data) {
/**
* Prints quiz summaries on MyMoodle Page
*
* @deprecated since 3.3
*
* @param arry $courses
* @param array $htmlarray
*/
function quiz_print_overview($courses, &$htmlarray) {
global $USER, $CFG;
debugging('The function quiz_print_overview() is now deprecated.', DEBUG_DEVELOPER);
// These next 6 Lines are constant in all modules (just change module name).
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();

View File

@ -1088,6 +1088,8 @@ function scorm_debug_log_remove($type, $scoid) {
/**
* writes overview info for course_overview block - displays upcoming scorm objects that have a due date
*
* @deprecated since 3.3
*
* @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
* @param array $htmlarray
* @return mixed
@ -1095,6 +1097,8 @@ function scorm_debug_log_remove($type, $scoid) {
function scorm_print_overview($courses, &$htmlarray) {
global $USER, $CFG;
debugging('The function scorm_print_overview() is now deprecated.', DEBUG_DEVELOPER);
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();
}