protected static function delete_user_evidence_of_prior_learning($userid) {
        global $DB;

        $usercontext = context_user::instance($userid);
        $ueids = $DB->get_fieldset_select(user_evidence::TABLE, 'id', 'userid = :userid', ['userid' => $userid]);
        if (empty($ueids)) {
            return;
        }
        list($insql, $inparams) = $DB->get_in_or_equal($ueids, SQL_PARAMS_NAMED);

        // Delete competencies associated with user evidence.
        $DB->delete_records_select(user_evidence_competency::TABLE, "userevidenceid $insql", $inparams);

        // Delete the user evidence.
        $DB->delete_records_select(user_evidence::TABLE, "id $insql", $inparams);

        // Delete the user evidence files.
        $fs = get_file_storage();
        $fs->delete_area_files($usercontext->id, 'core_competency', 'userevidence');
    }