From 5758596b955d0ddd84ef1d3a365ed4ffb0990178 Mon Sep 17 00:00:00 2001 From: Darko Miletic Date: Wed, 8 Feb 2012 16:01:55 -0300 Subject: [PATCH] MDL-31561: Implemented fix for honoring correct number of course sections --- backup/cc/cc_lib/cc_convert_moodle2.php | 11 ++++++++++- backup/cc/cc_lib/cc_resources.php | 22 ++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/backup/cc/cc_lib/cc_convert_moodle2.php b/backup/cc/cc_lib/cc_convert_moodle2.php index ffdc3424b52..5f6d9e4be1e 100644 --- a/backup/cc/cc_lib/cc_convert_moodle2.php +++ b/backup/cc/cc_lib/cc_convert_moodle2.php @@ -80,9 +80,17 @@ abstract class cc_convert_moodle2 { if ($docp->load($moodle_backup)) { //sections $sections = array(); + $coursef = new XMLGenericDocument(); + $course_file = $dir . DIRECTORY_SEPARATOR .'course' . DIRECTORY_SEPARATOR . 'course.xml'; + $coursef->load($course_file); + $numsections = (int)$coursef->nodeValue('/course/numsections'); $section_list = $docp->nodeList('/moodle_backup/information/contents/sections/section'); if (!empty($section_list)) { + $count = 0; foreach ($section_list as $node) { + if ($count > $numsections) { + break; + } $sectionid = $docp->nodeValue('sectionid', $node); $sectiontitle = $docp->nodeValue('title' , $node); $sectionpath = $docp->nodeValue('directory', $node); @@ -92,7 +100,7 @@ abstract class cc_convert_moodle2 { DIRECTORY_SEPARATOR . $sectionpath . DIRECTORY_SEPARATOR . - 'section.xml'; + 'section.xml'; if ($secp->load($section_file)) { $rawvalue = $secp->nodeValue('/section/sequence'); if ($rawvalue != '$@NULL@$') { @@ -100,6 +108,7 @@ abstract class cc_convert_moodle2 { } } $sections[$sectionid] = array($sectiontitle, $sequence); + $count++; } } //organization title diff --git a/backup/cc/cc_lib/cc_resources.php b/backup/cc/cc_lib/cc_resources.php index 43b9ac65d91..eb34779523d 100644 --- a/backup/cc/cc_lib/cc_resources.php +++ b/backup/cc/cc_lib/cc_resources.php @@ -183,20 +183,14 @@ class cc_resource implements cc_i_resource { throw new Exception('The file doesnt exist!'); } - //TODO: ver el tema de fpatch con el tema de unix y windows - //$fpathtocheck = $this->adjust_path($manifestroot,$fname); - //!empty($fpathtocheck) && - if (GetDepFiles($manifestroot, $fname, $this->folder, $this->files)) { - array_unshift($this->files,$folder.$fname); - $this->init_empty_new(); - $this->href = $folder.$fname; - $this->identifierref = $folder.$fname; - $this->filename = $fname; - $this->isempty = false; - $this->folder = $folder; - } else { - $this->init_clean(); - } + GetDepFiles($manifestroot, $fname, $this->folder, $this->files); + array_unshift($this->files,$folder.$fname); + $this->init_empty_new(); + $this->href = $folder.$fname; + $this->identifierref = $folder.$fname; + $this->filename = $fname; + $this->isempty = false; + $this->folder = $folder; } public function adjust_path($mroot, $fname) {