You are here

function CourseObjectAccessTiming::optionsForm in Course 6

Same name and namespace in other branches
  1. 7.2 plugins/course_object_access/timing.inc \CourseObjectAccessTiming::optionsForm()
  2. 7 plugins/course_object_access/timing.inc \CourseObjectAccessTiming::optionsForm()

Handlers can declare a form.

Overrides CourseHandler::optionsForm

File

plugins/course/access/timing.inc, line 67

Class

CourseObjectAccessTiming

Code

function optionsForm() {
  $form = array();
  $config = $this
    ->getOptions();
  if (module_exists('duration_element')) {
    $duration = duration_create();
    $duration
      ->set_seconds($config['duration']);
    $duration
      ->normalize();
    $form['duration'] = array(
      '#title' => t('Duration'),
      '#description' => 'Length of time a user can remain in this object before it is closed.',
      '#type' => 'duration_combo',
      '#largest_metric' => 'days',
      '#smallest_metric' => 'minutes',
      '#default_value' => $duration,
    );
  }
  else {
    $form['duration'] = array(
      '#title' => t('Duration'),
      '#description' => 'Length of time in seconds a user can remain in this object before it is closed.',
      '#type' => 'textfield',
      '#size' => 8,
      '#default_value' => $config['duration'],
    );
  }
  $form['release'] = array(
    '#title' => t('Release date'),
    '#description' => t('When this object can be accessed. If this object is required, users will not be able to proceed until after this date.'),
    '#type' => 'date_popup',
    '#default_value' => $config['release'],
  );
  $form['expiration'] = array(
    '#title' => t('Expiration date'),
    '#description' => t('When this object will close. If this object is required, users will not be able to proceed to the next activity after this date.'),
    '#type' => 'date_popup',
    '#default_value' => $config['expiration'],
  );
  $form['release_hidden'] = array(
    '#title' => 'Hide until release date',
    '#type' => 'checkbox',
    '#default_value' => $config['release_hidden'],
  );
  $form['expiration_hidden'] = array(
    '#title' => 'Hide after expiration date',
    '#type' => 'checkbox',
    '#description' => 'Hide the object after the expiration. For example, an optional pre-test that expires.',
    '#default_value' => $config['expiration_hidden'],
  );
  return $form;
}