Visvanath Ratnaweera
Posts made by Visvanath Ratnaweera
For an internal comparison I need to build the course categories tree on a fresh site to be identical, also the same id, to a different site. I thought restoring a dump of the mdl_course_categories table on this (fresh) site would do the trick.
Here's the file I restored:
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19-11.8.6-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: www01
-- ------------------------------------------------------
-- Server version 11.8.6-MariaDB-0+deb13u1 from Debian
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
--
-- Table structure for table `mdl_course_categories`
--
DROP TABLE IF EXISTS `mdl_course_categories`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mdl_course_categories` (
`id` bigint(10) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`idnumber` varchar(100) DEFAULT NULL,
`description` longtext DEFAULT NULL,
`descriptionformat` tinyint(2) NOT NULL DEFAULT 0,
`parent` bigint(10) NOT NULL DEFAULT 0,
`sortorder` bigint(10) NOT NULL DEFAULT 0,
`coursecount` bigint(10) NOT NULL DEFAULT 0,
`visible` tinyint(1) NOT NULL DEFAULT 1,
`visibleold` tinyint(1) NOT NULL DEFAULT 1,
`timemodified` bigint(10) NOT NULL DEFAULT 0,
`depth` bigint(10) NOT NULL DEFAULT 0,
`path` varchar(255) NOT NULL DEFAULT '',
`theme` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `mdl_courcate_par_ix` (`parent`)
) ENGINE=InnoDB AUTO_INCREMENT=1018 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Course categories';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mdl_course_categories`
--
SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0;
LOCK TABLES `mdl_course_categories` WRITE;
/*!40000 ALTER TABLE `mdl_course_categories` DISABLE KEYS */;
INSERT INTO `mdl_course_categories` VALUES
(31,'Grundlagen','','',1,0,10000,0,1,1,1540889739,1,'/31',NULL),
(32,'STEM',NULL,'',1,804,750000,20,1,1,0,3,'/31/804/32',NULL),
[deleted]
(1017,'JUMP-IN-HF','','',1,241,3200000,1,1,1,1777960320,2,'/241/1017',NULL);
/*!40000 ALTER TABLE `mdl_course_categories` ENABLE KEYS */;
UNLOCK TABLES;
COMMIT;
SET AUTOCOMMIT=@OLD_AUTOCOMMIT;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
-- Dump completed on 2026-05-22 16:37:41
It throws:
Error code: unknowncategoryDismiss this notification
- line 276 of /public/course/classes/category.php: core\exception\moodle_exception thrown
- line 419 of /public/course/classes/category.php: call to core_course_category::get()
- line 872 of /public/course/classes/category.php: call to core_course_category::get_default()
- line 59 of /public/course/classes/output/category_action_bar.php: call to core_course_category::is_simple_site()
- line 183 of /public/course/classes/output/category_action_bar.php: call to core_course\output\category_action_bar->get_category_select()
- line 995 of /public/course/renderer.php: call to core_course\output\category_action_bar->export_for_template()
- line 68 of /public/course/index.php: call to core_course_renderer->course_category()
Added a constructed category 1:
(1,'Category 1',NULL,NULL,1,0,10000,0,1,1,1779463546,1,'/1',NULL),
Now no error but the categories are not picked up, neither on mysite/course/ nor Site admin > Courses > Manage courses and categories. They show only the 'Category 1'.

What am I missing?
P.S. Both are identical Moodle 5.1