Ejemplo n.º 1
0
 public function __construct()
 {
     $this->courseCode = claro_get_current_course_id();
     $this->courseId = ClaroCourse::getIdFromCode($this->courseCode);
     $this->userId = claro_get_current_user_id();
     $this->profileId = claro_get_current_user_profile_id_in_course();
     $this->viewMode = claro_get_tool_view_mode();
     $this->courseObject = new ClaroCourse();
     $this->courseObject->load($this->courseCode);
     $this->currentCourseContext = Claro_Context::getUrlContext(array(CLARO_CONTEXT_COURSE => $this->courseCode));
     $this->template = new CoreTemplate('coursetoollist.tpl.php');
 }
Ejemplo n.º 2
0
 protected function isModuleAllowed()
 {
     $moduleData = get_module_data($this->moduleLabel);
     if ($moduleData['type'] == 'tool') {
         $contextList = get_module_context_list($this->moduleLabel);
         if (claro_is_in_a_course()) {
             $_mainToolId = get_tool_id_from_module_label($this->moduleLabel);
             $_profileId = claro_get_current_user_profile_id_in_course();
             $_cid = claro_get_current_course_id();
             if (claro_is_in_a_group()) {
                 $_groupProperties = claro_get_main_group_properties(claro_get_current_course_id());
                 $_mainToolId = get_tool_id_from_module_label('CLGRP');
                 $is_toolAllowed = array_key_exists($this->moduleLabel, $_groupProperties['tools']) && $_groupProperties['tools'][$this->moduleLabel] && claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid);
                 if ($_groupProperties['private']) {
                     $is_toolAllowed = $is_toolAllowed && (claro_is_group_member() || claro_is_group_tutor());
                 }
                 $is_toolAllowed = $is_toolAllowed || (claro_is_course_manager() || claro_is_platform_admin());
             } else {
                 // we ignore course visibility
                 if (!claro_is_allowed_tool_edit($_mainToolId, $_profileId, $_cid) && !claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid)) {
                     $is_toolAllowed = false;
                 } else {
                     $is_toolAllowed = true;
                 }
             }
         } else {
             if (in_array('platform', iterator_to_array($contextList))) {
                 $is_toolAllowed = get_module_data($this->moduleLabel, 'activation') == 'activated';
             } else {
                 $is_toolAllowed = false;
             }
         }
         return $is_toolAllowed;
     } else {
         // if an applet "tool", return true if activated
         // and let module manage it's access by itself
         return $moduleData['activation'] == 'activated';
     }
 }
 /**
  * Search in all activated modules
  *
  * @param string $cidReq
  */
 private function loadModuleRenderer()
 {
     if (!is_null($this->courseId)) {
         $profileId = claro_get_current_user_profile_id_in_course($this->courseId);
         $toolList = claro_get_course_tool_list($this->courseId, $profileId);
     } else {
         $toolList = claro_get_main_course_tool_list();
     }
     foreach ($toolList as $tool) {
         if (!is_null($tool['label'])) {
             $file = get_module_path($tool['label']) . '/connector/tracking.cnr.php';
             if (file_exists($file)) {
                 require_once $file;
                 if (claro_debug_mode()) {
                     pushClaroMessage('Tracking : ' . $tool['label'] . ' tracking renderers loaded', 'debug');
                 }
             }
         }
     }
 }
 /**
  * Returns the tool list for each cours of the user.
  * @throws InvalidArgumentException if the cid in not provided.
  * @webservice{/module/MOBILE/User/getCoursToolList/cidReq}
  * @ws_arg{method,getCoursToolList}
  * @ws_arg{cidReq,SYSCODE of requested cours}
  * @return array of course object with only the syscode and tool-related fields filled.
  */
 function getToolList()
 {
     $cid = claro_get_current_course_id();
     if ($cid == null) {
         throw new InvalidArgumentException('Missing cid argument!');
     }
     FromKernel::uses('courselist.lib');
     $tools = array();
     foreach (claro_get_course_tool_list($cid, claro_get_current_user_profile_id_in_course($cid)) as $tool) {
         if (isset($tool['label']) && $tool['installed'] && $tool['activated'] && ($tool['visibility'] || claro_is_allowed_to_edit())) {
             unset($tool['id']);
             unset($tool['tool_id']);
             unset($tool['external_name']);
             unset($tool['external']);
             unset($tool['icon']);
             unset($tool['activation']);
             unset($tool['url']);
             unset($tool['activated']);
             unset($tool['installed']);
             $tool['name'] = get_lang($tool['name']);
             $tool['visibility'] = $tool['visibility'] == true;
             // Force the boolean representation in JSON
             $tools[] = $tool;
         }
     }
     return $tools;
 }
Ejemplo n.º 5
0
 public function getResourceList(ResourceLocator $rootNodeLocator)
 {
     $courseToolList = claro_get_course_tool_list($rootNodeLocator->getCourseId(), claro_get_current_user_profile_id_in_course($rootNodeLocator->getCourseId()));
     $courseResource = new LinkerResourceIterator();
     foreach ($courseToolList as $courseTool) {
         if (!is_null($courseTool['label'])) {
             $locator = new ClarolineResourceLocator($rootNodeLocator->getCourseId(), $courseTool['label']);
             $name = get_lang($courseTool['name']);
         } else {
             $locator = new ExternalResourceLocator($courseTool['url']);
             $name = $courseTool['name'];
         }
         if (!is_null($courseTool['label']) && ResourceLinkerNavigator::loadModuleNavigator($courseTool['label'])) {
             $isNavigable = true;
         } else {
             $isNavigable = false;
         }
         $resource = new LinkerResource($name, $locator, true, $courseTool['visibility'] ? true : false, $isNavigable);
         $courseResource->addResource($resource);
     }
     return $courseResource;
 }
Ejemplo n.º 6
0
/**
 * Get the course tid for a given course tool from its main tool id
 * @param   int $tool_id id of the tool instance in the platform
 * @param   string $courseId id (sysCode) of the course (optional, current course used if missing)
 * @param   int $profileId profile of the user to get the tool list from (optional, current user used if missing)
 * @return  int tid, course tool id
 */
function claro_get_course_tid_from_tool_id($tool_id, $courseId = null, $profileId = null)
{
    $courseId = empty($courseId) ? claro_get_current_course_id() : $courseId;
    $profileId = empty($profileId) ? claro_get_current_user_profile_id_in_course($courseId) : $profileId;
    $courseToolList = claro_get_course_tool_list($courseId, $profileId);
    foreach ($courseToolList as $courseTool) {
        if ($courseTool['tool_id'] == $tool_id) {
            return $courseTool['id'];
        }
    }
    return false;
}