Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-3134

For plugin activities the size context menu item is not updating automatically without a refresh

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7.0
    • Fix Version/s: None
    • Component/s: Site add-ons
    • Labels:
    • Testing Instructions:
      Hide

      Testing requires a plugin activity that is ready for use in the mobile app. Please see setup instructions in mobile-files-notes.txt for full details.

      I have attached a sample plugin activity as a zip file - ouwiki.zip - that contains all files needed to replicate this issue when added as a plugin to a core Moodle site.

      From here it is assumed that it is possible to sign in to your test site on the app as a student enrolled on a course that contains a suitably set up plugin activity (e.g. ouwiki). This same test can be done with any non core activity that is set up for the mobile app and contains an image that is displayed in the app using the core-external-content directive.

      • Navigate to the activity plugin page and check the page appears and contains an image. The image is the file to be (or is) downloaded.
      • While on the activity page in the app click on the top right page menu (three vertical dots).
      • Before applying this patch: Expected: The image size menu item does not appear (without a refresh).
      • After applying this patch: Expected: The image size menu item does appear (without a refresh). The image has been downloaded as you have seen it in the page!
      Show
      Testing requires a plugin activity that is ready for use in the mobile app. Please see setup instructions in mobile-files-notes.txt for full details. I have attached a sample plugin activity as a zip file - ouwiki.zip - that contains all files needed to replicate this issue when added as a plugin to a core Moodle site. From here it is assumed that it is possible to sign in to your test site on the app as a student enrolled on a course that contains a suitably set up plugin activity (e.g. ouwiki). This same test can be done with any non core activity that is set up for the mobile app and contains an image that is displayed in the app using the core-external-content directive. Navigate to the activity plugin page and check the page appears and contains an image. The image is the file to be (or is) downloaded. While on the activity page in the app click on the top right page menu (three vertical dots). Before applying this patch: Expected: The image size menu item does not appear (without a refresh). After applying this patch: Expected: The image size menu item does appear (without a refresh). The image has been downloaded as you have seen it in the page!
    • Affected Branches:
      MOODLE_37_STABLE
    • Pull 3.7 Branch:
      wip-MOBILE-3134-integration

      Description

      The issue:
      For activity plugins image (and video) files included on a page using the core-external-content directive are being downloaded, stored and are viewable but the size menu item in the context menu (top right more icon) is not being displayed until the page is refreshed. For core activity plugins image files are always downloaded before the activity page displays (check the image url) and the size menu item displays the stored file size without the need for a refresh.

      To replicate:

      • From an existing moodle plugin activity (e.g. ouwiki) add the three files that enable moodle app functionality (db/mobile.php, classes/mobile.php and templates/main_view.mustache - see attached sample files). Keep the app functionality to the minimum, but add an image (a core-external-content element) in the template with a dynamic src.
      • On the website, run notifications, add a course, add a student and enroll on course, enable mobile, add the activity and add one image for display to the activity. This image src should then be used as the fixed image url to be passed to the template in the app code above (ensuring the image will be served properly as a plugin file).
      • On the app sign in as student, navigate to the course, select the activity, check the image appears.
      • On the activity page in the app view the top right menu (three vertical dots), check the image size menu item does not appear (without a refresh: but do not refresh for the moment). Also check the src of the image on the page - it is still showing as an external file ([https://|https:]...), where after a refresh it is served locally (filesystem:....).

      Comment:
      At this point the image is actually downloaded to the app and appears in the database (in filepool_files - view in chrome developer tools - Application > Storage > WebSQL). The file was downloaded by a call to addToQueueIfNeeded() (in filepoolProvider) that completed after the context menu items were refreshed. The activity is not downloaded completely so the download menu item displays (correct, because there could be other pages with files that may need downloading). Even though the file exists the size menu item does not appear. This is because the file queued for download completed after the context menu was last updated with an onContentLoaded() (core/siteplugins/components/module-index/module-index.ts) which would have refreshed the context menu.

      So now if the user navigates back to the course, and then to the activity for a second time (alternatively just press the refresh menu icon), the menu now displays a downloaded file that could be deleted.

      Our user testing indicates that it would be nice if the context menu would just update itself (like it does on a refresh) as it gives users more confidence over the size of local file storage on their devices. (Yes we have video and image heavy plugins, and users with concerns over storage capacity on their mobiles).

      In the images attached we can see the core activity plugin shows the size menu item displayed. And the other image is what displays for a core activity plugin if the file is deleted. This is the same menu as for a plugin activity - the size menu item is missing - yet the file has been downloaded as is taking space in the database on the device.

        Attachments

        1. mobile.php
          2 kB
        2. mobile_view.mustache
          1 kB
        3. moodledemo-download-cleared.jpg
          moodledemo-download-cleared.jpg
          50 kB
        4. moodledemo-downloaded.jpg
          moodledemo-downloaded.jpg
          50 kB
        5. mobile-files-notes.txt
          2 kB
        6. output-mobile.php
          3 kB
        7. cat-ramiz-dedakovic-u4gwRbr2_j0-unsplash.jpg
          cat-ramiz-dedakovic-u4gwRbr2_j0-unsplash.jpg
          2.41 MB
        8. ouwiki.zip
          2.66 MB

          Activity

            People

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

              Dates

              • Created:
                Updated: