You are here

public function CourseObjectAccessGrade::buildConfigurationForm in Course 3.x

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

Overrides CourseObjectAccessPluginBase::buildConfigurationForm

File

src/Plugin/course/CourseObjectAccess/CourseObjectAccessGrade.php, line 92

Class

CourseObjectAccessGrade
Plugin annotation @CourseObjectAccess( id = "grade", label = @Translation("Grade"), )

Namespace

Drupal\course\Plugin\course\CourseObjectAccess

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $config = $this
    ->getOptions();
  $options = $this
    ->getObjectOptions();
  $options[0] = '(this course)';
  $form['conditional_object'] = [
    '#title' => t('Grade to check'),
    '#type' => 'select',
    '#options' => $options,
    '#description' => t('This grade will be checked.'),
    '#default_value' => $config['conditional_object'],
  ];
  $form['course_grade_range'] = [
    '#type' => 'container',
  ];
  $form['course_grade_range']['low'] = [
    '#title' => t('Percentage low'),
    '#type' => 'textfield',
    '#size' => 4,
    '#default_value' => isset($config['course_grade_range']['low']) ? $config['course_grade_range']['low'] : '',
  ];
  $form['course_grade_range']['high'] = [
    '#title' => t('Percentage high'),
    '#type' => 'textfield',
    '#size' => 4,
    '#default_value' => isset($config['course_grade_range']['high']) ? $config['course_grade_range']['high'] : '',
  ];
  return $form;
}