function CourseObjectAccessGrade::optionsForm in Course 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/course/CourseObjectAccess/CourseObjectAccessGrade.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessGrade::optionsForm()
File
- src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessGrade.php, line 94
Class
- CourseObjectAccessGrade
- Plugin annotation @CourseObjectAccess( id = "grade", label = @Translation("Grade"), )
Namespace
Drupal\course\Plugin\course\CourseObjectAccessCode
function optionsForm(&$form, &$form_state) {
$config = $this
->getOptions();
$form['#description'] = t('The user will not be able to access this object unless the course grade is within the set range.');
$form['course_grade_range'] = array(
'#type' => 'container',
);
$form['course_grade_range']['low'] = array(
'#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'] = array(
'#title' => t('Percentage high'),
'#type' => 'textfield',
'#size' => 4,
'#default_value' => isset($config['course_grade_range']['high']) ? $config['course_grade_range']['high'] : '',
);
$options = $this
->getObjectOptions();
$options[0] = '(this course)';
$form['conditional_object'] = array(
'#title' => t('Grade to check'),
'#type' => 'select',
'#options' => $options,
'#description' => t('This grade will be checked.'),
'#default_value' => $config['conditional_object'],
);
$form['course_grade_hidden'] = array(
'#title' => t('Hide until grade met'),
'#description' => t('The user will not see this object until the grade is met.'),
'#type' => 'checkbox',
'#default_value' => $config['course_grade_hidden'],
);
return $form;
}