can't find data record error in moodle

1. Create a file called fixup.php with these contents: <?php require_once('config.php'); require_once($CFG-> dirroot . '/course/lib.php'); require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); move_courses(array(1,2,3,4,5,6,7,8,9,10), 1); // the numbers from 1 to 10 are courses ids then ',1' is the category where you will be moving all your courses. echo 'Done!'; 2. put it in your top level of your moodle application folder - where the config.php file is. 3. Go to your moodle instance plus /fixup.php in the url.

Change user to admininstrator

To make a user an administrator on a moodle instance, you need to find their UserID and add it to the moodle config table in the database. Step 1. Get the User ID:  select username,id from mdl_user where username="john"; This will print out something like the following: +----------+----+ | username | id | +----------+----+ | john     |  4 | +----------+----+ Step 2. Find out who is/are already administrator/s: select * from mdl_config where name="siteadmins"; This will print out something like this: +----+------------+--------------------------------------------------+ | id | name       | value                                            | +----+------------+--------------------------------------------------+ | 23 | siteadmins | 2,289,3497,10187,4164,10165,10175,210,10181,4184 | +----+------------+--------------------------------------------------+ This means that user ID numbers < 2,289,3497,10187,4164,10165,10175,210,10181,4184 > are admins Step 3. Add your u

migrating moodle from one server to another

When you migrate moodle from one server to another, you have to take a copy of three things and make certain changes. There are some caveats however which I will mention here. Moodle has three main parts, the app itself, the database, and the uploads and cache data repository. We are going to assume that the following paths are used by Moodle: /var/www/moodle/ - the app itself, containing folders like "admin, analytics, auth, availability, badges..." and importantly, the config.php file /var/www/moodle_data/ - the app cache data and uploads, containing the folders "cache, diag, filedir, lang, localcache, lock, muc, sessions, temp, trashdir" Let's assume for this example that your database is called moodle , your database username is moodle , and your password is abc123 . Let's also assume your target server allows you to upload files as root over ssh/scp. We divide the instructions up into source server and target server/new server. Let's assume you

PHP version problems

  How to force a specific version of php on linux: Let's say you want to force the linux machine to use php 7.2 specifically Do this: sudo add-apt-repository -y ppa:ondrej/php sudo apt-get install php7.2 php7.2-cli php7.2-common now tell apache: sudo a2dismod php5.6 sudo a2enmod php7.2 sudo service apache2 restart now tell bash: sudo update-alternatives --set php /usr/bin/php7.2 sudo update-alternatives --set phar /usr/bin/phar7.2 sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2

Controlling moodle from the command line when you can't login

 Sometimes you can't login to moodle because a plugin or other dependency has broken it. Install Moosh. sudo apt-add-repository 'deb trusty main' sudo apt-get update sudo apt-get install moosh The command Moosh understands the following sub-commands: activity-add activity-config-set activity-delete activity-move admin-login admin-remove-orphaned-modules apache-parse-extendedlog apache-parse-missing-files apache-parse-perflog audit-passwords auth-list auth-manage backup-info badge-delete base-path block-add block-manage cache-add-redis-store cache-clear cache-config-get cache-course-rebuild cache-edit-mappings cache-test category-config-set category-create category-delete category-export category-import category-list category-move category-resortcourses chkdatadir code-check cohort-create cohort-enrol cohort-enrolfile cohort-unenrol config-get config-pl

What to do if you crashed your database

Please see this page for detailed instructions.

could not find course/ could not find top level course/ could not find course category

Could not find course category If you get this error (could not find course category) this basically means the course/s that exist don't have categories in the category table. Look at the mdl_course table in mysql. Column 2 is the course category. Every course listed (per row) must have a category identified in the table mdl_course_categories . For example, if you have this as your data (1, 0 , 0, "course name", " course name ", "", "summary" , 0, "site", 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "", 1606214720, 1606215795, 0, 0, 0, 1606215383); You see the course category is zero . But there is a course category number one in the mdl_course_categories  table: |  1 | Miscellaneous | NULL     | NULL        |                 0 |      0 |     10000 |           0 |       1 |          1 |   1606214720 |     1 | /1   | NULL  | If there is a mismatch, correct it, e.g. by updating the course to belon