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

book_export_contents doesn't return the full filepath of the files

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.9.5, 3.0.3, 3.1
    • 2.9.6, 3.0.4
    • Book
    • MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • MOODLE_29_STABLE, MOODLE_30_STABLE
    • MDL-53671-master
    • Hide
      1. Create a course with a student. The course must have at least one section.
      2. Create a book in the course.
      3. Create a chapter in the book. Use the "Manage files" of the Atto editor to:
        • Add a file to the root folder.
        • Create a folder.
        • Add a file inside the folder you just created.
      4. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      5. Create a Token for the student user.
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, courseid and the URL of your moodle instance.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_get_contents&courseid=2&wstoken=5b6154a56566a194f60f7f395f235179' --compressed

      7. Search the book in the response. Inside the 'contents' property, check that:
        • The filepath of the file in the root folder is \/1\/.
        • The filepath of the file inside the subfolder is \/1\/FOLDERNAME\/.
      Show
      Create a course with a student. The course must have at least one section. Create a book in the course. Create a chapter in the book. Use the "Manage files" of the Atto editor to: Add a file to the root folder. Create a folder. Add a file inside the folder you just created. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student user. Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, courseid and the URL of your moodle instance. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_get_contents&courseid=2&wstoken=5b6154a56566a194f60f7f395f235179' --compressed Search the book in the response. Inside the 'contents' property, check that: The filepath of the file in the root folder is \/1\/. The filepath of the file inside the subfolder is \/1\/FOLDERNAME\/.

    Description

      The function book_export_contents returns a list of files in a book. The problem is that the filepath of each file is always set like this:

      $file['filepath']     = "/{$chapter->id}/";
      

      So if a file is inside one or more folders, the filepath doesn't contain them. Example:

      Image inside /folder/image.jpg
      filepath => '/1/'
      filename => 'image.jpg'
      fileurl => 'MOODLE/webservice/pluginfile.php/61/mod_book/chapter/1/folder/image.jpg'
      

      In the example above, the filepath should also contain the folder: /1/folder/.

      Attachments

        Activity

          People

            dpalou Dani Palou
            dpalou Dani Palou
            cameron1729 cameron1729
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            David Monllaó David Monllaó
            David Jones, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9/May/16