public function process_computed_correlation(stdClass $tagcorrelation) {
        global $DB;

        // You must provide a tagid and correlatedtags must be set and be an array.
        if (empty($tagcorrelation->tagid) || !isset($tagcorrelation->correlatedtags) ||
                !is_array($tagcorrelation->correlatedtags)) {
            return false;
        }

        $tagcorrelation->correlatedtags = join(',', $tagcorrelation->correlatedtags);
        if (!empty($tagcorrelation->id)) {
            // The tag correlation already exists so update it.
            $DB->update_record('tag_correlation', $tagcorrelation);
        } else {
            // This is a new correlation to insert.
            $tagcorrelation->id = $DB->insert_record('tag_correlation', $tagcorrelation);
        }
        return $tagcorrelation->id;
    }