by Boon-Hau Teh (boonhau at gmail dot com)
July 25, 2008
Fluid's Uploader can be integrated into a learning content management system, such as ATutor. Files are uploaded for several purposes such as uploading images for teaching material, student-submitted assignments, and audio tutorial files. The integration of Fluid's Uploader improves the user experience by allowing for multiple file uploads along with the progress bar and pause/resume features. ATutor aims to integrate Fluid's Uploader into its File Manager and have it ready for its next release (ATutor 1.6.2).
Fluid's Uploader script is called by the File Manager which is used in several places in ATutor, such as:
(logged in to an instructor account)
- Manage -> File Manager
- Content Editor -> File Manager
- Manage -> Tests -> Edit -> File Manager
Starting from ATutor 1.6.2, the entire source code of the Fluid Package is installed under /jscripts/fluid-components in the ATutor installation directory. In previous releases, only files from /fluid-components/js of the Fluid Package were installed directly in /jscripts and did not include folders such as /css and /swfupload.
When using the Fluid scripts, they need to be loaded and initialized in the header of a page. This is done by saving the necessary tags to the $_custom_head variable (in /tools/filemanager/index.php), which gets passed to /tools/filemanager/top.php to be written from the appropriate header include file. Most of the HTML code being used is borrowed from the sample-code provided by the Fluid Package in /sample-code/uploader/inline/uploader.html with changes made to paths and settings.
The Uploader calls a Flash script (swfupload_f9.swf), which handles most of the functionality. The URL to the swf file is specified by "flashURL".
Whenever a file gets uploaded, the swfupload_f9.swf calls a file handler (/include/lib/upload.php) which saves the file to its proper location. Therefore, the URL of the file handler (specified by "uploadURL") must be relative to swfupload_f9.swf
The code for the file handler itself is borrowed from the sample code provided in the Fluid Package (/sample-code/uploader.php) with a few alterations, namely the save path of the uploaded files:
The remaining settings for the Uploader can be configured through the "settings" variable. In the current implementation, the Uploader is configured to automatically reload the page (specified by "whenDone") when all the files are done uploading (specified by "continueAfterUpload"). Functionality for the "Cancel" button (specified by "whenCancel") is disabled so that it can be used by a toggle function in ATutor's File Manager (refer to Display section below).
For a more detailed reference of settings that can be configured for the Uploader, please refer to the Uploader API page.
After initializing the Fluid scripts, the Uploader gets displayed through /include/html/filemanager_display.inc.php. Most of the HTML code being used is borrowed from the sample-code provided by the Fluid Package in /sample-code/uploader/inline/uploader.html
Upon opening the File Manager, the Uploader itself is initially hidden in order to save space and keep the page simple. When needed, the user can click on the "Upload Files" button to display Fluid's Uploader interface.
From the Uploader, the "Cancel" button can be clicked to hide the interface and toggle back to the original view of the File Manager.
For information on the Uploader interface itself, please refer to the Uploader Wireframes Wiki.
Note that the current Flash detection handler will most likely be improved at a later time. If a later version of the Fluid Package implements its own Flash detector and non-Flash script, the current handler in ATutor can be easily removed. For now, the Flash detection takes place outside of the Fluid scripts in /include/vitals.inc.php
In the current implementation, a Flash detection script gets inserted into the header when a user initially accesses any page on ATutor. The script returns a value of "yes" or "no", which gets saved in a cookie ($_COOKIE[fluid:"flash"]) then sent to the server to be saved as a session variable ($_SESSION[fluid:'flash']). Once the session variable is set, the cookie is removed and the Flash detection script no longer gets called for the remainder of the session. When accessing the filemanager, the php script (/include/html/filemanager_display.inc.php) generates the appropriate uploader depending on the value of the session variable.
Developer's To Do List
- Improving Flash detection
- Internationalizing text in the Fluid Uploader, as the current ATutor is used in different languages
- Update File Manager list of files as new files get uploaded on the fly (may require Ajax)
- Save as a personal setting for choosing to display the Fluid Uploader or the simple single-file uploader (similar to how preferences are saved in ATutor for switching between the visual and text editor)
- Make the Fluid Uploader available for the File Storage section (this requires being able to input descriptions that associate with the files being uploaded)
A working demo of the current Fluid Uploader integrated into ATutor is available at: