You are here

function quiz_admin_node_form_submit in Quiz 8.4

Same name and namespace in other branches
  1. 6.4 quiz.admin.inc \quiz_admin_node_form_submit()
  2. 7.6 quiz.admin.inc \quiz_admin_node_form_submit()
  3. 7 quiz.admin.inc \quiz_admin_node_form_submit()
  4. 7.4 quiz.admin.inc \quiz_admin_node_form_submit()
  5. 7.5 quiz.admin.inc \quiz_admin_node_form_submit()

Submit function for quiz_admin_node_form

The default values are saved as the user settings for the "default user" The default user is created when quiz is installed. He has a unique uid, but doesn't exist as a real user.

Why? Default user settings can be loaded and saved using the same code and database tables as any other user settings, making the code a lot easier to maintain. Ref: http://en.wikipedia.org/wiki/Don%27t_repeat_yourself

1 string reference to 'quiz_admin_node_form_submit'
quiz_admin_node_form in ./quiz.admin.inc
Renders the quiz node form for the admin pages

File

./quiz.admin.inc, line 85
Administrator interface for Quiz module.

Code

function quiz_admin_node_form_submit($form, &$form_state) {

  // We add the uid for the "default user"
  $form_state['values']['save_def_uid'] = \Drupal::config('quiz.settings')
    ->get('quiz_def_uid') ?: NULL;
  $form_state['values']['nid'] = 0;
  $form_state['values']['vid'] = 0;
  $form_state['values']['aid'] = '';
  $values = $form_state['values'];
  $values = array_merge($values, $form_state['values']['taking']);
  $values = array_merge($values, $form_state['values']['taking']['feedback']);
  $values = array_merge($values, $form_state['values']['taking']['multiple_takes']);
  $values = array_merge($values, $form_state['values']['availability']);
  $values = array_merge($values, $form_state['values']['pass_fail']);
  $values = array_merge($values, $form_state['values']['pass_fail']['helper']);
  $form_state['values'] = $values;
  unset($form_state['values']['taking']);
  unset($form_state['values']['availability']);
  unset($form_state['values']['pass_fail']);
  unset($form_state['values']['feedback']);
  unset($form_state['values']['multiple_takes']);
  unset($form_state['values']['helper']);

  // Create dummy node for quiz_validate
  $form_state['values']['resultoptions'] = array();
  $form_state['values']['type'] = 'quiz';

  // @todo: Verify Once.
  $dummy_node = entity_create('node', $form_state['values']);
  _quiz_save_user_settings($dummy_node);
}