Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Roles tutorial - viewhiddenactivities.

Roles tutorial - viewhiddenactivities

From MoodleDocs

Note: Please give general feedback or suggestions for this tutorial in the discussion area for this page or make minor edits for better clarity directly to this page. This page is currently under development.

Note: Ask general role questions in the moodle.org forums.

Note: Post problems with the role feature in Moodle to tracker.moodle.org.


by Gary Anderson

One of the most useful features of Moodle's role system is the ability to make certain resources and activities visible to only a select group of individuals. This may be useful, for example, to make a forum within a class visible to only the teacher and students of that class, while otherwise keeping the course open for viewing, or to allow a course to be visible to all visitors while restricting a licensed textbook or other resources to only authenticated users with accounts on the system. More sophisticated uses might involve creating new roles, so, for example, certain assignments may be visible only to students in a particular section of a course, or creating a Faculty and Staff role that may restrict access to certain resources that should not be routinely be available to students.

Because resources hidden from others are displayed in gray, it gives the user a visual indication of the restricted nature of the content.

This tutorial will walk you through the steps of making resources and activities visible to only a select group of users. While written for the teacher and site administrator, it should be considered of intermediate to advanced use. Those setting up these features should be familiar with how Moodle courses work. They should also understand the importance of carefully testing all role assignments and the risks inherit in errors made in attempts to restrict access.

Note: Site administrators will need to make sure they have installed the latest update of Moodle. Unless they wish to do all these operations themselves, they will also need to enable the ability for teachers to override certain roles, such as those for students, guests, and authenticated users. Instructions and cautions about this are at the end of this article.

Use one: Restricting a forum to only course participants

Desire: You wish to have guests, parents, and other users view your course, the assignments, links, and other resources that you place there. But you would also like to preserve the privacy of your students as they discuss course content in the class forums.

  1. Create a course forum called something like "Class Discussion Forum". In the Common module settings area, change "Visible:" from "Show" to "Hide". In the alternative, you can click on the eye icon for such a module on your course page to hide the activity. Save the activity.
  2. Next, click the icon for the forum to edit the activity. Provided the site administrator has enabled your ability to override permissions, click the tab at the top of the page that is labeled "Override permissions".
  3. Click the student role
  4. At the top of the list of permissions, find "View hidden activities". For this capability, select "Allow". If you do not see this capability, you may need to ask your site administrator when they will be updating to the latest version of Moodle so that this feature will be available.
  5. Test access as a student, a guest, and as a teacher.

Use Two: Restricting to a course textbook to only Authenticated users

Desire: Your license for using a pdf textbook requires that it only be available to members of your institution. Further, you only set up accounts on your Moodle system for such users. You may also want access to this resource to be logged. Hence, you want your course to be open but access to this resource restricted to Authenticated users.

  1. From the course Administration block, select Files
  2. Select "Make a folder". Name the folder something like "CourseTextbook".
  3. Upload any resources you wish into this folder,
  4. Return to the course page, and from the menu "Add a resource", select "Display a directory". Name it something like "Course Textbook". Select your directory from the "Display a directory" menu. In the Common module settings area, set "Visible" to "Hide". Save and return to the course.
  5. Click the icon to edit this resource and click the tab at the top of the page that is labeled "Override permissions". Select "Authenticated users" from the list of roles.
  6. For the "View hidden activities" capablity, select "Allow". Save your changes.
  7. Test with various users to make sure it gives the desired access.
  8. Note that you could give more restrictive access by just giving this capability to students as in Use One. Your could also specifically select Prevent or Prohibit this capability for guests.

Use Three: Making activities visible to only a subset of students

Detailed instructions will follow after feedback is received on the first tow uses. Basically, the site administrator will create roles for each section (A-Block, B-Block) etc. S/he will not assign any capabilities to this role, nor users at the site level. Teachers will assign these students both as students and the additional role. Then, with overrides, some activities can be hidden from one group but not another. Note that groupings can do similar things.

Use Four: Restricting access to Faculty and staff

Details will follow after feedback from the previous instructions are received. Uses methods similar to use three.

Instructions for Site Administrators

Note: You will need to have the most recently weekly build (or a stable build) of at least 1.9.4+ from at least April 3, 2009 to have the Viewhiddenactivity capability be able to be overridden at the module level. This feature resolved MDL-13573 and MDL-18094.

Note: To allow teachers to override roles, you must enable that feature (otherwise you will need to always do these operations yourself). To enable teachers to override roles in their courses, from the site administration menu, chose Users->Define Roles->Allow role overrides.

For these tutorials, allow the teacher role to override Student, Guest, and Authenticated user, and any other special roles you have made that they should control.

Caution: Site administrators are much more likely to do bad things with roles than teachers. For example, don't give anyone site-wide roles with lots of capabilities, like a site-wide teacher role, unless you want to give them most of the capabilities of a Site Administrator. Carefully test everything. On the other hand, it is perfectly OK to make new roles with no capabilities, and let those be overridden in specific cases like is described in this tutorial.

Final Caution: With great power comes great responsibility. This is my gift, my curse. Spiderman