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

Store the raw mimetype (not translated) in resource_get_coursemodule_info

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.2
    • Fix Version/s: 3.7
    • Component/s: Resource
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin create a new course
      2. Upload a few file resources (different types) like a pdf file, a txt, mp3, mp4 ... to the course. In each of the resource settings, enable the "Show type" option.
      3. Enrol any user in the course (not admin)
      4. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      5. Create a Token in the mobile app service for the user enrolled in the course
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. Replace also the courseid with the course you created.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool"

      7. Check that for any module returned by the WS, you have a customdata field, displaying serialized data, like this: "a:3:{s:10:\"printintro\";i:0;s:8:\"showtype\";i:1;s:11:\"filedetails\";a:2:{s:4:\"type\";s:9:\"Text file\";s:8:\"mimetype\";s:10:\"text\/plain\";}} but displaying the correct mimetye depending on the type of the file, for example, for a PDF should be something like: application/pdf
      8. As admin in the sitem edit the settings of any of the resources you uploaded and disable the "Show type" option
      9. Execute again the CURL request and check that the customdata field does not containg the mimetype information for the resource you edited.
      Show
      As admin create a new course Upload a few file resources (different types) like a pdf file, a txt, mp3, mp4 ... to the course. In each of the resource settings, enable the "Show type" option. Enrol any user in the course (not admin) As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the user enrolled in the course Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. Replace also the courseid with the course you created. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool" Check that for any module returned by the WS, you have a customdata field, displaying serialized data, like this: "a:3:{s:10:\"printintro\";i:0;s:8:\"showtype\";i:1;s:11:\"filedetails\";a:2:{s:4:\"type\";s:9:\"Text file\";s:8:\"mimetype\";s:10:\"text\/plain\";}} but displaying the correct mimetye depending on the type of the file, for example, for a PDF should be something like: application/pdf As admin in the sitem edit the settings of any of the resources you uploaded and disable the "Show type" option Execute again the CURL request and check that the customdata field does not containg the mimetype information for the resource you edited.
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-63958-master

      Description

      Right now the mimetype is not cached in raw, it is translated.

      We should store the raw mimetype so we can receive it via Web Services and be able to calculate the icon to use when displaying a resource activity.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  20/May/19