Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-30689

get_question_options Field Mismatch in question_answers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.0.7
    • 2.0.6
    • Questions
    • windows IIS, MySQL
    • MySQL
    • MOODLE_20_STABLE
    • MOODLE_20_STABLE
    • Hide

      Override the function in your new question type or alter the main questiontype code.

      Further, for extending the questions table you use questionid_column_name in the same file. possibly create the same for answers or implement this function in the answer portion?

      Show
      Override the function in your new question type or alter the main questiontype code. Further, for extending the questions table you use questionid_column_name in the same file. possibly create the same for answers or implement this function in the answer portion?
    • Hide

      This does not affect any core question types, just the ease with which people can write third-party ones. Hence it is a very safe changes, but very hard to test. I think we can safely add this with no testing.

      Show
      This does not affect any core question types, just the ease with which people can write third-party ones. Hence it is a very safe changes, but very hard to test. I think we can safely add this with no testing.

      If you look at the function get_question_options in 2.0.1+ (yes we plan on upgrading) in \moodle\question\type\questiontype.php you will see
      $extra_answer_fields = $this->extra_answer_fields();
      if (is_array($extra_answer_fields)) {
      $answer_extension_table = array_shift($extra_answer_fields);
      $question->options->answers = $DB->get_records_sql("
      SELECT qa.*, qax." . implode(', qax.', $extra_answer_fields) . "
      FROM

      {question_answers} qa, {$answer_extension_table} qax
      WHERE qa.questionid = ? AND qax.answerid = qa.id", array($question->id));
      if (!$question->options->answers) { echo $OUTPUT->notification("Failed to load question answers from the table $answer_extension_table for questionid " . $question->id); return false; }
      }

      note that
      SELECT qa.*, qax." . implode(', qax.', $extra_answer_fields) . "
      FROM {question_answers}

      qa, {$answer_extension_table} qax
      WHERE qa.questionid = ? AND qax.answerid = qa.id", array($question->id)

      uses 'qa.questionid' whereas in the database the field is called 'question'. Easy fix is override but...

            timhunt Tim Hunt
            jmasiello Jeff Masiello
            Sam Hemelryk Sam Hemelryk
            Ankit Agarwal Ankit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.