MDL-22153 backup: delete old, unused, 1.9 files

This commit is contained in:
Eloy Lafuente (stronk7) 2013-04-07 13:05:07 +02:00
parent 422f68fb86
commit c1782ec626
12 changed files with 5 additions and 3266 deletions

View File

@ -1,426 +0,0 @@
<?php
//Prints course's messages info (tables message, message_read and message_contacts)
function backup_messages ($bf,$preferences) {
global $CFG, $DB;
$status = true;
/// Check we have something to backup
$unreads = $DB->count_records ('message');
$reads = $DB->count_records ('message_read');
$contacts= $DB->count_records ('message_contacts');
if ($unreads || $reads || $contacts) {
$counter = 0;
/// message open tag
fwrite ($bf,start_tag("MESSAGES",2,true));
if ($unreads) {
$rs_unreads = $DB->get_recordset('message');
/// Iterate over every unread
foreach ($rs_unreads as $unread) {
/// start message
fwrite($bf, start_tag("MESSAGE",3,true));
fwrite ($bf,full_tag("ID",4,false,$unread->id));
fwrite ($bf,full_tag("STATUS",4,false,"UNREAD"));
fwrite ($bf,full_tag("USERIDFROM",4,false,$unread->useridfrom));
fwrite ($bf,full_tag("USERIDTO",4,false,$unread->useridto));
fwrite ($bf,full_tag("MESSAGE",4,false,$unread->message));
fwrite ($bf,full_tag("FORMAT",4,false,$unread->format));
fwrite ($bf,full_tag("TIMECREATED",4,false,$unread->timecreated));
fwrite ($bf,full_tag("MESSAGETYPE",4,false,$unread->messagetype));
/// end message
fwrite ($bf,end_tag("MESSAGE",3,true));
/// Do some output
$counter++;
if ($counter % 20 == 0) {
echo ".";
if ($counter % 400 == 0) {
echo "<br />";
}
backup_flush(300);
}
}
$rs_unreads->close();
}
if ($reads) {
$rs_reads = $DB->get_recordset('message_read');
/// Iterate over every unread
foreach ($rs_reads as $read) {
/// start message
fwrite($bf, start_tag("MESSAGE",3,true));
fwrite ($bf,full_tag("ID",4,false,$read->id));
fwrite ($bf,full_tag("STATUS",4,false,"READ"));
fwrite ($bf,full_tag("USERIDFROM",4,false,$read->useridfrom));
fwrite ($bf,full_tag("USERIDTO",4,false,$read->useridto));
fwrite ($bf,full_tag("MESSAGE",4,false,$read->message));
fwrite ($bf,full_tag("FORMAT",4,false,$read->format));
fwrite ($bf,full_tag("TIMECREATED",4,false,$read->timecreated));
fwrite ($bf,full_tag("MESSAGETYPE",4,false,$read->messagetype));
fwrite ($bf,full_tag("TIMEREAD",4,false,$read->timeread));
fwrite ($bf,full_tag("MAILED",4,false,$read->mailed));
/// end message
fwrite ($bf,end_tag("MESSAGE",3,true));
/// Do some output
$counter++;
if ($counter % 20 == 0) {
echo ".";
if ($counter % 400 == 0) {
echo "<br />";
}
backup_flush(300);
}
}
$rs_reads->close();
}
if ($contacts) {
fwrite($bf, start_tag("CONTACTS",3,true));
$rs_contacts = $DB->get_recordset('message_contacts');
/// Iterate over every contact
foreach ($rs_contacts as $contact) {
/// start contact
fwrite($bf, start_tag("CONTACT",4,true));
fwrite ($bf,full_tag("ID",5,false,$contact->id));
fwrite ($bf,full_tag("USERID",5,false,$contact->userid));
fwrite ($bf,full_tag("CONTACTID",5,false,$contact->contactid));
fwrite ($bf,full_tag("BLOCKED",5,false,$contact->blocked));
/// end contact
fwrite ($bf,end_tag("CONTACT",4,true));
/// Do some output
$counter++;
if ($counter % 20 == 0) {
echo ".";
if ($counter % 400 == 0) {
echo "<br />";
}
backup_flush(300);
}
}
$rs_contacts->close();
fwrite($bf, end_tag("CONTACTS",3,true));
}
/// messages close tag
$status = fwrite ($bf,end_tag("MESSAGES",2,true));
}
return $status;
}
//Print blogs info (post table, module=blog, course=0)
function backup_blogs($bf, $preferences) {
global $CFG, $DB;
$status = true;
/// Check we have something to backup
$siteblogs = $DB->count_records('post', array('module'=>'blog', 'courseid'=>0));
if ($siteblogs) {
$counter = 0;
/// blogs open tag
fwrite ($bf, start_tag("BLOGS",2,true));
if ($siteblogs) {
$rs_blogs = $DB->get_records('post', array('module'=>'blog', 'courseid'=>0));
/// Iterate over every blog
foreach ($rs_blogs as $blog) {
backup_blog($bf, $blog->id, 3);
/// Do some output
$counter++;
if ($counter % 20 == 0) {
echo ".";
if ($counter % 400 == 0) {
echo "<br />";
}
backup_flush(300);
}
}
$rs_blogs-close();
}
/// blogs close tag
$status = fwrite($bf, end_tag("BLOGS",2,true));
}
return $status;
}
function backup_blog($bf, $blogid, $level) {
global $DB;
$blog = $DB->get_record('post', array('module'=>'blog', 'id'=>$blogid));
/// start blog
fwrite($bf, start_tag("BLOG",$level,true));
/// blog body
fwrite ($bf,full_tag("ID",$level+1,false,$blog->id));
fwrite ($bf,full_tag("MODULE",$level+1,false,$blog->module));
fwrite ($bf,full_tag("USERID",$level+1,false,$blog->userid));
fwrite ($bf,full_tag("COURSEID",$level+1,false,$blog->courseid));
fwrite ($bf,full_tag("GROUPID",$level+1,false,$blog->groupid));
fwrite ($bf,full_tag("MODULEID",$level+1,false,$blog->moduleid));
fwrite ($bf,full_tag("COURSEMODULEID",$level+1,false,$blog->coursemoduleid));
fwrite ($bf,full_tag("SUBJECT",$level+1,false,$blog->subject));
fwrite ($bf,full_tag("SUMMARY",$level+1,false,$blog->summary));
fwrite ($bf,full_tag("CONTENT",$level+1,false,$blog->content));
fwrite ($bf,full_tag("UNIQUEHASH",$level+1,false,$blog->uniquehash));
fwrite ($bf,full_tag("RATING",$level+1,false,$blog->rating));
fwrite ($bf,full_tag("FORMAT",$level+1,false,$blog->format));
fwrite ($bf,full_tag("ATTACHMENT",$level+1,false,$blog->attachment));
fwrite ($bf,full_tag("PUBLISHSTATE",$level+1,false,$blog->publishstate));
fwrite ($bf,full_tag("LASTMODIFIED",$level+1,false,$blog->lastmodified));
fwrite ($bf,full_tag("CREATED",$level+1,false,$blog->created));
fwrite ($bf,full_tag("USERMODIFIED",$level+1,false,$blog->usermodified));
/// Blog tags
/// Check if we have blog tags to backup
if (!empty($CFG->usetags)) {
if ($tags = tag_get_tags('post', $blog->id)) { //This return them ordered by default
/// Start BLOG_TAGS tag
fwrite ($bf,start_tag("BLOG_TAGS",$level+1,true));
/// Write blog tags fields
foreach ($tags as $tag) {
fwrite ($bf,start_tag("BLOG_TAG",$level+2,true));
fwrite ($bf,full_tag("NAME",$level+3,false,$tag->name));
fwrite ($bf,full_tag("RAWNAME",$level+3,false,$tag->rawname));
fwrite ($bf,end_tag("BLOG_TAG",$level+2,true));
}
/// End BLOG_TAGS tag
fwrite ($bf,end_tag("BLOG_TAGS",$level+1,true));
}
}
/// end blog
fwrite($bf, end_tag("BLOG",$level,true));
}
//Prints course's format data (any data the format might want to save).
function backup_format_data ($bf,$preferences) {
global $CFG, $DB;
// Check course format
if(!($format = $DB->get_field('course','format', array('id'=>$preferences->backup_course)))) {
return false;
}
// Write appropriate tag. Note that we always put this tag there even if
// blank, it makes parsing easier
fwrite ($bf,start_tag("FORMATDATA",2,true));
$file=$CFG->dirroot."/course/format/$format/backuplib.php";
if(file_exists($file)) {
// If the file is there, the function must be or it's an error.
require_once($file);
$function=$format.'_backup_format_data';
if(!function_exists($function)) {
return false;
}
if(!$function($bf,$preferences)) {
return false;
}
}
// This last return just checks the file writing has been ok (ish)
return fwrite ($bf,end_tag("FORMATDATA",2,true));
}
function backup_gradebook_categories_history_info($bf, $preferences) {
global $CFG, $DB;
$status = true;
// find all grade categories history
if ($chs = $DB->get_records('grade_categories_history', array('courseid'=>$preferences->backup_course))) {
fwrite ($bf,start_tag("GRADE_CATEGORIES_HISTORIES",3,true));
foreach ($chs as $ch) {
fwrite ($bf,start_tag("GRADE_CATEGORIES_HISTORY",4,true));
fwrite ($bf,full_tag("ID",5,false,$ch->id));
fwrite ($bf,full_tag("ACTION",5,false,$ch->action));
fwrite ($bf,full_tag("OLDID",5,false,$ch->oldid));
fwrite ($bf,full_tag("SOURCE",5,false,$ch->source));
fwrite ($bf,full_tag("TIMEMODIFIED",5,false,$ch->timemodified));
fwrite ($bf,full_tag("LOGGEDUSER",5,false,$ch->loggeduser));
fwrite ($bf,full_tag("PARENT",5,false,$ch->parent));
fwrite ($bf,full_tag("DEPTH",5,false,$ch->depth));
fwrite ($bf,full_tag("PATH",5,false,$ch->path));
fwrite ($bf,full_tag("FULLNAME",5,false,$ch->fullname));
fwrite ($bf,full_tag("AGGRETGATION",5,false,$ch->aggregation));
fwrite ($bf,full_tag("KEEPHIGH",5,false,$ch->keephigh));
fwrite ($bf,full_tag("DROPLOW",5,false,$ch->droplow));
fwrite ($bf,full_tag("AGGREGATEONLYGRADED",5,false,$ch->aggregateonlygraded));
fwrite ($bf,full_tag("AGGREGATEOUTCOMES",5,false,$ch->aggregateoutcomes));
fwrite ($bf,full_tag("AGGREGATESUBCATS",5,false,$ch->aggregatesubcats));
fwrite ($bf,end_tag("GRADE_CATEGORIES_HISTORY",4,true));
}
$status = fwrite ($bf,end_tag("GRADE_CATEGORIES_HISTORIES",3,true));
}
return $status;
}
function backup_gradebook_grades_history_info($bf, $preferences) {
global $CFG, $DB;
$status = true;
// find all grade categories history
if ($chs = $DB->get_records_sql("SELECT ggh.*
FROM {grade_grades_history} ggh
JOIN {grade_item} gi ON gi.id = ggh.itemid
WHERE gi.courseid = ?", array($preferences->backup_course))) {
fwrite ($bf,start_tag("GRADE_GRADES_HISTORIES",3,true));
foreach ($chs as $ch) {
/// Grades are only sent to backup if the user is one target user
if (backup_getid($preferences->backup_unique_code, 'user', $ch->userid)) {
fwrite ($bf,start_tag("GRADE_GRADES_HISTORY",4,true));
fwrite ($bf,full_tag("ID",5,false,$ch->id));
fwrite ($bf,full_tag("ACTION",5,false,$ch->action));
fwrite ($bf,full_tag("OLDID",5,false,$ch->oldid));
fwrite ($bf,full_tag("SOURCE",5,false,$ch->source));
fwrite ($bf,full_tag("TIMEMODIFIED",5,false,$ch->timemodified));
fwrite ($bf,full_tag("LOGGEDUSER",5,false,$ch->loggeduser));
fwrite ($bf,full_tag("ITEMID",5,false,$ch->itemid));
fwrite ($bf,full_tag("USERID",5,false,$ch->userid));
fwrite ($bf,full_tag("RAWGRADE",5,false,$ch->rawgrade));
fwrite ($bf,full_tag("RAWGRADEMAX",5,false,$ch->rawgrademax));
fwrite ($bf,full_tag("RAWGRADEMIN",5,false,$ch->rawgrademin));
fwrite ($bf,full_tag("RAWSCALEID",5,false,$ch->rawscaleid));
fwrite ($bf,full_tag("USERMODIFIED",5,false,$ch->usermodified));
fwrite ($bf,full_tag("FINALGRADE",5,false,$ch->finalgrade));
fwrite ($bf,full_tag("HIDDEN",5,false,$ch->hidden));
fwrite ($bf,full_tag("LOCKED",5,false,$ch->locked));
fwrite ($bf,full_tag("LOCKTIME",5,false,$ch->locktime));
fwrite ($bf,full_tag("EXPORTED",5,false,$ch->exported));
fwrite ($bf,full_tag("OVERRIDDEN",5,false,$ch->overridden));
fwrite ($bf,full_tag("EXCLUDED",5,false,$ch->excluded));
fwrite ($bf,full_tag("FEEDBACK",5,false,$ch->feedback));
fwrite ($bf,full_tag("FEEDBACKFORMAT",5,false,$ch->feedbackformat));
fwrite ($bf,full_tag("INFORMATION",5,false,$ch->information));
fwrite ($bf,full_tag("INFORMATIONFORMAT",5,false,$ch->informationformat));
fwrite ($bf,end_tag("GRADE_GRADES_HISTORY",4,true));
}
}
$status = fwrite ($bf,end_tag("GRADE_GRADES_HISTORIES",3,true));
}
return $status;
}
function backup_gradebook_items_history_info($bf, $preferences) {
global $CFG, $DB;
$status = true;
// find all grade categories history
if ($chs = $DB->get_records('grade_items_history', array('courseid'=>$preferences->backup_course))) {
fwrite ($bf,start_tag("GRADE_ITEM_HISTORIES",3,true));
foreach ($chs as $ch) {
fwrite ($bf,start_tag("GRADE_ITEM_HISTORY",4,true));
fwrite ($bf,full_tag("ID",5,false,$ch->id));
fwrite ($bf,full_tag("ACTION",5,false,$ch->action));
fwrite ($bf,full_tag("OLDID",5,false,$ch->oldid));
fwrite ($bf,full_tag("SOURCE",5,false,$ch->source));
fwrite ($bf,full_tag("TIMEMODIFIED",5,false,$ch->timemodified));
fwrite ($bf,full_tag("LOGGEDUSER",5,false,$ch->loggeduser));
fwrite ($bf,full_tag("CATEGORYID",5,false,$ch->categoryid));
fwrite ($bf,full_tag("ITEMNAME",5,false,$ch->itemname));
fwrite ($bf,full_tag("ITEMTYPE",5,false,$ch->itemtype));
fwrite ($bf,full_tag("ITEMMODULE",5,false,$ch->itemmodule));
fwrite ($bf,full_tag("ITEMINSTANCE",5,false,$ch->iteminstance));
fwrite ($bf,full_tag("ITEMNUMBER",5,false,$ch->itemnumber));
fwrite ($bf,full_tag("ITEMINFO",5,false,$ch->iteminfo));
fwrite ($bf,full_tag("IDNUMBER",5,false,$ch->idnumber));
fwrite ($bf,full_tag("CALCULATION",5,false,$ch->calculation));
fwrite ($bf,full_tag("GRADETYPE",5,false,$ch->gradetype));
fwrite ($bf,full_tag("GRADEMAX",5,false,$ch->grademax));
fwrite ($bf,full_tag("GRADEMIN",5,false,$ch->grademin));
fwrite ($bf,full_tag("SCALEID",5,false,$ch->scaleid));
fwrite ($bf,full_tag("OUTCOMEID",5,false,$ch->outcomeid));
fwrite ($bf,full_tag("GRADEPASS",5,false,$ch->gradepass));
fwrite ($bf,full_tag("MULTFACTOR",5,false,$ch->multfactor));
fwrite ($bf,full_tag("PLUSFACTOR",5,false,$ch->plusfactor));
fwrite ($bf,full_tag("AGGREGATIONCOEF",5,false,$ch->aggregationcoef));
fwrite ($bf,full_tag("SORTORDER",5,false,$ch->sortorder));
//fwrite ($bf,full_tag("DISPLAY",7,false,$ch->display));
//fwrite ($bf,full_tag("DECIMALS",7,false,$ch->decimals));
fwrite ($bf,full_tag("HIDDEN",5,false,$ch->hidden));
fwrite ($bf,full_tag("LOCKED",5,false,$ch->locked));
fwrite ($bf,full_tag("LOCKTIME",5,false,$ch->locktime));
fwrite ($bf,full_tag("NEEDSUPDATE",5,false,$ch->needsupdate));
fwrite ($bf,end_tag("GRADE_ITEM_HISTORY",4,true));
}
$status = fwrite ($bf,end_tag("GRADE_ITEM_HISTORIES",3,true));
}
return $status;
}
function backup_gradebook_outcomes_history($bf, $preferences) {
global $CFG, $DB;
$status = true;
// find all grade categories history
if ($chs = $DB->get_records('grade_outcomes_history', array('courseid'=>$preferences->backup_course))) {
fwrite ($bf,start_tag("GRADE_OUTCOME_HISTORIES",3,true));
foreach ($chs as $ch) {
fwrite ($bf,start_tag("GRADE_OUTCOME_HISTORY",4,true));
fwrite ($bf,full_tag("ID",5,false,$ch->id));
fwrite ($bf,full_tag("OLDID",5,false,$ch->oldid));
fwrite ($bf,full_tag("ACTION",5,false,$ch->action));
fwrite ($bf,full_tag("SOURCE",5,false,$ch->source));
fwrite ($bf,full_tag("TIMEMODIFIED",5,false,$ch->timemodified));
fwrite ($bf,full_tag("LOGGEDUSER",5,false,$ch->loggeduser));
fwrite ($bf,full_tag("SHORTNAME",5,false,$ch->shortname));
fwrite ($bf,full_tag("FULLNAME",5,false,$ch->fullname));
fwrite ($bf,full_tag("SCALEID",5,false,$ch->scaleid));
fwrite ($bf,full_tag("DESCRIPTION",5,false,$ch->description));
fwrite ($bf,end_tag("GRADE_OUTCOME_HISTORY",4,true));
}
$status = fwrite ($bf,end_tag("GRADE_OUTCOME_HISTORIES",3,true));
}
return $status;
}
//Backup events info (course events)
function backup_events_info($bf,$preferences) {
global $CFG, $DB;
$status = true;
//Counter, points to current record
$counter = 0;
//Get events (course events)
$events = $DB->get_records("event", array("courseid"=>$preferences->backup_course, 'instance'=>0),"id");
//Pring events header
if ($events) {
//Pring events header
fwrite ($bf,start_tag("EVENTS",2,true));
//Iterate
foreach ($events as $event) {
//Begin event tag
fwrite ($bf,start_tag("EVENT",3,true));
//Output event tag
fwrite ($bf,full_tag("ID",4,false,$event->id));
fwrite ($bf,full_tag("NAME",4,false,$event->name));
fwrite ($bf,full_tag("DESCRIPTION",4,false,$event->description));
fwrite ($bf,full_tag("FORMAT",4,false,$event->format));
fwrite ($bf,full_tag("GROUPID",4,false,$event->groupid));
fwrite ($bf,full_tag("USERID",4,false,$event->userid));
fwrite ($bf,full_tag("REPEATID",4,false,$event->repeatid));
fwrite ($bf,full_tag("EVENTTYPE",4,false,$event->eventtype));
fwrite ($bf,full_tag("MODULENAME",4,false,$event->modulename));
fwrite ($bf,full_tag("TIMESTART",4,false,$event->timestart));
fwrite ($bf,full_tag("TIMEDURATION",4,false,$event->timeduration));
fwrite ($bf,full_tag("VISIBLE",4,false,$event->visible));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$event->timemodified));
//End event tag
fwrite ($bf,end_tag("EVENT",3,true));
}
//End events tag
$status = fwrite ($bf,end_tag("EVENTS",2,true));
}
return $status;
}

