Development:Anonymous Users: Difference between revisions
Helen Foster (talk | contribs) (see also tracker link) |
mNo edit summary |
||
Line 31: | Line 31: | ||
== Code Changes == | == Code Changes == | ||
=== New | === New Tables === | ||
New table: '''anonymity_context''' | |||
The purpose of this table is to record the anonymity status in given contexts | |||
{| border="1" | |||
|- | |||
!field | |||
!type | |||
!description | |||
|- | |||
|id | |||
|int(10) unsigned | |||
|auto-increment | |||
|- | |||
|contextid | |||
|int(10) unsigned | |||
|id from the context table | |||
|- | |||
|status | |||
|int(4) signed | |||
|anonymity status | |||
|} | |||
New table: '''anonymity_user_context''' | |||
This table will record user aliases for a particular context | |||
{| border="1" | {| border="1" | ||
|- | |- | ||
Line 41: | Line 64: | ||
|- | |- | ||
|id | |id | ||
|int | |int(10) unsigned | ||
| | |auto-increment | ||
|- | |- | ||
|userid | |userid | ||
|int | |int(10) unsigned | ||
|id from the user table | |id from the user table | ||
|- | |- | ||
| | |contextid | ||
|int | |int(10) unsigned | ||
|id from the | |id from the context table | ||
|- | |- | ||
|alias | |alias | ||
| | |varchar(255) | ||
|the user's alias for this given | |the user's alias for this given context | ||
|} | |} | ||
Revision as of 08:51, 1 May 2010
Note: This article is a work in progress. Please use the page comments or an appropriate moodle.org forum for any recommendations/suggestions for improvement.
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
Course
Activity
User Profile
Code Changes
New Tables
New table: anonymity_context The purpose of this table is to record the anonymity status in given contexts
field | type | description |
---|---|---|
id | int(10) unsigned | auto-increment |
contextid | int(10) unsigned | id from the context table |
status | int(4) signed | anonymity status |
New table: anonymity_user_context This table will record user aliases for a particular context
field | type | description |
---|---|---|
id | int(10) unsigned | auto-increment |
userid | int(10) unsigned | id from the user table |
contextid | int(10) unsigned | id from the context table |
alias | varchar(255) | the user's alias for this given context |
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, $courseid=null, $link=false, $anonymous=null, $viewanonymous=false)
where the user object is required to contain firstname, lastname, alias
So what do we return?
$anonymous | $viewanonymous | return example |
---|---|---|
no | no | firstname lastname |
no | yes | firstname lastname |
yes | no | alias |
yes | yes | alias (firstname lastname) |
backwards compatibility
- If no anonymous mode is given then we check the current context to see if anonymous mode should be running. Check activity, course, global settings and determine anonymity status. We can grab the current context from the $PAGE object, otherwise find another way to do it.
- If no alias property is defined in the user object then we return get_string('anonymoususer') ie a global, default string;
See also
- MDL-1071 Add a forum option to allow anonymous posting