Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
Column
width65%

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).

Implementation

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

Starting from ATutor 1.6.2, the Fluid package is saved under /jscripts/fluid-components/ in the ATutor installation directory (In previous releases, only files from /fluid-components/js/ were saved directly under /jscripts/).

The Fluid scripts get loaded and initialized in the header (/tools/filemanager/index.php) before being displayed (/include/html/filemanager_display.inc.php).http://wiki.fluidproject.org/display/fluid/Uploader+API

For a more detailed reference of settings that can be configured for the Uploader, please refer to the Uploader API Wiki.

The Uploader script also needs to call a file handler (/include/lib/upload.php) which handles files as necessary after they have been uploaded.  This file handler 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:

Code Block
$save_path = urldecode($_GET['path']);

Interface

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.

This toggle feature is a simple Javascript function defined in /include/html/filemanager.inc.php that gets called through the "onclick" attribute of the "Uploade Files" and "Cancel" button.

Code Block
function toggleform(id, link) {
    var obj = document.getElementById(id);
    var btn = document.getElementById(link);

    if (obj.style.display == "none") {
        //show object
        obj.style.display='';   
        obj.focus();
        //hide button
        btn.style.display = 'none';
    } else {
        //hide object
        obj.style.display='none';
        //show button
        btn.style.display = '';
    }
}


For more information on the Uploader interface itself, please refer to the Uploader Wireframes Wiki.

Flash Detection

The current Uploader of the Fluid Package (v0.4beta1) partly relies on Flash for its interface.  This poses a problem for an ATutor user who may not have Flash installed.  Therefore, it is necessary to provide an alternative method for uploading files when Flash cannot be detected from the user's browser.  The current implementation in ATutor does so by providing a simple single-file uploader.

Note that the Flash detection handler will most likely be improved at a later time.  For now, the Flash detection takes place outside of the Fluid scripts (in /include/vitals.inc.php).  If a later version of the Fluid Package implements its own Flash detector and non-Flash script, the current implementation can be easily removed.

Code Block
if(isset($_COOKIE["flash"])) {
    $_SESSION['flash'] = $_COOKIE["flash"];

    //delete the cookie
    setcookie("flash",'',time()-3600);
}

if (!isset($_SESSION["flash"])) {
    $_custom_head .= '
        <script type="text/javascript">
        <!--
            //VB-Script for InternetExplorer
            function iExploreCheck()
            {
                document.writeln("<scr" + "ipt language=\'VBscript\'>");
                //document.writeln("\'Test to see if VBScripting works");
                document.writeln("detectableWithVB = False");
                document.writeln("If ScriptEngineMajorVersion >= 2 then");
                document.writeln("   detectableWithVB = True");
                document.writeln("End If");
                //document.writeln("\'This will check for the plugin");
                document.writeln("Function detectActiveXControl(activeXControlName)");
                document.writeln("   on error resume next");
                document.writeln("   detectActiveXControl = False");
                document.writeln("   If detectableWithVB Then");
                document.writeln("      detectActiveXControl = IsObject(CreateObject(activeXControlName))");
                document.writeln("   End If");
                document.writeln("End Function");
                document.writeln("</scr" + "ipt>");
                return detectActiveXControl("ShockwaveFlash.ShockwaveFlash.1");
            }

            var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ?
                               navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;
            if(!(plugin) && (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
                            && (navigator.appVersion.indexOf("Win") != -1))) {
                if (iExploreCheck()) {
                    flash_detect = "flash=yes";
                } else {
                    flash_detect = "flash=no";
                }
            } else if(plugin) {
                flash_detect = "flash=yes";
            } else {
                flash_detect = "flash=no";
            }

            writeCookie(flash_detect);

            function writeCookie(value)
            {
                var today = new Date();
                var the_date = new Date("December 31, 2099");
                var the_cookie_date = the_date.toGMTString();
                var the_cookie = value + ";expires=" + the_cookie_date;
                document.cookie = the_cookie;
            }
        //-->
        </script>
';
}

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["flash"]) then sent to the server to be saved as a session variable ($_SESSION['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 variable.

Code Block
if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {
    /*
           Display Fluid Uploader
     */
} else {
    /*
           Display non-Flash single file uploader
     */
}

Demo

A working demo of the current Fluid Uploader integrated into ATutor is available at:

http://www.atutor.ca/atutor/fluidtest/
login: fluid
password: fluid

Column
width35%
Panel
borderColor#566b30
bgColor#fff
titleBGColor#D3E3C4
titleOn this Page
borderStylesolid
Table of Contents
minlevel2

Screenshots

...