Calling all Regular Expression experts!
Apologies for this rather lengthy post, but if you can solve the following issue with some elegant regular expression code, you just might make a lot of current and future Moodle/IIS/SCORM users very happy. Read on if you dare...
First I'll lay out the background to this issue (apologies to those that already know it), then I'll explain what I think we need to provide as a solution to finally get SCORM packages working reliably on IIS.
HISTORY: For years now, we have been seeing numerous posts in the SCORM forum (and other forums) from baffled Moodle users trying to get this wonderful LMS to work seamlessly with the IIS web server. The complaints usually center around page not found (404) errors on combinations of files uploaded to Moodle that work perfectly anywhere else. Often those offering assistance comment that they have no issues playing the same content on their Moodle site running Apache server.
Now we all know Moodle can work well on IIS, and it will play of almost any type. BUT, sadly it can tend to fail when you upload course files into your moodledata folder...IF...those files require other linked files in order to play. So for example, if you have an HTM file in your course that needs a linked Javascript or SWF file to play course content,...THEN...you will likely encounter issues with IIS....specifically page not found or 404 errors. The files.php page digs out the requested HTM file, but then the browser goes looking for the other linked files in the same folder as files.php, not in the moodledata folder where the original HTM file resides!
The issue is due to the way that some pages in Moodle pass information about the URL address of another page by tacking this information on the end of a URL. (E.g. mypage.php?nextpage=/folder1/subfolder1/otherpage.php) Though a common enough technique in web development, this can prove problematic, especially for IIS. SCORM packages seem to be most affected by this issue because they often involve a complex cascade of pages calling other pages, passing arguments in links to play the content and communicate with the SCORM API on the LMS, etc, etc. Their complexity is their downfall in this case.
On Apache server, the issue often goes away as soon as you play with the Admin > Server > HTTP > Use Slash Arguments setting. But IIS 6 is unable to use slash arguments because Microsoft disabled this 'feature' as it was a well-known security hole exploited by hackers. (IIS 7 is rumoured to have options that allow it to operate safely again.)
About ISAPI Rewrite: The workaround successfully used by some Moodle-IIS users in various forum posts to fix IIS has been to install a small application called ISAPI Rewrite that intercepts the call to URLs on IIS and dynamically rewrites them into a more palatable format. This app is well known to webserver admins and used to implement redirects and/or improve search engine friendliness of websites. Once ISAPI Rewrite is installed on your webserver, you just create a new Web Service Extension in IIS Manager, point it to the ISAPI_Rewrite.dll, make a copy of the httpd.ini file from the C:\Program Files\Helicon\ISAPI_Rewrite and copy it into your Moodle root directory (so that any code there only affects Moodle), and finally add a rewrite rule. The rewrite rule quoted in many Moodle forum posts as pulling off the fix is a line of code (a regular expression) that looks like this:
RewriteRule (.*?\.php)(\/.+) $1\?file=$2 [N,I]
This normally works and cures the slash arguments issue on IIS,...if your content only involves a single HTM file calling other files (e.g. an HTM linking out to images, javascript, or SWF files). Happy days...almost.
However, it doesn't seem to work for most SCORM packages, and I believe the reason is that SCORMs involve much more complex interactions and argument passing between pages that this little rewrite rule doesn't allow for. Under SCORM, the rewrite rule can encounter not just one set of arguments but several.
I'm currently using Moodle 1.82 on IIS 6.0 and ISAPI Rewrite with the rule shown above. I can get any type of content to play,...except SCORM. Perusing IIS server logs I've found that the URL which is failing on my box looks like this:
http://myMoodleServer/file.php?file=/2/Lesson_1/Lesson_1.swf?SCORM_API=0.2&SCORM_TYPE=0
Notice that there are not one but two question marks in this URL? I think this is why IIS is falling over and if we could tweak the rewrite rule to allow for this, we might just be able to get SCORMs (at least those created by Captivate) to play on IIS. We may even need multiple rules customised to a given SCORM implementation to get them working.
Now since I don't know how to write regular expressions...is there anyone out there that can oblige?? If so, and we can put this issue to bed, we may have eliminated a major source of frustration for many Moodle users.
Suggestions please...?