Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 319... Línea 319...
319
        // Return course-module completion value
319
        // Return course-module completion value
320
        return $cm->completion;
320
        return $cm->completion;
321
    }
321
    }
Línea 322... Línea 322...
322
 
322
 
323
    /**
-
 
324
     * @deprecated since Moodle 2.0 - Use display_help_icon instead.
-
 
325
     */
-
 
326
    public function print_help_icon() {
-
 
327
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
-
 
328
    }
-
 
329
 
-
 
330
    /**
-
 
331
     * @deprecated since Moodle 4.0 - The 'Your progress' info isn't displayed any more.
-
 
332
     */
-
 
333
    public function display_help_icon() {
-
 
334
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
-
 
335
    }
-
 
336
 
-
 
337
    /**
323
    /**
338
     * Get a course completion for a user
324
     * Get a course completion for a user
339
     *
325
     *
340
     * @param int $user_id User id
326
     * @param int $user_id User id
341
     * @param int $criteriatype Specific criteria type to return
327
     * @param int $criteriatype Specific criteria type to return
Línea 489... Línea 475...
489
 
475
 
490
        return $aggregation->method;
476
        return $aggregation->method;
Línea 491... Línea 477...
491
    }
477
    }
492
 
-
 
493
    /**
-
 
494
     * @deprecated since Moodle 2.8 MDL-46290.
-
 
495
     */
-
 
496
    public function get_incomplete_criteria() {
-
 
497
        throw new coding_exception('completion_info->get_incomplete_criteria() is removed.');
-
 
498
    }
-
 
499
 
478
 
500
    /**
479
    /**
501
     * Clear old course completion criteria
480
     * Clear old course completion criteria
502
     */
481
     */
Línea 621... Línea 600...
621
                ($current->completionstate == COMPLETION_COMPLETE_PASS ||
600
                ($current->completionstate == COMPLETION_COMPLETE_PASS ||
622
                $current->completionstate == COMPLETION_COMPLETE_FAIL))) {
601
                $current->completionstate == COMPLETION_COMPLETE_FAIL))) {
623
            return;
602
            return;
624
        }
603
        }
Línea 625... Línea -...
625
 
-
 
626
        // The activity completion alters the course state cache for this particular user.
-
 
627
        $course = get_course($cm->course);
-
 
628
        if ($course) {
-
 
629
            course_format::session_cache_reset($course);
-
 
630
        }
-
 
631
 
604
 
632
        // For auto tracking, if the status is overridden to 'COMPLETION_COMPLETE', then disallow further changes,
605
        // For auto tracking, if the status is overridden to 'COMPLETION_COMPLETE', then disallow further changes,
633
        // unless processing another override.
606
        // unless processing another override.
634
        // Basically, we want those activities which have been overridden to COMPLETE to hold state, and those which have been
607
        // Basically, we want those activities which have been overridden to COMPLETE to hold state, and those which have been
635
        // overridden to INCOMPLETE to still be processed by normal completion triggers.
608
        // overridden to INCOMPLETE to still be processed by normal completion triggers.
Línea 657... Línea 630...
657
        if ($newstate != $current->completionstate) {
630
        if ($newstate != $current->completionstate) {
658
            $current->completionstate = $newstate;
631
            $current->completionstate = $newstate;
659
            $current->timemodified    = time();
632
            $current->timemodified    = time();
660
            $current->overrideby      = $override ? $USER->id : null;
633
            $current->overrideby      = $override ? $USER->id : null;
661
            $this->internal_set_data($cm, $current, $isbulkupdate);
634
            $this->internal_set_data($cm, $current, $isbulkupdate);
-
 
635
 
-
 
636
            // Dispatch the hook for course content update.
-
 
637
            // The activity completion alters the course state cache for this particular user.
-
 
638
            $course = get_course($cm->course);
-
 
639
            if ($course) {
-
 
640
                $modinfo = get_fast_modinfo($course);
-
 
641
                $cminfo = $modinfo->get_cm($cm->id);
-
 
642
                $hook = new \core_completion\hook\after_cm_completion_updated(
-
 
643
                    cm: $cminfo,
-
 
644
                    data: $current,
-
 
645
                );
-
 
646
                \core\di::get(\core\hook\manager::class)->dispatch($hook);
-
 
647
            }
662
        }
648
        }
