Ejemplo n.º 1
0
 /**
  * Adds a course module to the navigation node
  *
  * @param navigation_node $node
  * @param cm_info $cm
  * @return null|navigation_node
  */
 protected function navigation_add_activity(navigation_node $node, $cm)
 {
     if (!$cm->uservisible || !$cm->has_view()) {
         return null;
     }
     $activityname = $cm->get_formatted_name();
     $action = $cm->url;
     if ($cm->icon) {
         $icon = new pix_icon($cm->icon, $cm->modfullname, $cm->iconcomponent);
     } else {
         $icon = new pix_icon('icon', $cm->modfullname, $cm->modname);
     }
     $activitynode = $node->add($activityname, $action, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon);
     if (global_navigation::module_extends_navigation($cm->modname)) {
         $activitynode->nodetype = navigation_node::NODETYPE_BRANCH;
     } else {
         $activitynode->nodetype = navigation_node::NODETYPE_LEAF;
     }
     return $activitynode;
 }
Ejemplo n.º 2
0
 /**
  * Renders html to display a name with the link to the course module on a course page
  *
  * If module is unavailable for user but still needs to be displayed
  * in the list, just the name is returned without a link
  *
  * Note, that for course modules that never have separate pages (i.e. labels)
  * this function return an empty string
  *
  * @param cm_info $mod
  * @param array $displayoptions
  * @return string
  */
 public function course_section_cm_name_title(cm_info $mod, $displayoptions = array())
 {
     $output = '';
     if (!$mod->uservisible && empty($mod->availableinfo)) {
         // Nothing to be displayed to the user.
         return $output;
     }
     $url = $mod->url;
     if (!$url) {
         return $output;
     }
     //Accessibility: for files get description via icon, this is very ugly hack!
     $instancename = $mod->get_formatted_name();
     $altname = $mod->modfullname;
     // Avoid unnecessary duplication: if e.g. a forum name already
     // includes the word forum (or Forum, etc) then it is unhelpful
     // to include that in the accessible description that is added.
     if (false !== strpos(core_text::strtolower($instancename), core_text::strtolower($altname))) {
         $altname = '';
     }
     // File type after name, for alphabetic lists (screen reader).
     if ($altname) {
         $altname = get_accesshide(' ' . $altname);
     }
     // For items which are hidden but available to current user
     // ($mod->uservisible), we show those as dimmed only if the user has
     // viewhiddenactivities, so that teachers see 'items which might not
     // be available to some students' dimmed but students do not see 'item
     // which is actually available to current student' dimmed.
     $linkclasses = '';
     $accesstext = '';
     $textclasses = '';
     if ($mod->uservisible) {
         $conditionalhidden = $this->is_cm_conditionally_hidden($mod);
         $accessiblebutdim = (!$mod->visible || $conditionalhidden) && has_capability('moodle/course:viewhiddenactivities', $mod->context);
         if ($accessiblebutdim) {
             $linkclasses .= ' dimmed';
             $textclasses .= ' dimmed_text';
             if ($conditionalhidden) {
                 $linkclasses .= ' conditionalhidden';
                 $textclasses .= ' conditionalhidden';
             }
             // Show accessibility note only if user can access the module himself.
             $accesstext = get_accesshide(get_string('hiddenfromstudents') . ':' . $mod->modfullname);
         }
     } else {
         $linkclasses .= ' dimmed';
         $textclasses .= ' dimmed_text';
     }
     // Get on-click attribute value if specified and decode the onclick - it
     // has already been encoded for display (puke).
     $onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES);
     $groupinglabel = $mod->get_grouping_label($textclasses);
     // Display link itself.
     $activitylink = html_writer::empty_tag('img', array('src' => $mod->get_icon_url(), 'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation')) . $accesstext . html_writer::tag('span', $instancename . $altname, array('class' => 'instancename'));
     if ($mod->uservisible) {
         $output .= html_writer::link($url, $activitylink, array('class' => $linkclasses, 'onclick' => $onclick)) . $groupinglabel;
     } else {
         // We may be displaying this just in order to show information
         // about visibility, without the actual link ($mod->uservisible)
         $output .= html_writer::tag('div', $activitylink, array('class' => $textclasses)) . $groupinglabel;
     }
     return $output;
 }
