MDL-31561: Implemented fix for honoring correct number of course
authorDarko Miletic <dmiletic@moodlerooms.com>
Wed, 8 Feb 2012 19:01:55 +0000 (16:01 -0300)
committerDarko Miletic <dmiletic@moodlerooms.com>
Wed, 8 Feb 2012 19:01:55 +0000 (16:01 -0300)
sections

backup/cc/cc_lib/cc_convert_moodle2.php
backup/cc/cc_lib/cc_resources.php

index ffdc342..5f6d9e4 100644 (file)
@@ -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
index 43b9ac6..eb34779 100644 (file)
@@ -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) {