/** * Activate the module in all courses * @param string $moduleLabel * @return array array( Backlog $backlog, boolean $success ); * @todo remove the need of the Backlog and use Exceptions instead */ function activate_module_in_all_courses($toolLabel) { $toolId = get_tool_id_from_module_label($toolLabel); $tbl = claro_sql_get_main_tbl(); $sql = "SELECT `code` FROM `" . $tbl['course'] . "`"; $courseList = claro_sql_query_fetch_all($sql); foreach ($courseList as $course) { if (!update_course_tool_activation_in_course($toolId, $course['code'], true)) { return false; } } return true; }
$listOfToolsToAdd = array(); foreach ($mainCourseToolList as $thisToolId => $thisMainCourseTool) { if (!array_key_exists($thisMainCourseTool['label'], $tmp)) { $listOfToolsToAdd[$thisMainCourseTool['label']] = $thisToolId; } } foreach ($listOfToolsToAdd as $toolLabel => $toolId) { if (!is_module_registered_in_course($toolId, $_cid)) { register_module_in_single_course($toolId, $_cid); } if (!is_module_installed_in_course($toolLabel, $_cid) && 'AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) { install_module_in_course($toolLabel, $_cid); } if ('AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) { if ('activated' == get_module_data($toolLabel, 'activation')) { update_course_tool_activation_in_course($toolId, $_cid, true); set_module_visibility_in_course($toolId, $_cid, true); } } } } /*--------------------------------------------------------------------------- Course / tool relation initialisation ---------------------------------------------------------------------------*/ // if the requested tool is different from the current tool in session // (special request can come from the tool id, or the tool label) if ($tidReq && $tidReq != $_SESSION['_tid'] || $tlabelReq && (!isset($_SESSION['_courseTool']['label']) || $tlabelReq != $_SESSION['_courseTool']['label'])) { $tidReset = true; } if ($tidReset || $cidReset) { if (($tidReq || $tlabelReq) && $_cid) {
} } if ('exAddTool' == $cmd) { if (is_null($toolLabel)) { $dialogBox->error(get_lang('Missing tool label')); } else { $moduleData = get_module_data($toolLabel); if ($moduleData['access_manager'] == 'COURSE_ADMIN' || claro_is_platform_admin()) { // get tool id $toolId = get_tool_id_from_module_label($toolLabel); if ($toolId) { if (!is_module_registered_in_course($toolId, claro_get_current_course_id())) { register_module_in_single_course($toolId, claro_get_current_course_id()); } // update course_tool.activated if (update_course_tool_activation_in_course($toolId, claro_get_current_course_id(), true)) { set_module_visibility_in_course($toolId, $_cid, true); $dialogBox->success(get_lang('Tool added to course')); $cidReset = TRUE; $cidReq = claro_get_current_course_id(); $groupToolList = get_group_tool_label_list(); foreach ($groupToolList as $group) { if ($group['label'] == $toolLabel) { // this is a group tool, enable it in groups activate_module_in_groups(Claroline::getDatabase(), $toolLabel, claro_get_current_course_id()); } } include get_path('incRepositorySys') . '/claro_init_local.inc.php'; } else { $dialogBox->error(get_lang('Cannot add tool to course')); }