Ejemplo n.º 1
0
 protected function create_mod_info_details_mod_instances_instance($sheet, $instances_quantity, $instances)
 {
     $instance = '';
     $find_tags = array('[#mod_instance_id#]', '[#mod_name#]', '[#mod_user_info#]');
     for ($i = 1; $i <= $instances_quantity; $i++) {
         $user_info = $instances[$i - 1]['common_cartriedge_type'] == static::CC_TYPE_FORUM ? 'true' : 'false';
         if ($instances[$i - 1]['common_cartriedge_type'] == static::CC_TYPE_EMPTY) {
             if ($instances[$i - 1]['deep'] <= ROOT_DEEP) {
                 continue;
             }
         }
         $replace_values = array($instances[$i - 1]['instance'], entities::safexml($instances[$i - 1]['title']), $user_info);
         $instance .= str_replace($find_tags, $replace_values, $sheet);
     }
     return $instance;
 }
Ejemplo n.º 2
0
 public function generate_moodle_xml()
 {
     global $CFG;
     mkdir(self::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'course_files');
     $sheet_base = self::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');
     $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 entities();
     $entities->move_all_files();
     if (array_key_exists("index", self::$instances)) {
         if (!file_put_contents(self::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'moodle.xml', $result_xml)) {
             self::log_action('Cannot save the moodle manifest file: ' . self::$path_to_tmp_folder . DIRECTORY_SEPARATOR . 'moodle.xml', true);
         } else {
             $status = true;
         }
     } else {
         $status = false;
         notify('The course is empty');
         self::log_action('The course is empty', false);
     }
     return $status;
 }