Script to refresh all sections for all courses in Moodle system
$courses = get_courses(); foreach ($courses as $course){ course_create_sections_if_missing($course->id, [0,1,2,3,4,5,6,7,8,9,10,11,12]); rebuild_course_cache($course->id, true); }
Script to refresh all sections for all courses in Moodle system
$courses = get_courses(); foreach ($courses as $course){ course_create_sections_if_missing($course->id, [0,1,2,3,4,5,6,7,8,9,10,11,12]); rebuild_course_cache($course->id, true); }
Create directory /var/backups
mkdir /var/backups
crontab -e
Add Database backup to the cron file:
#Backup Database (Before each day starts, backup Moodle prod DB from MySQL/MariaDB) 4 4 * * * root mysqldump dbname -u user -ppsaaword | gzip > /var/backups/moodle-db-`date +\%Y-\%m-\%d-\%H-\%M-\%S`.sql.gz
Add moodledata backup to the cron file:
4 10 * * * zip -r /var/backups/moodledata-`date +\%Y-\%m-\%d-\%H-\%M-\%S`.zip /var/www/moodledata
Save 30 lasts backups
# Keep 30 SQL database backups and moodledata backups (last 30 backups of moodle) 2 2 * * * find /var/backups/* -mtime +10 -exec rm {} \;
Stack plugin on Moodle 3.3 got the Error: MOODLE CAS failed to return an evaluated expressions. Please check your connection with the CAS
Install Maxima Extension on your Ubuntu Server
sudo apt-get install maxima
In /course/index.php
add this code in line 64
if (($categoryid && !$category->visible && !has_capability('moodle/category:viewhiddencategories', $PAGE->context)) || !has_capability('local/awareness:course', $PAGE->context)) { throw new moodle_exception('unknowncategory'); }
How to upload custom file Moodle function
if(isset($_FILES['imageactivity']) && !empty($_FILES['imageactivity'])){ $file_url = $_FILES['imageactivity']['tmp_name']; $file_content = file_get_contents($file_url); $file_name = $_FILES['imageactivity']['name']; $fs = get_file_storage(); $draftitemid = file_get_unused_draft_itemid(); $contextid_local = 70; // Prepare file record object $fileinfo = array( 'contextid' => 165, // ID of context 165 'component' => 'user', // usually = table name 'filearea' => 'draft', // usually = table name 'itemid' => $draftitemid, // usually = ID of row in table 0 'filepath' => '/', // any path beginning and ending in / 'userid' => $USER->id, 'source' => $file_name, 'filename' => $file_name); // any filename // Create file containing content $fs->create_file_from_string($fileinfo, $file_content); file_prepare_draft_area($draftitemid, $contextid_local, 'local_metadata', 'image', 0); file_save_draft_area_files($draftitemid, $contextid_local, 'local_metadata', 'image', $draftitemid); }
Libreoffice service use CPU 100% on Server Moodle Ubuntu 16.04
Add to config.php file before include:
@error_reporting(E_ALL | E_STRICT); @ini_set('display_errors', '1'); $CFG->debug = (E_ALL | E_STRICT); $CFG->debugdisplay = 1;
After Updating files from MOODLE 3.1.5 to MOODLE 3.1.7 got this error:
Error code: codingerror !! !! Stack trace: * line 513
Continue reading Error code: codingerror !! !! Stack trace: * line 513
Moodle core function:
is_siteadmin();
Invalid signature in authentication with LTI connection.