You are here

function CourseObjectAccessTiming::optionsForm in Course 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::optionsForm()

File

src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php, line 64

Class

CourseObjectAccessTiming
Plugin annotation @CourseObjectAccess( id = "timing", label = @Translation("Timing"), )

Namespace

Drupal\course\Plugin\course\CourseObjectAccess

Code

function optionsForm(&$form, &$form_state) {
  $config = $this
    ->getOptions();
  if (Drupal::moduleHandler()
    ->moduleExists('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'],
    );
  }
  $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',
    '#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',
    '#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;
}