英文:
PHP Get Assign ID in Moodle
问题
如何从该对象中获取 id=2?
您可以使用以下代码从该对象中获取 id=2:
$id = $assign->instance->id;
这将从 $assign
对象的 instance
属性中获取 id
的值,该值为 2
。
英文:
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?
答案1
得分: 1
$instanceid = $assign->get_instance()->id;
英文:
Try this
$instanceid = $assign->get_instance()->id;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论