db_fetch_array() doesn't exist anymore in D7. This may not ever get called but might as well upgrade it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joelpittet created an issue. See original summary.

joelpittet’s picture

joelpittet’s picture

--relative flag on that patch

joelpittet’s picture

Status: Active » Needs review

The last submitted patch, 2: 2834587-2.patch, failed testing.

djdevin’s picture

Thanks!

This appears to be called from quiz_questions_form_submit() when making sure there are enough taxonomy terms for the requested number of questions and also in _quiz_get_random_questions() when getting the random questions.

It's a little odd that we haven't seen fatal for this so let me check if this is actually getting called.

Da_Cloud’s picture

As far as I can tell that function isn't used anymore. Both the on the manage questions page and when trying to start a quiz you'll get an error message that's triggered by the _quiz_build_categorized_question_list($quiz) function.

A full search on the _quiz_get_random_taxonomy_question_ids() function will result in 2 places where the function is being called.

1) Inside the function _quiz_get_random_questions($quiz)
This one only gets called when the quiz itself has a tid.

$tid = $quiz->tid;
$questions = array();
if ($num_random > 0) {
  if ($tid > 0) {
    $questions = _quiz_get_random_taxonomy_question_ids($tid, $num_random);
  }

2) Inside the function quiz_questions_form_submit($form, &$form_state)
This only gets called when $term_id is not empty. and $term_id is set with the following code

$term_id = isset($form_state['values']['random_term_id']) ? (int) $form_state['values']['random_term_id'] : 0;

Following the form field random_term_id we'll find the following code

if ($quiz->randomization == 3) {
  $terms = _quiz_taxonomy_select($quiz->tid);
  if (!empty($terms) && function_exists('taxonomy_get_vocabularies')) {
    $form['question_list']['random_settings']['random_term_id'] = array(
      '#type' => 'select',
      '#title' => t('Terms'),
      '#size' => 1,
      '#options' => _quiz_taxonomy_select($quiz->tid),
      '#default_value' => $quiz->tid,
      '#description' => t('Randomly select from questions with this term, or choose from the question pool below'),
      '#weight' => -4,
    );
  }
}

In both cases the code will only be called if $quiz->tid will not result empty. So naturally we'll take a look in the hook_schema what the field does and it seems to be a deprecated piece of code that has long been replaced with a better structure.

'tid' => array(
  'type' => 'int',
  'unsigned' => TRUE,
  'not null' => TRUE,
  'default' => 0,
  'description' => 'Deprecated field? This may have moved to {quiz_terms}',
),
Da_Cloud’s picture

Made a "quick" patch to see which code would be affected should we remove the old structure. Which as far as I can see, seems to be there to support older quizzes after upgrading to a newer version.

djdevin’s picture

Thanks, this looks great. The single term ID is very, very old and just hasn't been removed. In Quiz 4+ you could already have multiple taxonomy terms per quiz so that tid option must be from Quiz 3 or earlier.

I confirmed that there are tests in testCategorizedRandomQuestions for the current behavior.

djdevin’s picture

Status: Needs review » Reviewed & tested by the community

I'll leave it RTBC for a bit, but it looks fine to commit.

joelpittet’s picture

Ready to commit yet?

  • djdevin committed 07c8ac0 on 7.x-5.x authored by Da_Cloud
    Issue #2834587 by Da_Cloud: D6 leftover undefined function...
djdevin’s picture

Status: Reviewed & tested by the community » Fixed

Yes. Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.