Search code examples
phpmoodlemoodle-api

PHP Get Assign ID in Moodle


I have editing /mod/assign/view.php in moodle. in that file I'm printing $assign and showing result in browser like this.

assign Object
(
[instance:assign:private] => stdClass Object
    (
        [id] => 2
        [course] => 2
        [name] => create story telling
        [intro] => <p dir="ltr" style="text-align: left;">story from your self</p><p dir="ltr" style="text-align: left;"><br></p>
        [introformat] => 1
        [activity] => <p dir="ltr" style="text-align: left;">submit your pdf file</p>
        [activityformat] => 1
        [timelimit] => 0
        [submissionattachments] => 0
    )

how can I get id=2 from that object?


Solution

  • Try this

    $instanceid = $assign->get_instance()->id;