Selaa lähdekoodia

Rename class CourseCopyTestCategory

jmontoyaa 8 vuotta sitten
vanhempi
commit
eb9872167a

+ 1 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/CourseArchiver.php

@@ -227,7 +227,7 @@ class CourseArchiver
         class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\Attendance', 'Attendance');
         class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\CalendarEvent', 'CalendarEvent');
         class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyLearnpath', 'CourseCopyLearnpath');
-        class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyTestcategory', 'CourseCopyTestcategory');
+        class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyTestCategory', 'CourseCopyTestCategory');
         class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseDescription', 'CourseDescription');
         class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseSession', 'CourseSession');
         class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\Document', 'Document');

+ 4 - 3
src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php

@@ -11,7 +11,7 @@ use Chamilo\CourseBundle\Component\CourseCopy\Resources\Announcement;
 use Chamilo\CourseBundle\Component\CourseCopy\Resources\Attendance;
 use Chamilo\CourseBundle\Component\CourseCopy\Resources\CalendarEvent;
 use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyLearnpath;
-use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyTestcategory;
+use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseCopyTestCategory;
 use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseDescription;
 use Chamilo\CourseBundle\Component\CourseCopy\Resources\CourseSession;
 use Chamilo\CourseBundle\Component\CourseCopy\Resources\Document;
@@ -911,8 +911,9 @@ class CourseBuilder
             $courseId
         );
         foreach ($tab_test_categories_id as $test_category_id) {
-            $test_category = new TestCategory($test_category_id);
-            $copy_course_test_category = new CourseCopyTestcategory(
+            $test_category = new TestCategory();
+            $test_category = $test_category->getCategory($test_category_id);
+            $copy_course_test_category = new CourseCopyTestCategory(
                 $test_category_id,
                 $test_category->name,
                 $test_category->description

+ 2 - 2
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php

@@ -497,8 +497,8 @@ class CourseRecycler
     {
         if (isset($this->course->resources[RESOURCE_TEST_CATEGORY])) {
             foreach ($this->course->resources[RESOURCE_TEST_CATEGORY] as $tab_test_cat) {
-                $obj_cat = new TestCategory($tab_test_cat->source_id);
-                $obj_cat->removeCategory();
+                $obj_cat = new TestCategory();
+                $obj_cat->removeCategory($tab_test_cat->source_id);
             }
         }
     }

+ 17 - 12
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

@@ -2051,12 +2051,12 @@ class CourseRestorer
         $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table
         if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) {
             $resources = $this->course->resources;
-            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory ) {
-                $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id;
+            foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory ) {
+                $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $id;
                 // check if this test_category already exist in the destination BDD
                 // do not Database::escape_string $title and $description, it will be done later
-                $title = $CourseCopyTestcategory->title;
-                $description = $CourseCopyTestcategory->description;
+                $title = $CourseCopyTestCategory->title;
+                $description = $CourseCopyTestCategory->description;
 
                 if (TestCategory::category_exists_with_title($title)) {
                     switch ($this->file_option) {
@@ -2068,27 +2068,32 @@ class CourseRestorer
                             while (TestCategory::category_exists_with_title(
                                 $new_title
                             )) {
-                                $new_title .= "_";
+                                $new_title .= '_';
                             }
-                            $test_category = new TestCategory(0, $new_title, $description);
+                            $test_category = new TestCategory();
+                            $test_category->name = $new_title;
+                            $test_category->description = $description;
                             $new_id = $test_category->addCategoryInBDD();
-                            $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $new_id;
+                            $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $new_id;
                             break;
                         case FILE_OVERWRITE:
                             $id = TestCategory::get_category_id_for_title($title);
-                            $my_cat = new TestCategory($id);
+                            $my_cat = new TestCategory();
+                            $my_cat = $my_cat->getCategory($id);
                             $my_cat->name = $title;
                             $my_cat->modifyCategory();
-                            $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id;
+                            $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $id;
                             break;
                     }
                 } else {
                     // create a new test_category
-                    $test_category = new TestCategory(0, $title, $description);
+                    $test_category = new TestCategory();
+                    $test_category->name = $title;
+                    $test_category->description = $description;
                     $new_id = $test_category->addCategoryInBDD();
-                    $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $new_id;
+                    $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $new_id;
                 }
-                $this->course->resources[RESOURCE_TEST_CATEGORY][$id]->destination_id = $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id];
+                $this->course->resources[RESOURCE_TEST_CATEGORY][$id]->destination_id = $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id];
             }
         }
         // lets check if quizzes-question are restored too, to redo the link between test_category and quizzes question for questions restored

+ 2 - 2
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyTestcategory.php → src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyTestCategory.php

@@ -4,11 +4,11 @@
 namespace Chamilo\CourseBundle\Component\CourseCopy\Resources;
 
 /**
- * Class CourseCopyTestcategory
+ * Class CourseCopyTestCategory
  * @author Hubert Borderiou <hubert.borderiou@grenet.fr>
  * @package chamilo.backup
  */
-class CourseCopyTestcategory extends Resource
+class CourseCopyTestCategory extends Resource
 {
     /**
      * The title