function quiz_form_alter in Quiz 7
Same name and namespace in other branches
- 6.6 quiz.module \quiz_form_alter()
- 6.2 quiz.module \quiz_form_alter()
- 6.3 quiz.module \quiz_form_alter()
- 6.4 quiz.module \quiz_form_alter()
- 6.5 quiz.module \quiz_form_alter()
- 7.6 quiz.module \quiz_form_alter()
- 7.4 quiz.module \quiz_form_alter()
- 7.5 quiz.module \quiz_form_alter()
Implements hook_form_alter().
Override settings in some existing forms. For example, we remove the preview button on a quiz.
File
- ./
quiz.module, line 581 - Quiz Module
Code
function quiz_form_alter(&$form, $form_state, $form_id) {
// Remove revision fieldset if user don't have access to revise quiz manually.
if (isset($form['#quiz_check_revision_access'])) {
if (!user_access('manual quiz revisioning') || variable_get('quiz_auto_revisioning', 1)) {
$form['revision_information']['revision']['#type'] = 'value';
$form['revision_information']['revision']['#value'] = $form['revision_information']['revision']['#default_value'];
$form['revision_information']['log']['#type'] = 'value';
$form['revision_information']['log']['#value'] = $form['revision_information']['log']['#default_value'];
unset($form['revision_information']['#type'], $form['revision_information']['#title'], $form['revision_information']['#description']);
}
unset($form['buttons']['preview'], $form['buttons']['preview_changes']);
$form['buttons']['submit']['#access'] = TRUE;
// Quiz questions might want to add a cancel button.
if (isset($form['#cancel_button'])) {
$form['buttons']['cancel'] = array(
'#markup' => l(t('Cancel'), $form_state['#redirect']),
'#weight' => 6,
);
}
$form['buttons']['#weight'] = 50;
}
}