$ce_check = array();

if ($rs = get_recordset_sql($sql)) {
    while ($completion = rs_fetch_next_record($rs)) {
        $dangling_total++;

        $completion->locked = 1;

        // Make sure a timemodified value is set, just in case
        if ($completion->timemodified == 0) {
            $completion->timemodified = $timenow;
        }

        if (update_record(GRDTABLE, $completion)) {
            $dangling_fixed++;
        }
    }

    rs_close($rs);
}
*/
$a = new stdClass();
$a->fixed = $dangling_fixed;
$a->total = $dangling_total;
mtrace(' >>> ' . get_string('health_dangling_fixed_counts', 'block_curr_admin', $a));
if ($dangling_fixed > 0) {
    mtrace(' >>> ' . get_string('health_dangling_recalculate', 'block_curr_admin'), '');
    cm_update_class_grades();
    mtrace(get_string('done', 'block_curr_admin') . '!');
}
Example #2
0
/**
 * Get all of the data from Moodle and update the curriculum system.
 * This should do the following:
 *      - Get all Moodle courses connected with classes.
 *      - Get all users in each Moodle course.
 *      - Get grade records from the class's course and completion elements.
 *      - For each user:
 *          - Check if they have an enrolment record in CM, and add if not.
 *          - Update grade information in the enrollment and grade tables in CM.
 *
 */
function cm_update_student_progress()
{
    global $CFG;
    require_once $CFG->dirroot . '/grade/lib.php';
    require_once $CFG->dirroot . '/grade/querylib.php';
    /// Get all grades in all relevant courses for all relevant users.
    require_once $CFG->dirroot . '/curriculum/lib/classmoodlecourse.class.php';
    require_once $CFG->dirroot . '/curriculum/lib/student.class.php';
    require_once $CFG->dirroot . '/curriculum/lib/cmclass.class.php';
    require_once $CFG->dirroot . '/curriculum/lib/course.class.php';
    /// Start with the Moodle classes...
    mtrace("Synchronizing Moodle class grades<br />\n");
    cm_synchronize_moodle_class_grades();
    flush();
    sleep(1);
    /// Now we need to check all of the student and grade records again, since data may have come from sources
    /// other than Moodle.
    mtrace("Updating all class grade completions.<br />\n");
    cm_update_class_grades();
    return true;
}