From 9ff5e44a93394ed686868de3f2e985ff1d89983a Mon Sep 17 00:00:00 2001 From: moodler Date: Tue, 8 Feb 2005 07:19:49 +0000 Subject: [PATCH] Added Blackboard restore using XSLT. Works with BB 5.5 and BB 6.0. Completely untested by me but it LOOKS like it should work. It's quite standalone, and is basically a single function call during the restore precheck which looks in the backup to see if it's a BB file, then converts it using XSLT. Apart from a little tidyup and renaming, I added a check so that it should just silently fail if XSLT functions aren't available Many thanks to Ziba Scott who wrote it! --- backup/bb/README.txt | 73 ++++ backup/bb/bb5.5_to_moodle.xsl | 737 ++++++++++++++++++++++++++++++++++ backup/bb/bb6_to_moodle.xsl | 690 +++++++++++++++++++++++++++++++ backup/bb/restore_bb.php | 81 ++++ backup/restore.php | 1 + backup/restorelib.php | 7 + 6 files changed, 1589 insertions(+) create mode 100644 backup/bb/README.txt create mode 100644 backup/bb/bb5.5_to_moodle.xsl create mode 100644 backup/bb/bb6_to_moodle.xsl create mode 100644 backup/bb/restore_bb.php diff --git a/backup/bb/README.txt b/backup/bb/README.txt new file mode 100644 index 0000000000..e19a3c9aa3 --- /dev/null +++ b/backup/bb/README.txt @@ -0,0 +1,73 @@ +Ziba Scott 11/19/04 + +This is a beta demonstration of a utility to convert Blackboard +Course export zip files into Moodle course export zip files. It +has been successfully tested with Blackboard 5.5 and +Moodle 1.4.1 and Moodle CVS. There is minimal Blackboard 6 support. +It will convert: + + * Course Name/Title + * Forum Topics + * Course Documents + * Assignments + * External Links + +The current status of this project is +exploration/proof-of-concept. We have successfully converted +basic Blackboard course information as well as course documents +and forum topics using the XSLT methods described above. + +AUTOMATED OPERATION: + + REQUIREMENTS FOR WEB INTERFACE: + *Moodle 1.4.1 or greater + *PHP compiled with --enable-xslt --with-xslt-sablot options + (Check php.net for instructions on enabling xslt for your platform) + + INSTALLATION: + *Unpack this file into the "backup" directory + + + +MANUAL OPERATION: + + REQUIREMENTS: + + *An XSLT 1.0 processor (like Sablotron) + *A zipping utility + + REQUIREMENTS FOR WEB INTERFACE: + + *Linux/Unix + *PHP compiled with --enable-xslt --with-xslt-sablot options. + *Apache with write access to /tmp + *A commandline zipping utility + + COMMAND LINE INSTRUCTIONS: + + 1) Download and uncompress the Blackboard export into a directory. + + 2) Copy bb2moodle.xslt into the Blackboard course directory. + + 3) Run your XSLT processor on imsmanifest.xml with bb2moodle.xslt + as the input and moodle.xml as the output. If you are using + Sablotron on linux, this command will look like this: + sabcmd bb2moodle.xslt imsmanifest.xml > moodle.xml + + 4) Create a moodle zip file with this structure: + moodle.xml + user_files/ + course_files/ + + 5) Copy every subdirectory and its contents from the Blackboard + export directory into the course_files directory. This does + not include the Blackboard XML files, only the course + documents. Your moodle zip file will now look similar to + this: + moodle.xml + user_files/ + course_files/res0009/myfile.doc + course_files/res0010/myotherfile.doc + course_files/res0010/mypicture.jpg + + 6) Upload and restore your moodle zip file diff --git a/backup/bb/bb5.5_to_moodle.xsl b/backup/bb/bb5.5_to_moodle.xsl new file mode 100644 index 0000000000..bf87485d8b --- /dev/null +++ b/backup/bb/bb5.5_to_moodle.xsl @@ -0,0 +1,737 @@ + + + + + + backup-from-blackboard.zip + 2004083100 + 1.4 + 2004083100 + 1.4 + 1094240862 + INSERT URL HERE +
+ + assignment + true + true + + + chat + true + true + + + choice + true + true + + + forum + true + true + + + glossary + true + true + + + journal + true + true + + + label + true + true + + + lesson + true + true + + + quiz + true + true + + + resource + true + true + + + scorm + true + true + + + survey + true + true + + + wiki + true + true + + + workshop + true + true + + course + false + true + true +
+
+ + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + true + + + + + + + + + + +
+
+ + +
+ 2 + + + + + + 4 + topics + 1 + participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity + 5 + Teacher + Teachers + Student + Students + 0 + 1094270400 + 0 + 10 + 2097152 + 0 + 0 + 0 + + + 0 + 1 + 0 + 1094240775 + 1094240775 + + + +
+
+ + + + +
+ 0 + 0 + <div style="text-align: center;"><font size="5" style="font-family: arial,helvetica,sans-serif;"></font></div> + + + 1 + + + 1 + + +
+
+ + + 1. + +
+ + + <span style="font-weight: bold;"></span> + 1 + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + 1. + 1. + + + + + + + + + + + + + + + + + + + + + + + + + + 1. + + 1. + + + + + + + + + + + label + + + + + + 0 + + resource + + + + + + + + + + + + + label + + + + + + + + + + resource + + + + + + + + + + label + + + + + + + resource + + + + + + + + + + + + + + 1. + 1. + + + + 10 + + + + + + + 1094240775 + 0 + 0 + + 1 + 0 + + + + + + + + 1. + + + + label + + + + + + + + <span style="font-style: italic;"> + + + + + :</span> + + + + + + 1094240775 + + + + + + 1. + + + resource + + + + + file + + + / + + + summary broken + + + + + frame + 1094240775 + + + + + + 1. + + + resource + + + + + + text + + + + + + + + + + + + + + 1094240775 + + + + + + 1. + + + resource + + + + file + + + + + <br/> + + + + + + + frame + 1094240775 + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + 1. + + + + + + + + + + + + + + 1. + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1. + + + forum + general + + + + + + + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + + + + 1 + 1094748430 + 1094748430 + 1 + + + 1 + + 0 + + + + + + + 0 + + + + + + + 1. + + 1 + + News forum + + news + 1 + 1094240775 + 0 + 0 + 0 + 1 + 0 + + + + + 1. + + + forum + news + News forum + General news and announcements + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + 1. + + + + + + + 1 + -1 + 1 + 1094748430 + 1 + + + + 0 + 1 + 1094748430 + 1094748430 + 1 + + + 1 + + 0 + + + + + + + + +
+ diff --git a/backup/bb/bb6_to_moodle.xsl b/backup/bb/bb6_to_moodle.xsl new file mode 100644 index 0000000000..1bbabb75da --- /dev/null +++ b/backup/bb/bb6_to_moodle.xsl @@ -0,0 +1,690 @@ + + + + + + backup-from-blackboard.zip + 2004083100 + 1.4 + 2004083100 + 1.4 + 1094240862 + INSERT URL HERE +
+ + assignment + true + true + + + chat + true + true + + + choice + true + true + + + forum + true + true + + + glossary + true + true + + + journal + true + true + + + label + true + true + + + lesson + true + true + + + quiz + true + true + + + resource + true + true + + + scorm + true + true + + + survey + true + true + + + wiki + true + true + + + workshop + true + true + + course + false + true + true +
+
+ + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + true + + + + + + +
+
+ + +
+ 2 + + + + + + 4 + topics + 1 + participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity + 5 + Teacher + Teachers + Student + Students + 0 + 1094270400 + 0 + 10 + 2097152 + 0 + 0 + 0 + + + 0 + 1 + 0 + 1094240775 + 1094240775 + + + +
+
+ + +
+ 0 + 0 + <div style="text-align: center;"><font size="5" style="font-family: arial,helvetica,sans-serif;"></font></div> + + + 1 + + +
+
+ + + 1. + +
+ + + <span style="font-weight: bold;"></span> + 1 + + + + + + + 0 + + + + + + + + + + + 0 + + + + + + +
+
+ + + 1. + 1. + + + + + + + + + + + + + + + + + + + + + + + + 1. + 1. + + + + + + + + + + + + + + + + + + 1. + + 1. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1. + 1. + + 10 + + + + + + + label + + 1094240775 + 0 + 0 + + 1 + 0 + + + + + + + 1. + 1. + + 0 + + + + + + + resource + + 1094240775 + 0 + 0 + + 1 + 0 + + + + + + + 1. + 1. + + 0 + + + + resource + + 1094240775 + 0 + 0 + + 1 + 0 + + + + + + + 1. + + + label + + + + + + + + <span style="font-style: italic;"> + + + + + :</span> + + + + + + + + 1094240775 + + + + + + 1. + + + + resource + + + + + + + file + / + + + + + + frame + 1094240775 + + + + + + 1. + + + resource + + + + + + + text + + + + + + + + + + + + + + + + 1094240775 + + + + + + 1. + + + resource + + + + file + + + + + <br/> + + + + + + + frame + 1094240775 + + + + + + 1. + + + + + + + + + + + + + + 1. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1. + + + forum + general + + + + + + + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + + + + 1 + 1094748430 + 1094748430 + 1 + + + 1 + + 0 + + + + + + + 0 + + + + +
+ + + + diff --git a/backup/bb/restore_bb.php b/backup/bb/restore_bb.php new file mode 100644 index 0000000000..238b8a6745 --- /dev/null +++ b/backup/bb/restore_bb.php @@ -0,0 +1,81 @@ + 10-25-04 + +function get_subdirs($directory){ + $opendirectory = opendir( $directory ); + while($filename = readdir($opendirectory)) { + if (is_dir($directory.$filename) and $filename != ".." and $filename != "."){ + $subdirs[] = $filename; + } + } + closedir($opendirectory); + return $subdirs; +} + + +function choose_bb_xsl($manifest){ + $f = fopen($manifest,"r"); + $buffer = fgets($f, 400); + $buffer = fgets($f, 400); + fclose($f); + if (strstr($buffer,"xmlns:bb=\"http://www.blackboard.com/content-packaging/\"")){ + return "bb6_to_moodle.xsl"; + } + return "bb5.5_to_moodle.xsl"; +} + + +function blackboard_convert($dir){ + global $CFG; + + if (!function_exists('xslt_create')) { // XSLT MUST be installed for this to work + return true; + } + + // Check for a Blackboard manifest file + if(is_file($dir."/imsmanifest.xml")){ + + //Select the proper XSL file + $xslt_file = choose_bb_xsl($dir."/imsmanifest.xml"); + + //TODO: Use the get_string function + echo "
  • Converting Blackboard export
  • "; + + // The XSL file must be in the same directory as the Blackboard files when it is processed + copy($CFG->dirroot."/backup/bb/$xslt_file", "$dir/$xslt_file"); + $startdir = getcwd(); + chdir($dir); + + + // Process the Blackboard XML files with the chosen XSL file. + // The imsmanifest contains all the XML files and their relationships. + // The XSL processor will open them as needed. + $xsltproc = xslt_create(); + if (!xslt_process($xsltproc, "imsmanifest.xml", $xslt_file, "$dir/moodle.xml")) { + dump("Failed writing xml file"); + chdir($startdir); + return false; + } + + + // Copy the Blackboard course files into the moodle course_files structure + $subdirs = get_subdirs($dir."/"); + mkdir("$dir/course_files"); + foreach ($subdirs as $subdir){ + rename($subdir, "course_files/$subdir"); + } + + chdir($startdir); + + // Blackboard export successfully converted + return true; + } + // This is not a Blackboard export + return true; + +} + +?> diff --git a/backup/restore.php b/backup/restore.php index 4bf37a62ca..5ec5769ec5 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -9,6 +9,7 @@ require_once ("../course/lib.php"); require_once ("lib.php"); require_once ("restorelib.php"); + require_once ("bb/restore_bb.php"); require_once("$CFG->libdir/blocklib.php"); //Optional diff --git a/backup/restorelib.php b/backup/restorelib.php index 801974ebdc..bad9eaa06c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -3525,6 +3525,13 @@ notify("Error unzipping backup file. Invalid zip file."); } } + + //Check for Blackboard backups and convert + if ($status){ + require_once("$CFG->dirroot/backup/bb/restore_bb.php"); + echo "
  • ".get_string("checkingforbbexport"); + $status = blackboard_convert($CFG->dataroot."/temp/backup/".$backup_unique_code); + } //Now check for the moodle.xml file if ($status) { -- 2.39.5