663
    }
649
    }
Línea 664... Línea 650...
664
 
650
 
665
    /**
651
    /**
Línea 1393... Línea 1379...
1393
     * @param context $extracontext If set, includes extra user information fields
1379
     * @param context $extracontext If set, includes extra user information fields
1394
     *   as appropriate to display for current user in this context
1380
     *   as appropriate to display for current user in this context
1395
     * @return array Array of user objects with user fields (including all identity fields)
1381
     * @return array Array of user objects with user fields (including all identity fields)
1396
     */
1382
     */
1397
    public function get_tracked_users($where = '', $whereparams = array(), $groupid = 0,
1383
    public function get_tracked_users($where = '', $whereparams = array(), $groupid = 0,
1398
             $sort = '', $limitfrom = '', $limitnum = '', context $extracontext = null) {
1384
             $sort = '', $limitfrom = '', $limitnum = '', ?context $extracontext = null) {
Línea 1399... Línea 1385...
1399
 
1385
 
Línea 1400... Línea 1386...
1400
        global $DB;
1386
        global $DB;
1401
 
1387
 
Línea 1445... Línea 1431...
1445
     * @return array with ->total and ->start (same as $start) and ->users;
1431
     * @return array with ->total and ->start (same as $start) and ->users;
1446
     *   an array of user objects (like mdl_user id, firstname, lastname)
1432
     *   an array of user objects (like mdl_user id, firstname, lastname)
1447
     *   containing an additional ->progress array of coursemoduleid => completionstate
1433
     *   containing an additional ->progress array of coursemoduleid => completionstate
1448
     */
1434
     */
1449
    public function get_progress_all($where = '', $where_params = array(), $groupid = 0,
1435
    public function get_progress_all($where = '', $where_params = array(), $groupid = 0,
1450
            $sort = '', $pagesize = '', $start = '', context $extracontext = null) {
1436
            $sort = '', $pagesize = '', $start = '', ?context $extracontext = null) {
1451
        global $CFG, $DB;
1437
        global $CFG, $DB;
Línea 1452... Línea 1438...
1452
 
1438
 
1453
        // Get list of applicable users
1439
        // Get list of applicable users
1454
        $users = $this->get_tracked_users($where, $where_params, $groupid, $sort,
1440
        $users = $this->get_tracked_users($where, $where_params, $groupid, $sort,
Línea 1639... Línea 1625...
1639
            unset($data->cmvuserid);
1625
            unset($data->cmvuserid);
1640
        }
1626
        }
Línea 1641... Línea 1627...
1641
 
1627
 
1642
        return (array)$data;
1628
        return (array)$data;
-
 
1629
    }
-
 
1630
 
-
 
1631
    /**
-
 
1632
     * Return the number of modules completed by a user in one specific course.
-
 
1633
     *
-
 
1634
     * @param int $userid The User ID.
-
 
1635
     * @return int Total number of modules completed by a user
-
 
1636
     */
-
 
1637
    public function count_modules_completed(int $userid): int {
-
 
1638
        global $DB;
-
 
1639
 
-
 
1640
        $sql = "SELECT COUNT(1)
-
 
1641
                  FROM {course_modules} cm
-
 
1642
                  JOIN {course_modules_completion} cmc ON cm.id = cmc.coursemoduleid
-
 
1643
                 WHERE cm.course = :courseid
-
 
1644
                       AND cmc.userid = :userid
-
 
1645
                       AND (cmc.completionstate = " . COMPLETION_COMPLETE . "
-
 
1646
                        OR cmc.completionstate = " . COMPLETION_COMPLETE_PASS . ")";
-
 
1647
        $params = ['courseid' => $this->course_id, 'userid' => $userid];
-
 
1648
 
-
 
1649
        return $DB->count_records_sql($sql, $params);
1643
    }
1650
    }
Línea 1644... Línea 1651...
1644
}
1651
}
1645
 
1652
 
1646
/**
1653
/**