MDL-82351 course: fix course_ajax_enabled function

The course_ajax_enabled was using a course_format_ajax_support which
does not initialize the course format with the correct parameters.
Having a global function to get something the format base format can
provide is unnecessary and redudant, for this reason the function is now
deprecated.
This commit is contained in:
ferranrecio
2024-11-22 17:20:55 +01:00
committed by ferran
parent 505a85eb9a
commit 4053bd2139
2 changed files with 12 additions and 1 deletions
@@ -0,0 +1,7 @@
issueNumber: MDL-82351
notes:
core_course:
- message: >-
The course_format_ajax_support function is now deprecated. Use
course_get_format($course)->supports_ajax() instead.
type: deprecated
+5 -1
View File
@@ -1718,10 +1718,14 @@ function course_format_uses_sections($format) {
* The returned object's property (boolean)capable indicates that
* the course format supports Moodle course ajax features.
*
* @deprecated since Moodle 5.0 MDL-82351
* @todo MDL-83417 Remove this function in Moodle 6.0
* @param string $format
* @return stdClass
*/
#[\core\attribute\deprecated(since: '5.0', mdl: 'MDL-82351')]
function course_format_ajax_support($format) {
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
$course = new stdClass();
$course->format = $format;
return course_get_format($course)->supports_ajax();
@@ -2738,7 +2742,7 @@ function course_ajax_enabled($course) {
// Check that the course format supports ajax functionality
// The site 'format' doesn't have information on course format support
if ($SITE->id !== $course->id) {
$courseformatajaxsupport = course_format_ajax_support($course->format);
$courseformatajaxsupport = course_get_format($course)->supports_ajax();
if (!$courseformatajaxsupport->capable) {
return false;
}