/**
 * Delete cohort.
 * @param  stdClass $cohort
 * @return void
 */
function meditraxcohort_delete_cohort($cohort)
{
    global $DB;
    if ($cohort->component) {
        // TODO: add component delete callback
    }
    $DB->delete_records('cohort_members', array('cohortid' => $cohort->id));
    $DB->delete_records('cohort', array('id' => $cohort->id));
    $event = \core\event\cohort_deleted::create(array('context' => context::instance_by_id($cohort->contextid), 'objectid' => $cohort->id));
    $event->add_record_snapshot('cohort', $cohort);
    $event->trigger();
}
Example #2
0
/**
 * Delete cohort.
 * @param  stdClass $cohort
 * @return void
 */
function cohort_delete_cohort($cohort)
{
    global $DB;
    if ($cohort->component) {
        // TODO: add component delete callback
    }
    $DB->delete_records('cohort_members', array('cohortid' => $cohort->id));
    $DB->delete_records('cohort', array('id' => $cohort->id));
    // Notify the competency subsystem.
    \core_competency\api::hook_cohort_deleted($cohort);
    $event = \core\event\cohort_deleted::create(array('context' => context::instance_by_id($cohort->contextid), 'objectid' => $cohort->id));
    $event->add_record_snapshot('cohort', $cohort);
    $event->trigger();
}