Hi,
is there a way to add a Block to a course via Web services or Api?
Moodle 2.8
Thanks
Hi Obeld
I this add block a course via webservice not option there. So we customize the code for PHP code. You accombish the following code
$context = get_context_instance(CONTEXT_COURSE, 'Courseid');
$contextid = $context->id;
$record = new stdClass();
$record->id = '';
$record->blockname = 'block name';
$record->parentcontextid = $contextid;
$record->showinsubcontexts = '0';
$record->pagetypepattern = 'course-view-*';
$record->subpagepattern = '';
$record->defaultregion = 'side-pre';
$record->defaultweight = '2';
$record->configdata = '';
$lastinsertid = $DB->insert_record('block_instances', $record, false);
This code what ever you need put this code and change course id.
Thanks
Kathir R
Hi Kathir,
so I can try this.
Thank you.
Welcome
happy Moodling