$tbl_tool = $tbl_mdb_names['tool']; $sql = " SELECT pct.id AS toolId ,\n pct.claro_label AS label\n\n FROM `" . $_course['dbNameGlu'] . "tool_list` AS ctl\n INNER JOIN `" . $tbl_tool . "` AS pct\n ON `ctl`.`tool_id` = `pct`.`id`\n WHERE ctl.installed = 'true'"; $courseToolList = claro_sql_query_fetch_all_rows($sql); $tmp = array(); foreach ($courseToolList as $thisCourseTool) { $tmp[$thisCourseTool['label']] = $thisCourseTool['toolId']; } // 3. compare the two lists and register and install/activate missing tool if necessary $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
} } else { $dialogBox->error(get_lang('Not a valid tool')); } } } 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()); } }