Permalink
Browse files

MDL-29956: Implement common cartridge export (r16882)

  • Loading branch information...
1 parent 3319af8 commit 42dffc6febd333ade45e4dcdc66e3ee8d2d743cb @mrmark mrmark committed with stronk7 Oct 26, 2011
Showing with 15,661 additions and 196 deletions.
  1. +2 −1 backup/backup.class.php
  2. +205 −0 backup/cc/cc112moodle.php
  3. +171 −108 backup/cc/cc2moodle.php
  4. +40 −0 backup/cc/cc_includes.php
  5. +64 −0 backup/cc/cc_lib/cc_asssesment.php
  6. +181 −0 backup/cc/cc_lib/cc_basiclti.php
  7. +41 −0 backup/cc/cc_lib/cc_builder_creator.php
  8. +194 −0 backup/cc/cc_lib/cc_convert_moodle2.php
  9. +49 −0 backup/cc/cc_lib/cc_converter_basiclti.php
  10. +61 −0 backup/cc/cc_lib/cc_converter_forum.php
  11. +46 −0 backup/cc/cc_lib/cc_converter_lti.php
  12. +59 −0 backup/cc/cc_lib/cc_converter_resource.php
  13. +62 −0 backup/cc/cc_lib/cc_converter_url.php
  14. +129 −0 backup/cc/cc_lib/cc_converters.php
  15. +93 −0 backup/cc/cc_lib/cc_forum.php
  16. +71 −0 backup/cc/cc_lib/cc_general.php
  17. +116 −0 backup/cc/cc_lib/cc_interfaces.php
  18. +377 −0 backup/cc/cc_lib/cc_manifest.php
  19. +236 −0 backup/cc/cc_lib/cc_metadata.php
  20. +58 −0 backup/cc/cc_lib/cc_metadata_file.php
  21. +60 −0 backup/cc/cc_lib/cc_metadata_resource.php
  22. +278 −0 backup/cc/cc_lib/cc_organization.php
  23. +244 −0 backup/cc/cc_lib/cc_resources.php
  24. +383 −0 backup/cc/cc_lib/cc_utils.php
  25. +566 −0 backup/cc/cc_lib/cc_version1.php
  26. +93 −0 backup/cc/cc_lib/cc_version11.php
  27. +131 −0 backup/cc/cc_lib/cc_version_base.php
  28. +99 −0 backup/cc/cc_lib/cc_weblink.php
  29. +168 −0 backup/cc/cc_lib/gral_lib/ccdependencyparser.php
  30. +261 −0 backup/cc/cc_lib/gral_lib/cssparser.php
  31. +131 −0 backup/cc/cc_lib/gral_lib/functions.php
  32. +149 −0 backup/cc/cc_lib/gral_lib/parser.php
  33. +419 −0 backup/cc/cc_lib/gral_lib/pathutils.php
  34. +406 −0 backup/cc/cc_lib/xmlbase.php
  35. +4 −7 backup/cc/entities.class.php
  36. +58 −0 backup/cc/entities11.class.php
  37. +58 −12 backup/cc/entity.forum.class.php
  38. +4 −4 backup/cc/entity.label.class.php
  39. +25 −26 backup/cc/entity.quiz.class.php
  40. +12 −11 backup/cc/entity.resource.class.php
  41. +119 −0 backup/cc/entity11.basiclti.class.php
  42. +177 −0 backup/cc/entity11.forum.class.php
  43. +112 −0 backup/cc/entity11.lti.class.php
  44. +956 −0 backup/cc/entity11.quiz.class.php
  45. +112 −0 backup/cc/entity11.resource.class.php
  46. +4 −0 backup/cc/includes/constants.php
  47. +1 −1 backup/cc/schemas/domainProfile_4/ims_qtiasiv1p2.xsd
  48. +1 −1 backup/cc/schemas/domainProfile_4/ims_qtiasiv1p2_def_copy.xsd
  49. +1 −1 backup/cc/schemas/domainProfile_4/ims_qtiasiv1p2_localised.xsd
  50. +1 −1 backup/cc/schemas/imscp_v1p2.xsd
  51. +1 −1 backup/cc/schemas/imscp_v1p2_localised.xsd
  52. +19 −0 backup/cc/schemas11/cc11libxml2validator.xsd
  53. +203 −0 backup/cc/schemas11/ccv1p1_imsccauth_v1p1.xsd
  54. +827 −0 backup/cc/schemas11/ccv1p1_imscp_v1p2_v1p0.xsd
  55. +222 −0 backup/cc/schemas11/ccv1p1_imsdt_v1p1.xsd
  56. +202 −0 backup/cc/schemas11/ccv1p1_imswl_v1p1.xsd
  57. +822 −0 backup/cc/schemas11/ccv1p1_lommanifest_v1p0.xsd
  58. +273 −0 backup/cc/schemas11/ccv1p1_lomresource_v1p0.xsd
  59. +1,890 −0 backup/cc/schemas11/ccv1p1_qtiasiv1p2p1_v1p0.xsd
  60. +194 −0 backup/cc/schemas11/imsbasiclti_v1p0p1.xsd
  61. +231 −0 backup/cc/schemas11/imslticc_v1p0p1.xsd
  62. +207 −0 backup/cc/schemas11/imslticm_v1p0.xsd
  63. +288 −0 backup/cc/schemas11/imslticp_v1p0.xsd
  64. +145 −0 backup/cc/schemas11/xml.xsd
  65. +1 −1 backup/cc/sheets/course_header.xml
  66. +30 −0 backup/cc/sheets/course_modules_mod_basiclti.xml
  67. +2 −2 backup/cc/sheets/course_modules_mod_forum.xml
  68. +2 −2 backup/cc/sheets/course_modules_mod_label.xml
  69. +18 −0 backup/cc/sheets/course_modules_mod_lti.xml
  70. +3 −3 backup/cc/sheets/course_modules_mod_resource.xml
  71. +2 −2 backup/cc/sheets/course_question_categories_question_category.xml
  72. +3 −3 backup/cc/sheets/course_question_categories_question_category_question.xml
  73. +2 −2 backup/cc/sheets/course_question_categories_question_category_question_answer.xml
  74. +1 −1 backup/cc/sheets/info_details_mod_instance.xml
  75. +1,837 −0 backup/cc/sheets/moodle_blti_export.xml
  76. +253 −0 backup/cc/validator.php
  77. +165 −0 backup/converter/imscc11/backuplib.php
  78. +124 −0 backup/converter/imscc11/lib.php
  79. +13 −0 backup/converter/moodle1/backuplib.php
  80. +25 −1 backup/moodle2/backup_final_task.class.php
  81. +25 −1 backup/moodle2/backup_root_task.class.php
  82. +118 −0 backup/moodle2/backup_root_task.class.php.orig
  83. +4 −0 backup/util/helper/backup_general_helper.class.php
  84. +50 −3 backup/util/helper/convert_helper.class.php
  85. +12 −0 backup/util/settings/base_setting.class.php
  86. +157 −0 backup/util/settings/setting_dependency.class.php
  87. +2 −1 lang/en/backup.php
