Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get $cm->id based on the $courseId In Moodle 2.6.0 Version?

Tags:

php

moodle

I need $cm->id Because In latest Moodle 2.6.0 Version.
$context = get_context_instance(CONTEXT_MODULE, $courseId);
Not Working Above Code.
Instead Of this given code I need to implement.

$contextmodule = context_module::instance($cm->id);
Use of this code i need $contextId;

Hence my point is how can I get $cm->id Or $contextmodule using $courseId.

Thanks in advance.

like image 606
GJK President Avatar asked Jan 25 '26 03:01

GJK President


1 Answers

You should use course module ID as the argument for the function.

$contextModuleData = context_module::instance($contextModule->id);
like image 196
gnuwings Avatar answered Jan 27 '26 19:01

gnuwings



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!