本文整理汇总了PHP中delete_course_module函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_course_module函数的具体用法?PHP delete_course_module怎么用?PHP delete_course_module使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_course_module函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ma_delete_execute
function ma_delete_execute($modids)
{
global $CFG;
$in_list = "(" . join(", ", $modids) . ")";
$sql = "SELECT cm.id as coursemodule, cm.section, cm.course, mo.name as modulename, instance\n FROM {$CFG->prefix}course_modules cm\n LEFT JOIN {$CFG->prefix}modules mo on mo.id=cm.module\n WHERE cm.id IN {$in_list}";
$records = get_records_sql($sql);
$courses = array();
$message = '';
if ($records) {
foreach ($records as $id => $record) {
$modlib = "{$CFG->dirroot}/mod/{$record->modulename}/lib.php";
$courses[] = $record->course;
if (file_exists($modlib)) {
include_once $modlib;
} else {
$message .= "This module is missing important code! ({$modlib}) ";
continue;
}
$deleteinstancefunction = $record->modulename . "_delete_instance";
if (!$deleteinstancefunction($record->instance)) {
$message .= "Could not delete the {$record->modulename} (instance) ";
continue;
}
if (!delete_course_module($record->coursemodule)) {
$message .= "Could not delete the {$record->modulename} (coursemodule) ";
continue;
}
if (!delete_mod_from_section($record->coursemodule, "{$record->section}")) {
$message .= "Could not delete the {$record->modulename} from that section ";
continue;
}
}
}
return $message;
}
示例2: forumng_delete_instance
function forumng_delete_instance($id)
{
global $DB;
require_once dirname(__FILE__) . '/mod_forumng.php';
$cm = get_coursemodule_from_instance('forumng', $id);
$forum = mod_forumng::get_from_id($id, mod_forumng::CLONE_DIRECT, true, $cm);
$forum->delete_all_data();
if (mod_forumng::search_installed()) {
$cm = $forum->get_course_module();
local_ousearch_document::delete_module_instance_data($cm);
}
if ($forum->is_shared()) {
// Find all the clone instances.
$clones = $forum->get_clone_details();
$transaction = $DB->start_delegated_transaction();
foreach ($clones as $clone) {
if (!forumng_delete_instance($clone->cloneforumngid)) {
notify("Could not delete the Clone forumng (id) {$clone->cloneforumngid} ");
return false;
}
if (!delete_course_module($clone->context->instanceid)) {
notify("Could not delete the Clone\n forumng (coursemoduleid) {$clone->context}->instanceid ");
return false;
}
if (!delete_mod_from_section($clone->context->instanceid, $clone->sectionid)) {
notify("Could not delete the sectionid {$clone->sectionid} from that section");
return false;
}
rebuild_course_cache($clone->courseid, true);
}
$transaction->allow_commit();
}
return $DB->delete_records('forumng', array('id' => $id));
}
示例3: delete
private static function delete($modulename, $course, $title, $section)
{
global $DB, $CFG;
$sql = 'SELECT cm.id FROM {course_sections} AS cs JOIN {course_modules} AS cm ON cm.section = cs.id JOIN {modules} AS ms ON ms.id = cm.module JOIN {' . $modulename . '} AS m ON m.id = cm.instance WHERE cs.course = ? AND cs.section = ? AND m.name = ? AND ms.name = ?';
$instances = $DB->get_records_sql($sql, array($course->id, $section, $title, $modulename));
foreach ($instances as $instance) {
$cm = get_coursemodule_from_id('', $instance->id);
$modlib = "{$CFG->dirroot}/mod/{$cm->modname}/lib.php";
if (file_exists($modlib)) {
require_once $modlib;
} else {
return false;
}
$deleteinstancefunction = $cm->modname . "_delete_instance";
if (!$deleteinstancefunction($cm->instance)) {
return false;
}
if (!delete_course_module($cm->id)) {
return false;
}
if (!delete_mod_from_section($cm->id, $cm->section)) {
return false;
}
// Trigger a mod_deleted event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $cm->modname;
$eventdata->cmid = $cm->id;
$eventdata->courseid = $course->id;
$eventdata->userid = 0;
events_trigger('mod_deleted', $eventdata);
}
return true;
}
示例4: finish_setup_course_module
/**
* Called after the mod has set itself up, to finish off any course module settings
* (set instance id, add to correct section, set visibility, etc.) and send the response
*
* @param int $instanceid id returned by the mod when it was created
*/
protected function finish_setup_course_module($instanceid)
{
global $DB, $USER;
if (!$instanceid) {
// Something has gone wrong - undo everything we can.
delete_course_module($this->cm->id);
throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
}
$DB->set_field('course_modules', 'instance', $instanceid, array('id' => $this->cm->id));
// Rebuild the course cache after update action
rebuild_course_cache($this->course->id, true);
$this->course->modinfo = null;
// Otherwise we will just get the old version back again.
$sectionid = course_add_cm_to_section($this->course, $this->cm->id, $this->section);
set_coursemodule_visible($this->cm->id, true);
// retrieve the final info about this module.
$info = get_fast_modinfo($this->course);
if (!isset($info->cms[$this->cm->id])) {
// The course module has not been properly created in the course - undo everything.
delete_course_module($this->cm->id);
throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
}
$mod = $info->cms[$this->cm->id];
$mod->groupmodelink = $this->cm->groupmodelink;
$mod->groupmode = $this->cm->groupmode;
// Trigger mod_created event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $mod->modname;
$eventdata->name = $mod->name;
$eventdata->cmid = $mod->id;
$eventdata->courseid = $this->course->id;
$eventdata->userid = $USER->id;
events_trigger('mod_created', $eventdata);
add_to_log($this->course->id, "course", "add mod", "../mod/{$mod->modname}/view.php?id={$mod->id}", "{$mod->modname} {$instanceid}");
add_to_log($this->course->id, $mod->modname, "add", "view.php?id={$mod->id}", "{$instanceid}", $mod->id);
$this->send_response($mod);
}
示例5: project_remove_section_contents
/**
* セクション内のコンテンツを削除
*
* @param object &$restore
* @return bool
*/
function project_remove_section_contents(&$restore)
{
global $CFG;
$status = true;
// 対象のコース情報の取得
if (!($course = get_record("course", "id", $restore->course_id))) {
error("Course ID was incorrect (can't find it)");
}
// 対象のセクション情報の取得
if (!($section = get_course_section($restore->section, $restore->course_id))) {
error("Section data was incorrect (can't find it)");
}
if ($restore->currentdirectoryname) {
$currentdirectoryname = $restore->currentdirectoryname;
} else {
// 現在のセクションのディレクトリ名を取得
if (!($sectiontitle = project_format_get_title($course, $section->id))) {
error("Section directory was incorrect");
}
$currentdirectoryname = $sectiontitle->directoryname;
}
// インスタンスを削除する
// セクション内のモジュールを取得
get_all_mods($course->id, &$mods, &$modnames, &$modnamesplural, &$modnamesused);
$modules = array();
foreach ($mods as $mod) {
if ($mod->section == $section->id) {
$modules[] = $mod;
}
}
// セクション内からモジュールを削除する
foreach ($modules as $mod) {
$modlib = "{$CFG->dirroot}/mod/{$mod->modname}/lib.php";
if (file_exists($modlib)) {
include_once $modlib;
} else {
error("This module is missing important code! ({$modlib})");
}
$deleteinstancefunction = $mod->modname . "_delete_instance";
if (!$deleteinstancefunction($mod->instance)) {
notify("Could not delete the {$mod->type} (instance)");
}
if (!delete_course_module($mod->id)) {
notify("Could not delete the {$mod->type} (coursemodule)");
}
if (!delete_mod_from_section($mod->id, $section->id)) {
notify("Could not delete the {$mod->type} from that section");
}
}
// ディレクトリを削除する
if (!($basedir = make_upload_directory("{$course->id}"))) {
error("The site administrator needs to fix the file permissions");
}
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("deletedirectory", 'format_project');
}
if (!($status = fulldelete($basedir . "/" . $currentdirectoryname))) {
if (!defined('RESTORE_SILENTLY')) {
notify("Error deleting directory");
} else {
$errorstr = "Error deleting directory.";
return false;
}
}
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
return $status;
}
示例6: voicepresentation_delete_all_instance_of_resource
function voicepresentation_delete_all_instance_of_resource($id)
{
/// Given an ID of an instance of this module,
/// this function will permanently delete the instance
/// and any data that depends on it.
//delete the resource of the vt list
$result = true;
wimba_add_log(WIMBA_INFO, voicepresentation_LOGS, "Delete the resouce " . $id);
if ($voicepresentation = get_records("voicepresentation", "rid", $id)) {
# Delete any dependent records here #
foreach ($voicepresentation as $voicetool) {
//get the course_module instance linked to the liveclassroom instance
$cm = get_coursemodule_from_instance("voicepresentation", $voicetool->id, $voicetool->course);
if (!empty($cm)) {
if (!delete_course_module($cm->id)) {
wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "Problem to delete the course module : " . $cm->id);
$result = false;
//Delete a course module and any associated data at the course level (events)
}
//delete the instance
if (!delete_records("voicepresentation", "id", $voicetool->id)) {
wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "Problem to delete all the activities associated to the voice tools");
$result = false;
}
//delete in the course section too
if (!delete_mod_from_section($cm->id, $cm->section)) {
wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, "Could not delete the " . $cm->id . " from that section : " . $cm->section);
$result = false;
}
voicepresentation_deleteCalendarEvent($voicetool->id);
}
}
}
voicepresentation_delete_resource($id);
return $result;
}
示例7: RWSADQuiz
function RWSADQuiz()
{
global $CFG;
global $RWSLB;
RWSCMAuth();
RWSCRAuth();
RWSCMUSvc();
RWSCMMaint();
$r_pm = RWSGSOpt("quizid", PARAM_ALPHANUM);
if ($r_pm === false || strlen($r_pm) == 0) {
RWSSErr("2067");
}
$r_qzmi = intval($r_pm);
$r_rcd = RWSCMUQuiz($r_qzmi);
$r_cid = $r_rcd->course;
RWSCMUCourse($r_cid, true);
if (respondusws_floatcompare($CFG->version, 2013051400, 2) >= 0) {
course_delete_module($r_qzmi);
} else {
if (!quiz_delete_instance($r_rcd->instance)) {
RWSSErr("2068");
}
if (!delete_course_module($r_qzmi)) {
RWSSErr("2069");
}
if (!delete_mod_from_section($r_qzmi, $r_rcd->section)) {
RWSSErr("2070");
}
}
if ($RWSLB->mok) {
lockdown_delete_options($r_rcd->instance);
} else {
if ($RWSLB->bok) {
lockdown_delete_options($r_rcd->instance);
}
}
rebuild_course_cache($r_cid);
RWSSStat("1003");
}
示例8: require_login
require_login($course_module->course);
// needed to setup proper $COURSE
$context_course = context_course::instance($course_module->course);
require_capability('moodle/course:manageactivities', $context_course);
if ($that_instance = $DB->get_record("referentiel", array("id" => "{$course_module->instance}"))) {
if (function_exists('course_delete_module')) {
// Moodle v 2.5 et suivantes
if (course_delete_module($course_module->id)) {
if (delete_mod_from_section($course_module->id, "{$course_module->section}")) {
rebuild_course_cache($course_record->id);
$msg .= get_string('instance_deleted', 'referentiel') . ' ' . $that_instance->name;
}
}
} else {
// Moodle v 2.x
if (delete_course_module($course_module->id)) {
if (delete_mod_from_section($course_module->id, "{$course_module->section}")) {
rebuild_course_cache($course_record->id);
$msg .= get_string('instance_deleted', 'referentiel') . ' ' . $that_instance->name;
}
}
}
// Supprimer l'instance
if (!referentiel_delete_instance($that_instance->id)) {
$record_course = $DB->get_record('course', array('id' => $that_instance->course));
$msg .= "<br />" . get_string('instance', 'referentiel') . " {$that_instance->name} (#{$that_instance->id}) " . get_string('course') . " {$record_course->fullname} ({$record_course->shortname}) " . get_string('not_deleted', 'referentiel') . "\n";
}
}
}
}
}
示例9: taskchain_navigation_accesscontrol_form
//.........这里部分代码省略.........
}
foreach ($selected_cmids as $cmid => $cm) {
$updated = false;
$skipped = false;
$regrade_item_id = 0;
$modhaslibfile = file_exists("{$CFG->dirroot}/mod/{$cm->modname}/lib.php");
// get the $instance of this $cm (include idnumber for grading)
$instance = $DB->get_record($cm->modname, array('id' => $cm->instance));
$instance->cmidnumber = $cm->idnumber;
// get module context
$modulecontext = context_module::instance($cm->id);
if ($action == 'delete') {
if (function_exists('course_delete_module')) {
// Moodle >= 2.5
course_delete_module($cm->id);
} else {
// Moodle <= 2.4
$filepath = $CFG->dirroot . '/mod/' . $cm->modname . '/lib.php';
if (!file_exists($filepath)) {
$msg = "{$cm->modname} lib.php not found at {$filepath}";
echo $OUTPUT->notification($msg);
}
require_once $filepath;
$deleteinstancefunction = $cm->modname . '_delete_instance';
if (!function_exists($deleteinstancefunction)) {
$msg = "{$cm->modname} delete function not found ({$deleteinstancefunction})";
echo $OUTPUT->notification($msg);
}
// copied from "course/mod.php"
if (!$deleteinstancefunction($cm->instance)) {
$msg = "Could not delete the {$cm->modname} (instance id={$cm->instance})";
echo $OUTPUT->notification($msg);
}
if (!delete_course_module($cm->id)) {
$msg = "Could not delete the {$cm->modname} (coursemodule, id={$cm->id})";
echo $OUTPUT->notification($msg);
}
if (!($sectionid = $DB->get_field('course_sections', 'id', array('course' => $cm->course, 'section' => $cm->sectionnum)))) {
$msg = "Could not get section id (course id={$cm->course}, section num={$cm->sectionnum})";
echo $OUTPUT->notification($msg);
}
if (!delete_mod_from_section($cm->id, $sectionid)) {
$msg = "Could not delete the {$cm->modname} (id={$cm->id}) from that section (id={$sectionid})";
echo $OUTPUT->notification($msg);
}
add_to_log($cm->course, 'course', 'delete mod', "view.php?id={$cm->course}", "{$cm->modname} {$cm->instance}", $cm->id);
}
$rebuild_course_cache = true;
$updated = true;
}
// only check completion/conditions once per $cm
$conditions_checked = false;
$completion_updated = false;
// Note: $selected_settings should only contain anything if $action=='apply'
foreach ($selected_settings as $setting) {
switch ($setting) {
// activity instance settings
case 'availablefrom':
case 'availableuntil':
case 'availablecutoff':
case 'maxgrade':
case 'rating':
if ($cm->modname == 'taskchain') {
$table = 'taskchain_chains';
$id = $DB->get_field($table, 'id', array('parenttype' => 0, 'parentid' => $cm->instance));
} else {
示例10: delete_course_module
/**
* This function deletes the old assignment course module after
* it has been upgraded. This code is adapted from "course/mod.php".
*
* @param stdClass $cm The course module to delete.
* @return bool
*/
private function delete_course_module($cm)
{
global $CFG, $USER, $DB, $OUTPUT;
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$coursecontext = context_course::instance($course->id);
$modcontext = context_module::instance($cm->id);
$modlib = "{$CFG->dirroot}/mod/{$cm->modname}/lib.php";
if (file_exists($modlib)) {
require_once $modlib;
} else {
print_error('modulemissingcode', '', '', $modlib);
}
$deleteinstancefunction = $cm->modname . "_delete_instance";
if (!$deleteinstancefunction($cm->instance)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} (instance)");
}
// remove all module files in case modules forget to do that
$fs = get_file_storage();
$fs->delete_area_files($modcontext->id);
if (!delete_course_module($cm->id)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} (coursemodule)");
}
if (!delete_mod_from_section($cm->id, $cm->section)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} from that section");
}
// Trigger a mod_deleted event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $cm->modname;
$eventdata->cmid = $cm->id;
$eventdata->courseid = $course->id;
$eventdata->userid = $USER->id;
events_trigger('mod_deleted', $eventdata);
add_to_log($course->id, 'course', "delete mod", "view.php?id={$cm->course}", "{$cm->modname} {$cm->instance}", $cm->id);
return true;
}
示例11: delete_module
/**
* function used to delete a module - copied from course/mod.php, it would
* be nice for this to be a core function.
* @param stdclass $cm full course modules record
*/
public function delete_module($cm)
{
global $CFG, $OUTPUT, $USER, $DB;
$cm->modname = $DB->get_field("modules", "name", array("id" => $cm->module));
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$modlib = "{$CFG->dirroot}/mod/{$cm->modname}/lib.php";
if (file_exists($modlib)) {
require_once $modlib;
} else {
print_error('modulemissingcode', '', '', $modlib);
}
$deleteinstancefunction = $cm->modname . "_delete_instance";
if (!$deleteinstancefunction($cm->instance)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} (instance)");
}
// Remove all module files in case modules forget to do that.
$fs = get_file_storage();
$fs->delete_area_files($modcontext->id);
if (!delete_course_module($cm->id)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} (coursemodule)");
}
if (!delete_mod_from_section($cm->id, $cm->section)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} from that section");
}
// Trigger a mod_deleted event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $cm->modname;
$eventdata->cmid = $cm->id;
$eventdata->courseid = $cm->course;
$eventdata->userid = $USER->id;
events_trigger('mod_deleted', $eventdata);
add_to_log($cm->course, 'course', "delete mod", "view.php?id={$cm->course}", "{$cm->modname} {$cm->instance}", $cm->id);
rebuild_course_cache($cm->course);
}
示例12: delete_course_module
delete_course_module($cm->id);
redirect("../../course/view.php?id={$course->id}");
}
} else {
if (!($wwassignment = get_record("wwassignment", "id", $a))) {
error("Course module is incorrect");
}
if (!($course = get_record("course", "id", $wwassignment->course))) {
error("Course is misconfigured");
}
if (!($cm = get_coursemodule_from_instance("wwassignment", $wwassignment->id, $course->id))) {
error("Course Module ID was incorrect");
}
if ($wwassignment->webwork_set == "undefined") {
delete_records("wwassignment", "webwork_set", "undefined");
delete_course_module($cm->id);
redirect("../../course/view.php?id={$course->id}");
}
}
require_login($course->id);
$webworksetlink = wwassignment_view_link($wwassignment->id);
add_to_log($course->id, "wwassignment", "view", "view.php?id={$cm->id}", "{$wwassignment->id}");
/// Print the page header
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->";
}
$strwwassignments = get_string("modulenameplural", "wwassignment");
$strwwassignment = get_string("modulename", "wwassignment");
print_header("{$course->shortname}: {$wwassignment->name}", "{$course->fullname}", "{$navigation} <a href='index.php?id={$course->id}'>{$strwwassignments}</a> -> {$wwassignment->name}", "", "", true, update_module_button($cm->id, $course->id, $strwwassignment), navmenu($course, $cm));
/// Print the main part of the page
print "<p style='font-size: smaller; color: #aaa;'>" . get_string("iframeNoShow-1", "wwassignment") . "<a href='{$sSetLink}'>" . get_string("iframeNoShow-2", "wwassignment") . "</a>.</p>\n";
示例13: perform_deletion
/**
* perform the actual deletion of the selected course modules
* @param array $modules
*/
function perform_deletion($modules)
{
global $CFG, $OUTPUT, $DB, $USER;
require_once $CFG->dirroot . '/course/lib.php';
foreach ($modules as $cm_record) {
if (!($cm = get_coursemodule_from_id('', $cm_record->id, 0, true))) {
print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record('course', array('id' => $cm->course)))) {
print_error('invalidcourseid');
}
$context = context_course::instance($course->id);
$modcontext = context_module::instance($cm->id);
require_capability('moodle/course:manageactivities', $context);
$modlib = $CFG->dirroot . '/mod/' . $cm->modname . '/lib.php';
if (file_exists($modlib)) {
require_once $modlib;
} else {
print_error('modulemissingcode', '', '', $modlib);
}
if (function_exists('course_delete_module')) {
// available from Moodle 2.5
course_delete_module($cm->id);
} else {
// pre Moodle 2.5
$deleteinstancefunction = $cm->modname . "_delete_instance";
if (!$deleteinstancefunction($cm->instance)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} (instance)");
}
// remove all module files in case modules forget to do that
$fs = get_file_storage();
$fs->delete_area_files($modcontext->id);
if (!delete_course_module($cm->id)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} (coursemodule)");
}
if (!delete_mod_from_section($cm->id, $cm->section)) {
echo $OUTPUT->notification("Could not delete the {$cm->modname} from that section");
}
// Trigger a mod_deleted event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $cm->modname;
$eventdata->cmid = $cm->id;
$eventdata->courseid = $course->id;
$eventdata->userid = $USER->id;
events_trigger('mod_deleted', $eventdata);
add_to_log($course->id, 'course', "delete mod", "view.php?id={$cm->course}", "{$cm->modname} {$cm->instance}", $cm->id);
}
}
}
示例14: update_file
public function update_file($cmid, $updatefilepath)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/mod/resource/lib.php';
require_once $CFG->dirroot . '/mod/resource/locallib.php';
// course module should contain section (id)
$coursemodule = $DB->get_record('course_modules', array('id' => $cmid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $coursemodule->course), '*', MUST_EXIST);
$resource = $DB->get_record('resource', array('id' => $coursemodule->instance), '*', MUST_EXIST);
self::require_access($course->id);
// should be able to get record including context id and instance - file id
$contextid = $DB->get_field('context', 'id', array('instanceid' => $coursemodule->id, 'contextlevel' => CONTEXT_MODULE));
$fs = get_file_storage();
$files = $fs->get_area_files($contextid, 'mod_resource', 'content', 0, 'sortorder, itemid, filepath, filename', false);
foreach ($files as $file) {
// delete the file
$file->delete();
// delete from database tables course_module, resource, context (via
// delete course module), section sequence (via delete mod from
// section), etext_usage
$DB->delete_records('resource', array('id' => $resource->id));
delete_mod_from_section($coursemodule, $coursemodule->section);
delete_course_module($cmid);
$DB->delete_records('coursereport_etexts_usage', array('cmid' => $cmid));
}
$this->add_file($coursemodule->section, $resource->name, $updatefilepath, $resource->display);
}
示例15: liveclassroom_delete_all_instance_of_room
function liveclassroom_delete_all_instance_of_room($roomid)
{
global $CFG;
// / Given an ID of an instance of this module,
// / this function will permanently delete the instance
// / and any data that depends on it.
$api = new LCApi($CFG->liveclassroom_servername, $CFG->liveclassroom_adminusername, $CFG->liveclassroom_adminpassword);
$result = true;
if ($liveclassrooms = get_records("liveclassroom", "type", $roomid)) {
$roomname = $api->lcapi_get_room_name($liveclassroom->type);
// Delete any dependent records here #
foreach ($liveclassrooms as $liveclassroom) {
// get the course_module instance linked to the liveclassroom instance
if (!($cm = get_coursemodule_from_instance("liveclassroom", $liveclassroom->id, $liveclassroom->course))) {
error("Course Module ID was incorrect");
}
if (!delete_course_module($cm->id)) {
wimba_add_log(WIMBA_ERROR, WC, "Problem to delete the course module : " . $cm->id);
$result = false;
// Delete a course module and any associated data at the course level (events)
// notify("Could not delete the $cm->id (coursemodule)");
}
if (!delete_records("liveclassroom", "id", "{$liveclassroom->id}")) {
wimba_add_log(WIMBA_ERROR, WC, "Problem to delete all the activities associated to the voice tools");
$result = false;
}
// delete in the course section too
if (!delete_mod_from_section($cm->id, "{$cm->section}")) {
wimba_add_log(WIMBA_ERROR, WC, "Could not delete the " . $cm->id . " from that section : " . $cm->section);
$result = false;
// notify("Could not delete the $mod->modulename from that section");
}
}
}
return $result;
}