PHP获取Moodle中的分配ID

huangapple go评论46阅读模式
英文:

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;

huangapple
  • 本文由 发表于 2023年7月13日 13:22:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76676163.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定