Skip to content

Commit

Permalink
MDL-66369 libraries: Remove [modname]_scale_used functions
Browse files Browse the repository at this point in the history
These functions were only used by the deprecated function
which was deprecated in 3.1, and removed in 3.6.
  • Loading branch information
Amaia Anabitarte committed Aug 16, 2019
1 parent 7e16c70 commit c0375ba
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 138 deletions.
21 changes: 4 additions & 17 deletions mod/assign/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 4 additions & 10 deletions mod/book/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions mod/book/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 4 additions & 3 deletions mod/feedback/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions mod/feedback/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 8 additions & 0 deletions mod/forum/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}
22 changes: 0 additions & 22 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
5 changes: 5 additions & 0 deletions mod/forum/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
21 changes: 4 additions & 17 deletions mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
4 changes: 4 additions & 0 deletions mod/glossary/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
25 changes: 5 additions & 20 deletions mod/lti/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions mod/lti/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
24 changes: 5 additions & 19 deletions mod/wiki/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
4 changes: 4 additions & 0 deletions mod/wiki/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
34 changes: 4 additions & 30 deletions mod/workshop/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions mod/workshop/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit c0375ba

Please sign in to comment.