Development:Anonymous Users: Difference between revisions
From MoodleDocs
mNo edit summary |
m (→Core Code) |
||
Line 68: | Line 68: | ||
Proposed changes are: | Proposed changes are: | ||
function fullname($user, $override=false, $anonymous=false) | function fullname($user, $override=false, $anonymous=false, $viewanonymous=false) | ||
where the user object is required to contain '''firstname''', '''lastname''', '''alias''' | where the user object is required to contain '''firstname''', '''lastname''', '''alias''' | ||
So what do we return? | |||
* If the anonymous flag is set, we just return the alias | |||
* If the anonymous flag is set and the $viewanonymous flag is set, then we return ''' |
Revision as of 11:35, 9 December 2009
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.
Objective
To allow users to switch into an anonymous mode when using certain activities eg when posting to a forum, so that the user's real identity cannot be ascertained by other non-privileged users.
Possible Use Cases
- Activity: for example a forum may be switched into anonymous mode by teacher rendering all posts anonymous.
- User: a user may choose to participate in an activity anonymously. In this case the teacher would switch the activity into an optional mode. For example, the forum module, when posting to a forum in an optional anonymous mode, the student could choose at the time of posting whether the post should be anonymous;
- Role Play: a teacher may choose to run the whole course in an anonymous mode to allow students to role play. In this case the anonymous mode will be forced to "yes" in the course settings.
Settings
Global
- Anonymous Mode: On/Off
- Anonymous Images: On/Off
- Enable Course Anonymous Mode: On/Off
Course
- Anonymous Mode: On/Off/Optional
Activity
- Anonymous Mode: On/Off/Optional
User Profile
The following additional fields will be added
- Alias
- Alias image
Code Changes
New Table
A new table user_course_alias will be added
field | type | description |
---|---|---|
id | int | autoincrement |
userid | int | id from the user table |
courseid | int | id from the course table |
alias | string | the user's alias for this given course |
Core Code
The fullname function in lib/moodlelib.php will need to be changed. Currently it is defined as:
function fullname($user, $override=false)
where the user object is only required to contain firstname and lastname properties.
Proposed changes are:
function fullname($user, $override=false, $anonymous=false, $viewanonymous=false)
where the user object is required to contain firstname, lastname, alias So what do we return?
- If the anonymous flag is set, we just return the alias
- If the anonymous flag is set and the $viewanonymous flag is set, then we return