Moodle
  1. Moodle
  2. MDL-32831

Docx and xlsx and pptx files not showing their filetype in Moodle 2.3

    Details

    • Testing Instructions:
      Hide

      To test:

      • in a Moodle 2.3, click add a resource>file
      • Upload or drag in a MS Office 2007 or later file and select the option to display the file type
      • Save and verify that the file type does not display.
      Show
      To test: in a Moodle 2.3, click add a resource>file Upload or drag in a MS Office 2007 or later file and select the option to display the file type Save and verify that the file type does not display.
    • Affected Branches:
      MOODLE_23_STABLE
    • Rank:
      39861

      Description

      When testing the display of file types on the QA Moodle I discovered that files with the extension docx and xlsx and pptx were not showing their types.

        Issue Links

          Activity

          Hide
          Sam Hemelryk added a comment -

          Hi Mary,

          Thanks for creating this issue.
          The file types are not being displayed at the moment because there is no string identifier for the mimetypes of those files (basically we don't have a string to describe those file types).
          The docx/xlsx... file types are a very good candidate to translate however there are lots of other mime types that we havn't translated.
          I suppose at some point we will need to decide which to translate for.

          To get this issue kick started the following patch introduces strings for a few more file types.

          diff --git a/lang/en/mimetypes.php b/lang/en/mimetypes.php
          index 17d224e..052e326 100644
          --- a/lang/en/mimetypes.php
          +++ b/lang/en/mimetypes.php
          @@ -25,8 +25,14 @@
           
           $string['application/msword'] = 'Word document';
           $string['application/pdf'] = 'PDF document';
          +$string['application/vnd.moodle.backup'] = 'Moodle backup';
           $string['application/vnd.ms-excel'] = 'Excel spreadsheet';
           $string['application/vnd.ms-powerpoint'] = 'Powerpoint presentation';
          +$string['application/vnd.openxmlformats-officedocument.presentationml.presentation'] = 'Powerpoint presentation';
          +$string['application/vnd.openxmlformats-officedocument.presentationml.slideshow'] = 'Powerpoint slideshow';
          +$string['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'] = 'Excel spreadsheet';
          +$string['application/vnd.openxmlformats-officedocument.spreadsheetml.template'] = 'Excel template';
          +$string['application/vnd.openxmlformats-officedocument.wordprocessingml.document'] = 'Word document';
           $string['application/zip'] = 'zip archive';
           $string['audio/mp3'] = 'MP3 audio file';
           $string['audio/wav'] = 'sound file';
          @@ -35,5 +41,6 @@ $string['image/bmp'] = 'uncompressed BMP image';
           $string['image/gif'] = 'GIF image';
           $string['image/jpeg'] = 'JPEG image';
           $string['image/png'] = 'PNG image';
          +$string['text/html'] = 'HTML document';
           $string['text/plain'] = 'text file';
          -$string['text/rtf'] = 'RTF document';
          +$string['text/rtf'] = 'RTF document';
          \ No newline at end of file
          

          As well as that we should consider adding upgrade code to re-parse the resource records in the database and updating the field that caches that information for each resource.
          If we only add the strings then in order for the type to be displayed a teacher or such will have to edit and save each resource.
          Perhaps given this information isn't essential that is fine, however still to be considered.

          Marking this triaged and with a patch.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hi Mary, Thanks for creating this issue. The file types are not being displayed at the moment because there is no string identifier for the mimetypes of those files (basically we don't have a string to describe those file types). The docx/xlsx... file types are a very good candidate to translate however there are lots of other mime types that we havn't translated. I suppose at some point we will need to decide which to translate for. To get this issue kick started the following patch introduces strings for a few more file types. diff --git a/lang/en/mimetypes.php b/lang/en/mimetypes.php index 17d224e..052e326 100644 --- a/lang/en/mimetypes.php +++ b/lang/en/mimetypes.php @@ -25,8 +25,14 @@ $string['application/msword'] = 'Word document'; $string['application/pdf'] = 'PDF document'; +$string['application/vnd.moodle.backup'] = 'Moodle backup'; $string['application/vnd.ms-excel'] = 'Excel spreadsheet'; $string['application/vnd.ms-powerpoint'] = 'Powerpoint presentation'; +$string['application/vnd.openxmlformats-officedocument.presentationml.presentation'] = 'Powerpoint presentation'; +$string['application/vnd.openxmlformats-officedocument.presentationml.slideshow'] = 'Powerpoint slideshow'; +$string['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'] = 'Excel spreadsheet'; +$string['application/vnd.openxmlformats-officedocument.spreadsheetml.template'] = 'Excel template'; +$string['application/vnd.openxmlformats-officedocument.wordprocessingml.document'] = 'Word document'; $string['application/zip'] = 'zip archive'; $string['audio/mp3'] = 'MP3 audio file'; $string['audio/wav'] = 'sound file'; @@ -35,5 +41,6 @@ $string['image/bmp'] = 'uncompressed BMP image'; $string['image/gif'] = 'GIF image'; $string['image/jpeg'] = 'JPEG image'; $string['image/png'] = 'PNG image'; +$string['text/html'] = 'HTML document'; $string['text/plain'] = 'text file'; -$string['text/rtf'] = 'RTF document'; +$string['text/rtf'] = 'RTF document'; \ No newline at end of file As well as that we should consider adding upgrade code to re-parse the resource records in the database and updating the field that caches that information for each resource. If we only add the strings then in order for the type to be displayed a teacher or such will have to edit and save each resource. Perhaps given this information isn't essential that is fine, however still to be considered. Marking this triaged and with a patch. Cheers Sam
          Hide
          Sam Marshall added a comment -

          Just a comment - rather than re-parsing resources manually, the cached information can be recalculated more easily using rebuild_course_cache (for all courses, with the flag that means it only clears it). So it becomes a one-liner upgrade.

          Show
          Sam Marshall added a comment - Just a comment - rather than re-parsing resources manually, the cached information can be recalculated more easily using rebuild_course_cache (for all courses, with the flag that means it only clears it). So it becomes a one-liner upgrade.
          Hide
          Marina Glancy added a comment -

          This has been fixed in Moodle 2.3 by introducing 'string' attribute in get_mimetypes_array(). Now several different extensions may have the same string associated with them.

          Show
          Marina Glancy added a comment - This has been fixed in Moodle 2.3 by introducing 'string' attribute in get_mimetypes_array(). Now several different extensions may have the same string associated with them.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: