From c0375ba73ff389b3916a031bb68bace2cc426b8a Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Mon, 12 Aug 2019 14:08:07 +0800 Subject: [PATCH] MDL-66369 libraries: Remove [modname]_scale_used functions These functions were only used by the deprecated function which was deprecated in 3.1, and removed in 3.6. --- mod/assign/lib.php | 21 ++++----------------- mod/assign/upgrade.txt | 2 ++ mod/book/lib.php | 14 ++++---------- mod/book/upgrade.txt | 5 +++++ mod/feedback/lib.php | 7 ++++--- mod/feedback/upgrade.txt | 5 +++++ mod/forum/deprecatedlib.php | 8 ++++++++ mod/forum/lib.php | 22 ---------------------- mod/forum/upgrade.txt | 5 +++++ mod/glossary/lib.php | 21 ++++----------------- mod/glossary/upgrade.txt | 4 ++++ mod/lti/lib.php | 25 +++++-------------------- mod/lti/upgrade.txt | 5 +++++ mod/wiki/lib.php | 24 +++++------------------- mod/wiki/upgrade.txt | 4 ++++ mod/workshop/lib.php | 34 ++++------------------------------ mod/workshop/upgrade.txt | 5 +++++ 17 files changed, 73 insertions(+), 138 deletions(-) diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 2fe28775da915..af12729cfd9ae 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -901,24 +901,11 @@ function assign_print_recent_mod_activity($activity, $courseid, $detail, $modnam } /** - * Checks if a scale is being used by an assignment. - * - * This is used by the backup code to decide whether to back up a scale - * @param int $assignmentid - * @param int $scaleid - * @return boolean True if the scale is used by the assignment + * @deprecated since Moodle 3.8 */ -function assign_scale_used($assignmentid, $scaleid) { - global $DB; - - $return = false; - $rec = $DB->get_record('assign', array('id'=>$assignmentid, 'grade'=>-$scaleid)); - - if (!empty($rec) && !empty($scaleid)) { - $return = true; - } - - return $return; +function assign_scale_used() { + throw new coding_exception('assign_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/assign/upgrade.txt b/mod/assign/upgrade.txt index f0c9e8cc4321a..52685333bbe27 100644 --- a/mod/assign/upgrade.txt +++ b/mod/assign/upgrade.txt @@ -1,6 +1,8 @@ This files describes API changes in the assign code. === 3.8 === * Webservice function mod_assign_get_submission_status, return value 'warnofungroupedusers', changed from PARAM_BOOL to PARAM_ALPHA. See the description for possible values. +* The following functions have been finally deprecated and can not be used anymore: + * assign_scale_used() === 3.7 === * Submissions plugins should implement the "remove" function to remove data when "Remove submission" is used. diff --git a/mod/book/lib.php b/mod/book/lib.php index 0b4887f80ba04..e28942dfef108 100644 --- a/mod/book/lib.php +++ b/mod/book/lib.php @@ -215,17 +215,11 @@ function book_grades($bookid) { } /** - * This function returns if a scale is being used by one book - * it it has support for grading and scales. Commented code should be - * modified if necessary. See book, glossary or journal modules - * as reference. - * - * @param int $bookid - * @param int $scaleid - * @return boolean True if the scale is used by any journal + * @deprecated since Moodle 3.8 */ -function book_scale_used($bookid, $scaleid) { - return false; +function book_scale_used() { + throw new coding_exception('book_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/book/upgrade.txt b/mod/book/upgrade.txt index 1fb902803a851..f58e5dc285c38 100644 --- a/mod/book/upgrade.txt +++ b/mod/book/upgrade.txt @@ -1,5 +1,10 @@ This files describes API changes in the book code. +=== 3.8 === + +* The following functions have been finally deprecated and can not be used anymore: + * book_scale_used() + === 3.7 === * book_export_contents() callback now returns tags information for every chapter. diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 85959693cc582..124bc3c9ebcfb 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -586,10 +586,11 @@ function feedback_cron () { } /** - * @return bool false + * @deprecated since Moodle 3.8 */ -function feedback_scale_used ($feedbackid, $scaleid) { - return false; +function feedback_scale_used() { + throw new coding_exception('feedback_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/feedback/upgrade.txt b/mod/feedback/upgrade.txt index e084e6007360a..c9a0ef6877f82 100644 --- a/mod/feedback/upgrade.txt +++ b/mod/feedback/upgrade.txt @@ -1,3 +1,8 @@ +=== 3.8 === + +* The following functions have been finally deprecated and can not be used anymore: + * feedback_scale_used() + === 3.6 === * The following functions have been finally deprecated and can not be used anymore: diff --git a/mod/forum/deprecatedlib.php b/mod/forum/deprecatedlib.php index f884344b38d2d..8e71f22be1e3c 100644 --- a/mod/forum/deprecatedlib.php +++ b/mod/forum/deprecatedlib.php @@ -1651,3 +1651,11 @@ function forum_count_replies($post, $children = true) { true ); } + +/** + * @deprecated since Moodle 3.8 + */ +function forum_scale_used() { + throw new coding_exception('forum_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); +} diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 8d1b4e189fcc3..62f242353a38f 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -804,28 +804,6 @@ function forum_grade_item_delete($forum) { return grade_update('mod/forum', $forum->course, 'mod', 'forum', $forum->id, 0, NULL, array('deleted'=>1)); } - -/** - * This function returns if a scale is being used by one forum - * - * @global object - * @param int $forumid - * @param int $scaleid negative number - * @return bool - */ -function forum_scale_used ($forumid,$scaleid) { - global $DB; - $return = false; - - $rec = $DB->get_record("forum",array("id" => "$forumid","scale" => "-$scaleid")); - - if (!empty($rec) && !empty($scaleid)) { - $return = true; - } - - return $return; -} - /** * Checks if scale is being used by any instance of forum * diff --git a/mod/forum/upgrade.txt b/mod/forum/upgrade.txt index 6f5c9b9df41a9..e64b5fbd0fcf4 100644 --- a/mod/forum/upgrade.txt +++ b/mod/forum/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in /mod/forum/*, information provided here is intended especially for developers. +=== 3.8 === + +* The following functions have been finally deprecated and can not be used anymore: + * forum_scale_used() + === 3.7 === * Changed the forum discussion rendering to use templates rather than print functions. * Added new forum entities, factories, exporters, renderers, and vaults in the local namespace to better encapsulate the forum data. diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index c0b44d147deae..6de89ca5bc8a2 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -865,24 +865,11 @@ function glossary_grade_item_delete($glossary) { } /** - * @global object - * @param int $gloassryid - * @param int $scaleid - * @return bool + * @deprecated since Moodle 3.8 */ -function glossary_scale_used ($glossaryid,$scaleid) { -//This function returns if a scale is being used by one glossary - global $DB; - - $return = false; - - $rec = $DB->get_record("glossary", array("id"=>$glossaryid, "scale"=>-$scaleid)); - - if (!empty($rec) && !empty($scaleid)) { - $return = true; - } - - return $return; +function glossary_scale_used() { + throw new coding_exception('glossary_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/glossary/upgrade.txt b/mod/glossary/upgrade.txt index 2ce13564b1aef..7738fe567a30c 100644 --- a/mod/glossary/upgrade.txt +++ b/mod/glossary/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in /mod/glossary/*, information provided here is intended especially for developers. +=== 3.8 === +* The following functions have been finally deprecated and can not be used anymore: + * glossary_scale_used() + === 3.7 === * External functions get_entries_by_* and get_entry now return an additional field "tags" containing the entry tags. diff --git a/mod/lti/lib.php b/mod/lti/lib.php index 9553ae442d457..0d98e57edef14 100644 --- a/mod/lti/lib.php +++ b/mod/lti/lib.php @@ -363,26 +363,11 @@ function lti_grades($basicltiid) { } /** - * This function returns if a scale is being used by one basiclti - * it it has support for grading and scales. Commented code should be - * modified if necessary. See forum, glossary or journal modules - * as reference. - * - * @param int $basicltiid ID of an instance of this module - * @return mixed - * - * @TODO: implement this moodle function (if needed) - **/ -function lti_scale_used ($basicltiid, $scaleid) { - $return = false; - - // $rec = get_record("basiclti","id","$basicltiid","scale","-$scaleid"); - // - // if (!empty($rec) && !empty($scaleid)) { - // $return = true; - // } - - return $return; + * @deprecated since Moodle 3.8 + */ +function lti_scale_used() { + throw new coding_exception('lti_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/lti/upgrade.txt b/mod/lti/upgrade.txt index 707cbc9169d77..4e8e5b9d3e096 100644 --- a/mod/lti/upgrade.txt +++ b/mod/lti/upgrade.txt @@ -1,5 +1,10 @@ This files describes API changes in the lti code. +=== 3.8 === + +* The following functions have been finally deprecated and can not be used anymore: + * lti_scale_used() + === 3.7 === * Deprecated functions to add support for LTI 1 tools to access services: diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index 0d0738ad9dd6a..3a07fa5a43f49 100644 --- a/mod/wiki/lib.php +++ b/mod/wiki/lib.php @@ -366,25 +366,11 @@ function wiki_grades($wikiid) { } /** - * This function returns if a scale is being used by one wiki - * it it has support for grading and scales. Commented code should be - * modified if necessary. See forum, glossary or journal modules - * as reference. - * - * @param int $wikiid ID of an instance of this module - * @return mixed - * @todo Finish documenting this function - **/ -function wiki_scale_used($wikiid, $scaleid) { - $return = false; - - //$rec = get_record("wiki","id","$wikiid","scale","-$scaleid"); - // - //if (!empty($rec) && !empty($scaleid)) { - // $return = true; - //} - - return $return; + * @deprecated since Moodle 3.8 + */ +function wiki_scale_used() { + throw new coding_exception('wiki_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/wiki/upgrade.txt b/mod/wiki/upgrade.txt index bc1bfd9cfa918..6f643bf87b867 100644 --- a/mod/wiki/upgrade.txt +++ b/mod/wiki/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in /mod/wiki/*, information provided here is intended especially for developers. +=== 3.8 === +* The following functions have been finally deprecated and can not be used anymore: + * wiki_scale_used() + === 3.7 === * External functions get_subwiki_pages and get_page_contents now return an additional field "tags" returning the entry tags. diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 866a3d15de326..cfe4922266e1b 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1057,37 +1057,11 @@ function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modn } /** - * Is a given scale used by the instance of workshop? - * - * The function asks all installed grading strategy subplugins. The workshop - * core itself does not use scales. Both grade for submission and grade for - * assessments do not use scales. - * - * @param int $workshopid id of workshop instance - * @param int $scaleid id of the scale to check - * @return bool + * @deprecated since Moodle 3.8 */ -function workshop_scale_used($workshopid, $scaleid) { - global $CFG; // other files included from here - - $strategies = core_component::get_plugin_list('workshopform'); - foreach ($strategies as $strategy => $strategypath) { - $strategylib = $strategypath . '/lib.php'; - if (is_readable($strategylib)) { - require_once($strategylib); - } else { - throw new coding_exception('the grading forms subplugin must contain library ' . $strategylib); - } - $classname = 'workshop_' . $strategy . '_strategy'; - if (method_exists($classname, 'scale_used')) { - if (call_user_func_array(array($classname, 'scale_used'), array($scaleid, $workshopid))) { - // no need to include any other files - scale is used - return true; - } - } - } - - return false; +function workshop_scale_used() { + throw new coding_exception('workshop_scale_used() can not be used anymore. Plugins can implement ' . + '_scale_used_anywhere, all implementations of _scale_used are now ignored'); } /** diff --git a/mod/workshop/upgrade.txt b/mod/workshop/upgrade.txt index 06bd0e4f41693..a2d7342455e06 100644 --- a/mod/workshop/upgrade.txt +++ b/mod/workshop/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in /mod/workshop - activity modules, information provided here is intended especially for developers. +=== 3.8 === + +* The following functions have been finally deprecated and can not be used anymore: + * workshop_scale_used() + === 3.7 === * workshop_cron() has been removed. Sub-plugins should now implement scheduled tasks.