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

Book HTML zip import incorrect URL produced for internal linking to other chapters

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5
    • 2.4.7, 2.5.3
    • Book
    • MOODLE_25_STABLE
    • MOODLE_24_STABLE, MOODLE_25_STABLE
    • wip-MDL-41473-master
    • Hide

      Do not use links in html files that you are using to import to a book

      Show
      Do not use links in html files that you are using to import to a book
    • Easy
    • Hide

      1) Create a new book module and save and display.
      2) Progress to the import chapter page (Administration > Import chapter).
      3) Use the attached bookimporttest.zip file as the Zip file, and leave the Type as the default Each Html file represents one chapter.
      4) Once the import processing has completed view the first of the two pages (named a.html and b.html). There is a link on each page to the other page. Without this patch the links are broken (though the addition of 'id' in the url will correct them).

      Show
      1) Create a new book module and save and display. 2) Progress to the import chapter page (Administration > Import chapter). 3) Use the attached bookimporttest.zip file as the Zip file, and leave the Type as the default Each Html file represents one chapter. 4) Once the import processing has completed view the first of the two pages (named a.html and b.html). There is a link on each page to the other page. Without this patch the links are broken (though the addition of 'id' in the url will correct them).

    Description

      Scenario:
      HTML file A has a relative link to HTML file B. Both files are added to a Zip. The Zip is imported into a Book and chapters are created from the HTML files. The Book module attempts to preserve the link from A to B, using the new paths created as A and B are now chapters in the book. However, there is an error in the link created as it uses 'chapter' as a parameter instead of 'chapterid'.

      Solution:

      In mod/book/tool/importhtml/locallib.php

      In function toolbook_importhtml_import_chapters

      Line 140/141

      Change

      $newcontent = str_replace($match, 'href="'.new moodle_url('/mod/book/view.php',
      array('id'=>$context->instanceid, 'chapter'=>$target->id)).'"', $newcontent);

      to

      $newcontent = str_replace($match, 'href="'.new moodle_url('/mod/book/view.php',
      array('id'=>$context->instanceid, 'chapterid'=>$target->id)).'"', $newcontent);

      Sorry, I'm just an occasional user so not used to creating patch files myself. Hope it helps!

      Attachments

        Activity

          People

            jb23347 John Beedell
            mattcornock Matt Cornock
            Ankit Agarwal Ankit Agarwal
            Damyon Wiese Damyon Wiese
            Sam Hemelryk Sam Hemelryk
            David Jones, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11/Nov/13