You are here

function CourseObjectAccessTiming::optionsForm in Course 7.2

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

Define the form to be used in the object access settings area.

Overrides CourseObjectAccess::optionsForm

File

plugins/course_object_access/timing.inc, line 61

Class

CourseObjectAccessTiming

Code

function optionsForm($form, &$form_state) {
  $config = $this
    ->getOptions();
  if (module_exists('timeperiod')) {
    $form['duration'] = array(
      '#title' => t('Duration'),
      '#description' => t('Length of time a user can remain in this object before it is closed.'),
      '#type' => 'timeperiod_select',
      '#units' => array(
        '86400' => array(
          'max' => 30,
          'step size' => 1,
        ),
        '3600' => array(
          'max' => 24,
          'step size' => 1,
        ),
        '60' => array(
          'max' => 60,
          'step size' => 1,
        ),
      ),
      '#default_value' => $config['duration'],
    );
  }
  else {
    $form['duration'] = array(
      '#title' => t('Duration'),
      '#description' => t('Length of time in seconds a user can remain in this object before it is closed.'),
      '#type' => 'textfield',
      '#size' => 8,
      '#default_value' => $config['duration'],
    );
  }
  if (module_exists('date_popup')) {
    $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' => t('Hide until release date'),
      '#type' => 'checkbox',
      '#description' => t('Hide the object until the release date. For example, an evaluation after a live event.'),
      '#default_value' => $config['release_hidden'],
    );
    $form['expiration_hidden'] = array(
      '#title' => t('Hide after expiration date'),
      '#type' => 'checkbox',
      '#description' => t('Hide the object after the expiration. For example, an optional pre-test that expires.'),
      '#default_value' => $config['expiration_hidden'],
    );
  }
  return $form;
}