/** * Is the given module activated in the groups of the given course ? * @param string $courseId course code * @param string $toolLabel module label * @return boolean */ function is_tool_activated_in_groups($courseId, $toolLabel) { $activatedGroupToolList = get_activated_group_tool_label_list($courseId); foreach ($activatedGroupToolList as $groupTool) { if ($groupTool['label'] == $toolLabel) { return true; } } return false; }
public function getResourceList(ResourceLocator $rootNodeLocator) { $groupToolList = get_activated_group_tool_label_list($rootNodeLocator->getCourseId()); $groupProperties = claro_get_main_group_properties($rootNodeLocator->getCourseId()); $groupResource = new LinkerResourceIterator(); foreach ($groupToolList as $groupTool) { // skip disabled group tools if (!array_key_exists($groupTool['label'], $groupProperties['tools']) || !$groupProperties['tools'][$groupTool['label']]) { continue; } $locator = new ClarolineResourceLocator($rootNodeLocator->getCourseId(), $groupTool['label'], null, $rootNodeLocator->getGroupId()); if (ResourceLinkerNavigator::loadModuleNavigator($groupTool['label'])) { $isNavigable = true; } else { $isNavigable = false; } $resource = new LinkerResource($groupTool['name'], $locator, true, $groupTool['visibility'] ? true : false, $isNavigable); $groupResource->addResource($resource); } return $groupResource; }
/** * This function return properties for groups in a given course context. * * @param string $courseId sysCode of the course. * * @return array ('registrationAllowed' , 'self_registration', 'private', 'nbGroupPerUser', 'tools' => array ('CLFRM', 'CLDOC', 'CLWIKI', 'CLCHT') ) * The 4th first properties are course properties dedicated to groups as default value. * The 'tool' array is like course.tool_list. */ function claro_get_main_group_properties($courseId) { $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId)); $tbl_course_properties = $tbl_cdb_names['course_properties']; $sql = "SELECT name,\n value\n FROM `" . $tbl_course_properties . "`\n WHERE category = 'GROUP'"; $dbDataList = claro_sql_query_fetch_all($sql); if (is_array($dbDataList)) { foreach ($dbDataList as $thisData) { $tempList[$thisData['name']] = (int) $thisData['value']; } $propertyList = array(); $propertyList['registrationAllowed'] = isset($tempList['self_registration']) && $tempList['self_registration'] == 1; $propertyList['unregistrationAllowed'] = isset($tempList['self_unregistration']) && $tempList['self_unregistration'] == 1; $propertyList['tutorRegistrationAllowed'] = isset($tempList['tutor_registration']) && $tempList['tutor_registration'] == 1; $propertyList['private'] = !isset($tempList['private']) || $tempList['private'] == 1; $propertyList['nbGroupPerUser'] = isset($tempList['nbGroupPerUser']) ? $tempList['nbGroupPerUser'] : 1; $propertyList['tools'] = array(); $groupToolList = get_activated_group_tool_label_list($courseId); foreach ($groupToolList as $thisGroupTool) { $thisGroupToolLabel = $thisGroupTool['label']; $propertyList['tools'][$thisGroupToolLabel] = isset($tempList[$thisGroupToolLabel]) ? $tempList[$thisGroupToolLabel] == 1 : false; } return $propertyList; } else { return false; } }