Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1436
Línea 33... Línea 33...
33
 *
33
 *
34
 * @package    core_completion
34
 * @package    core_completion
35
 * @copyright  2017 Mark Nelson <markn@moodle.com>
35
 * @copyright  2017 Mark Nelson <markn@moodle.com>
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
37
 */
38
class progress {
38
class progress
-
 
39
{
Línea 39... Línea 40...
39
 
40
 
40
    /**
41
    /**
41
     * Returns the course percentage completed by a certain user, returns null if no completion data is available.
42
     * Returns the course percentage completed by a certain user, returns null if no completion data is available.
42
     *
43
     *
43
     * @param \stdClass $course Moodle course object
44
     * @param \stdClass $course Moodle course object
44
     * @param int $userid The id of the user, 0 for the current user
45
     * @param int $userid The id of the user, 0 for the current user
45
     * @return null|float The percentage, or null if completion is not supported in the course,
46
     * @return null|float The percentage, or null if completion is not supported in the course,
46
     *         or there are no activities that support completion.
47
     *         or there are no activities that support completion.
47
     */
48
     */
-
 
49
    public static function get_course_progress_percentage($course, $userid = 0)
48
    public static function get_course_progress_percentage($course, $userid = 0) {
50
    {
Línea 49... Línea 51...
49
        global $USER;
51
        global $USER;
50
 
52
 
51
        // Make sure we continue with a valid userid.
53
        // Make sure we continue with a valid userid.
Línea 84... Línea 86...
84
                $completed += 0;
86
                $completed += 0;
85
            } else {
87
            } else {
86
                $completed += 1;
88
                $completed += 1;
87
            };
89
            };
88
        }
90
        }
-
 
91
        if ($count == 0) {
-
 
92
            return 0;
89
 
93
        }
90
        return ($completed / $count) * 100;
94
        return ($completed / $count) * 100;
91
    }
95
    }
92
}
96
}