Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21570

hack: hide activity or resource and still have it active (by prefixing it with a "." character)

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • 1.9
    • Course, Resource, Usability
    • None
    • MOODLE_19_STABLE
    • Easy

      this is a small hack to hide an activity or a resource
      by prefixing the title/subject of the activity / resource it with a "." character
      and still have it active and useful to students.

      especially useful for teachers who would like to link to it from some other
      Label resource and not have it show up in the topics / sections.
      (for visual purposes, mainly)

      open "course/lib.php" and change the line:

      echo '<li class="activity '.$mod->modname.'" id="module-'.$modnumber.'">'; // Unique ID

      to:

      // Hide Activities or Resource by prefixing a "." in the title of the activity
      if (mb_substr($modinfo->cms[$modnumber]->name,0,1) == '.' AND !$isediting)

      { $activebuthidden = ' style="display:none;" '; }

      else

      { $activebuthidden = ''; }

      echo '<li '.$activebuthidden.' class="activity '.$mod->modname.'" id="module-'.$modnumber.'">'; // Unique ID

      and save it.

      now you are ready.

      as a teacher, go into editing mode and...
      just add a DOT ( "." ) character in the beginning of the subject of the activity or resource...
      which makes it invisible to students ( and still visible to teachers in edit mode)

      i know ! it is a ugly hack and it is better solved seriously
      by adding the proper statuses to the already available "two modes" visibility field
      of each module. but i guess this should be discussed in another issue

      enjoy

            moodle.com Moodle HQ
            nadavkav Nadav Kavalerchik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.