public function mark_complete($timecomplete = null) {
        global $USER;

        // Never change a completion time.
        if ($this->timecompleted) {
            return;
        }

        // Use current time if nothing supplied.
        if (!$timecomplete) {
            $timecomplete = time();
        }

        // Set time complete.
        $this->timecompleted = $timecomplete;

        // Save record.
        if ($result = $this->_save()) {
            $data = $this->get_record_data();
            \core\event\course_completed::create_from_completion($data)->trigger();
        }

        return $result;
    }
public function mark_complete($timecomplete = null) {
        global $USER;

        // Never change a completion time.
        if ($this->timecompleted) {
            return;
        }

        // Use current time if nothing supplied.
        if (!$timecomplete) {
            $timecomplete = time();
        }

        // Set time complete.
        $this->timecompleted = $timecomplete;

        // Save record.
        if ($result = $this->_save()) {
            $data = $this->get_record_data();
            \core\event\course_completed::create_from_completion($data)->trigger();
        }

        return $result;
    }
public function mark_complete ( $ timecomplete = null ) { global $ USER ; // Never change a completion time. if ( $ this -> timecompleted ) { return ; } // Use current time if nothing supplied. if ( ! $ timecomplete ) { $ timecomplete = time ( ) ; } // Set time complete. $ this -> timecompleted = $ timecomplete ; // Save record. if ( $ result = $ this -> _save ( ) ) { $ data = $ this -> get_record_data ( ) ; \ core \ event \ course_completed :: create_from_completion ( $ data ) -> trigger ( ) ; } return $ result ; }
Mark this user complete in this course

This generally happens when the required completion criteria
in the course are complete.

@param integer $timecomplete Time completed (optional)
@return void
Mark this user complete in this course