public function save_user_extension($userid, $extensionduedate) {
        global $DB;

        // Need submit permission to submit an assignment.
        require_capability('mod/assign:grantextension', $this->context);

        if (!is_enrolled($this->get_course_context(), $userid)) {
            return false;
        }
        if (!has_capability('mod/assign:submit', $this->context, $userid)) {
            return false;
        }

        if ($this->get_instance()->duedate && $extensionduedate) {
            if ($this->get_instance()->duedate > $extensionduedate) {
                return false;
            }
        }
        if ($this->get_instance()->allowsubmissionsfromdate && $extensionduedate) {
            if ($this->get_instance()->allowsubmissionsfromdate > $extensionduedate) {
                return false;
            }
        }

        $flags = $this->get_user_flags($userid, true);
        $flags->extensionduedate = $extensionduedate;

        $result = $this->update_user_flags($flags);

        if ($result) {
            \mod_assign\event\extension_granted::create_from_assign($this, $userid)->trigger();
        }
        return $result;
    }
public function save_user_extension($userid, $extensionduedate) {
        global $DB;

        // Need submit permission to submit an assignment.
        require_capability('mod/assign:grantextension', $this->context);

        if (!is_enrolled($this->get_course_context(), $userid)) {
            return false;
        }
        if (!has_capability('mod/assign:submit', $this->context, $userid)) {
            return false;
        }

        if ($this->get_instance()->duedate && $extensionduedate) {
            if ($this->get_instance()->duedate > $extensionduedate) {
                return false;
            }
        }
        if ($this->get_instance()->allowsubmissionsfromdate && $extensionduedate) {
            if ($this->get_instance()->allowsubmissionsfromdate > $extensionduedate) {
                return false;
            }
        }

        $flags = $this->get_user_flags($userid, true);
        $flags->extensionduedate = $extensionduedate;

        $result = $this->update_user_flags($flags);

        if ($result) {
            \mod_assign\event\extension_granted::create_from_assign($this, $userid)->trigger();
        }
        return $result;
    }
public function save_user_extension ( $ userid , $ extensionduedate ) { global $ DB ; // Need submit permission to submit an assignment. require_capability ( 'mod/assign:grantextension' , $ this -> context ) ; if ( ! is_enrolled ( $ this -> get_course_context ( ) , $ userid ) ) { return false ; } if ( ! has_capability ( 'mod/assign:submit' , $ this -> context , $ userid ) ) { return false ; } if ( $ this -> get_instance ( ) -> duedate && $ extensionduedate ) { if ( $ this -> get_instance ( ) -> duedate > $ extensionduedate ) { return false ; } } if ( $ this -> get_instance ( ) -> allowsubmissionsfromdate && $ extensionduedate ) { if ( $ this -> get_instance ( ) -> allowsubmissionsfromdate > $ extensionduedate ) { return false ; } } $ flags = $ this -> get_user_flags ( $ userid , true ) ; $ flags -> extensionduedate = $ extensionduedate ; $ result = $ this -> update_user_flags ( $ flags ) ; if ( $ result ) { \ mod_assign \ event \ extension_granted :: create_from_assign ( $ this , $ userid ) -> trigger ( ) ; } return $ result ; }
Save the extension date for a single user.

@param int $userid The user id
@param mixed $extensionduedate Either an integer date or null
@return boolean
Save the extension date for a single user .