Moodle
  1. Moodle
  2. MDL-30435

When importing Common Cartridge package, link are broken.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.2
    • Component/s: Backup: IMS-CC
    • Labels:
    • Environment:
      Local. Linux w/mysql.
    • Rank:
      33094

      Description

      For test MDLQA-1426 (A teacher can import an IMS Common Cartridge package)downloaded this IMS Common Cartrige package: http://openlearn.open.ac.uk/blocks/formats/logrequest.php?url=/file.php/2592/exports/MST209_1_imscc.zip. After importing, found that what should have been links to external link resources were file resources. The links on the page were, therefore, broken.

      The following messages also appeared in the error log:

      [Wed Nov 23 13:52:02 2011] [error] [client 160.94.168.34] PHP Notice:  Trying to get property of non-object in /home/moodle/2.2-core/docs/backup/cc/entities.class.php on line 212, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:02 2011] [error] [client 160.94.168.34] PHP Notice:  Trying to get property of non-object in /home/moodle/2.2-core/docs/backup/cc/entities.class.php on line 213, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) no handler attached /MOODLE_BACKUP/COURSE/BLOCKS/BLOCK/, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) no handler attached /MOODLE_BACKUP/COURSE/BLOCKS/BLOCK/SEARCH_FORUMS, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) no handler attached /MOODLE_BACKUP/COURSE/BLOCKS/BLOCK/NEWS_ITEMS, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) no handler attached /MOODLE_BACKUP/COURSE/BLOCKS/BLOCK/CALENDAR_UPCOMING, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) no handler attached /MOODLE_BACKUP/COURSE/BLOCKS/BLOCK/RECENT_ACTIVITY, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] PHP Warning:  copy() [<a href='function.copy'>function.copy</a>]: The first argument to copy() function cannot be a directory in /home/moodle/2.2-core/docs/backup/converter/moodle1/lib.php on line 1409, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) error migrating the resource main file course_files/, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] PHP Warning:  copy() [<a href='function.copy'>function.copy</a>]: The first argument to copy() function cannot be a directory in /home/moodle/2.2-core/docs/backup/converter/moodle1/lib.php on line 1409, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) error migrating the resource main file course_files/, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] PHP Warning:  copy() [<a href='function.copy'>function.copy</a>]: The first argument to copy() function cannot be a directory in /home/moodle/2.2-core/docs/backup/converter/moodle1/lib.php on line 1409, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) error migrating the resource main file course_files/, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] PHP Warning:  copy() [<a href='function.copy'>function.copy</a>]: The first argument to copy() function cannot be a directory in /home/moodle/2.2-core/docs/backup/converter/moodle1/lib.php on line 1409, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      [Wed Nov 23 13:52:05 2011] [error] [client 160.94.168.34] (moodle1) error migrating the resource main file course_files/, referer: https://moodledev.oit.umn.edu/2.2-core/backup/restore.php
      

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          Thanks for creating that bug, Colin.

          We'll get on to this as soon as we can.

          Show
          Michael de Raadt added a comment - Thanks for creating that bug, Colin. We'll get on to this as soon as we can.
          Hide
          David Mudrak added a comment -

          I'm on it

          Show
          David Mudrak added a comment - I'm on it
          Hide
          Helen Foster added a comment -

          Hi David,

          I understand from Kris Stokking (whom I am adding as a watcher to this issue) that they've been testing IMS CC import using the Common Cartridge 1.1 test data (available at http://www.imsglobal.org/developers/alliance/compliancetesting.cfm). Kris says:

          The import process should also be compatible with 1.0 cartridges, but we don't support 1.2 (yet).

          In addition, the import process should also work with other 1.1 cartridges, but it's a little strict on its validation currently. If you run into a failure, it's best to check the cartridge against the IMS validator to make sure there are no critical errors (available at http://validator.imsglobal.org).

          Show
          Helen Foster added a comment - Hi David, I understand from Kris Stokking (whom I am adding as a watcher to this issue) that they've been testing IMS CC import using the Common Cartridge 1.1 test data (available at http://www.imsglobal.org/developers/alliance/compliancetesting.cfm ). Kris says: The import process should also be compatible with 1.0 cartridges, but we don't support 1.2 (yet). In addition, the import process should also work with other 1.1 cartridges, but it's a little strict on its validation currently. If you run into a failure, it's best to check the cartridge against the IMS validator to make sure there are no critical errors (available at http://validator.imsglobal.org ).
          Hide
          David Mudrak added a comment -

          Hm, interesting. I am actually experiencing IMS CC validation error when trying to restore the referenced package (see MDL-30444). I'm wondering how did it happen that the same validation error did not appear for Colin here.

          Show
          David Mudrak added a comment - Hm, interesting. I am actually experiencing IMS CC validation error when trying to restore the referenced package (see MDL-30444 ). I'm wondering how did it happen that the same validation error did not appear for Colin here.
          Hide
          David Mudrak added a comment -

          Thanks Helen. I tried to validate the referenced file at http://validator.imsglobal.org (profile CC v1.0) and the file is reported as valid:

          Source: IMS Online Validator
          Profile: 1.0.5
          Identifier: openlearn_open_ac_uk-353
          Timestamp: Thursday, November 24, 2011 09:55 AM UTC
          Status: VALID!
          Conformant: true

          List of all Files Validated:
          imsmanifest.xml
          Links/link1.xml
          Links/link2.xml
          Links/link3.xml
          Links/link4.xml
          Forums/forum0.xml

          ----- VALID! -----
          Resource Validation Results
          The document is valid.

          ----- VALID! -----
          Schema Location Results
          Schema locations are valid.

          ----- VALID! -----
          Schema Validation Results
          The document is valid.

          ----- VALID! -----
          Schematron Validation Results
          The document is valid.

          Show
          David Mudrak added a comment - Thanks Helen. I tried to validate the referenced file at http://validator.imsglobal.org (profile CC v1.0) and the file is reported as valid: Source: IMS Online Validator Profile: 1.0.5 Identifier: openlearn_open_ac_uk-353 Timestamp: Thursday, November 24, 2011 09:55 AM UTC Status: VALID! Conformant: true List of all Files Validated: imsmanifest.xml Links/link1.xml Links/link2.xml Links/link3.xml Links/link4.xml Forums/forum0.xml ----- VALID! ----- Resource Validation Results The document is valid. ----- VALID! ----- Schema Location Results Schema locations are valid. ----- VALID! ----- Schema Validation Results The document is valid. ----- VALID! ----- Schematron Validation Results The document is valid.
          Hide
          Darko Miletic added a comment -

          This package has incorrectly encoded url's within links.
          If you look into any link xml you will see that href value is urlencoded. Links in Moodle are resources and since Moodle is unable to distinguish reference value as valid url it assumes it is file and hence the behaviour you observe.

          For example:

          <?xml version="1.0" encoding="UTF-8"?>
          <wl:webLink
            xmlns:wl="http://www.imsglobal.org/xsd/imswl_v1p0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.imsglobal.org/xsd/imswl_v1p0 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd">
            <title>An OU course on this topic</title>
            <url href="http%3A%2F%2Fwww3.open.ac.uk%2Fstudy%2Fundergraduate%2Fcourse%2Fmst209.htm" target="_blank"/>
          </wl:webLink>
          

          and it should be:

          <?xml version="1.0" encoding="UTF-8"?>
          <wl:webLink
            xmlns:wl="http://www.imsglobal.org/xsd/imswl_v1p0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.imsglobal.org/xsd/imswl_v1p0 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd">
            <title>An OU course on this topic</title>
            <url href="http://www3.open.ac.uk/study/undergraduate/course/mst209.htm" target="_blank"/>
          </wl:webLink>
          
          Show
          Darko Miletic added a comment - This package has incorrectly encoded url's within links. If you look into any link xml you will see that href value is urlencoded. Links in Moodle are resources and since Moodle is unable to distinguish reference value as valid url it assumes it is file and hence the behaviour you observe. For example: <?xml version= "1.0" encoding= "UTF-8" ?> <wl:webLink xmlns:wl = "http://www.imsglobal.org/xsd/imswl_v1p0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.imsglobal.org/xsd/imswl_v1p0 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd" > <title> An OU course on this topic </title> <url href= "http%3A%2F%2Fwww3.open.ac.uk%2Fstudy%2Fundergraduate%2Fcourse%2Fmst209.htm" target= "_blank" /> </wl:webLink> and it should be: <?xml version= "1.0" encoding= "UTF-8" ?> <wl:webLink xmlns:wl = "http://www.imsglobal.org/xsd/imswl_v1p0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.imsglobal.org/xsd/imswl_v1p0 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd" > <title> An OU course on this topic </title> <url href= "http://www3.open.ac.uk/study/undergraduate/course/mst209.htm" target= "_blank" /> </wl:webLink>
          Hide
          Darko Miletic added a comment -

          There is still need to improve link validation and detection so I will add minor update for link conversion process.

          Show
          Darko Miletic added a comment - There is still need to improve link validation and detection so I will add minor update for link conversion process.
          Hide
          Darko Miletic added a comment -

          Pull request sent to moodle repo on github.

          Here is the commit for review

          https://github.com/kiklop74/moodle/commit/adf8f7a172a14a0d625aae00f035a6fccce9ed40

          And here is the actual branch

          https://github.com/kiklop74/moodle/tree/MDL-30435

          Show
          Darko Miletic added a comment - Pull request sent to moodle repo on github. Here is the commit for review https://github.com/kiklop74/moodle/commit/adf8f7a172a14a0d625aae00f035a6fccce9ed40 And here is the actual branch https://github.com/kiklop74/moodle/tree/MDL-30435
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks! (nice fallback)

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, thanks! (nice fallback)
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Nobody tested this. MDLQA-1426 will.

          Show
          Eloy Lafuente (stronk7) added a comment - Nobody tested this. MDLQA-1426 will.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The master fixes corresponding to this issue have been sent upstream. Fixes for other branches (19, 20, 21 stable) will be sent in the very-next days.

          Thanks for the hard work! Closing, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The master fixes corresponding to this issue have been sent upstream. Fixes for other branches (19, 20, 21 stable) will be sent in the very-next days. Thanks for the hard work! Closing, ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: