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

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: Course, Resource, Usability
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              moodle.com moodle.com
              Reporter:
              nadavkav Nadav Kavalerchik
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Barbara Ramiro, Bas Brands
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: