Moosh\Command\Moodle23\Course\CourseCreate::execute PHP Method

execute() public method

public execute ( )
    public function execute()
    {
        global $CFG;
        require_once $CFG->dirroot . '/course/lib.php';
        foreach ($this->arguments as $argument) {
            $this->expandOptionsManually(array($argument));
            $options = $this->expandedOptions;
            $course = new \stdClass();
            $course->fullname = $options['fullname'];
            $course->shortname = $argument;
            $course->description = $options['description'];
            $format = $options['format'];
            if (!$format) {
                $format = get_config('moodlecourse', 'format');
            }
            $course->format = $format;
            $course->idnumber = $options['idnumber'];
            $visible = strtolower($options['visible']);
            if ($visible == 'n' || $visible == 'no') {
                $visible = 0;
            } else {
                $visible = 1;
            }
            $course->visible = $visible;
            $course->category = $options['category'];
            $course->summary = '';
            $course->summaryformat = FORMAT_HTML;
            $course->startdate = time();
            //either use API create_course
            $newcourse = create_course($course);
            echo $newcourse->id . "\n";
        }
    }