FAQ Database Discussion Community

Export Moodle report in csv file

Does anyone know any Moodle built in feature to export custom report into a csv file? I've tried to find in documentation but there is nothing. There's this old book which also have no practical information on exporting report into a csv file. I've tried to dig into the source...

.Moodle Local plugin , menu item not getting added to Site Administration

I am new to moodle. I have created a local plugin setmotd. A new menu item is not getting added to Site Administration. Using moodle 2.8.5 In lib.php i have placed function : function local_setmotd_extends_settings_navigation($settingsnav, $context) { global $CFG, $PAGE; /* // Only let users with the appropriate capability see...

Moodle: Is it possible to get all blog entries by a teacher/admin in the form of an array etc.?

Just like we have get_courses function to get an array of all the courses, is there a way to retrieve a list (array, object, anything) of all the blog posts made by a user, or may be all of the blog posts on the site? By some function? or by...

Moodle, mysql query users enrolment status by course

this is a query in moodle to get alumn status in courses. A 'X' indicates user is enrolled, empty not enrolled. We have to add a subquery for every course we have... Could anyone help to do a better query? SELECT user1.firstname AS Firstname, user1.lastname AS Lastname, user1.email AS Email,...

Moodle login page language change

In my moodle site english and chinese are enabled. The rest of site changes to chinese when language is changed, but the login page does not change. Can anyone guide me ? Please help.

moodle getting values out of database

I stored several values in new fields of my plugin in the settings.php However now I'm trying to put those values that I made onscreen, and I couldn't find a way to do that in moodle. Is there a way to do this in Moodle? Any help is greatly appreciated....

Why moodle block is not showing?

I have fallowing Moodle document for creating a new block, called "simplehtml" liked document, I can install this block, but why when I put this fallowing code in layout, it is not returning anything for rend? Code in layout for call my block: <?php echo $OUTPUT->blocks('simplehtml', 'span4 desktop-first-column'); ?> ...

Local plugin enabling chinese

I am new to moodle.I have created a local plugin and inside the lang folder created a folder zh_cn for chinese. Inside zh_cn folder i placed php file local_pluginname and put chinese strings.But it is not working. Please help.

How to setup cron script in moodle through plugin

I want to run my cron script at sheduled intervels created at blocks/plugin_name/cron.php . Please help me how to create and call this cron script to run at regular intervels.

moodle development course for version 2.2+

I've just started developing moodle site and looking for a good tutorial, maybe course or book. So far I found this book which is good but it's for old v.1.9 release. The current version is 2.9. Please help me with this. Thanks....

How can I recover from a mistake in installing a plugin?

I mistakenly put the plugin I wanted to install into the mod folder, instead of putting it in mod/local. I clicked on install and got an error, and then I realized my mistake. Now, when I put the plugin into mod/local, I don't get shown any plugins in the list...

Where can I find the columns of each forum-related table in the Moodle database?

I have seen all the 9 tables related to a forum in this diagram. A screenshot of the relevant part of the diagram is as follows. The question is that how can I find out what columns are there in each of these tables? I tried to google it, but...

Moodle - use plugin/db/install.xml or plugin/db/install.php when creating a new plugin?

Is there any reason for which I should prefer one of the means of creating new database tables for a plugin over the other? It seems like most of the core plugins use an XML file but I know that I can also use the $DB->get_manager() to create tables, as...

Is it possible to alter a table when you install a new plugin in the install.xml in moodle?

Basicly, I need to add a new column in the course table. And I do not know how to make this change for then export the module to others schools Without to execute the "alter table" query in each database in each school Thanks!...

applicable_formats for only the user 'My home'

What needs to be in the array in the applicable_formats() function so it only is available on the My home page of the user? I've set my-index to true. acces.php <?php $capabilities = array( 'block/groups:myaddinstance' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( 'user' => CAP_ALLOW ),...

Test Moodle plugin without reinstalling the plugin

How do I test a Moodle plugin without reinstalling it everytime? It's pretty annoying if you change a little thing and then you have to change the version in version.php and reinstalling the plugin to just find out that what you did is not working....

A required parameter (id) was missing

I am trying to move the selected items from one table to another and get this error: A required parameter (id) was missing $objs = array(); $objs[0] =& $mform->createElement('select', 'choosedepartments', get_string('Choose', 'dlist'), $table, $choices, 'size="25"'); $objs[0]->setMultiple(true); $objs[1] =& $mform->createElement('select', "selecteddepartments", get_string('Select', 'dlist'), $schoices, 'size="15"'); $objs[1]->setMultiple(true); $grp =& $mform->addElement('group', 'departmentgrp',...

Why browser-sync is not working with moodle theme

I am trying to using browser-sync with moodle theme, but I am not getting success for using it's features for moodle theme. What I am trying to do is change the color by watching the css file. So I have run below command from moodle root directory. browser-sync start --proxy...

Creating array from html to display using D3 Wordcloud

I'm afraid this is a very basic Javascript question on building an array from HTML elements. I've had a search for answers, but I think there's important fundamentals that aren't clicking for me and I'm going in circles, so some outside, expert perspective would be appreciated! We're using Moodle to...

Authenticating Moodle using phpldapadmin server

I'm using Moodle 2.7,i have enabled LDAP authentication for users.I have a phpldapadmin(openldap) server which with DNS as cn=admin,dc=demoldap,dc=org and i have created many users accounts in the DN. when i tried to login with those user account in moodle im getting the following error "The user account "user1" is...

Where is the latest version of template?

I need to build a custom type of question for Moodle 2.8 The only place I could find a question template is at: https://moodle.org/mod/data/view.php?d=13&rid=443&filter=1 But, when I downloaded the template, in the READ ME file: '''WARNING, THIS TEMPLATE IS NOT COMPLETE YET!''' So, AM I looking in the wrong place...

How to run some function during installation of a moodle block?

I am just wondering if there is any way to run some custom function when a block is being installed? I can see that there is after_installation() function used in a block, but there is no function declaration in the super class block_base.

Mysql left join 4 possible values

we're running this query in moodle database: SELECT l.*, MAX(l.time) as time,cat.id as catid, cat.name as catname,c.id as courseid, c.fullname as coursename, m.name as module, r.revision as revision, r.name as resourcename, sco.name as scormname, glo.name as glossaryname, qui.name as quizname FROM {log} l INNER JOIN {user} u ON l.userid =...

Moodle php get current user country

How can I get current logged in users country from profile information? I have searched many sites, have found some answers, but I haven't got them working. I currently have this code, that doesn't do the work: global $user; if ($user->country == 'Estonia') { redirect($CFG->wwwroot .'/course/view.php?id=15'); } else { redirect($CFG->wwwroot...

Invalid reference to FROM-clause entry for table “mdl_user”

I'm trying to build a report of all users and their score for a particular course for a Moodle v2.7 database (which uses PostgreSQL 9.3. I am getting the following error and have looked at questions and other examples that produce the same error, but none of them provide an...

Update moodle 2.6 to 2.7

When upgrading from moodle 2.6 to 2.7 error occurs. We see a white screen. The version of PHP and MySQL comply with the requirements. If install the moodle 2.7, everything works. Problems when trying to update. MySQL tip table - InnoDb

MOODLE JSON file to direct email to specific region

I have 5 regions: Region1, Region2, Region3, Region4, Region5. Within each region is a number of Proctors (for testing): For Region1 -- Mary, Jack, and Mark When a student takes a test, a generated email is sent to all the Proctors in that Region. This is currently handled by a...

Does Moodle cache User Profile Field for activity restriction?

I am trying to restrict access to Moodle course activities based on a user profile field. The profile field tracks eligibility based on other criteria such as whether they have filled in certain important information about their business. The field is required, locked and set to a default value, although...

Add containing folder to project in PhpStorm

I'm developing a plugin for Moodle and created a project inside my Moodle installation. I'm extending a class called block_base but PhpStorm says undefined class block_base. My guess is that is because all the moodle files (including the class block_base) aren't in the project files. How do I add this...

How can I restore forum posts from a Moodle backup into another server installed from scratch?

Last year I taught an online course in my university Moodle website (back then, running Moodle 1.9) . There were a lot of forum posts in that course that I wanted to save for further analysis so I asked my university's technical staff a backup (.zip) of that course. So...

Cannot find moodle values in database

This might sound stupid, but i'm clueless right now. I'm trying copied the ''page'' module from moodle and restyled it slightly, now I'm trying to access values stored in the database. However I'm unsure how to bring those to display on my page, because I can't even find them in...

Moodle: How to add new independent global language file?

I am customizing moodle in a new project. I want to add my limited strings to my special language file, in order to call it in any place. So I need to add a new file to language packs, e.g. bahar.php Where should I put this file? How I should...

Moodle Reading data from Database: How to SELECT the first record which meets the WHERE clause? TOP does not work

I want to retrieve the blog post title of the latest blog post by a particular user with the id stored in $myUserId. So from this doc, I have learnt to do this: $latestPostSubject = $DB->get_record_sql('SELECT subject FROM {post} WHERE userid = ?', array($meUserId)); The problem is that this returns...

How to convert simple_html_dom object back to string?

I have used PHP Simple HTML DOM Parser to first convert an HTML string to DOM object by str_get_html() method of simple_html_dom.php $summary = str_get_html($html_string); Then I extracted an <img> object from the $summary by foreach ($summary->find('img') as $img) { $image = $img; break; } Now I needed to convert...

How to display course list in moodle form?

I want to display course list in moodle form and using following code; $options = array(); $allcourses = coursecat::get(0)->get_courses(array('recursive' = true); foreach ($allcourses as $course) { $options[$course->id] = $course-fullname; } $mform->addElement('select', 'courseid', get_string('course'), $options); $mform->setDefault('courseid', $currentcourseid); $mform->setType(PARAM_INT); But it displays error at $allcourses = coursecat::get(0)->get_courses(array('recursive' = true); any guidance or...

Where is the LDAP auth settings stored in the Moodle server?

I have recently updated the Moodle LDAP-auth settings under Site Administration > Plugins > Authentication > LDAP Server I have done this to change the LDAP server settings from using our old EDIR to our new and preferred AD. Now I can't log-in. I have gone into the db and...

Linking Moodle with Alfresco

I have recently installed moodle-2.8.3 and alfresco-community-5.0.c on my local. I did the tutorial from packtpub.com My moodle and alfresco works well independently, but when I try to add a file from an alfresco repository I cannot connect to this one. I have added the alfresco link in the...

Moodle Student Login Quiz administration Logs

I am new to moodle I have created a quiz in moodle. For student login, in the Quiz Administration there is "Logs" available. In these logs, the student can view logs for all participants and all activities. Is there any way i can set it so that only the currently...

Moodle Email Function Not Working

Hi i want to send an email as soon as record is inserted in moodle database table, following code is not working if ($recs = $ti_form->get_data()) { // Do something with the data, then redirect to a new page $lastinsertid = $DB->insert_record('suggestions', $recs); $toUser = '[email protected]'; $fromUser = 'ICAN'; $subject...

How do I install moodle with the CodeRunner module on windows localhost?

I'm study and try about moodle now and have installed moodle on windows localhost though I'm not really understand of how it works. Now I want to try install CodeRunner https://github.com/trampgeek/CodeRunner moodle question type on this moodle so I can made a programming question that can compile the submitted program...

How to upgrade MySQL in a Bitnami Moodle stack?

I have a Bitnami Moodle stack I use for local development. When I upgraded the Moodle version to 2.8.1, which is the current production version, the Moodle install page says I need to upgrade from MySQL 5.5.21 to 5.5.31. Is there a way to simply upgrade MySQL within the existing...

Issue in flash course due to auto logout in Moodle

My Moodle version is 2.3.1 I am uploading flash course having 2 different windows 1 is launcher page from which I am launching the actual course in another window which contains flash content for learning purpose. Recently I found a problem due to Auto logout feature of Moodle LMS which...


I want to customize the Moodle login page. That is why I want to change the keywords like "Username" to "uid" and also the keyword "password" to "Userpassword". I'm using Moodle version: 2.7, theme: clean. Suggest me some steps to make changes to those keywords....

Why change of custom.css in “clean” of Moodle theme is not working?

I'm working with Moodle Framework, so I need change layout of clean theme, in the document is written: /style/custom.css This is where all the settings CSS is generated. But why my change in the custom.css is not affect in my layout?...