View File

@ -1,70 +0,0 @@
Ziba Scott <ziba@linuxbox.com> 06/23/05
This is 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
AUTOMATED OPERATION:
REQUIREMENTS FOR WEB INTERFACE:
*Moodle 1.4.1 or greater
*PHP 4.3 compiled with --enable-xslt --with-xslt-sablot options
(Check php.net for instructions on enabling xslt for your platform)
*Alternatively, PHP 5 compiled with xml and xsl support (-with-xsl)
INSTALLATION:
*Unpack this file into the "backup" directory
MANUAL OPERATION:
REQUIREMENTS:
*An XSLT 1.0 processor (like Sablotron)
*A zipping utility
REQUIREMENTS FOR COMMAND LINE INTERFACE:
*Linux/Unix
*PHP 4 compiled with --enable-xslt --with-xslt-sablot options.
*PHP 5 compiled with -with-xsl and the default xml support left in.
*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

View File

@ -1,804 +0,0 @@
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:template match="/">
<MOODLE_BACKUP>
<INFO>
<NAME>backup-from-blackboard.zip</NAME>
<MOODLE_VERSION>2004083100</MOODLE_VERSION>
<MOODLE_RELEASE>1.4</MOODLE_RELEASE>
<BACKUP_VERSION>2004083100</BACKUP_VERSION>
<BACKUP_RELEASE>1.4</BACKUP_RELEASE>
<DATE>1094240862</DATE>
<ORIGINAL_WWWROOT>INSERT URL HERE</ORIGINAL_WWWROOT>
<DETAILS>
<MOD>
<NAME>assignment</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>chat</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>choice</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>forum</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>glossary</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>journal</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>label</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>lesson</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>quiz</NAME>
<INCLUDED>false</INCLUDED>
<USERINFO>false</USERINFO>
</MOD>
<MOD>
<NAME>resource</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>scorm</NAME>
<INCLUDED>false</INCLUDED>
<USERINFO>false</USERINFO>
</MOD>
<MOD>
<NAME>survey</NAME>
<INCLUDED>false</INCLUDED>
<USERINFO>false</USERINFO>
</MOD>
<MOD>
<NAME>wiki</NAME>
<INCLUDED>false</INCLUDED>
<USERINFO>false</USERINFO>
</MOD>
<MOD>
<NAME>workshop</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<USERS>course</USERS>
<LOGS>false</LOGS>
<USERFILES>false</USERFILES>
<COURSEFILES>true</COURSEFILES>
</DETAILS>
</INFO>
<COURSE>
<!-- Get course specific information -->
<xsl:apply-templates select="document('res00001.dat')//COURSE"/>
<SECTIONS>
<!-- Create a title section -->
<xsl:for-each select="document('res00001.dat')" >
<xsl:call-template name="title_section" />
</xsl:for-each>
<!-- Create a topic for each top level Bb item and add section modules ONE folder deep -->
<xsl:for-each select="manifest/organizations/tableofcontents/item">
<xsl:variable name="section_number" select="position()"/>
<xsl:call-template name="sections">
<xsl:with-param name="section_number" select="$section_number"/>
<xsl:with-param name="recurse" >false</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<!-- Create a topic for each second level Bb item which is a folder, recursively make section modules -->
<xsl:for-each select="manifest/organizations/tableofcontents/item/item">
<xsl:sort order="descending" select="document(concat(@identifierref,'.dat'))/CONTENT/FLAGS/ISFOLDER/@value"/>
<xsl:if test="document(concat(@identifierref,'.dat'))/CONTENT/FLAGS/ISFOLDER/@value = 'true'">
<xsl:variable name="prev_sections" select="count(/manifest/organizations/tableofcontents/item)"/>
<xsl:variable name="section_number" select="position()+$prev_sections"/>
<xsl:call-template name="sections">
<xsl:with-param name="section_number" select="$section_number"/>
<xsl:with-param name="recurse" >true</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</SECTIONS>
<MODULES>
<xsl:call-template name="modules" />
</MODULES>
</COURSE>
</MOODLE_BACKUP>
</xsl:template>
<xsl:template match="COURSE">
<HEADER>
<ID>2</ID>
<CATEGORY>
<ID></ID>
<NAME><xsl:value-of select="CATEGORIES/CATEGORY/@value"/></NAME>
</CATEGORY>
<PASSWORD></PASSWORD>
<IDNUMBER>4</IDNUMBER>
<FORMAT>topics</FORMAT>
<SHOWGRADES>1</SHOWGRADES>
<BLOCKINFO>participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity</BLOCKINFO>
<NEWSITEMS>5</NEWSITEMS>
<TEACHER>Teacher</TEACHER>
<TEACHERS>Teachers</TEACHERS>
<STUDENT>Student</STUDENT>
<STUDENTS>Students</STUDENTS>
<GUEST>
<xsl:choose>
<xsl:when test="FLAGS/ALLOWGUESTS/@value = 'true' ">1</xsl:when>
<xsl:when test="FLAGS/ALLOWGUESTS/@value = 'false' ">0</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</GUEST>
<STARTDATE>1094270400</STARTDATE>
<ENROLPERIOD>0</ENROLPERIOD>
<NUMSECTIONS>10</NUMSECTIONS>
<MAXBYTES>2097152</MAXBYTES>
<SHOWREPORTS>0</SHOWREPORTS>
<GROUPMODE>0</GROUPMODE>
<GROUPMODEFORCE>0</GROUPMODEFORCE>
<LANG></LANG>
<COST></COST>
<MARKER>0</MARKER>
<VISIBLE>
<xsl:choose>
<xsl:when test="FLAGS/ISAVAILABLE/@value = 'true' ">1</xsl:when>
<xsl:when test="FLAGS/ISAVAILABLE/@value = 'false' ">0</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</VISIBLE>
<HIDDENSECTIONS>0</HIDDENSECTIONS>
<TIMECREATED>1094240775</TIMECREATED>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
<SUMMARY><xsl:value-of select="DESCRIPTION"/></SUMMARY>
<SHORTNAME><xsl:value-of select="COURSEID/@value"/></SHORTNAME>
<FULLNAME><xsl:value-of select="TITLE/@value"/></FULLNAME>
</HEADER>
</xsl:template>
<!-- ############# Sections ############# -->
<xsl:template name="title_section" match="resource">
<SECTION>
<ID>0</ID>
<NUMBER>0</NUMBER>
<SUMMARY>&lt;div style="text-align: center;"&gt;&lt;font size="5" style="font-family: arial,helvetica,sans-serif;"&gt;<xsl:value-of select="COURSE/TITLE/@value"/>&lt;/font&gt;&lt;/div&gt;
<xsl:value-of select="COURSE/DESCRIPTION"/>
</SUMMARY>
<VISIBLE>1</VISIBLE>
<MODS>
<xsl:call-template name="news_forum_section_mod" >
<xsl:with-param name="mod_number">1</xsl:with-param>
</xsl:call-template>
</MODS>
</SECTION>
</xsl:template>
<xsl:template name="sections" match="resource">
<xsl:param name="section_number">1. </xsl:param>
<xsl:param name="recurse"/>
<SECTION>
<ID><xsl:value-of select="$section_number"/></ID>
<NUMBER><xsl:value-of select="$section_number"/></NUMBER>
<SUMMARY>&lt;span style="font-weight: bold;"&gt;<xsl:value-of select="@title"/>&lt;/span&gt;</SUMMARY>
<VISIBLE>1</VISIBLE>
<MODS>
<xsl:choose>
<xsl:when test="$recurse = 'true'">
<xsl:variable name="mod_number" select="substring-after(@identifierref,'res')"/>
<xsl:call-template name="item_recurse_files" >
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" >0</xsl:with-param>
<xsl:with-param name="recurse" select="$recurse" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$recurse = 'false'">
<xsl:for-each select="item">
<xsl:variable name="mod_number" select="substring-after(@identifierref,'res')"/>
<!-- Create one section-mod -->
<xsl:for-each select="document(concat(@identifierref,'.dat'))">
<xsl:call-template name="section_mod">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="0"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</MODS>
</SECTION>
</xsl:template>
<xsl:template name="item_recurse_files">
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<xsl:param name="recurse"/>
<!-- Create one section-mod -->
<xsl:for-each select="document(concat(@identifierref,'.dat'))">
<xsl:call-template name="section_mod">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:for-each>
<!-- Depth first recursion to preserve order -->
<xsl:for-each select="item">
<xsl:variable name="m_number" select="substring-after(@identifierref,'res')"/>
<xsl:call-template name="item_recurse_files" >
<xsl:with-param name="mod_number" select="$m_number"/>
<xsl:with-param name="indent" select="$indent + 1"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- Determines the type of section mod entry and calls the appropriate creation template -->
<xsl:template name="section_mod" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="contenttype" />
<xsl:param name="indent">1. </xsl:param>
<!-- Every file will have a label module describing it -->
<xsl:choose>
<!-- Detected one or more files -->
<xsl:when test="CONTENT/FILES/FILEREF/RELFILE/@value != ''">
<!-- Create a label -->
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" ><xsl:value-of select="$mod_number"/></xsl:with-param>
<xsl:with-param name="indent" ><xsl:value-of select="$indent"/></xsl:with-param>
<xsl:with-param name="type" >label</xsl:with-param>
</xsl:call-template>
<!-- Create a resource for each file -->
<xsl:for-each select="CONTENT/FILES/FILEREF">
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" ><xsl:value-of select="$mod_number"/>0<xsl:value-of select="position()"/></xsl:with-param>
<xsl:with-param name="indent" select="$indent + 1"/>
<xsl:with-param name="type" >resource</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<!-- Detected a folder -->
<xsl:when test="CONTENT/FLAGS/ISFOLDER/@value = 'true'">
<!-- Create a label -->
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
<xsl:with-param name="type" >label</xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- Detected text -->
<xsl:when test="CONTENT/MAINDATA/FLAGS/ISHTML/@value = 'true'">
<!-- Create a resource -->
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
<xsl:with-param name="type" >resource</xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- Detected external link -->
<xsl:when test="EXTERNALLINK/TITLE/@value != '' ">
<!-- Create a label -->
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
<xsl:with-param name="type" >label</xsl:with-param>
</xsl:call-template>
<!-- Create a resource -->
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
<xsl:with-param name="type" >resource</xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- Detected staffinfo -->
<xsl:when test="STAFFINFO/COURSEID/@value != '' ">
<!-- Create a resource -->
<xsl:call-template name="section_mod_generic">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
<xsl:with-param name="type" >resource</xsl:with-param>
</xsl:call-template> -->
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ############# Section Modules ############# -->
<!-- Creates one section module entry.
Works for types: label, resource (text), resource (externallink)
-->
<xsl:template name="section_mod_generic" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<xsl:param name="type"/>
<MOD>
<ID><xsl:if test="$type = 'label'">1</xsl:if><xsl:value-of select="$mod_number"/>0</ID>
<ZIBA_NAME>
<xsl:value-of select="CONTENT/TITLE"/>
<xsl:value-of select="EXTERNALLINK/TITLE/@value"/>
</ZIBA_NAME>
<TYPE><xsl:value-of select="$type"/></TYPE>
<INSTANCE><xsl:value-of select="$mod_number"/></INSTANCE>
<ADDED>1094240775</ADDED>
<DELETED>0</DELETED>
<SCORE>0</SCORE>
<INDENT><xsl:value-of select="$indent"/></INDENT>
<VISIBLE>1</VISIBLE>
<GROUPMODE>0</GROUPMODE>
</MOD>
</xsl:template>
<!-- ############# Modules ############# -->
<!-- Creates a module-label entry -->
<xsl:template name="module_label" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<LABELFOUND></LABELFOUND>
<MODTYPE>label</MODTYPE>
<NAME>
<!-- for CONTENT text -->
<xsl:value-of select="TITLE"/>
<!-- for EXTERNALLINK text -->
<xsl:value-of select="TITLE/@value"/>
</NAME>
<CONTENT>
&lt;span style="font-style: italic;"&gt;
<!-- for CONTENT text -->
<xsl:value-of select="TITLE"/>
<!-- for EXTERNALLINK text -->
<xsl:value-of select="TITLE/@value"/>
:&lt;/span&gt;
<!-- for CONTENT text -->
<xsl:value-of select="MAINDATA/TEXT"/>
<!-- for EXTERNALLINK text -->
<xsl:value-of select="DESCRIPTION/TEXT"/>
</CONTENT>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-file entry -->
<xsl:template name="module_file" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="summary"/>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<!-- <xsl:value-of select="FILES/FILEREF/RELFILE/@value"/> -->
<xsl:value-of select="RELFILE/@value"/>
</NAME>
<TYPE>file</TYPE>
<REFERENCE>
<!-- <xsl:value-of select="FILES/FILEREF/CONTENTID/@value"/>/<xsl:value-of select="FILES/FILEREF/RELFILE/@value"/> -->
<xsl:value-of select="CONTENTID/@value"/>/<xsl:value-of select="RELFILE/@value"/>
</REFERENCE>
<SUMMARY>
<xsl:value-of select="$summary"/>
</SUMMARY>
<ALLTEXT></ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-text-staffinfo entry -->
<!-- TODO staff photo -->
<xsl:template name="module_text_staffinfo" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<xsl:value-of select="CONTACT/NAME/FORMALTITLE/@value"/><xsl:text> </xsl:text><xsl:value-of select="CONTACT/NAME/GIVEN/@value"/><xsl:text> </xsl:text><xsl:value-of select="CONTACT/NAME/FAMILY/@value"/>
</NAME>
<TYPE>text</TYPE>
<REFERENCE></REFERENCE>
<SUMMARY>
<xsl:value-of select="CONTACT/NAME/FORMALTITLE/@value"/><xsl:text> </xsl:text><xsl:value-of select="CONTACT/NAME/GIVEN/@value"/><xsl:text> </xsl:text><xsl:value-of select="CONTACT/NAME/FAMILY/@value"/>
</SUMMARY>
<ALLTEXT>
Title:<xsl:value-of select="CONTACT/NAME/FORMALTITLE/@value"/>
Given Name:<xsl:value-of select="CONTACT/NAME/GIVEN/@value"/>
Family Name:<xsl:value-of select="CONTACT/NAME/FAMILY/@value"/>
Phone:<xsl:value-of select="CONTACT/PHONE"/>
Office Hours:<xsl:value-of select="CONTACT/OFFICE/HOURS"/>
Office Address:<xsl:value-of select="CONTACT/OFFICE/ADDRESS"/>
Homepage:<xsl:value-of select="HOMEPAGE/@value"/>
</ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-text entry -->
<xsl:template name="module_text" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<xsl:value-of select="TITLE"/>
<!-- For announcements -->
<xsl:value-of select="TITLE/@value"/>
</NAME>
<TYPE>text</TYPE>
<REFERENCE></REFERENCE>
<SUMMARY>
<xsl:value-of select="TITLE"/>
<!-- For announcements -->
<xsl:value-of select="TITLE/@value"/>
</SUMMARY>
<ALLTEXT>
<xsl:value-of select="MAINDATA/TEXT"/>
<!-- For announcements -->
<xsl:value-of select="DESCRIPTION/TEXT"/>
</ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-link entry -->
<xsl:template name="module_link" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<xsl:value-of select="URL/@value"/>
</NAME>
<TYPE>file</TYPE>
<REFERENCE>
<xsl:value-of select="URL/@value"/>
</REFERENCE>
<SUMMARY>
<xsl:value-of select="TITLE/@value"/>&lt;br/&gt;
<xsl:value-of select="URL/@value"/>
</SUMMARY>
<ALLTEXT>
<xsl:value-of select="DESCRIPTION/TEXT"/>
</ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- ############# Modules Decisions ############# -->
<!-- Creates all module entries -->
<xsl:template name="modules" match="resource">
<!-- Create the News Forum Module -->
<xsl:call-template name="news_forum_mod">
<xsl:with-param name="mod_number" >1</xsl:with-param>
</xsl:call-template>
<!-- Create all other modules -->
<xsl:for-each select="//resource">
<xsl:variable name="mod_number" select="substring-after(@identifier,'res')"/>
<xsl:for-each select="document(concat('',@file))">
<xsl:apply-templates select="//FORUM">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:apply-templates>
<xsl:apply-templates select="//CONTENT">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:apply-templates>
<xsl:apply-templates select="//EXTERNALLINK">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:apply-templates>
<xsl:apply-templates select="//STAFFINFO">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<!-- Create an EXTERNALLINK module entry -->
<xsl:template match="EXTERNALLINK">
<xsl:param name="mod_number">1. </xsl:param>
<!-- Every link module will have a label module describing it -->
<xsl:call-template name="module_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
<xsl:call-template name="module_link">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:template>
<!-- Create a STAFFINFO module entry -->
<xsl:template match="STAFFINFO">
<xsl:param name="mod_number">1. </xsl:param>
<!-- Every staffinfo module will have a label module describing it -->
<xsl:call-template name="module_text_staffinfo">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:template>
<!-- Create a CONTENT module entry -->
<xsl:template match="CONTENT">
<xsl:param name="mod_number">1. </xsl:param>
<xsl:choose>
<!-- Detected a file -->
<xsl:when test="FILES/FILEREF/RELFILE/@value != ''">
<!-- Every file module will have a label module describing it -->
<xsl:call-template name="module_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
<xsl:variable name="summary" select="MAINDATA/TEXT"/>
<xsl:for-each select="FILES/FILEREF">
<xsl:call-template name="module_file">
<xsl:with-param name="mod_number" ><xsl:value-of select="$mod_number"/>0<xsl:value-of select="position()"/></xsl:with-param>
<xsl:with-param name="summary" ><xsl:value-of select="$summary"/></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<!-- Detected a folder -->
<xsl:when test="FLAGS/ISFOLDER/@value = 'true'">
<xsl:call-template name="module_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:when>
<!-- Detected text -->
<xsl:when test="MAINDATA/FLAGS/ISHTML/@value = 'true'">
<xsl:call-template name="module_text">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<UNKNOWN>
<xsl:value-of select="TITLE"/>
</UNKNOWN>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ############# Forum conversion ################# -->
<xsl:template match="FORUM">
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>forum</MODTYPE>
<TYPE>general</TYPE>
<NAME>
<xsl:value-of select="TITLE/@value"/>
</NAME>
<INTRO>
<xsl:value-of select="DESCRIPTION/TEXT"/>
</INTRO>
<OPEN>2</OPEN>
<ASSESSED>0</ASSESSED>
<ASSESSPUBLIC>0</ASSESSPUBLIC>
<ASSESSTIMESTART>0</ASSESSTIMESTART>
<ASSESSTIMEFINISH>0</ASSESSTIMEFINISH>
<MAXBYTES>0</MAXBYTES>
<SCALE>0</SCALE>
<FORCESUBSCRIBE>0</FORCESUBSCRIBE>
<RSSTYPE>0</RSSTYPE>
<RSSARTICLES>0</RSSARTICLES>
<TIMEMODIFIED></TIMEMODIFIED>
<!--
<DISCUSSIONS>
<xsl:for-each select="MESSAGETHREADS/MSG">
<xsl:variable name="discussion_id" select="position()"/>
<DISCUSSION>
<ID>
<xsl:value-of select="$mod_number"/>0<xsl:value-of select="$discussion_id"/>
</ID>
<NAME>
<xsl:value-of select="TITLE/@value"/>
</NAME>
<FIRSTPOST>2</FIRSTPOST>
<USERID>1</USERID>
<GROUPID>-1</GROUPID>
<ASSESSED>1</ASSESSED>
<TIMEMODIFIED>1094748430</TIMEMODIFIED>
<USERMODIFIED>1</USERMODIFIED>
<POSTS>
<xsl:call-template name="MSG">
<xsl:with-param name="parent" select="0"/>
<xsl:with-param name="post_id">
<xsl:value-of select="$mod_number"/>0<xsl:value-of select="$discussion_id"/>0<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:call-template>
</POSTS>
</DISCUSSION>
</xsl:for-each>
</DISCUSSIONS>
-->
</MOD>
</xsl:template>
<xsl:template name="MSG" match="MSG">
<xsl:param name="parent" select="1"/>
<xsl:param name="post_id" select="1"/>
<POST>
<ID><xsl:value-of select="$post_id"/></ID>
<PARENT> <xsl:value-of select="$parent"/></PARENT>
<USERID>1</USERID>
<CREATED>1094748430</CREATED>
<MODIFIED>1094748430</MODIFIED>
<MAILED>1</MAILED>
<SUBJECT><xsl:value-of select="TITLE/@value"/></SUBJECT>
<MESSAGE><xsl:value-of select="MESSAGETEXT"/></MESSAGE>
<FORMAT>1</FORMAT>
<ATTACHMENT></ATTACHMENT>
<TOTALSCORE>0</TOTALSCORE>
</POST>
<xsl:for-each select="MSG">
<xsl:call-template name="MSG">
<xsl:with-param name="parent" select="$post_id"/>
<xsl:with-param name="post_id">
<xsl:value-of select="$post_id"/>0<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="news_forum_section_mod" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID>1</ID>
<ZIBA_NAME>
News forum
</ZIBA_NAME>
<TYPE>news</TYPE>
<INSTANCE>1</INSTANCE>
<ADDED>1094240775</ADDED>
<DELETED>0</DELETED>
<SCORE>0</SCORE>
<INDENT>0</INDENT>
<VISIBLE>1</VISIBLE>
<GROUPMODE>0</GROUPMODE>
</MOD>
</xsl:template>
<xsl:template name="news_forum_mod" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>forum</MODTYPE>
<TYPE>news</TYPE>
<NAME>News forum</NAME>
<INTRO>General news and announcements</INTRO>
<OPEN>2</OPEN>
<ASSESSED>0</ASSESSED>
<ASSESSPUBLIC>0</ASSESSPUBLIC>
<ASSESSTIMESTART>0</ASSESSTIMESTART>
<ASSESSTIMEFINISH>0</ASSESSTIMEFINISH>
<MAXBYTES>0</MAXBYTES>
<SCALE>0</SCALE>
<FORCESUBSCRIBE>0</FORCESUBSCRIBE>
<RSSTYPE>0</RSSTYPE>
<RSSARTICLES>0</RSSARTICLES>
<TIMEMODIFIED></TIMEMODIFIED>
<DISCUSSIONS>
<xsl:for-each select="//resource">
<xsl:variable name="m_number" select="substring-after(@identifier,'res')"/>
<xsl:variable name="discussion_id" select="position()"/>
<xsl:for-each select="document(concat('',@file))">
<xsl:if test="//ANNOUNCEMENT/TITLE/@value != ''">
<xsl:call-template name="ANNOUNCEMENT">
<xsl:with-param name="discussion_id" select="$discussion_id"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</DISCUSSIONS>
</MOD>
</xsl:template>
<!-- Create an ANNOUNCEMENT forum entry -->
<xsl:template name="ANNOUNCEMENT" >
<xsl:param name="discussion_id">1. </xsl:param>
<DISCUSSION>
<ID>
<xsl:value-of select="$discussion_id"/>
</ID>
<NAME><xsl:value-of select="//ANNOUNCEMENT/TITLE/@value"/></NAME>
<FIRSTPOST><xsl:value-of select="$discussion_id"/></FIRSTPOST>
<USERID>1</USERID>
<GROUPID>-1</GROUPID>
<ASSESSED>1</ASSESSED>
<TIMEMODIFIED>1094748430</TIMEMODIFIED>
<USERMODIFIED>1</USERMODIFIED>
<POSTS>
<POST>
<ID><xsl:value-of select="$discussion_id"/></ID>
<PARENT>0</PARENT>
<USERID>1</USERID>
<CREATED>1094748430</CREATED>
<MODIFIED>1094748430</MODIFIED>
<MAILED>1</MAILED>
<SUBJECT><xsl:value-of select="//ANNOUNCEMENT/TITLE/@value"/></SUBJECT>
<MESSAGE><xsl:value-of select="//ANNOUNCEMENT/DESCRIPTION/TEXT"/></MESSAGE>
<FORMAT>1</FORMAT>
<ATTACHMENT></ATTACHMENT>
<TOTALSCORE>0</TOTALSCORE>
</POST>
</POSTS>
</DISCUSSION>
<!--
<xsl:call-template name="MSG">
<xsl:with-param name="parent" select="0"/>
<xsl:with-param name="post_id">
<xsl:value-of select="$mod_number"/>0<xsl:value-of select="$discussion_id"/>0<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:call-template>
-->
</xsl:template>
</xsl:stylesheet>

