本文整理汇总了PHP中moodle1_converter类的典型用法代码示例。如果您正苦于以下问题:PHP moodle1_converter类的具体用法?PHP moodle1_converter怎么用?PHP moodle1_converter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moodle1_converter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_facetoface
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/FACETOFACE
* data available
*/
public function process_facetoface($data)
{
global $CFG;
// Get the course module id and context id.
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// Replay the upgrade step 2009042006.
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['description'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// Get a fresh new file manager for this instance.
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_facetoface');
// Convert course files embedded into the intro.
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// Start writing facetoface.xml.
$this->open_xml_writer("activities/facetoface_{$this->moduleid}/facetoface.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'facetoface', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('facetoface', array('id' => $instanceid));
unset($data['id']);
foreach ($data as $field => $value) {
$this->xmlwriter->full_tag($field, $value);
}
return $data;
}
示例2: process_label
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/LABEL
* data available
*/
public function process_label($data)
{
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// get a fresh new file manager for this instance
$fileman = $this->converter->get_file_manager($contextid, 'mod_label');
// convert course files embedded into the intro
$fileman->filearea = 'intro';
$fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $fileman);
// write inforef.xml
$this->open_xml_writer("activities/label_{$moduleid}/inforef.xml");
$this->xmlwriter->begin_tag('inforef');
$this->xmlwriter->begin_tag('fileref');
foreach ($fileman->get_fileids() as $fileid) {
$this->write_xml('file', array('id' => $fileid));
}
$this->xmlwriter->end_tag('fileref');
$this->xmlwriter->end_tag('inforef');
$this->close_xml_writer();
// write label.xml
$this->open_xml_writer("activities/label_{$moduleid}/label.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid, 'modulename' => 'label', 'contextid' => $contextid));
$this->write_xml('label', $data, array('/label/id'));
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();
return $data;
}
示例3: process_forum
/**
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM data
*/
public function process_forum($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_forum');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// Convert the introformat if necessary.
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// start writing forum.xml
$this->open_xml_writer("activities/forum_{$this->moduleid}/forum.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'forum', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('forum', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('discussions');
return $data;
}
示例4: process_hsuforum
/**
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/HSUFORUM data
*/
public function process_hsuforum($data)
{
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_hsuforum');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
if (!array_key_exists('maxattachments', $data)) {
$data['maxattachments'] = 1;
}
if (array_key_exists('multiattach', $data) && empty($data['multiattach'])) {
$data['maxattachments'] = 0;
}
unset($data['multiattach']);
// start writing forum.xml
$this->open_xml_writer("activities/hsuforum_{$this->moduleid}/hsuforum.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'hsuforum', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('hsuforum', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('discussions');
return $data;
}
示例5: process_assignment
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/ASSIGNMENT
* data available
*/
public function process_assignment($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
//store assignment type for possible subplugin conversions.
$this->currentsubpluginname = $data['assignmenttype'];
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_assignment');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// convert the introformat if necessary
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// start writing assignment.xml
$this->open_xml_writer("activities/assignment_{$this->moduleid}/assignment.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'assignment', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('assignment', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
//after writing the assignment type element, let the subplugin add on whatever it wants.
$this->handle_assignment_subplugin($data);
$this->xmlwriter->begin_tag('submissions');
return $data;
}
示例6: process_feedback
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/FEEDBACK
* data available
*/
public function process_feedback($data)
{
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_feedback');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// start writing feedback.xml
$this->open_xml_writer("activities/feedback_{$this->moduleid}/feedback.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'feedback', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('feedback', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('items');
return $data;
}
示例7: process_legacy_resource
/**
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data
* Called by moodle1_mod_resource_handler::process_resource()
*/
public function process_legacy_resource(array $data, array $raw = null)
{
$instanceid = $data['id'];
$currentcminfo = $this->get_cminfo($instanceid);
$moduleid = $currentcminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// Prepare the new imscp instance record.
$imscp = array();
$imscp['id'] = $data['id'];
$imscp['name'] = $data['name'];
$imscp['intro'] = $data['intro'];
$imscp['introformat'] = $data['introformat'];
$imscp['revision'] = 1;
$imscp['keepold'] = 1;
$imscp['structure'] = null;
$imscp['timemodified'] = $data['timemodified'];
// Prepare a fresh new file manager for this instance.
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_imscp');
// Convert course files embedded into the intro.
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$imscp['intro'] = moodle1_converter::migrate_referenced_files($imscp['intro'], $this->fileman);
// Migrate package backup file.
if ($data['reference']) {
$packagename = basename($data['reference']);
$packagepath = $this->converter->get_tempdir_path() . '/moddata/resource/' . $data['id'] . '/' . $packagename;
if (file_exists($packagepath)) {
$this->fileman->filearea = 'backup';
$this->fileman->itemid = 1;
$this->fileman->migrate_file('moddata/resource/' . $data['id'] . '/' . $packagename);
} else {
$this->log('missing imscp package', backup::LOG_WARNING, 'moddata/resource/' . $data['id'] . '/' . $packagename);
}
}
// Migrate extracted package data.
$this->fileman->filearea = 'content';
$this->fileman->itemid = 1;
$this->fileman->migrate_directory('moddata/resource/' . $data['id']);
// Parse manifest.
$structure = $this->parse_structure($this->converter->get_tempdir_path() . '/moddata/resource/' . $data['id'] . '/imsmanifest.xml', $imscp, $contextid);
$imscp['structure'] = is_array($structure) ? serialize($structure) : null;
// Write imscp.xml.
$this->open_xml_writer("activities/imscp_{$moduleid}/imscp.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid, 'modulename' => 'imscp', 'contextid' => $contextid));
$this->write_xml('imscp', $imscp, array('/imscp/id'));
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();
// Write inforef.xml.
$this->open_xml_writer("activities/imscp_{$moduleid}/inforef.xml");
$this->xmlwriter->begin_tag('inforef');
$this->xmlwriter->begin_tag('fileref');
foreach ($this->fileman->get_fileids() as $fileid) {
$this->write_xml('file', array('id' => $fileid));
}
$this->xmlwriter->end_tag('fileref');
$this->xmlwriter->end_tag('inforef');
$this->close_xml_writer();
}
示例8: process_scorm
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/SCORM
* data available
*/
public function process_scorm($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$currentcminfo = $this->get_cminfo($instanceid);
$this->moduleid = $currentcminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_scorm');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// check 1.9 version where backup was created
$backupinfo = $this->converter->get_stash('backup_info');
if ($backupinfo['moodle_version'] < 2007110503) {
// as we have no module version data, assume $currmodule->version <= $module->version
// - fix data as the source 1.9 build hadn't yet at time of backing up.
$data['grademethod'] = $data['grademethod'] % 10;
}
// update scormtype (logic is consistent as done in scorm/db/upgrade.php)
$ismanifest = preg_match('/imsmanifest\\.xml$/', $data['reference']);
$iszippif = preg_match('/.(zip|pif)$/', $data['reference']);
$isurl = preg_match('/^((http|https):\\/\\/|www\\.)/', $data['reference']);
if ($isurl) {
if ($ismanifest) {
$data['scormtype'] = 'external';
} else {
if ($iszippif) {
$data['scormtype'] = 'localtype';
}
}
}
// migrate scorm package file
$this->fileman->filearea = 'package';
$this->fileman->itemid = 0;
$this->fileman->migrate_file('course_files/' . $data['reference']);
// start writing scorm.xml
$this->open_xml_writer("activities/scorm_{$this->moduleid}/scorm.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'scorm', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('scorm', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('scoes');
return $data;
}
示例9: convert_configdata
protected function convert_configdata(array $olddata)
{
$instanceid = $olddata['id'];
$contextid = $this->converter->get_contextid(CONTEXT_BLOCK, $olddata['id']);
$configdata = unserialize(base64_decode($olddata['configdata']));
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'block_html');
// convert course files embedded in the block content
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
$configdata->text = moodle1_converter::migrate_referenced_files($configdata->text, $this->fileman);
$configdata->format = FORMAT_HTML;
return base64_encode(serialize($configdata));
}
示例10: process_legacy_resource
/**
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data
* Called by moodle1_mod_resource_handler::process_resource()
*/
public function process_legacy_resource(array $data, array $raw = null) {
// get the course module id and context id
$instanceid = $data['id'];
$currentcminfo = $this->get_cminfo($instanceid);
$moduleid = $currentcminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// convert legacy data into the new folder record
$folder = array();
$folder['id'] = $data['id'];
$folder['name'] = $data['name'];
$folder['intro'] = $data['intro'];
$folder['introformat'] = $data['introformat'];
$folder['revision'] = 1;
$folder['timemodified'] = $data['timemodified'];
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_folder');
// migrate the files embedded into the intro field
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$folder['intro'] = moodle1_converter::migrate_referenced_files($folder['intro'], $this->fileman);
// migrate the folder files
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
$this->fileman->migrate_directory('course_files/'.$data['reference']);
// write folder.xml
$this->open_xml_writer("activities/folder_{$moduleid}/folder.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid,
'modulename' => 'folder', 'contextid' => $contextid));
$this->write_xml('folder', $folder, array('/folder/id'));
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();
// write inforef.xml
$this->open_xml_writer("activities/folder_{$moduleid}/inforef.xml");
$this->xmlwriter->begin_tag('inforef');
$this->xmlwriter->begin_tag('fileref');
foreach ($this->fileman->get_fileids() as $fileid) {
$this->write_xml('file', array('id' => $fileid));
}
$this->xmlwriter->end_tag('fileref');
$this->xmlwriter->end_tag('inforef');
$this->close_xml_writer();
}
示例11: process_data
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/DATA
* data available
*/
public function process_data($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// replay the upgrade step 2007101512
if (!array_key_exists('asearchtemplate', $data)) {
$data['asearchtemplate'] = null;
}
// replay the upgrade step 2007101513
if (is_null($data['notification'])) {
$data['notification'] = 0;
}
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
$data['introformat'] = FORMAT_HTML;
}
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_data');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// @todo: user data - upgrade content to new file storage
// add 'export' tag to list and single template.
$pattern = '/\\#\\#delete\\#\\#(\\s+)\\#\\#approve\\#\\#/';
$replacement = '##delete##$1##approve##$1##export##';
$data['listtemplate'] = preg_replace($pattern, $replacement, $data['listtemplate']);
$data['singletemplate'] = preg_replace($pattern, $replacement, $data['singletemplate']);
//@todo: user data - move data comments to comments table
//@todo: user data - move data ratings to ratings table
// start writing data.xml
$this->open_xml_writer("activities/data_{$this->moduleid}/data.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'data', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('data', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('fields');
return $data;
}
示例12: process_customlabel
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/CUSTOMLABEL
* data available
*/
public function process_customlabel($data)
{
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// shifts content from name (moodle 1.9 label hacking location) to processed content and
// computes a new explicit name
$storedcontent = base64_decode($data['content']);
$customlabel = json_decode($storedcontent);
$data['processedcontent'] = $data['name'];
$data['name'] = $customlabel->labelclass . $data['id'];
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_customlabel');
// convert course files embedded into the content
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
// try get files and reencode from stored content stub.
$storedcontent = moodle1_converter::migrate_referenced_files($storedcontent, $this->fileman);
$data['content'] = base64_encode($storedcontent);
$data['processedcontent'] = moodle1_converter::migrate_referenced_files($data['processedcontent'], $this->fileman);
// write inforef.xml
$this->open_xml_writer("activities/customlabel_{$moduleid}/inforef.xml");
$this->xmlwriter->begin_tag('inforef');
$this->xmlwriter->begin_tag('fileref');
foreach ($this->fileman->get_fileids() as $fileid) {
$this->write_xml('file', array('id' => $fileid));
}
$this->xmlwriter->end_tag('fileref');
$this->xmlwriter->end_tag('inforef');
$this->close_xml_writer();
// write customlabel.xml
$this->open_xml_writer("activities/customlabel_{$moduleid}/customlabel.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid, 'modulename' => 'customlabel', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('customlabel', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
// finish writing customlabel.xml
$this->xmlwriter->end_tag('customlabel');
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();
return $data;
}
示例13: process_geogebra
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/GEOGEBRA
* data available
*/
public function process_geogebra($data)
{
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_geogebra');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// migrate geogebra package file
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
// Migrate file
parse_str($data['url'], $parsedVarsURL);
try {
$this->fileman->migrate_file('course_files/' . $parsedVarsURL['filename']);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), ' File: \'' . $parsedVarsURL['filename'] . '\' (from URL \'', $data['url'], '\') on GeoGebra activity \'' . $data['name'] . '\' <br>';
}
// From Moodle 2, URL field only contains information about the GGB file location
$data['url'] = $parsedVarsURL['filename'];
if (strrpos($data['url'], '/') !== FALSE) {
// Remove folder path to leave only file name
$data['url'] = substr($data['url'], strrpos($data['url'], '/') + 1);
}
// Remove filename from parsedVarsURL array (to avoid save twice)
unset($parsedVarsURL['filename']);
// Store other attributes in the new param
$data['attributes'] = http_build_query($parsedVarsURL, '', '&');
// start writing geogebra.xml
$this->open_xml_writer("activities/geogebra_{$this->moduleid}/geogebra.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'geogebra', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('geogebra', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
return $data;
}
示例14: process_jclic
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/JCLIC
* data available
*/
public function process_jclic($data)
{
// get the course module id and context id
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_jclic');
// convert course files embedded into the intro
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// migrate jclic package file
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
if (!jclic_is_valid_external_url($data['url'])) {
// Migrate file
try {
$this->fileman->migrate_file('course_files/' . $data['url']);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), ' File: \'', $data['url'], '\' on JClic activity \'' . $data['name'] . '\' <br>';
}
}
// To avoid problems if maxgrade is null
if ($data['maxgrade'] === NULL) {
$data['maxgrade'] = 100;
}
// get grade value from maxgrade
$data['grade'] = $data['maxgrade'];
// start writing jclic.xml
$this->open_xml_writer("activities/jclic_{$this->moduleid}/jclic.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'jclic', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('jclic', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
return $data;
}
示例15: process_rcontent
/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/RCONTENT
* data available
*/
public function process_rcontent($data)
{
global $CFG;
// get the course module id and context id
$instanceid = $data['id'];
$currentcminfo = $this->get_cminfo($instanceid);
$this->moduleid = $currentcminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
// conditionally migrate to html format in summary
if ($CFG->texteditors !== 'textarea') {
$data['intro'] = text_to_html($data['intro'], false, false, true);
}
// get a fresh new file manager for this instance
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_rcontent');
// convert course files embedded into the summary
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
// check 1.9 version where backup was created
$backupinfo = $this->converter->get_stash('backup_info');
if ($backupinfo['moodle_version'] < 2007110503) {
// as we have no module version data, assume $currmodule->version <= $module->version
// - fix data as the source 1.9 build hadn't yet at time of backing up.
if (isset($data['grademethod'])) {
$data['grademethod'] = $data['grademethod'] % 10;
}
}
// start writing rcontent.xml
$this->open_xml_writer("activities/rcontent_{$this->moduleid}/rcontent.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid, 'modulename' => 'rcontent', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('rcontent', array('id' => $instanceid));
foreach ($data as $field => $value) {
if ($field != 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->xmlwriter->begin_tag('grades');
return $data;
}