protected function build_limitcourseids(\stdClass $formdata) {
        $limitcourseids = false;

        if (!empty($formdata->mycoursesonly)) {
            $limitcourseids = array_keys($this->get_my_courses(false));
        }

        if (!empty($formdata->courseids)) {
            if (empty($limitcourseids)) {
                $limitcourseids = $formdata->courseids;
            } else {
                $limitcourseids = array_intersect($limitcourseids, $formdata->courseids);
            }
        }

        return $limitcourseids;
    }