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

IMS CC restore fails on QTI answers that have embedded images.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.4
    • Backup: IMS-CC
    • MOODLE_24_STABLE

      I have an IMS CC package with a QTI assessment. The assessment has both questions and answers that contain HTML content, including images. The images in the question text import fine. The images in the answer does not. I've found that the code performs an extra step for the question than for the answers. The code change is very simple:

      1. Edit the file: backup/cc/entity11.quiz.class.php
      2. Locate the function: private function get_questions ($assessment, &$last_question_id, &$last_answer_id, $root_path, $is_question_bank)
      3. Near the end of the function is a line that calls "get_answers": $questions[$question_identifier]['answers'] = $this->get_answers($question_identifier, $assessment, $last_answer_id);
      4. Add the parameter "$root_path" like this: $questions[$question_identifier]['answers'] = $this->get_answers($question_identifier, $assessment, $last_answer_id, $root_path);
      NOTE: this is safe because get_answers is private and this is the only place in the file where it gets called.
      5. Locate the function: private function get_answers ($identifier, $assessment, &$last_answer_id)
      6. Add the paramer "$root_path" to the parameter list: private function get_answers ($identifier, $assessment, &$last_answer_id, $root_path)
      7. In "get_answers", there is a line that looks like this: $answer_title = !empty($answer_title->item(0)>nodeValue)? $answer_title>item(0)->nodeValue: '';
      8. Replace that line with this block of code:
      if(!empty($answer_title->item(0)->nodeValue))

      { $answer_title = $answer_title->item(0)->nodeValue; //This is the important part. These 2 lines are run on the question text but not the answer text. //The result is that embedded images for the question get imported and embedded images for the answer do not. $answer_title = $this->update_sources($answer_title, $root_path); //This line converts the base path of the image in any src/href attributes $answer_title = !empty($answer_title) ? str_replace("%24", "\$", $this->include_titles($answer_title)) : ''; //This line urldecodes the $ for the PHP base path sequence }

      else

      { $answer_title = ''; }

      I can provide sample test data. Email me at pcross@montereyinstitute.org. It's such a tiny and safe change I have not committed it to github but if you really insist, let me know.

            darko.miletic Darko Miletic
            mitemouse Phil Cross
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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