예제 #1
0
    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) {
        $tbl_mdb_names = claro_sql_get_main_tbl();
예제 #2
0
파일: manage.lib.php 프로젝트: rhertzog/lcs
/**
 * Set module visibility in all courses
 * @param int $moduleId id of the module
 * @param bool $visibility true for visible, false for invisible
 * @return array( backlog, boolean )
 *      backlog object
 *      boolean true if suceeded, false otherwise
 * @todo remove the need of the Backlog and use Exceptions instead
 */
function set_module_visibility($moduleId, $visibility)
{
    $backlog = new Backlog();
    $success = true;
    $tbl = claro_sql_get_main_tbl();
    $moduleInfo = get_module_info($moduleId);
    $tool_id = get_course_tool_id($moduleInfo['label']);
    $sql = "SELECT `code` FROM `" . $tbl['course'] . "`";
    $course_list = claro_sql_query_fetch_all($sql);
    $default_visibility = false;
    foreach ($course_list as $course) {
        if (false === set_module_visibility_in_course($tool_id, $course['code'], $visibility)) {
            $success = false;
            $backlog->failure(get_lang('Cannot change module visibility in %course', array('%course' => $course['code'])));
            break;
        }
    }
    return array($backlog, $success);
}