$cms = array();
$modinfo = get_courses();
foreach ($modinfo->cms as $id => $othercm) {
$cms[] = (object)array('id' => $id,
'name' => format_string($othercm->fullname, true, array('context' => $context)),
'completiongradeitemnumber' => $othercm->shortname);
}
var_dump($cms);die();
any error?