Import a Moodle Glossary

Moodle glossary imports need a file in XML format. Here is how I did it for Moodle 3.8

First create a glossary with two entries. Export as XML and you have an example of the file you need.

I used a simple text editor to examine the file. Each entry in the table is sandwiched between entry tags

<?xml version="1.0" encoding="UTF-8"?>

The XML is nicely formatted to help a human reader but it is not necessary. We can create every entry between entry tags as a single line.

There are two bits of information we must supply for a simple glossary, the word and its definition. There are three bits of XML to add, the section before the definition, the section between the word and definition and the section after the definition. Here is a sample entry we must replicate.


And the last section of the XML file is


Create a 5 column spreadsheet. Column 1 is all the XML before the word abandon ie <ENTRY> <CONCEPT>, all on one line. Column 2 is the entry (abandon), column 3 is the XML starting with </CONCEPT> up to <DEFINITION>, column 4 is the definition, then the rest of the XML up to </ENTRY>

Column 6 uses a formula to concatenate columns 1 to 5. Add your words and definitions to columns 2 and 4 and you are good to go.

Now copy all of column 6 to replace the area between the entries tag in your exported file. And you have an XML file ready to import

Using scp and rync to move files

FTP is usually the best choice for transferring files to a remote computer but sometimes for a single file, scp is an alternative. Use this command.
Once it is in place we can unzip it:
It will create a directory structure but the tree will be under ~/transfer. We need to move it while preserving the file structure. The easiest way is to use rsync with the r ( recursive function)
sudo mkdir /var/www/html/xerte
rsync -r ~/transfer/ /var/www/html/xerte

The command copies all the files to the new directory.
Becoming familiar with these commands is very useful when working in Linux. Don’t worry about remembering the syntax – I often google and copy. What is important is knowing which command to use.

Backing up Moodle

If you have students on your Moodle site, you have the responsibility to keep their work safe. Some time ago, while using a cheap VPS, I found my site had simply disappeared. The server was never seen again. Luckily I had course backups manually created and downloaded to my desktop. There were a couple of days old so an embarrassing situation but not critical.

So how should you back up? Automatically, at least daily and with a copy stored in an offsite location. Here is how I do it:

First an automatic course back up. I set this up for around midnight, a time when mos students are finished. The backup creates a .mbz file can be used to restore a course on a different Moodle server. Set this up in:

Site administration -> Courses -> Backups -> Automated backup setup.

Set the schedule to daily, execute time can be left to default ( midnight), and specify the directory to /home/user/backup. You may have to first create this folder manually in Linux.

cd ~
mkdir backup

(The command cd ~ is a shortcut to your home directory ie /home/jimmy/)

Next step is a database dump. You can use the instructions from Moodle docs but there are a few problems with their instructions.

cd /my/backup/directory
mv moodle-database.sql.gz moodle-database-old.sql.gz
mysqldump -h -u myusername --password=mypassword -C -Q -e --create-options mydatabasename > moodle-database.sql
gzip moodle-database.sql

First, the password is exposed in the script, not the best for security. Second, the database backups only go back one day. Finally, the backups are stored on the same server Moodle is running on so failure on the server could wipe Moodle and the backups. I want to suggest a better way – storing up to a week of database dumps, a daily back up offsite, and a daily delete of old files. Here is how to do it.

Copy Moodle back ups off site

In my previous post, I showed how to back up the Moodle database and courses backed up automatically every night to the server running Moodle. All good but what if you lose access to the server? It happens.

You need to move a copy of your backup to a different location. It needs to be automatic and daily as you never know when it may go down.

You can use rsync, sshpass and rsa keys to sync to another Linux machine. The problem is you need another Linux box which is running at backup time. I used an always running obsolete Linux netbook for this and you could also use another VPS at a different location, But there is a better way.

Dropbox gives you 2 Gb of storage. It is free and always available, So how do you automatically back up to Dropbox?

My instructions for this come from Linux Additive Tips A shell script called is used to create a crontab entry which will load your files to a dropbox account. Back up your database dump, course backups. moodledata and moodle code every night and know even if your Production server disappears completely, you can rebuild.

Just one last thing. There is really no need to keep all your backups and even a 2Gb Dropbox is going to fill up. Add this script to your database dump script to remove backups older than 3 days:

find /home/user/backup/ -type f -name '*.mbz' -mtime +3 -exec rm {} \;

Chinese names in Moodle

Handling Chinese names is a big problem for those who can’t read characters. Here is how I handle the names of Chinese students in Moodle.
Chinese students usually have a 3 character name with the first character being their family name. It is also common for students to have an “English” name, which is an informal nickname and can change through the year. I am still unsure how Chinese names are sorted but the lists I am given are sorted by a class number ( Student 1 often through Student 60) and this is based on student ID. Chinese do not appear to have the negative connotations of being referred to by a number,
Moodle expects both a first and surname so how do we fit Chinese names into this pattern?
First of all, I use their school issued user id as their Moodle user id. This is a unique number and I will use the student ID to match Moodle grades to school grades. This is the link between the two systems.
Using language customization, I replace the string “First name” with “English name” and “Surname” with Chinese name. I refer to students by their English names while their Chinese names is written in Chinese characters. That displays an English nickname followed by their 3 character Chinese name ie Cary 格兰特. Having both names are useful for both me and the students as I think of them using their English names, their classmates think of them using their Chinese names.
Google translate is able to translate Hanzi into Pinyin so the Chinese characters can be quickly converted to a phonetic spelling.  Moodle provides a field for “First name – phonetic “so this could be added to this field to allow the names to be easily read by someone like myself.

New Semester

Just over a week to go before the new semester starts. I am in Taiwan and so away from my computer but am looking forward to getting Moodle up and running for my students.

This year I will have computers available in the classroom for each student. In the past I have loaded up students from class lists and since I don’t get this information for a week or so, this has taken a while. This time I will get the students to sign up in the classroom on the first day.

So much to do. As I prepare Moodle I will go through the set up for my classes.

Why use Moodle?

Moodle could be your classroom on the internet. But why should you use Moodle to create your virtual classroom?

Asking what Moodle can do is the wrong question. The right questions are:

  • Which parts of my teaching do I want to improve?
  • How can I be more effective as a teacher?

I currently teach English in China to over 350 students organised into 8 classes and I see them 3 times in two weeks. Some things I wanted to improve:

  • Initial assessment of student ability as individuals and as a class
  • Monitoring of student progress
  • Setting and marking of homework to ensure students maintained good study habits
  • Avoiding total reliance on an end of semester exam

All of these are standard for any teacher and are usually done on paper. However with nearly 60 students in a class marking of student work is onerous and time consuming. Even printing test paper and other resources is difficult – at even 1 page of handout per student per class, I would be printing a 500 page box of paper every week.

What I needed was a low cost way of presenting material and assessing students. It should allow me to base questions on paragraphs of text and avoid the tedium of marking hundreds of submissions each week.

Moodle was the answer for me. My initial use of it was to set and mark homework. In my first semester, I set 10 – 20 questions per week for students to complete outside class and allowed students to repeat the exercise to improve their mark. Each week over 5000 questions had been marked and over the semester, close to 100 000 questions were set, marked and a grade assigned to students. Each homework assignment was marked within seconds and the reasons why it was wrong could be explained to a student.

It was a work load I couldn’t have done manually. I had less than 1 out of 100 students who didn’t complete the majority of the homework and many did the questions over and over to get a perfect score. Students were largely positive and were proud of their scores.

Each teacher has their own set of problems. If many of your problems are due to providing resource material, assessment and grading, then Moodle may improve your teaching.