Note:

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

User:Shane Elliott/Draft:Data Fields: Difference between revisions

From MoodleDocs
Line 40: Line 40:
|
|
|-
|-
| type
| extendedcontext
| int(10)
| int(10)
| no
| no
Line 46: Line 46:
|
|
|
|
|
| the (extended) context of data eg user, course, group, ...
|-
|-
| name
| name
Line 85: Line 85:
|
|
|-
|-
| userid
| extendedcontextid
| int(10)
| no
|
|
|
| the (extended) context of data eg user, course, group, ...
|-
| instanceid
| int(10)
| int(10)
| no
| no
Line 91: Line 99:
| 0
| 0
|
|
| id from the user table
| id for the particular extended context type instance
|-
|-
| fieldid
| fieldid

Revision as of 04:22, 1 June 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 description
id int(10) no primary null auto_increment
extendedcontext int(10) no the (extended) context of data eg user, course, group, ...
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
extendedcontextid int(10) no the (extended) context of data eg user, course, group, ...
instanceid int(10) no foreign 0 id for the particular extended context type instance
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

Interfaces

Upgrade Issues

Standard User Profile Fields

Custom User Profile Fields

User fields for condition acitivities