Ejemplo n.º 3
0
/**
 * Obtains shared data that is used in print_section when displaying a
 * course-module entry.
 *
 * Deprecated. Instead of:
 * list($content, $name) = get_print_section_cm_text($cm, $course);
 * use:
 * $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
 * $name = $cm->get_formatted_name();
 *
 * @deprecated since 2.5
 * @see cm_info::get_formatted_content()
 * @see cm_info::get_formatted_name()
 *
 * This data is also used in other areas of the code.
 * @param cm_info $cm Course-module data (must come from get_fast_modinfo)
 * @param object $course (argument not used)
 * @return array An array with the following values in this order:
 *   $content (optional extra content for after link),
 *   $instancename (text of link)
 */
function get_print_section_cm_text(cm_info $cm, $course)
{
    debugging('Function get_print_section_cm_text() is deprecated. Please use ' . 'cm_info::get_formatted_content() and cm_info::get_formatted_name()', DEBUG_DEVELOPER);
    return array($cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)), $cm->get_formatted_name());
}
Ejemplo n.º 4
0
 /**
  * Renders html to display a name with the link to the course module on a course page
  *
  * If module is unavailable for user but still needs to be displayed
  * in the list, just the name is returned without a link
  *
  * Note, that for course modules that never have separate pages (i.e. labels)
  * this function return an empty string
  *
  * @param cm_info $mod
  * @param array $displayoptions
  * @return string
  */
 public function course_section_cm_name(cm_info $mod, $displayoptions = array())
 {
     global $CFG;
     $output = '';
     if (!$mod->uservisible && (empty($mod->showavailability) || empty($mod->availableinfo))) {
         // nothing to be displayed to the user
         return $output;
     }
     $url = $mod->get_url();
     if (!$url) {
         return $output;
     }
     //Accessibility: for files get description via icon, this is very ugly hack!
     $instancename = $mod->get_formatted_name();
     $altname = '';
     $altname = $mod->modfullname;
     // Avoid unnecessary duplication: if e.g. a forum name already
     // includes the word forum (or Forum, etc) then it is unhelpful
     // to include that in the accessible description that is added.
     if (false !== strpos(textlib::strtolower($instancename), textlib::strtolower($altname))) {
         $altname = '';
     }
     // File type after name, for alphabetic lists (screen reader).
     if ($altname) {
         $altname = get_accesshide(' ' . $altname);
     }
     $conditionalhidden = $this->is_cm_conditionally_hidden($mod);
     $accessiblebutdim = !$mod->visible || $conditionalhidden;
     $linkclasses = '';
     $accesstext = '';
     $textclasses = '';
     if ($accessiblebutdim) {
         $linkclasses .= ' dimmed';
         $textclasses .= ' dimmed_text';
         if ($conditionalhidden) {
             $linkclasses .= ' conditionalhidden';
             $textclasses .= ' conditionalhidden';
         }
         if ($mod->uservisible) {
             // show accessibility note only if user can access the module himself
             $accesstext = get_accesshide(get_string('hiddenfromstudents') . ': ');
         }
     }
     // Get on-click attribute value if specified and decode the onclick - it
     // has already been encoded for display (puke).
     $onclick = htmlspecialchars_decode($mod->get_on_click(), ENT_QUOTES);
     $groupinglabel = '';
     if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', context_course::instance($mod->course))) {
         $groupings = groups_get_all_groupings($mod->course);
         $groupinglabel = html_writer::tag('span', '(' . format_string($groupings[$mod->groupingid]->name) . ')', array('class' => 'groupinglabel ' . $textclasses));
     }
     // Display link itself.
     $activitylink = html_writer::empty_tag('img', array('src' => $mod->get_icon_url(), 'class' => 'iconlarge activityicon', 'alt' => $mod->modfullname)) . $accesstext . html_writer::tag('span', $instancename . $altname, array('class' => 'instancename'));
     if ($mod->uservisible) {
         $output .= html_writer::link($url, $activitylink, array('class' => $linkclasses, 'onclick' => $onclick)) . $groupinglabel;
     } else {
         // We may be displaying this just in order to show information
         // about visibility, without the actual link ($mod->uservisible)
         $output .= html_writer::tag('div', $activitylink, array('class' => $textclasses)) . $groupinglabel;
     }
     return $output;
 }