public static function convert_flat_itemids_to_array($itemids) {
        $items = array();

        // We just have one single item id.
        if (is_int($itemids)) {
            $itemid = clean_param($itemids, PARAM_INT);
            $items[$itemid] = 1;
        } else {
            // Few grade items.
            $items = array_flip(explode(',', $itemids));
            foreach ($items as $itemid => $value) {
                $itemid = clean_param($itemid, PARAM_INT);
                $items[$itemid] = 1;
            }
        }
        return $items;
    }