You are here

function course_schema in Course 7

Same name and namespace in other branches
  1. 8.3 course.install \course_schema()
  2. 8.2 course.install \course_schema()
  3. 6 course.install \course_schema()
  4. 7.2 course.install \course_schema()

Implements hook_schema().

1 call to course_schema()
course_token_info in ./course.module
Implements hook_token_info().

File

./course.install, line 61
course.install Install and update functions for Courses.

Code

function course_schema() {
  $schema = array();
  $schema['course_report'] = array(
    'description' => "Stores users' course reports.",
    'fields' => array(
      'crid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Course report record ID.',
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Drupal course node.',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Drupal user ID.',
      ),
      'date_completed' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'default' => NULL,
        'description' => 'Date completed.',
      ),
      'updated' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'default' => NULL,
        'description' => 'Date this record was updated.',
      ),
      'grade_result' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => FALSE,
        'description' => 'Course grade received.',
      ),
      'section' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "Key of current section.",
      ),
      'section_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "Name of current section.",
      ),
      'complete' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Flag to mark this course as complete.',
      ),
      'data' => array(
        'serialize' => TRUE,
        'type' => 'text',
        'description' => 'Extra serialized course report data.',
        'size' => 'medium',
      ),
      'coid' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Identifier for the course object.',
      ),
    ),
    'primary key' => array(
      'crid',
    ),
    'unique keys' => array(
      'uk' => array(
        'nid',
        'uid',
      ),
    ),
    'indexes' => array(
      'date_completed' => array(
        'date_completed',
      ),
    ),
  );
  $schema['course_enrollment'] = array(
    'description' => 'Stores enrollment records.',
    'fields' => array(
      'eid' => array(
        'description' => 'Primary Key: The eid of the enrollment.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The nid of the course node',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The uid of the user',
      ),
      'enrollmenttype' => array(
        'type' => 'varchar',
        'length' => '128',
        'not null' => FALSE,
        'default' => '',
        'description' => 'The type of enrollment, if applicable',
      ),
      'status' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The enrollment status.',
      ),
      'created' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The time this enrollment was created.',
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The time the user started the course.',
      ),
      'enroll_end' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Date enrollment ends.',
      ),
      'code' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The access code used to enroll.',
      ),
      'user_type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The user type while in the context of this enrollment.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this enrollment type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'data' => array(
        'serialize' => TRUE,
        'type' => 'text',
        'description' => "Extra serialized enrollment data.",
        'size' => 'medium',
      ),
    ),
    'primary key' => array(
      'eid',
    ),
    'unique keys' => array(
      'nid_uid' => array(
        'nid',
        'uid',
      ),
    ),
  );
  $schema['course_node'] = array(
    'description' => 'Stores course node settings.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Course node ID.',
      ),
      'outline' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Course outline display handler.',
      ),
      'credits' => array(
        'type' => 'numeric',
        'description' => 'Course credit.',
        'precision' => 6,
        'scale' => 2,
      ),
      'open' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'description' => 'Date course opens.',
      ),
      'close' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'description' => 'Date course closes.',
      ),
      'duration' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Amount of time a user has to access this course.',
      ),
      'external_id' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'External ID of the course.',
      ),
      'enrollment_type' => array(
        'description' => 'The machine-readable name of this enrollment type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  $schema['course_outline'] = array(
    'description' => "Stores users' course reports",
    'fields' => array(
      'coid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique identifier for the course object record.',
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'nid.',
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "The implementing module name (course_quiz etc)",
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "The item title",
      ),
      'object_type' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "The course object key as defined by hook_course_handlers()",
      ),
      'enabled' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'is this item enabled?',
      ),
      'info' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "The item info",
      ),
      'instance' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'The object instance',
      ),
      'required' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'is this item required?',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => FALSE,
        'default' => 0,
        'description' => 'Order in course outline.',
      ),
      'hidden' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Visibility in course utline',
      ),
      'duration' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Amount of time in seconds a user has to access this object.',
      ),
      'uuid' => array(
        'type' => 'varchar',
        'length' => 36,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The Universally Unique Identifier.',
      ),
      'data' => array(
        'description' => 'Extra serialized course object data.',
        'type' => 'text',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'coid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
      'instance' => array(
        'instance',
      ),
    ),
    'unique keys' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );
  $schema['course_outline_fulfillment'] = array(
    'description' => "Stores users' course reports",
    'fields' => array(
      'cofid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique identifier for the course object fufillment record.',
      ),
      'coid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Identifier for the course object.',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'uid of {user}.',
      ),
      'complete' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is this item complete?',
      ),
      'grade_result' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => FALSE,
        'description' => 'Object grade received.',
      ),
      'date_started' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'default' => NULL,
        'description' => 'Date object was started.',
      ),
      'date_completed' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'default' => NULL,
        'description' => 'Date object was completed.',
      ),
      'info' => array(
        'type' => 'text',
        'serialize' => TRUE,
        'description' => 'Extra serialized course object fulfillment enrollment data.',
      ),
      'uuid' => array(
        'type' => 'varchar',
        'length' => 36,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The Universally Unique Identifier.',
      ),
      'instance' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'The fulfillment instance',
      ),
    ),
    'primary key' => array(
      'cofid',
    ),
    'unique keys' => array(
      'coid_uid' => array(
        'coid',
        'uid',
      ),
      'uuid' => array(
        'uuid',
      ),
    ),
    'indexes' => array(
      'coid' => array(
        'coid',
      ),
      'date_completed' => array(
        'date_completed',
      ),
      'instance' => array(
        'instance',
      ),
    ),
  );
  $schema['course_enrollment_type'] = array(
    'description' => 'Stores information about all defined profile types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Unique enrollment type ID.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this enrollment type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this enrollment type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'type' => array(
        'type',
      ),
    ),
  );
  return $schema;
}