Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
.
/**
* Contains class used to return completion progress information.
*
* @package core_completion
* @copyright 2017 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_completion;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/completionlib.php');
/**
* Class used to return completion progress information.
*
* @package core_completion
* @copyright 2017 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class progress {
/**
* Returns the course percentage completed by a certain user, returns null if no completion data is available.
*
* @param \stdClass $course Moodle course object
* @param int $userid The id of the user, 0 for the current user
* @return null|float The percentage, or null if completion is not supported in the course,
* or there are no activities that support completion.
*/
public static function get_course_progress_percentage($course, $userid = 0) {
global $USER;
// Make sure we continue with a valid userid.
if (empty($userid)) {
$userid = $USER->id;
}
$completion = new \completion_info($course);
// First, let's make sure completion is enabled.
if (!$completion->is_enabled()) {
return null;
}
if (!$completion->is_tracked_user($userid)) {
return null;
}
// Before we check how many modules have been completed see if the course has.
if ($completion->is_course_complete($userid)) {
return 100;
}
// Get the number of modules that support completion.
$modules = $completion->get_activities();
$count = count($modules);
if (!$count) {
return null;
}
// Get the number of modules that have been completed.
$completed = 0;
foreach ($modules as $module) {
$data = $completion->get_data($module, true, $userid);
if (($data->completionstate == COMPLETION_INCOMPLETE) || ($data->completionstate == COMPLETION_COMPLETE_FAIL)) {
$completed += 0;
} else {
$completed += 1;
};
}
return ($completed / $count) * 100;
}
}