mNo edit summary |
mNo edit summary |
||
Line 278: | Line 278: | ||
| generic field for the plugin to store information | | generic field for the plugin to store information | ||
|} | |} | ||
Revision as of 08:04, 22 May 2012
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the talk.
This is a draft specification outlining changes to the custom user profile fields to extend the functionality to generic custom data fields that may be applied to moodle objects
Description
We are seeing an increasing number of requests for adding additional fields to be associated with users and courses. Information to be stored against users can already be achieved through the custom user profile fields, although the interface is sadly lacking. However associated custom data with other areas of moodle, eg courses, currently requires hacking of the code. It is the goal of this document to provide a specification to allow the addition of custom data fields to be associated with any moodle objects with a consistent interface and API functions that allows for easy integration with existing and 3rd party plugins.
Moodle Objects
In this specification a moodle object refers to any one of the following: user, course, course category, file, group, cohort, activity module, block
Specification
API functions
Database tables
The database tables will closely reflect the existing custom user profile field tables
data_category
field | type | null | key | default | extra |
---|---|---|---|---|---|
id | int(10) | no | primary | null | auto_increment |
name | char(255) | no | |||
sortorder | int(10) | no | 0 |
data_data
field | type | null | key | default | extra | description |
---|---|---|---|---|---|---|
id | int(10) | no | primary | null | auto_increment | |
userid | int(10) | no | foreign | 0 | id from the user table | |
fieldid | int(10) | no | 0 | id from the data_field table | ||
data | text | no | the stored data for a given user | |||
dataformat | int(2) | no | 0 |
data_field
field | type | null | key | default | extra | description |
---|---|---|---|---|---|---|
id | int(10) | no | primary | null | auto_increment | |
shortname | char(255) | no | ||||
name | text | no | ||||
datatype | char(255) | no | the data field plugin | |||
description | text | no | yes | |||
descriptionformat | int(2) | no | 0 | |||
categoryid | int(10) | no | foreign | 0 | id from the data_category table | |
sortorder | int(10) | no | 0 | |||
required | int(2) | no | 0 | is the field required | ||
locked | int(2) | no | 0 | lock status of the data | ||
visible | int(4) | no | 0 | visibility status | ||
forceunique | int(2) | no | 0 | uniqueness requirement | ||
signup | int(2) | no | 0 | should the field appear on the signup page? | ||
defaultdata | text | yes | ||||
defaultdataformat | int(2) | no | 0 | |||
param1 | text | yes | generic field for the plugin to store information | |||
param2 | text | yes | generic field for the plugin to store information | |||
param3 | text | yes | generic field for the plugin to store information | |||
param4 | text | yes | generic field for the plugin to store information | |||
param5 | text | yes | generic field for the plugin to store information |