You are here

function quizfileupload_update_7500 in Quiz File Upload 7.5

Update the modules data structure to support quiz 5.x.

File

./quizfileupload.install, line 193
The install file for installing the quizfileupload module.

Code

function quizfileupload_update_7500() {

  // We may store empty files (as users are allowed to skip the question).
  $spec = array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
  );
  db_change_field('quiz_fileupload_user_answers', 'fid', 'fid', $spec);

  // Match the data storage of the Quiz 5.x version.
  db_drop_index('quiz_fileupload_user_answers', 'answer_id');
  db_add_field('quiz_fileupload_user_answers', 'result_answer_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
  ));
  db_query("UPDATE {quiz_fileupload_user_answers} qfua\n    INNER JOIN {quiz_node_results_answers} qnra ON (qfua.question_nid = qnra.question_nid\n    AND qfua.question_vid = qnra.question_vid\n    AND qfua.result_id = qnra.result_id)\n    SET qfua.result_answer_id = qnra.result_answer_id");
  db_drop_field('quiz_fileupload_user_answers', 'result_id');
  db_drop_field('quiz_fileupload_user_answers', 'question_nid');
  db_drop_field('quiz_fileupload_user_answers', 'question_vid');
  db_add_unique_key('quiz_fileupload_user_answers', 'result_answer_id', array(
    'result_answer_id',
  ));

  // Rename the variable to match the default naming of the quiz module.
  variable_set('quizfileupload_default_max_score', variable_get('quizfileupload_default_score', 1));
  variable_del('quizfileupload_default_score');
}