Menambahkan File JavaScript eksternal (.js) ke Moodle

Terkadang kita perlu menambahkan file javascript (*.js) ke dalam LMS Moodle yang sedang kita kembangkan. Berikut adalah langkah-langkahnya:

Masuk ke Folder Theme Anda
Pertama-tama , masuklah ke direktori /theme/Nama_Theme_Anda. Jika di dalamnya belum ada folder bernama javascript, buatlah folder baru dengan nama tersebut.

Unggah File JavaScript
Letakkan file .js yang ingin ditambahkan ke dalam folder javascript yang baru dibuat.

Edit File config.php
Buka file config.php yang berada di dalam folder theme Anda (/theme/Nama_Theme_Anda/config.php). Di bagian paling bawah file tersebut, tambahkan baris kode berikut untuk menyertakan file JavaScript Anda:

#To load the js files in your header:
$THEME->javascripts = array(‘yourfirstjsfile’,’yoursecondjsfile’); 

#To load the js files in your footer:
$THEME->javascripts_footer = array(‘yourfirstjsfile’,’yoursecondjsfile’);

Perlu dicatat bahwa: Pada saat menambahkan nama file JavaScript dalam konfigurasi, jangan sertakan ekstensi .js. Contohnya, gunakan’youfirstjsfile’ bukan ‘yourfirstjsfile.js’. Agar perubahan tersebut berlaku, maka kita perlu membersihkan cache situs Moodle, kemudian bersihkan cache browser dan reload.

Referensi: https://dzone.com/articles/adding-external-javascript-files-js-into-moodle

Enlightlite bugs resolve

Moodle specification:
Version 3.9.x, 3.10.x
Theme: Enlightlite

changing in enlightlite/classes/core/course_renderer.php
search: top_course_menu

$sql = "SELECT a.category , a.cnt from ( SELECT category , count(category) as cnt FROM {course} C";
$sql .= " INNER JOIN {course_categories} cc ON cc.id = c.category WHERE category != 0 and c.visible <>1 and cc.visible<>1 group by category ) as a order by a.cnt desc ";

Custom Moodle User Profile Page

Follow these steps to customize the user profile page. 

1. Go to theme/config.php file and find this code.

  // My public page.

    ‘mypublic’ => array(

        ‘file’ => ‘columns2.php’,

        ‘regions’ => array(‘side-pre’),

        ‘defaultregion’ => ‘side-pre’,

    ),

2. Create your custom layout file in layout folder and replace it like below

  // My public page.

    ‘mypublic’ => array(

        ‘file’ => ‘yourcustomlayout.php’,

        ‘regions’ => array(‘side-pre’),

        ‘defaultregion’ => ‘side-pre’,

    ),3. Create a template file(yourcustom.mustache) in templates folder in theme.

4. in your custom layout php file get all user information and render it on .mustache file like below

echo $OUTPUT->render_from_template(‘theme_custom/mypublic’, $templatecontext);

Reference:
https://moodle.org/mod/forum/discuss.php?d=370809