You are here

function _multichoice_update_6400 in Quiz 7.4

Same name and namespace in other branches
  1. 8.4 question_types/multichoice/multichoice_update_6400.inc \_multichoice_update_6400()
  2. 6.4 question_types/multichoice/multichoice_update_6400.inc \_multichoice_update_6400()
  3. 7 question_types/multichoice/multichoice_update_6400.inc \_multichoice_update_6400()

Helper function for multichoice_update_6400

Converts the database from the old to the new multichoice module

Parameters

$sandbox: Array to store progress in

Return value

Array with progress data

File

question_types/multichoice/multichoice_update_6400.inc, line 18

Code

function _multichoice_update_6400(&$sandbox = NULL) {
  $to_return = array();
  $sandbox['current_step'] = isset($sandbox['current_step']) ? $sandbox['current_step'] : 0;

  // Create datastructure for organizing the update process
  $steps = array();
  $steps[] = array(
    'alter_user_answers1',
    'next_step',
  );
  $steps[] = array(
    'move_old_answers',
  );
  $steps[] = array(
    'alter_user_answers2',
    'create_properties',
    'alter_answers',
    'next_step',
  );
  $steps[] = array(
    'check_answers',
  );
  $steps[] = array(
    'create_user_settings',
    'next_step',
  );

  // Do all the updates in the cureent step
  foreach ($steps[$sandbox['current_step']] as $value) {
    $function = '_multichoice_' . $value;
    $function($to_return, $sandbox);
  }

  // Update progress so that the batch_api can update the status bar, and knows when the update is finished
  $to_return['#finished'] = $sandbox['current_step'] / count($steps);
  return $to_return;
}