View File

@ -1,690 +0,0 @@
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:template match="/">
<MOODLE_BACKUP>
<INFO>
<NAME>backup-from-blackboard.zip</NAME>
<MOODLE_VERSION>2004083100</MOODLE_VERSION>
<MOODLE_RELEASE>1.4</MOODLE_RELEASE>
<BACKUP_VERSION>2004083100</BACKUP_VERSION>
<BACKUP_RELEASE>1.4</BACKUP_RELEASE>
<DATE>1094240862</DATE>
<ORIGINAL_WWWROOT>INSERT URL HERE</ORIGINAL_WWWROOT>
<DETAILS>
<MOD>
<NAME>assignment</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>chat</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>choice</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>forum</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>glossary</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>journal</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>label</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>lesson</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>quiz</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>resource</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>scorm</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>survey</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>wiki</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<MOD>
<NAME>workshop</NAME>
<INCLUDED>true</INCLUDED>
<USERINFO>true</USERINFO>
</MOD>
<USERS>course</USERS>
<LOGS>false</LOGS>
<USERFILES>true</USERFILES>
<COURSEFILES>true</COURSEFILES>
</DETAILS>
</INFO>
<COURSE>
<!-- Get course specific information -->
<xsl:apply-templates select="document('res00001.dat')//COURSE"/>
<xsl:call-template name="modules" />
<SECTIONS>
<!-- Create a title section -->
<xsl:for-each select="document('res00001.dat')" >
<xsl:call-template name="title_section" />
</xsl:for-each>
<!-- Create a topic for each top level Bb item and add section modules ONE folder deep -->
<xsl:for-each select="manifest/organizations/organization/item">
<xsl:variable name="section_number" select="position()"/>
<xsl:call-template name="sections">
<xsl:with-param name="section_number" select="$section_number"/>
<xsl:with-param name="recurse" >false</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<!-- Create a topic for each second level Bb item which is a folder, recursively make section modules -->
<xsl:for-each select="manifest/organizations/organization/item/item">
<xsl:sort order="descending" select="document(concat(@identifierref,'.dat'))/CONTENT/FLAGS/ISFOLDER/@value"/>
<xsl:if test="document(concat(@identifierref,'.dat'))/CONTENT/FLAGS/ISFOLDER/@value = 'true'">
<xsl:variable name="prev_sections" select="count(/manifest/organizations/tableofcontents/item)"/>
<xsl:variable name="section_number" select="position()+$prev_sections"/>
<xsl:call-template name="sections">
<xsl:with-param name="section_number" select="$section_number"/>
<xsl:with-param name="recurse" >true</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</SECTIONS>
</COURSE>
</MOODLE_BACKUP>
</xsl:template>
<xsl:template match="COURSE">
<HEADER>
<ID>2</ID>
<CATEGORY>
<ID></ID>
<NAME><xsl:value-of select="CATEGORIES/CATEGORY/@value"/></NAME>
</CATEGORY>
<PASSWORD></PASSWORD>
<IDNUMBER>4</IDNUMBER>
<FORMAT>topics</FORMAT>
<SHOWGRADES>1</SHOWGRADES>
<BLOCKINFO>participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity</BLOCKINFO>
<NEWSITEMS>5</NEWSITEMS>
<TEACHER>Teacher</TEACHER>
<TEACHERS>Teachers</TEACHERS>
<STUDENT>Student</STUDENT>
<STUDENTS>Students</STUDENTS>
<GUEST>0</GUEST>
<STARTDATE>1094270400</STARTDATE>
<ENROLPERIOD>0</ENROLPERIOD>
<NUMSECTIONS>10</NUMSECTIONS>
<MAXBYTES>2097152</MAXBYTES>
<SHOWREPORTS>0</SHOWREPORTS>
<GROUPMODE>0</GROUPMODE>
<GROUPMODEFORCE>0</GROUPMODEFORCE>
<LANG></LANG>
<COST></COST>
<MARKER>0</MARKER>
<VISIBLE>1</VISIBLE>
<HIDDENSECTIONS>0</HIDDENSECTIONS>
<TIMECREATED>1094240775</TIMECREATED>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
<SUMMARY><xsl:value-of select="DESCRIPTION"/></SUMMARY>
<SHORTNAME><xsl:value-of select="COURSEID/@value"/></SHORTNAME>
<FULLNAME><xsl:value-of select="TITLE/@value"/></FULLNAME>
</HEADER>
</xsl:template>
<xsl:template name="title_section" match="resource">
<SECTION>
<ID>0</ID>
<NUMBER>0</NUMBER>
<SUMMARY>&lt;div style="text-align: center;"&gt;&lt;font size="5" style="font-family: arial,helvetica,sans-serif;"&gt;<xsl:value-of select="COURSE/TITLE/@value"/>&lt;/font&gt;&lt;/div&gt;
<xsl:value-of select="COURSE/DESCRIPTION"/>
</SUMMARY>
<VISIBLE>1</VISIBLE>
<MODS>
</MODS>
</SECTION>
</xsl:template>
<xsl:template name="sections" match="resource">
<xsl:param name="section_number">1. </xsl:param>
<xsl:param name="recurse"/>
<SECTION>
<ID><xsl:value-of select="$section_number"/></ID>
<NUMBER><xsl:value-of select="$section_number"/></NUMBER>
<SUMMARY>&lt;span style="font-weight: bold;"&gt;<xsl:value-of select="title"/>&lt;/span&gt;</SUMMARY>
<VISIBLE>1</VISIBLE>
<MODS>
<xsl:if test="$recurse = 'true'">
<xsl:variable name="mod_number" select="substring-after(@identifierref,'res')"/>
<xsl:call-template name="item_recurse_files" >
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" >0</xsl:with-param>
<xsl:with-param name="recurse" select="$recurse" />
</xsl:call-template>
</xsl:if>
<xsl:if test="$recurse = 'false'">
<xsl:for-each select="item">
<xsl:variable name="mod_number" select="substring-after(@identifierref,'res')"/>
<xsl:call-template name="item" >
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" >0</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
</MODS>
</SECTION>
</xsl:template>
<xsl:template name="item_recurse_files">
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<xsl:param name="recurse"/>
<!-- Create one section-mod -->
<xsl:for-each select="document(concat(@identifierref,'.dat'))">
<xsl:call-template name="section_mod">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:for-each>
<!-- Depth first recursion to preserve order -->
<xsl:for-each select="item">
<xsl:variable name="m_number" select="substring-after(@identifierref,'res')"/>
<xsl:call-template name="item_recurse_files" >
<xsl:with-param name="mod_number" select="$m_number"/>
<xsl:with-param name="indent" select="$indent + 1"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="item">
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<GETHERE></GETHERE>
<xsl:if test="document(concat(@identifierref,'.dat'))/CONTENT/FLAGS/ISFOLDER/@value != 'true' or document(concat(@identifierref,'.dat'))/EXTERNALLINK/DESCRIPTION/FLAGS/ISHTML/@value ='true'">
<!-- Create one section-mod -->
<xsl:for-each select="document(concat(@identifierref,'.dat'))">
<xsl:call-template name="section_mod">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
</xsl:template>
<!-- Determines the type of section mod entry and calls the appropriate creation template -->
<xsl:template name="section_mod" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="contenttype" />
<xsl:param name="indent">1. </xsl:param>
<!-- Every file will have a label module describing it -->
<xsl:choose>
<!-- Detected a file -->
<xsl:when test="CONTENT/FILE/@id != '' or CONTENT/FILES/FILE/NAME != ''">
<!-- Create a label -->
<xsl:call-template name="section_mod_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
<!-- Create a resource -->
<xsl:call-template name="section_mod_resource">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:when>
<!-- Detected a folder -->
<xsl:when test="CONTENT/FLAGS/ISFOLDER/@value = 'true'">
<MAKINGLABEL></MAKINGLABEL>
<!-- Create a label -->
<xsl:call-template name="section_mod_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:when>
<!-- Detected text -->
<xsl:when test="CONTENT/MAINDATA/FLAGS/ISHTML/@value = 'true' or CONTENT/BODY/TYPE/@value = 'H' ">
<MAKINGTEXT></MAKINGTEXT>
<!-- Create a resource -->
<xsl:call-template name="section_mod_resource">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:when>
<!-- Detected external link -->
<xsl:when test="EXTERNALLINK/TITLE/@value != '' ">
<!-- Create a label -->
<xsl:call-template name="section_mod_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
<!-- Create a resource -->
<xsl:call-template name="section_mod_externallink">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<UNKNOWN>
</UNKNOWN>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Creates one section-mod-label -->
<xsl:template name="section_mod_label" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<MOD>
<ID>1<xsl:value-of select="$mod_number"/>0</ID>
<ZIBA_NAME>
<!-- BB5.5 -->
<xsl:value-of select="CONTENT/TITLE"/>
<!-- BB6 -->
<xsl:value-of select="CONTENT/TITLE/@value"/>
</ZIBA_NAME>
<TYPE>label</TYPE>
<INSTANCE><xsl:value-of select="$mod_number"/></INSTANCE>
<ADDED>1094240775</ADDED>
<DELETED>0</DELETED>
<SCORE>0</SCORE>
<INDENT><xsl:value-of select="$indent"/></INDENT>
<VISIBLE>1</VISIBLE>
<GROUPMODE>0</GROUPMODE>
</MOD>
</xsl:template>
<!-- Creates one section-mod-resource -->
<xsl:template name="section_mod_resource" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/>0</ID>
<ZIBA_NAME>
<!-- BB5.5 -->
<xsl:value-of select="CONTENT/TITLE"/>
<!-- BB6 -->
<xsl:value-of select="CONTENT/TITLE/@value"/>
</ZIBA_NAME>
<TYPE>resource</TYPE>
<INSTANCE><xsl:value-of select="$mod_number"/></INSTANCE>
<ADDED>1094240775</ADDED>
<DELETED>0</DELETED>
<SCORE>0</SCORE>
<INDENT><xsl:value-of select="$indent"/></INDENT>
<VISIBLE>1</VISIBLE>
<GROUPMODE>0</GROUPMODE>
</MOD>
</xsl:template>
<!-- Creates one section-mod-externallink -->
<xsl:template name="section_mod_externallink" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="indent">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/>0</ID>
<ZIBA_NAME>
<xsl:value-of select="EXTERNALLINK/TITLE/@value"/>
</ZIBA_NAME>
<TYPE>resource</TYPE>
<INSTANCE><xsl:value-of select="$mod_number"/></INSTANCE>
<ADDED>1094240775</ADDED>
<DELETED>0</DELETED>
<SCORE>0</SCORE>
<INDENT><xsl:value-of select="$indent"/></INDENT>
<VISIBLE>1</VISIBLE>
<GROUPMODE>0</GROUPMODE>
</MOD>
</xsl:template>
<!-- Creates a module-label entry -->
<xsl:template name="module_label" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>label</MODTYPE>
<NAME>
<!-- for CONTENT text -->
<xsl:value-of select="TITLE"/>
<!-- for EXTERNALLINK text -->
<xsl:value-of select="TITLE/@value"/>
</NAME>
<CONTENT>
&lt;span style="font-style: italic;"&gt;
<!-- for CONTENT text -->
<xsl:value-of select="TITLE"/>
<!-- for EXTERNALLINK text -->
<xsl:value-of select="TITLE/@value"/>
:&lt;/span&gt;
<!-- for CONTENT text -->
<xsl:value-of select="MAINDATA/TEXT"/>
<!-- for EXTERNALLINK text -->
<xsl:value-of select="DESCRIPTION/TEXT"/>
<!-- for BB6 text -->
<xsl:value-of select="BODY/TEXT"/>
</CONTENT>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-file entry -->
<xsl:template name="module_file" >
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="identifier"/>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<!-- BB5 -->
<xsl:value-of select="FILES/FILEREF/RELFILE/@value"/>
<!-- BB6 -->
<xsl:value-of select="FILES/FILE/NAME"/>
</NAME>
<TYPE>file</TYPE>
<REFERENCE><!-- BB5 --><xsl:value-of select="FILES/FILEREF/CONTENTID/@value"/><!-- BB6 --><xsl:value-of select="$identifier"/>/<!-- BB5 --><xsl:value-of select="FILES/FILEREF/RELFILE/@value"/><!-- BB6 --><xsl:value-of select="FILES/FILE/NAME"/></REFERENCE>
<SUMMARY>
<xsl:value-of select="MAINDATA/TEXT"/>
</SUMMARY>
<ALLTEXT></ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-text entry -->
<xsl:template name="module_text" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<!-- BB5.5 -->
<xsl:value-of select="TITLE"/>
<!-- BB6 -->
<xsl:value-of select="TITLE/@value"/>
</NAME>
<TYPE>text</TYPE>
<REFERENCE></REFERENCE>
<SUMMARY>
<!-- BB5.5 -->
<xsl:value-of select="TITLE"/>
<!-- BB6 -->
<xsl:value-of select="TITLE/@value"/>
</SUMMARY>
<ALLTEXT>
<!-- BB5.5 -->
<xsl:value-of select="MAINDATA/TEXT"/>
<!-- BB6 -->
<xsl:value-of select="BODY/TEXT"/>
</ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Creates one module-link entry -->
<xsl:template name="module_link" >
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>resource</MODTYPE>
<NAME>
<xsl:value-of select="URL/@value"/>
</NAME>
<TYPE>file</TYPE>
<REFERENCE>
<xsl:value-of select="URL/@value"/>
</REFERENCE>
<SUMMARY>
<xsl:value-of select="TITLE/@value"/>&lt;br/&gt;
<xsl:value-of select="URL/@value"/>
</SUMMARY>
<ALLTEXT>
<xsl:value-of select="DESCRIPTION/TEXT"/>
</ALLTEXT>
<POPUP></POPUP>
<OPTIONS></OPTIONS>
<TIMEMODIFIED>1094240775</TIMEMODIFIED>
</MOD>
</xsl:template>
<!-- Create a CONTENT module entries -->
<xsl:template match="EXTERNALLINK">
<xsl:param name="mod_number">1. </xsl:param>
<!-- Every link module will have a label module describing it -->
<xsl:call-template name="module_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
<xsl:call-template name="module_link">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:template>
<!-- Create a CONTENT module entries -->
<xsl:template match="CONTENT">
<xsl:param name="mod_number">1. </xsl:param>
<xsl:param name="identifier"/>
<xsl:choose>
<!-- Detected a file
<FILEFOUND></FILEFOUND>
-->
<xsl:when test="FILES/FILE/@id != ''">
<!-- Every file module will have a label module describing it -->
<xsl:call-template name="module_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
<xsl:call-template name="module_file">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="identifier" select="$identifier"/>
</xsl:call-template>
</xsl:when>
<!-- Detected a folder
<FOLDERFOUND></FOLDERFOUND>
-->
<xsl:when test="FLAGS/ISFOLDER/@value = 'true'">
<xsl:call-template name="module_label">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:when>
<!-- Detected text
<TEXTFOUND></TEXTFOUND>
-->
<xsl:when test="MAINDATA/FLAGS/ISHTML/@value = 'true' or BODY/TYPE/@value = 'H' ">
<xsl:call-template name="module_text">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<UNKNOWN>
<xsl:value-of select="TITLE"/>
</UNKNOWN>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Creates all module entries -->
<xsl:template name="modules" match="resource">
<MODULES>
<xsl:for-each select="//resource">
<xsl:variable name="mod_number" select="substring-after(@identifier,'res')"/>
<xsl:variable name="identifier" select="@identifier"/>
<xsl:for-each select="document(concat(@identifier,'.dat'))">
<xsl:apply-templates select="//FORUM">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:apply-templates>
<xsl:apply-templates select="//CONTENT">
<xsl:with-param name="mod_number" select="$mod_number"/>
<xsl:with-param name="identifier" select="$identifier"/>
</xsl:apply-templates>
<xsl:apply-templates select="//EXTERNALLINK">
<xsl:with-param name="mod_number" select="$mod_number"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:for-each>
</MODULES>
</xsl:template>
<!-- ############# Forum conversion ################# -->
<xsl:template match="FORUM">
<xsl:param name="mod_number">1. </xsl:param>
<MOD>
<ID><xsl:value-of select="$mod_number"/></ID>
<MODTYPE>forum</MODTYPE>
<TYPE>general</TYPE>
<NAME>
<xsl:value-of select="TITLE/@value"/>
</NAME>
<INTRO>
<xsl:value-of select="DESCRIPTION/TEXT"/>
</INTRO>
<OPEN>2</OPEN>
<ASSESSED>0</ASSESSED>
<ASSESSPUBLIC>0</ASSESSPUBLIC>
<ASSESSTIMESTART>0</ASSESSTIMESTART>
<ASSESSTIMEFINISH>0</ASSESSTIMEFINISH>
<MAXBYTES>0</MAXBYTES>
<SCALE>0</SCALE>
<FORCESUBSCRIBE>0</FORCESUBSCRIBE>
<RSSTYPE>0</RSSTYPE>
<RSSARTICLES>0</RSSARTICLES>
<TIMEMODIFIED></TIMEMODIFIED>
<!--
<DISCUSSIONS>
<xsl:for-each select="MESSAGETHREADS/MSG">
<xsl:variable name="discussion_id" select="position()"/>
<DISCUSSION>
<ID>
<xsl:value-of select="$mod_number"/>0<xsl:value-of select="$discussion_id"/>
</ID>
<NAME>
<xsl:value-of select="TITLE/@value"/>
</NAME>
<FIRSTPOST>2</FIRSTPOST>
<USERID>1</USERID>
<GROUPID>-1</GROUPID>
<ASSESSED>1</ASSESSED>
<TIMEMODIFIED>1094748430</TIMEMODIFIED>
<USERMODIFIED>1</USERMODIFIED>
<POSTS>
<xsl:call-template name="MSG">
<xsl:with-param name="parent" select="0"/>
<xsl:with-param name="post_id">
<xsl:value-of select="$mod_number"/>0<xsl:value-of select="$discussion_id"/>0<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:call-template>
</POSTS>
</DISCUSSION>
</xsl:for-each>
</DISCUSSIONS>
-->
</MOD>
</xsl:template>
<xsl:template name="MSG" match="MSG">
<xsl:param name="parent" select="1"/>
<xsl:param name="post_id" select="1"/>
<POST>
<ID><xsl:value-of select="$post_id"/></ID>
<PARENT> <xsl:value-of select="$parent"/></PARENT>
<USERID>1</USERID>
<CREATED>1094748430</CREATED>
<MODIFIED>1094748430</MODIFIED>
<MAILED>1</MAILED>
<SUBJECT><xsl:value-of select="TITLE/@value"/></SUBJECT>
<MESSAGE><xsl:value-of select="MESSAGETEXT"/></MESSAGE>
<FORMAT>1</FORMAT>
<ATTACHMENT></ATTACHMENT>
<TOTALSCORE>0</TOTALSCORE>
</POST>
<xsl:for-each select="MSG">
<xsl:call-template name="MSG">
<xsl:with-param name="parent" select="$post_id"/>
<xsl:with-param name="post_id">
<xsl:value-of select="$post_id"/>0<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,125 +0,0 @@
<?php
// This file facilitates the conversion of a Blackboard course export
// into a Moodle course export. It assumes an unzipped directory and makes in-place alterations.
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
// Ziba Scott <ziba@linuxbox.com> 10-25-04
require_once($CFG->dirroot.'/backup/bb/xsl_emulate_xslt.inc');
function get_subdirs($directory){
if (!$opendirectory = opendir( $directory )) {
return array();
}
while(false !== ($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, $OUTPUT;
throw new coding_exception('bb_convert was not converted to new file api yet, sorry');
// Check for a Blackboard manifest file
if (is_readable($dir.'/imsmanifest.xml') && !is_readable($dir.'/moodle.xml')){
if (!function_exists('xslt_create')) { // XSLT MUST be installed for this to work
echo $OUTPUT->notification('You need the XSLT library installed in PHP to open this Blackboard file');
return false;
}
//Select the proper XSL file
$xslt_file = choose_bb_xsl($dir.'/imsmanifest.xml');
//TODO: Use the get_string function for this
echo "<li>Converting Blackboard export</li>";
// The XSL file must be in the same directory as the Blackboard files when it is processed
if (!copy($CFG->dirroot."/backup/bb/$xslt_file", "$dir/$xslt_file")) {
echo $OUTPUT->notification('Could not copy the XSLT file to '."$dir/$xslt_file");
return false;
}
// Change to that directory
$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', "$dir/$xslt_file", "$dir/moodle.xml")) {
echo $OUTPUT->notification('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", $CFG->directorypermissions);
foreach ($subdirs as $subdir){
rename($subdir, "course_files/$subdir");
rename_hexfiles($subdir);
}
chdir($startdir);
// Blackboard export successfully converted
return true;
}
// This is not a Blackboard export
return true;
}
/**
* grabs all files in the directory, checks if the filenames start with a ! or @
* then checks to see if the name is a hex - if so, it translates/renames correctly.
*
* @param string $subdir - the directory to parse.
*
*/
function rename_hexfiles($subdir) {
//this bit of code grabs all files in the directory, and if they start with ! or @, performs the name conversion
if ($handle = opendir("course_files/$subdir")) {
while ($file = readdir($handle)) {
if ($file == '..' or $file == '.') { //don't bother processing these!
continue;
}
if(substr($file,0,1)=="!" || substr($file,0,1)=="@"){
$outputfilename = "";
$filebase = substr($file,1,strrpos($file,".")-1);
if (ctype_xdigit($filebase)) { //check if this name is a hex - if not, don't bother to rename
$filenamesplit = str_split($filebase,2);
foreach($filenamesplit as $hexvalue){
$outputfilename .= chr(hexdec($hexvalue));
}
$outputfilename .= strrchr($file,".");
rename("course_files/$subdir/$file","course_files/$subdir/$outputfilename");
}
}
}
closedir($handle);
}
}

View File

@ -1,43 +0,0 @@
<?php
// This file adds xslt_xxx emulation functions.
// It is intended for systems, e.g. those running PHP 5, where:
// 1) The XSLT library is not installed.
// 2) The XSL library is installed.
//
// Note that not everything is implemented.
// In particular, only the bare minimum to support the BB conversion is here.
// This silliness is required to prevent PHP from evaluating the function() blocks before processing the return;s
if(true) {
if(function_exists('xslt_create')) return; // xslt_create() already exists, so emulation isn't needed.
if(!class_exists('XSLTProcessor')) return; // There is no XSLTProcessor class, so emulation isn't possible.
if(!class_exists('DOMDocument')) return; // There is no DOMDocument class, so emulation isn't possible.
function xslt_create() {
return new XSLTProcessor();
}
// We don't support arguments or parameters because the Bb import doesn't use them
function xslt_process($proc, $xmlfile, $xslfile, $resultfile = null, $unsupported_args = null, $unsupported_params = null) {
$doc = new DOMDocument;
$doc->load($xmlfile);
$xsl = new DOMDocument;
$xsl->load($xslfile);
$proc->importStylesheet($xsl);
// Squash warnings here because xsl complains about COURSE_ACCESS tags which really are invalid XML (multiple root elements)
if($resultfile !== null) {
$fp = fopen($resultfile, 'w');
fwrite($fp, @$proc->transformToXML($doc));
fclose($fp);
return true;
} else {
return @$proc->transformToXML($doc);
}
}
} // end if(true)

View File

@ -1,491 +0,0 @@
<?php
//This file contains all the general function needed (file manipulation...)
//not directly part of the backup/restore utility plus some constants
// Define "restoreto" options
define('RESTORETO_CURRENT_DELETING', 0);
define('RESTORETO_CURRENT_ADDING', 1);
define('RESTORETO_NEW_COURSE', 2);
define('RESTORETO_EXISTING_DELETING', 3);
define('RESTORETO_EXISTING_ADDING', 4);
require_once($CFG->libdir . '/completionlib.php');
//Sets a name/value pair in config_plugin table
function backup_set_config($name, $value) {
return set_config($name, $value, 'backup');
}
//Gets all the information from config_plugin table
function backup_get_config() {
$backup_config = get_config('backup');
return (object)$backup_config;
}
//Delete old data in backup tables (if exists)
//Four hours seem to be appropiate now that backup is stable
function backup_delete_old_data() {
global $CFG, $DB;
//Change this if you want !!
$hours = 4;
//End change this
$seconds = $hours * 60 * 60;
$delete_from = time()-$seconds;
//Now delete from tables
$status = $DB->execute("DELETE FROM {backup_ids}
WHERE backup_code < ?", array($delete_from));
if ($status) {
$status = $DB->execute("DELETE FROM {backup_files}
WHERE backup_code < ?", array($delete_from));
}
//Now, delete old directory (if exists)
if ($status) {
$status = backup_delete_old_dirs($delete_from);
}
return($status);
}
//Function to delete dirs/files into temp/backup directory
//older than $delete_from
function backup_delete_old_dirs($delete_from) {
global $CFG;
$status = true;
//Get files and directories in the temp backup dir witout descend
$list = get_directory_list($CFG->tempdir."/backup", "", false, true, true);
foreach ($list as $file) {
$file_path = $CFG->tempdir."/backup/".$file;
$moddate = filemtime($file_path);
if ($status && $moddate < $delete_from) {
//If directory, recurse
if (is_dir($file_path)) {
$status = delete_dir_contents($file_path);
//There is nothing, delete the directory itself
if ($status) {
$status = rmdir($file_path);
}
//If file
} else {
unlink("$file_path");
}
}
}
return $status;
}
//Function to check and create the needed dir to
//save all the backup
function check_and_create_backup_dir($backup_unique_code) {
global $CFG;
$status = check_dir_exists($CFG->tempdir."",true);
if ($status) {
$status = check_dir_exists($CFG->tempdir."/backup",true);
}
if ($status) {
$status = check_dir_exists($CFG->tempdir."/backup/".$backup_unique_code,true);
}
return $status;
}
//Function to delete all the directory contents recursively
//it supports a excluded dit too
//Copied from the web !!
function delete_dir_contents ($dir,$excludeddir="") {
global $CFG;
if (!is_dir($dir)) {
// if we've been given a directory that doesn't exist yet, return true.
// this happens when we're trying to clear out a course that has only just
// been created.
return true;
}
$slash = "/";
// Create arrays to store files and directories
$dir_files = array();
$dir_subdirs = array();
// Make sure we can delete it
chmod($dir, $CFG->directorypermissions);
if ((($handle = opendir($dir))) == FALSE) {
// The directory could not be opened
return false;
}
// Loop through all directory entries, and construct two temporary arrays containing files and sub directories
while (false !== ($entry = readdir($handle))) {
if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != "." && $entry != $excludeddir) {
$dir_subdirs[] = $dir. $slash .$entry;
}
else if ($entry != ".." && $entry != "." && $entry != $excludeddir) {
$dir_files[] = $dir. $slash .$entry;
}
}
// Delete all files in the curent directory return false and halt if a file cannot be removed
$countdirfiles = count($dir_files);
for ($i=0; $i<$countdirfiles; $i++) {
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == FALSE) {
return false;
}
}
// Empty sub directories and then remove the directory
$countdirsubdirs = count($dir_subdirs);
for($i=0; $i<$countdirsubdirs; $i++) {
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if (delete_dir_contents($dir_subdirs[$i]) == FALSE) {
return false;
}
else {
if (remove_dir($dir_subdirs[$i]) == FALSE) {
return false;
}
}
}
// Close directory
closedir($handle);
// Success, every thing is gone return true
return true;
}
//Function to clear (empty) the contents of the backup_dir
function clear_backup_dir($backup_unique_code) {
global $CFG;
$rootdir = $CFG->tempdir."/backup/".$backup_unique_code;
//Delete recursively
$status = delete_dir_contents($rootdir);
return $status;
}
//Returns the module type of a course_module's id in a course
function get_module_type ($courseid,$moduleid) {
global $DB;
$results = $DB->get_records_sql("SELECT cm.id, m.name
FROM {course_modules} cm, {modules} m
WHERE cm.course = ? AND cm.id = ? AND
m.id = cm.module", array($courseid, $moduleid));
if ($results) {
$name = $results[$moduleid]->name;
} else {
$name = false;
}
return $name;
}
//This function return the names of all directories under a give directory
//Not recursive
function list_directories ($rootdir) {
$results = null;
$dir = opendir($rootdir);
while (false !== ($file=readdir($dir))) {
if ($file=="." || $file=="..") {
continue;
}
if (is_dir($rootdir."/".$file)) {
$results[$file] = $file;
}
}
closedir($dir);
return $results;
}
//This function return the names of all directories and files under a give directory
//Not recursive
function list_directories_and_files ($rootdir) {
$results = "";
$dir = opendir($rootdir);
while (false !== ($file=readdir($dir))) {
if ($file=="." || $file=="..") {
continue;
}
$results[$file] = $file;
}
closedir($dir);
return $results;
}
//This function clean data from backup tables and
//delete all temp files used
function clean_temp_data ($preferences) {
global $CFG, $DB;
$status = true;
//true->do it, false->don't do it. To debug if necessary.
if (true) {
//Now delete from tables
$status = $DB->delete_records('backup_ids', array('backup_code'=>$preferences->backup_unique_code))
&& $DB->delete_records('backup_files', array('backup_code'=>$preferences->backup_unique_code));
//Now, delete temp directory (if exists)
$file_path = $CFG->tempdir."/backup/".$preferences->backup_unique_code;
if (is_dir($file_path)) {
$status = delete_dir_contents($file_path);
//There is nothing, delete the directory itself
if ($status) {
$status = rmdir($file_path);
}
}
}
return $status;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//This functions are used to copy any file or directory ($from_file)
//to a new file or directory ($to_file). It works recursively and
//mantains file perms.
//I've copied it from: http://www.php.net/manual/en/function.copy.php
//Little modifications done
function backup_copy_file ($from_file,$to_file,$log_clam=false) {
global $CFG;
if (is_file($from_file)) {
//echo "<br />Copying ".$from_file." to ".$to_file; //Debug
//$perms=fileperms($from_file);
//return copy($from_file,$to_file) && chmod($to_file,$perms);
umask(0000);
if (copy($from_file,$to_file)) {
chmod($to_file,$CFG->directorypermissions);
if (!empty($log_clam)) {
//clam_log_upload($to_file,null,true);
}
return true;
}
return false;
}
else if (is_dir($from_file)) {
return backup_copy_dir($from_file,$to_file);
}
else{
//echo "<br />Error: not file or dir ".$from_file; //Debug
return false;
}
}
function backup_copy_dir($from_file,$to_file) {
global $CFG;
$status = true; // Initialize this, next code will change its value if needed
if (!is_dir($to_file)) {
//echo "<br />Creating ".$to_file; //Debug
umask(0000);
$status = mkdir($to_file,$CFG->directorypermissions);
}
$dir = opendir($from_file);
while (false !== ($file=readdir($dir))) {
if ($file=="." || $file=="..") {
continue;
}
$status = backup_copy_file ("$from_file/$file","$to_file/$file");
}
closedir($dir);
return $status;
}
///Ends copy file/dirs functions
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* Are we restoring a backup that was made on the same site that we are restoring to?
* This relies on some information that was only added to backup files in January 2009.
* For older backup files, fall back to guessing based on wwwroot. MDL-16614 explains
* when this guess could give the wrong answer.
* @return boolean true if the backup was made on the same site we are restoring to.
*/
function backup_is_same_site(&$restore) {
global $CFG;
static $hashedsiteid = null;
if (is_null($hashedsiteid)) {
$hashedsiteid = md5(get_site_identifier());
}
if (!empty($restore->original_siteidentifier)) {
return $restore->original_siteidentifier == $hashedsiteid;
} else {
return $restore->original_wwwroot == $CFG->wwwroot;
}
}
//This function is used to insert records in the backup_ids table
//If the info field is greater than max_db_storage, then its info
//is saved to filesystem
function backup_putid($backup_unique_code, $table, $old_id, $new_id, $info="") {
global $CFG, $DB;
$max_db_storage = 128; //Max bytes to save to db, else save to file
$status = true;
//First delete to avoid PK duplicates
$status = backup_delid($backup_unique_code, $table, $old_id);
//Now, serialize info
$info_ser = serialize($info);
//Now, if the size of $info_ser > $max_db_storage, save it to filesystem and
//insert a "infile" in the info field
if (strlen($info_ser) > $max_db_storage) {
//Calculate filename (in current_backup_dir, $backup_unique_code_$table_$old_id.info)
$filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
//Save data to file
$status = backup_data2file($filename,$info_ser);
//Set info_to save
$info_to_save = "infile";
} else {
//Saving to db
$info_to_save = $info_ser;
}
//Now, insert the record
if ($status) {
//Build the record
$rec = new stdClass();
$rec->backup_code = $backup_unique_code;
$rec->table_name = $table;
$rec->old_id = $old_id;
$rec->new_id = ($new_id === null? 0 : $new_id);
$rec->info = $info_to_save;
$DB->insert_record('backup_ids', $rec, false);
}
return $status;
}
//This function is used to delete recods from the backup_ids table
//If the info field is "infile" then the file is deleted too
function backup_delid ($backup_unique_code, $table, $old_id) {
global $DB;
return $DB->delete_records('backup_ids', array('backup_code'=>$backup_unique_code, 'table_name'=>$table, 'old_id'=>$old_id));
}
//This function is used to get a record from the backup_ids table
//If the info field is "infile" then its info
//is read from filesystem
function backup_getid ($backup_unique_code, $table, $old_id) {
global $CFG, $DB;
$status = true;
$status2 = true;
$status = $DB->get_record("backup_ids", array("backup_code"=>$backup_unique_code,
"table_name"=>$table, "old_id"=>$old_id));
//If info field = "infile", get file contents
if (!empty($status->info) && $status->info == "infile") {
$filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
//Read data from file
$status2 = backup_file2data($filename,$info);
if ($status2) {
//unserialize data
$status->info = unserialize($info);
} else {
$status = false;
}
} else {
//Only if status (record exists)
if (!empty($status->info)) {
if ($status->info === 'needed') {
// TODO: ugly hack - fix before 1.9.1
debugging('Incorrect string "needed" in $status->info, please fix the code (table:'.$table.'; old_id:'.$old_id.').', DEBUG_DEVELOPER);
} else {
////First strip slashes
$temp = $status->info;
//Now unserialize
$status->info = unserialize($temp);
}
}
}
return $status;
}
//This function is used to add slashes (and decode from UTF-8 if needed)
//It's used intensivelly when restoring modules and saving them in db
function backup_todb ($data) {
// MDL-10770
if ($data === '$@NULL@$') {
return null;
} else {
return restore_decode_absolute_links($data);
}
}
//This function is used to check that every necessary function to
//backup/restore exists in the current php installation. Thanks to
//gregb@crowncollege.edu by the idea.
function backup_required_functions($justcheck=false) {
if(!function_exists('utf8_encode')) {
if (empty($justcheck)) {
print_error('needphpext', '', '', 'XML');
} else {
return false;
}
}
return true;
}
//This function send n white characters to the browser and flush the
//output buffer. Used to avoid browser timeouts and to show the progress.
function backup_flush($n=0,$time=false) {
if (defined('RESTORE_SILENTLY_NOFLUSH')) {
return;
}
if ($time) {
$ti = strftime("%X",time());
} else {
$ti = "";
}
echo str_repeat(" ", $n) . $ti . "\n";
flush();
}
//This function creates the filename and write data to it
//returning status as result
function backup_data2file ($file,&$data) {
$status = true;
$status2 = true;
$f = fopen($file,"w");
$status = fwrite($f,$data);
$status2 = fclose($f);
return ($status && $status2);
}
//This function read the filename and read data from it
function backup_file2data ($file,&$data) {
$status = true;
$status2 = true;
$f = fopen($file,"r");
$data = fread ($f,filesize($file));
$status2 = fclose($f);
return ($status && $status2);
}

View File

@ -1,614 +0,0 @@
<?php
//This function iterates over all modules in backup file, searching for a
//MODNAME_refresh_events() to execute. Perhaps it should ve moved to central Moodle...
function restore_refresh_events($restore) {
global $CFG;
$status = true;
//Take all modules in backup
$modules = $restore->mods;
//Iterate
foreach($modules as $name => $module) {
//Only if the module is being restored
if (isset($module->restore) && $module->restore == 1) {
//Include module library
include_once("$CFG->dirroot/mod/$name/lib.php");
//If module_refresh_events exists
$function_name = $name."_refresh_events";
if (function_exists($function_name)) {
$status = $function_name($restore->course_id);
}
}
}
return $status;
}
//Called to set up any course-format specific data that may be in the file
function restore_set_format_data($restore,$xml_file) {
global $CFG, $DB;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
return false;
}
//Load data from XML to info
if(!($info = restore_read_xml_formatdata($xml_file))) {
return false;
}
//Process format data if there is any
if (isset($info->format_data)) {
if(!$format=$DB->get_field('course','format', array('id'=>$restore->course_id))) {
return false;
}
// If there was any data then it must have a restore method
$file=$CFG->dirroot."/course/format/$format/restorelib.php";
if(!file_exists($file)) {
return false;
}
require_once($file);
$function=$format.'_restore_format_data';
if(!function_exists($function)) {
return false;
}
return $function($restore,$info->format_data);
}
// If we got here then there's no data, but that's cool
return true;
}
//This function creates all the structures messages and contacts
function restore_create_messages($restore,$xml_file) {
global $CFG, $DB;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
//info will contain the id and name of every table
//(message, message_read and message_contacts)
//in backup_ids->info will be the real info (serialized)
$info = restore_read_xml_messages($restore,$xml_file);
//If we have info, then process messages & contacts
if ($info > 0) {
//Count how many we have
$unreadcount = $DB->count_records ('backup_ids', array('backup_code'=>$restore->backup_unique_code, 'table_name'=>'message'));
$readcount = $DB->count_records ('backup_ids', array('backup_code'=>$restore->backup_unique_code, 'table_name'=>'message_read'));
$contactcount = $DB->count_records ('backup_ids', array('backup_code'=>$restore->backup_unique_code, 'table_name'=>'message_contacts'));
if ($unreadcount || $readcount || $contactcount) {
//Start ul
if (!defined('RESTORE_SILENTLY')) {
echo '<ul>';
}
//Number of records to get in every chunk
$recordset_size = 4;
//Process unread
if ($unreadcount) {
if (!defined('RESTORE_SILENTLY')) {
echo '<li>'.get_string('unreadmessages','message').'</li>';
}
$counter = 0;
while ($counter < $unreadcount) {
//Fetch recordset_size records in each iteration
$recs = $DB->get_records("backup_ids", array('table_name'=>'message', 'backup_code'=>$restore->backup_unique_code),"old_id","old_id",$counter,$recordset_size);
if ($recs) {
foreach ($recs as $rec) {
//Get the full record from backup_ids
$data = backup_getid($restore->backup_unique_code,"message",$rec->old_id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now build the MESSAGE record structure
$dbrec = new stdClass();
$dbrec->useridfrom = backup_todb($info['MESSAGE']['#']['USERIDFROM']['0']['#']);
$dbrec->useridto = backup_todb($info['MESSAGE']['#']['USERIDTO']['0']['#']);
$dbrec->message = backup_todb($info['MESSAGE']['#']['MESSAGE']['0']['#']);
$dbrec->format = backup_todb($info['MESSAGE']['#']['FORMAT']['0']['#']);
$dbrec->timecreated = backup_todb($info['MESSAGE']['#']['TIMECREATED']['0']['#']);
$dbrec->messagetype = backup_todb($info['MESSAGE']['#']['MESSAGETYPE']['0']['#']);
//We have to recode the useridfrom field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->useridfrom);
if ($user) {
//echo "User ".$dbrec->useridfrom." to user ".$user->new_id."<br />"; //Debug
$dbrec->useridfrom = $user->new_id;
}
//We have to recode the useridto field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->useridto);
if ($user) {
//echo "User ".$dbrec->useridto." to user ".$user->new_id."<br />"; //Debug
$dbrec->useridto = $user->new_id;
}
//Check if the record doesn't exist in DB!
$exist = $DB->get_record('message', array('useridfrom'=>$dbrec->useridfrom,
'useridto'=>$dbrec->useridto,
'timecreated'=>$dbrec->timecreated));
if (!$exist) {
//Not exist. Insert
$status = $DB->insert_record('message',$dbrec);
} else {
//Duplicate. Do nothing
}
}
//Do some output
$counter++;
if ($counter % 10 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if ($counter % 200 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
}
}
//Process read
if ($readcount) {
if (!defined('RESTORE_SILENTLY')) {
echo '<li>'.get_string('readmessages','message').'</li>';
}
$counter = 0;
while ($counter < $readcount) {
//Fetch recordset_size records in each iteration
$recs = $DB->get_records("backup_ids", array('table_name'=>'message_read', 'backup_code'=>$restore->backup_unique_code),"old_id","old_id",$counter,$recordset_size);
if ($recs) {
foreach ($recs as $rec) {
//Get the full record from backup_ids
$data = backup_getid($restore->backup_unique_code,"message_read",$rec->old_id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now build the MESSAGE_READ record structure
$dbrec->useridfrom = backup_todb($info['MESSAGE']['#']['USERIDFROM']['0']['#']);
$dbrec->useridto = backup_todb($info['MESSAGE']['#']['USERIDTO']['0']['#']);
$dbrec->message = backup_todb($info['MESSAGE']['#']['MESSAGE']['0']['#']);
$dbrec->format = backup_todb($info['MESSAGE']['#']['FORMAT']['0']['#']);
$dbrec->timecreated = backup_todb($info['MESSAGE']['#']['TIMECREATED']['0']['#']);
$dbrec->messagetype = backup_todb($info['MESSAGE']['#']['MESSAGETYPE']['0']['#']);
$dbrec->timeread = backup_todb($info['MESSAGE']['#']['TIMEREAD']['0']['#']);
$dbrec->mailed = backup_todb($info['MESSAGE']['#']['MAILED']['0']['#']);
//We have to recode the useridfrom field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->useridfrom);
if ($user) {
//echo "User ".$dbrec->useridfrom." to user ".$user->new_id."<br />"; //Debug
$dbrec->useridfrom = $user->new_id;
}
//We have to recode the useridto field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->useridto);
if ($user) {
//echo "User ".$dbrec->useridto." to user ".$user->new_id."<br />"; //Debug
$dbrec->useridto = $user->new_id;
}
//Check if the record doesn't exist in DB!
$exist = $DB->get_record('message_read', array('useridfrom'=>$dbrec->useridfrom,
'useridto'=>$dbrec->useridto,
'timecreated'=>$dbrec->timecreated));
if (!$exist) {
//Not exist. Insert
$status = $DB->insert_record('message_read',$dbrec);
} else {
//Duplicate. Do nothing
}
}
//Do some output
$counter++;
if ($counter % 10 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if ($counter % 200 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
}
}
//Process contacts
if ($contactcount) {
if (!defined('RESTORE_SILENTLY')) {
echo '<li>'.textlib::strtolower(get_string('contacts','message')).'</li>';
}
$counter = 0;
while ($counter < $contactcount) {
//Fetch recordset_size records in each iteration
$recs = $DB->get_records("backup_ids", array('table_name'=>'message_contacts', 'backup_code'=>$restore->backup_unique_code),"old_id","old_id",$counter,$recordset_size);
if ($recs) {
foreach ($recs as $rec) {
//Get the full record from backup_ids
$data = backup_getid($restore->backup_unique_code,"message_contacts",$rec->old_id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now build the MESSAGE_CONTACTS record structure
$dbrec->userid = backup_todb($info['CONTACT']['#']['USERID']['0']['#']);
$dbrec->contactid = backup_todb($info['CONTACT']['#']['CONTACTID']['0']['#']);
$dbrec->blocked = backup_todb($info['CONTACT']['#']['BLOCKED']['0']['#']);
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->userid);
if ($user) {
//echo "User ".$dbrec->userid." to user ".$user->new_id."<br />"; //Debug
$dbrec->userid = $user->new_id;
}
//We have to recode the contactid field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->contactid);
if ($user) {
//echo "User ".$dbrec->contactid." to user ".$user->new_id."<br />"; //Debug
$dbrec->contactid = $user->new_id;
}
//Check if the record doesn't exist in DB!
$exist = $DB->get_record('message_contacts', array('userid'=>$dbrec->userid,
'contactid'=>$dbrec->contactid));
if (!$exist) {
//Not exist. Insert
$status = $DB->insert_record('message_contacts',$dbrec);
} else {
//Duplicate. Do nothing
}
}
//Do some output
$counter++;
if ($counter % 10 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if ($counter % 200 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
}
}
if (!defined('RESTORE_SILENTLY')) {
//End ul
echo '</ul>';
}
}
}
}
return $status;
}
//This function creates all the structures for blogs and blog tags
function restore_create_blogs($restore,$xml_file) {
global $CFG, $DB;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
//info will contain the number of blogs in the backup file
//in backup_ids->info will be the real info (serialized)
$info = restore_read_xml_blogs($restore,$xml_file);
//If we have info, then process blogs & blog_tags
if ($info > 0) {
//Count how many we have
$blogcount = $DB->count_records('backup_ids', array('backup_code'=>$restore->backup_unique_code, 'table_name'=>'blog'));
if ($blogcount) {
//Number of records to get in every chunk
$recordset_size = 4;
//Process blog
if ($blogcount) {
$counter = 0;
while ($counter < $blogcount) {
//Fetch recordset_size records in each iteration
$recs = $DB->get_records("backup_ids", array("table_name"=>'blog', 'backup_code'=>$restore->backup_unique_code),"old_id","old_id",$counter,$recordset_size);
if ($recs) {
foreach ($recs as $rec) {
//Get the full record from backup_ids
$data = backup_getid($restore->backup_unique_code,"blog",$rec->old_id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now build the BLOG record structure
$dbrec = new stdClass();
$dbrec->module = backup_todb($info['BLOG']['#']['MODULE']['0']['#']);
$dbrec->userid = backup_todb($info['BLOG']['#']['USERID']['0']['#']);
$dbrec->courseid = backup_todb($info['BLOG']['#']['COURSEID']['0']['#']);
$dbrec->groupid = backup_todb($info['BLOG']['#']['GROUPID']['0']['#']);
$dbrec->moduleid = backup_todb($info['BLOG']['#']['MODULEID']['0']['#']);
$dbrec->coursemoduleid = backup_todb($info['BLOG']['#']['COURSEMODULEID']['0']['#']);
$dbrec->subject = backup_todb($info['BLOG']['#']['SUBJECT']['0']['#']);
$dbrec->summary = backup_todb($info['BLOG']['#']['SUMMARY']['0']['#']);
$dbrec->content = backup_todb($info['BLOG']['#']['CONTENT']['0']['#']);
$dbrec->uniquehash = backup_todb($info['BLOG']['#']['UNIQUEHASH']['0']['#']);
$dbrec->rating = backup_todb($info['BLOG']['#']['RATING']['0']['#']);
$dbrec->format = backup_todb($info['BLOG']['#']['FORMAT']['0']['#']);
$dbrec->attachment = backup_todb($info['BLOG']['#']['ATTACHMENT']['0']['#']);
$dbrec->publishstate = backup_todb($info['BLOG']['#']['PUBLISHSTATE']['0']['#']);
$dbrec->lastmodified = backup_todb($info['BLOG']['#']['LASTMODIFIED']['0']['#']);
$dbrec->created = backup_todb($info['BLOG']['#']['CREATED']['0']['#']);
$dbrec->usermodified = backup_todb($info['BLOG']['#']['USERMODIFIED']['0']['#']);
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$dbrec->userid);
if ($user) {
//echo "User ".$dbrec->userid." to user ".$user->new_id."<br />"; //Debug
$dbrec->userid = $user->new_id;
}
//Check if the record doesn't exist in DB!
$exist = $DB->get_record('post', array('userid'=>$dbrec->userid,
'subject'=>$dbrec->subject,
'created'=>$dbrec->created));
$newblogid = 0;
if (!$exist) {
//Not exist. Insert
$newblogid = $DB->insert_record('post',$dbrec);
}
//Going to restore related tags. Check they are enabled and we have inserted a blog
if ($CFG->usetags && $newblogid) {
//Look for tags in this blog
if (isset($info['BLOG']['#']['BLOG_TAGS']['0']['#']['BLOG_TAG'])) {
$tagsarr = $info['BLOG']['#']['BLOG_TAGS']['0']['#']['BLOG_TAG'];
//Iterate over tags
$tags = array();
$sizetagsarr = sizeof($tagsarr);
for ($i = 0; $i < $sizetagsarr; $i++) {
$tag_info = $tagsarr[$i];
///traverse_xmlize($tag_info); //Debug
///print_object ($GLOBALS['traverse_array']); //Debug
///$GLOBALS['traverse_array']=""; //Debug
$name = backup_todb($tag_info['#']['NAME']['0']['#']);
$rawname = backup_todb($tag_info['#']['RAWNAME']['0']['#']);
$tags[] = $rawname; //Rawname is all we need
}
tag_set('post', $newblogid, $tags); //Add all the tags in one API call
}
}
}
//Do some output
$counter++;
if ($counter % 10 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if ($counter % 200 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
}
}
}
}
}
}
return $status;
}
//This function creates all the course events
function restore_create_events($restore,$xml_file) {
global $DB;
global $CFG, $SESSION;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
//events will contain the old_id of every event
//in backup_ids->info will be the real info (serialized)
$events = restore_read_xml_events($restore,$xml_file);
}
//Get admin->id for later use
$admin = get_admin();
$adminid = $admin->id;
//Now, if we have anything in events, we have to restore that
//events
if ($events) {
if ($events !== true) {
//Iterate over each event
foreach ($events as $event) {
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code,"event",$event->id);
//Init variables
$create_event = false;
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Events', $restore, $info['EVENT']['#'], array('TIMESTART'));
}
//Now build the EVENT record structure
$eve = new stdClass();
$eve->name = backup_todb($info['EVENT']['#']['NAME']['0']['#']);
$eve->description = backup_todb($info['EVENT']['#']['DESCRIPTION']['0']['#']);
$eve->format = backup_todb($info['EVENT']['#']['FORMAT']['0']['#']);
$eve->courseid = $restore->course_id;
$eve->groupid = backup_todb($info['EVENT']['#']['GROUPID']['0']['#']);
$eve->userid = backup_todb($info['EVENT']['#']['USERID']['0']['#']);
$eve->repeatid = backup_todb($info['EVENT']['#']['REPEATID']['0']['#']);
$eve->modulename = "";
if (!empty($info['EVENT']['#']['MODULENAME'])) {
$eve->modulename = backup_todb($info['EVENT']['#']['MODULENAME']['0']['#']);
}
$eve->instance = 0;
$eve->eventtype = backup_todb($info['EVENT']['#']['EVENTTYPE']['0']['#']);
$eve->timestart = backup_todb($info['EVENT']['#']['TIMESTART']['0']['#']);
$eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']);
$eve->visible = backup_todb($info['EVENT']['#']['VISIBLE']['0']['#']);
$eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']);
//Now search if that event exists (by name, description, timestart fields) in
//restore->course_id course
//Going to compare LOB columns so, use the cross-db sql_compare_text() in both sides.
$compare_description_clause = $DB->sql_compare_text('description') . "=" . $DB->sql_compare_text("'" . $eve->description . "'");
$eve_db = $DB->get_record_select('event',
"courseid = ? AND name = ? AND $compare_description_clause AND timestart = ?",
array($eve->courseid, $eve->name, $eve->timestart));
//If it doesn't exist, create
if (!$eve_db) {
$create_event = true;
}
//If we must create the event
if ($create_event) {
//We must recode the userid
$user = backup_getid($restore->backup_unique_code,"user",$eve->userid);
if ($user) {
$eve->userid = $user->new_id;
} else {
//Assign it to admin
$eve->userid = $adminid;
}
//We have to recode the groupid field
$group = backup_getid($restore->backup_unique_code,"groups",$eve->groupid);
if ($group) {
$eve->groupid = $group->new_id;
} else {
//Assign it to group 0
$eve->groupid = 0;
}
//The structure is equal to the db, so insert the event
$newid = $DB->insert_record ("event",$eve);
//We must recode the repeatid if the event has it
//The repeatid now refers to the id of the original event. (see Bug#5956)
if ($newid && !empty($eve->repeatid)) {
$repeat_rec = backup_getid($restore->backup_unique_code,"event_repeatid",$eve->repeatid);
if ($repeat_rec) { //Exists, so use it...
$eve->repeatid = $repeat_rec->new_id;
} else { //Doesn't exists, calculate the next and save it
$oldrepeatid = $eve->repeatid;
$eve->repeatid = $newid;
backup_putid($restore->backup_unique_code,"event_repeatid", $oldrepeatid, $eve->repeatid);
}
$eve->id = $newid;
// update the record to contain the correct repeatid
$DB->update_record('event',$eve);
}
} else {
//get current event id
$newid = $eve_db->id;
}
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"event",
$event->id, $newid);
}
}
}
}
} else {
$status = false;
}
return $status;
}
function restore_execute(&$restore,$info,$course_header,&$errorstr) {
global $CFG, $USER, $DB, $OUTPUT;
$status = true;
//Now create events as needed
if ($status) {
if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string("creatingevents");
}
if (!$status = restore_create_events($restore,$xml_file)) {
if (!defined('RESTORE_SILENTLY')) {
echo $OUTPUT->notification("Could not restore course events!");
} else {
$errorstr = "Could not restore course events!";
return false;
}
}
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
}
if ($status) {
//If we are deleting and bringing into a course or making a new course, same situation
if ($restore->restoreto == RESTORETO_CURRENT_DELETING ||
$restore->restoreto == RESTORETO_EXISTING_DELETING ||
$restore->restoreto == RESTORETO_NEW_COURSE) {
if (!defined('RESTORE_SILENTLY')) {
echo '<li>'.get_string('courseformatdata');
}
if (!$status = restore_set_format_data($restore, $xml_file)) {
$error = "Error while setting the course format data";
if (!defined('RESTORE_SILENTLY')) {
echo $OUTPUT->notification($error);
} else {
$errorstr=$error;
return false;
}
}
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
}
}
//Now, if all is OK, adjust activity events
if ($status) {
if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string("refreshingevents");
}
if (!$status = restore_refresh_events($restore)) {
if (!defined('RESTORE_SILENTLY')) {
echo $OUTPUT->notification("Could not refresh events for activities!");
} else {
$errorstr = "Could not refresh events for activities!";
return false;
}
}
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
}
}

View File

@ -7,6 +7,8 @@ information provided here is intended especially for developers.
specify the ORDER BY clause to be used. Previously it was required
to use the set_source_sql() more complex alternative in places
requiring ordering.
* The old 1.9 files backuplib.php, lib.php and restorelib.php and the bb directory,
(all under /backup) have been deleted and no code should rely on them anymore.
=== 2.4 ===

View File

@ -338,6 +338,8 @@ function upgrade_stale_php_files_present() {
$someexamplesofremovedfiles = array(
// removed in 2.5dev
'/backup/lib.php',
'/backup/bb/README.txt',
'/lib/excel/test.php',
// removed in 2.4dev
'/admin/tool/unittest/simpletestlib.php',

View File

@ -27,7 +27,6 @@
require(dirname(__FILE__).'/../../../../config.php');
require_once(dirname(__FILE__).'/locallib.php');
require_once($CFG->dirroot.'/mod/book/locallib.php');
require_once($CFG->dirroot.'/backup/lib.php');
require_once($CFG->libdir.'/filelib.php');
$id = required_param('id', PARAM_INT); // Course Module ID

View File

@ -25,7 +25,6 @@
require_once('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/backup/lib.php');
// Required for constants in backup_cron_automated_helper
require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php');
@ -115,4 +114,4 @@ if (empty($automatedbackupsenabled)) {
}
echo html_writer::table($table);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
echo $OUTPUT->footer();