Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * List of deprecated mod_scorm functions.
 *
 * @package   mod_scorm
 * @copyright 2021 Shamim Rezaie <shamim@moodle.com>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/**
< * Obtains the automatic completion state for this scorm based on any conditions < * in scorm settings. < *
* @deprecated since Moodle 3.11
< * @todo MDL-71196 Final deprecation in Moodle 4.3 < * @see \mod_scorm\completion\custom_completion < * @param stdClass $course Course < * @param cm_info|stdClass $cm Course-module < * @param int $userid User ID < * @param bool $type Type of comparison (or/and; can be used as return value if no conditions) < * @return bool True if completed, false if not. (If no conditions, then return < * value depends on comparison type)
*/
< function scorm_get_completion_state($course, $cm, $userid, $type) { < global $DB; < < // No need to call debugging here. Deprecation debugging notice already being called in \completion_info::internal_get_state(). < < $result = $type; < < // Get scorm. < if (!$scorm = $DB->get_record('scorm', array('id' => $cm->instance))) { < print_error('cannotfindscorm'); < } < // Only check for existence of tracks and return false if completionstatusrequired or completionscorerequired < // this means that if only view is required we don't end up with a false state. < if ($scorm->completionstatusrequired !== null || $scorm->completionscorerequired !== null) { < // Get user's tracks data. < $tracks = $DB->get_records_sql( < " < SELECT < id, < scoid, < element, < value < FROM < {scorm_scoes_track} < WHERE < scormid = ? < AND userid = ? < AND element IN < ( < 'cmi.core.lesson_status', < 'cmi.completion_status', < 'cmi.success_status', < 'cmi.core.score.raw', < 'cmi.score.raw' < ) < ", < array($scorm->id, $userid) < ); < < if (!$tracks) { < return completion_info::aggregate_completion_states($type, $result, false); < } < } < < // Check for status. < if ($scorm->completionstatusrequired !== null) { < < // Get status. < $statuses = array_flip(scorm_status_options()); < $nstatus = 0; < // Check any track for these values. < $scostatus = array(); < foreach ($tracks as $track) { < if (!in_array($track->element, array('cmi.core.lesson_status', 'cmi.completion_status', 'cmi.success_status'))) { < continue; < } < if (array_key_exists($track->value, $statuses)) { < $scostatus[$track->scoid] = true; < $nstatus |= $statuses[$track->value]; < } < } < < if (!empty($scorm->completionstatusallscos)) { < // Iterate over all scos and make sure each has a lesson_status. < $scos = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id, 'scormtype' => 'sco')); < foreach ($scos as $sco) { < if (empty($scostatus[$sco->id])) { < return completion_info::aggregate_completion_states($type, $result, false); < } < } < return completion_info::aggregate_completion_states($type, $result, true); < } else if ($scorm->completionstatusrequired & $nstatus) { < return completion_info::aggregate_completion_states($type, $result, true); < } else { < return completion_info::aggregate_completion_states($type, $result, false); < } < } < < // Check for score. < if ($scorm->completionscorerequired !== null) { < $maxscore = -1; < < foreach ($tracks as $track) { < if (!in_array($track->element, array('cmi.core.score.raw', 'cmi.score.raw'))) { < continue; < } < < if (strlen($track->value) && floatval($track->value) >= $maxscore) { < $maxscore = floatval($track->value); < } < } < < if ($scorm->completionscorerequired <= $maxscore) { < return completion_info::aggregate_completion_states($type, $result, true); < } else { < return completion_info::aggregate_completion_states($type, $result, false); < } < } < < return $result;
> function scorm_get_completion_state() { > $completionclass = \mod_scorm\completion\custom_completion::class; > throw new coding_exception(__FUNCTION__ . "() has been removed, please use the '{$completionclass}' class instead");
}