View
@@ -41,7 +41,8 @@
// Backup format
const FORMAT_MOODLE = 'moodle2';
const FORMAT_MOODLE1 = 'moodle1';
- const FORMAT_IMSCC = 'imscc';
+ const FORMAT_IMSCC1 = 'imscc1';
+ const FORMAT_IMSCC11 = 'imscc11';
const FORMAT_UNKNOWN = 'unknown';
// Interactive
View
@@ -0,0 +1,205 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * @package moodlecore
+ * @subpackage backup-imscc
+ * @copyright 2011 Darko Miletic (dmiletic@moodlerooms.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
+
+require_once($CFG->dirroot . '/backup/cc/cc2moodle.php');
+require_once($CFG->dirroot . '/backup/cc/entities11.class.php');
+require_once($CFG->dirroot . '/backup/cc/entity11.resource.class.php');
+require_once($CFG->dirroot . '/backup/cc/entity11.forum.class.php');
+require_once($CFG->dirroot . '/backup/cc/entity11.quiz.class.php');
+require_once($CFG->dirroot . '/backup/cc/entity11.lti.class.php');
+
+class cc112moodle extends cc2moodle {
+ const CC_TYPE_FORUM = 'imsdt_xmlv1p1';
+ const CC_TYPE_QUIZ = 'imsqti_xmlv1p2/imscc_xmlv1p1/assessment';
+ const CC_TYPE_QUESTION_BANK = 'imsqti_xmlv1p2/imscc_xmlv1p1/question-bank';
+ const CC_TYPE_WEBLINK = 'imswl_xmlv1p1';
+ const CC_TYPE_ASSOCIATED_CONTENT = 'associatedcontent/imscc_xmlv1p1/learning-application-resource';
+ const CC_TYPE_BASICLTI = 'imsbasiclti_xmlv1p0';
+
+ public static $namespaces = array('imscc' => 'http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1',
+ 'lomimscc' => 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest',
+ 'lom' => 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource',
+ 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
+ 'cc' => 'http://www.imsglobal.org/xsd/imsccv1p1/imsccauth_v1p1');
+
+ public static $restypes = array('associatedcontent/imscc_xmlv1p1/learning-application-resource', 'webcontent');
+ public static $forumns = array('dt' => 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1');
+ public static $quizns = array('xmlns' => 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2');
+ public static $resourcens = array('wl' => 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1');
+ public static $basicltins = array(
+ 'xmlns' => 'http://www.imsglobal.org/xsd/imslticc_v1p0',
+ 'blti' => 'http://www.imsglobal.org/xsd/imsbasiclti_v1p0',
+ 'lticm' => 'http://www.imsglobal.org/xsd/imslticm_v1p0',
+ 'lticp' => 'http://www.imsglobal.org/xsd/imslticp_v1p0'
+ );
+
+
+ public function __construct($path_to_manifest) {
+ parent::__construct($path_to_manifest);
+ }
+
+ public function generate_moodle_xml () {
+
+ global $CFG;
+
+ mkdir(static::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'course_files');
+
+ $sheet_base = static::loadsheet(SHEET_BASE);
+
+ // MOODLE_BACKUP / INFO / DETAILS / MOD
+ $node_info_details_mod = $this->create_code_info_details_mod();
+
+ // MOODLE_BACKUP / BLOCKS / BLOCK
+ $node_course_blocks_block = $this->create_node_course_blocks_block();
+
+ // MOODLE_BACKUP / COURSES / SECTIONS / SECTION
+ $node_course_sections_section = $this->create_node_course_sections_section();
+
+ // MOODLE_BACKUP / COURSES / QUESTION_CATEGORIES
+ $node_course_question_categories = $this->create_node_question_categories();
+
+ // MOODLE_BACKUP / COURSES / MODULES / MOD
+ $node_course_modules_mod = $this->create_node_course_modules_mod();
+
+ // MOODLE_BACKUP / COURSE / HEADER
+ $node_course_header = $this->create_node_course_header();
+
+ // GENERAL INFO
+ $filename = optional_param('file', 'not_available.zip', PARAM_RAW);
+ $filename = basename($filename);
+
+ $www_root = $CFG->wwwroot;
+
+ $find_tags = array('[#zip_filename#]',
+ '[#www_root#]',
+ '[#node_course_header#]',
+ '[#node_info_details_mod#]',
+ '[#node_course_blocks_block#]',
+ '[#node_course_sections_section#]',
+ '[#node_course_question_categories#]',
+ '[#node_course_modules#]');
+
+ $replace_values = array($filename,
+ $www_root,
+ $node_course_header,
+ $node_info_details_mod,
+ $node_course_blocks_block,
+ $node_course_sections_section,
+ $node_course_question_categories,
+ $node_course_modules_mod);
+
+ $result_xml = str_replace($find_tags, $replace_values, $sheet_base);
+
+ // COPY RESOURSE FILES
+ $entities = new entities11();
+
+ $entities->move_all_files();
+
+ if (array_key_exists("index", self::$instances)) {
+
+ if (!file_put_contents(static::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'moodle.xml', $result_xml)) {
+ static::log_action('Cannot save the moodle manifest file: ' . static::$path_to_tmp_folder . DIRECTORY_SEPARATOR . 'moodle.xml', true);
+ } else {
+ $status = true;
+ }
+
+ } else {
+ $status = false;
+ static::log_action('The course is empty', false);
+ }
+
+ return $status;
+
+ }
+
+ public function convert_to_moodle_type ($cc_type) {
+ $type = parent::convert_to_moodle_type($cc_type);
+
+ if ($type == TYPE_UNKNOWN) {
+ if ($cc_type == static::CC_TYPE_BASICLTI) {
+ $type = MOODLE_TYPE_LTI;
+ }
+ }
+
+ return $type;
+ }
+
+ protected function create_node_question_categories () {
+
+ $quiz = new cc11_quiz();
+
+ static::log_action('Creating node: QUESTION_CATEGORIES');
+
+ $node_course_question_categories = $quiz->generate_node_question_categories();
+
+ return $node_course_question_categories;
+ }
+
+ protected function create_code_info_details_mod () {
+ $result = parent::create_code_info_details_mod();
+
+ $count_blti = $this->count_instances(MOODLE_TYPE_LTI);
+
+ $sheet_info_details_mod_instances_instance = static::loadsheet(SHEET_INFO_DETAILS_MOD_INSTANCE);
+
+ $blti_mod = '';
+
+ if ($count_blti > 0) {
+ $blti_instance = $this->create_mod_info_details_mod_instances_instance($sheet_info_details_mod_instances_instance, $count_blti, static::$instances['instances'][MOODLE_TYPE_LTI]);
+ $blti_mod = $blti_instance ? $this->create_mod_info_details_mod(MOODLE_TYPE_LTI, $blti_instance) : '';
+ }
+
+ return $result . $blti_mod;
+ }
+
+ protected function create_node_course_modules_mod () {
+ $resources = new cc11_resource();
+ $forums = new cc11_forum();
+ $quiz = new cc11_quiz();
+ $basiclti = new cc11_lti();
+
+ static::log_action('Creating node: COURSE/MODULES/MOD');
+
+ // RESOURCES (WEB CONTENT AND WEB LINK)
+ $node_course_modules_mod_resource = $resources->generate_node();
+
+ // FORUMS
+ $node_course_modules_mod_forum = $forums->generate_node();
+
+ // QUIZ
+ $node_course_modules_mod_quiz = $quiz->generate_node_course_modules_mod();
+
+ //BasicLTI
+ $node_course_modules_mod_basiclti = $basiclti->generate_node();
+
+ $node_course_modules = $node_course_modules_mod_resource .
+ $node_course_modules_mod_forum .
+ $node_course_modules_mod_quiz .
+ $node_course_modules_mod_basiclti;
+
+ return $node_course_modules;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 42dffc6

Please sign in to comment.