Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

PublicPrivate: Difference between revisions

From MoodleDocs
Line 51: Line 51:


TODO: describe the following:
TODO: describe the following:
#initial setup
 
#how-it-works
=== Setup ===
#making a resource/activity public
Setup is very simple.  Once moodle is installed, All that needs to take place before using Public/Private is going into Administration->Miscellaneous->Experimental, and check both "Enable groupings", and "Enable Public/Private"
#making a resource/activity private
 
Now, create a course like normal, and add either a resource or activity to that course.  The default behavior should be that when a resource or activity is added, it will read "(Private Course Material)" next to it, and have an extra icon: a lock.  If that lock icon is pressed, the "(Private Course Material)" text will disapear, and an open-lock icon will replace the closed-lock icon.  This indicates that the course is now unlocked, and available to everyone.
 
 
=== How it Works - Behind the Scenes ===
 
 
=== Code: Make Private ===
The below code demonstrates how to make a forum private.  The same technique can be applied for any course module.
 
                $grouping_id = groups_get_grouping_publicprivate($COURSE->id);
                $course_module = get_record("course_modules", "instance", $forum->id, "course", $COURSE->id);
                set_coursemodule_groupingid($course_module->id, $grouping_id);
                set_coursemodule_groupmembersonly($course_module->id,1);
 
=== Code: Make Public ===
The below code demonstrates how to make a forum public.  The same technique can be applied for any course module.
                $grouping_id = groups_get_grouping_publicprivate($COURSE->id);
                $course_module = get_record("course_modules", "instance", $forum->id, "course", $COURSE->id);
                set_coursemodule_groupingid($course_module->id, 0);
                set_coursemodule_groupmembersonly($course_module->id,0);

Revision as of 22:31, 9 July 2009

Executive Summary

This page will spec out the features of Public/Private.

Public/Private is a means whereby any resource within moodle can be made private to only members of that course, or public and available to anyone that visits that site (including guests).

A practical use for this feature is making the syllabus public so that potential students can shop around for classes, but the rest of the course material is private and only available to the members of that course.

Database structures

Below are the fields that are added to the already existing table.

course

Field Type Default Info
groupautoassign BIGINT(10) 0 Group id to auto-assign members of the course.
grouppublicprivate TINYINT(1) 0 Whether public/private is enabled for that course.


groups_members

Field Type Default Info
type VARCHAR(36) NULL This field indicates whether the user was auto-assigned to a group, or not. (as opposed to manually added)

Overview of module communication

TODO: describe the following:

Setup

Setup is very simple. Once moodle is installed, All that needs to take place before using Public/Private is going into Administration->Miscellaneous->Experimental, and check both "Enable groupings", and "Enable Public/Private"

Now, create a course like normal, and add either a resource or activity to that course. The default behavior should be that when a resource or activity is added, it will read "(Private Course Material)" next to it, and have an extra icon: a lock. If that lock icon is pressed, the "(Private Course Material)" text will disapear, and an open-lock icon will replace the closed-lock icon. This indicates that the course is now unlocked, and available to everyone.


How it Works - Behind the Scenes

Code: Make Private

The below code demonstrates how to make a forum private. The same technique can be applied for any course module.

               $grouping_id = groups_get_grouping_publicprivate($COURSE->id);
               $course_module = get_record("course_modules", "instance", $forum->id, "course", $COURSE->id);
               set_coursemodule_groupingid($course_module->id, $grouping_id);
               set_coursemodule_groupmembersonly($course_module->id,1);

Code: Make Public

The below code demonstrates how to make a forum public. The same technique can be applied for any course module.

               $grouping_id = groups_get_grouping_publicprivate($COURSE->id);
               $course_module = get_record("course_modules", "instance", $forum->id, "course", $COURSE->id);
               set_coursemodule_groupingid($course_module->id, 0);
               set_coursemodule_groupmembersonly($course_module->id,0);