Only One .emacs

I keep my Emacs init files on Dropbox – that way I only have to maintain one set of files no matter how many machines I run Emacs on. My local .emacs file simply loads the init files on Dropbox.

One minor problem is that Dropbox can have a different path according to the operating system.

This is easily resolved using the system-type variable. For my set up, I’m only interested in whether I’m running on a ‘gnu/linux or a ‘windows-nt system.
The following code sets the path of my Dropbox folder and then uses the format function to append the appropriate init files to that location. The individual files are then loaded. I’ve split my .emacs file across several files for tidiness and convenience. Even so, it still manages to degenerate into a mess when I’m not watching it.

1: (if (eq system-type 'windows-nt)
2:     (setq dot-emacs-files "c:/Users/username/Dropbox/emacs")
3:   (setq dot-emacs-files  "~/Dropbox/emacs")
4: )
5: 
6: (load (format "%s/%s" dot-emacs-files "packages-dot-emacs.el"))
7: (load (format "%s/%s" dot-emacs-files "org-dot-emacs.el"))
8: (load (format "%s/%s" dot-emacs-files "common-dot-emacs.el"))
9: (load (format "%s/%s" dot-emacs-files "elisp.el"))

The Turtle System

I’ve always been a huge fan of Logo as a way of teaching programming: not just the use of turtle graphics to provide immediate visual feedback, but also the way the structure of the language naturally leads students through key programming concepts as they learn how to draw increasingly complicated shapes.

So I was rather delighted whilst at BETT to discover Peter Millican’s Turtle System. Originally written with Pascal in mind, it’s now being developed to use a simplified version of Java to produce turtle graphics and more.

The system comes as a lightweight Windows exe (which runs perfectly fine on Linux under WINE) and a simplified browser based version.

To program in Java…

  1. View|Display Power User Menu. Amongst other things, this will make the Language option appear in the menu bar
  2. Choose Language|Java. This is the preliminary version. I notice that a Python and BASIC version are still to come.
  3. Choose Help|Illustrative Java Programs to see some samples. Notice the simplified syntax in the main() method signature.

Sample Program

class drawPause
{
    void main()
    {
            colour(green);
            blot(100); //green blot
            pause(1000); //pause 1 sec
            colour(red);
            forward(450); //red line
            pause(1000);
            right(90); //90 degrees
            thickness(9); //thickness 9
            colour(blue);
            pause(1000);
            forward(300); //blue line
    }
}

 

Measuring the Success of a Moodle Implementation

It’s a mistake to measure the success of a Moodle implementation by the amount of content on the site.

Why?

Just think about your own site for a moment.

Many Moodles have loads of resources placed there by staff back in the early days and never looked at since. You know the sort of thing, a member of staff receives some training, decides that Moodle is the best thing ever and spends the next few weeks uploading every PowerPoint they’ve ever written, pasting images onto every topic heading, setting up Forums, writing quizzes and setting assignments. Two months later they realize that what they’ve added isn’t being used, not that it matters because they’ve moved on to a new enthusiasm. Even so, the course remains there and is held up as an example of good practice, despite the fact no one ever looks at it.

And that’s just the tip of the iceberg. Think of the obsolete resources that staff can’t bear to delete or archive, the duplicated materials, the imported materials someone’s put on just in case it might be of use someday…

Although good content will make your site successful, the amount of content is not a measure of success.

So what is?

Well, the simplest measure is to see if those resources are being used. Moodle provides a number of ways of doing this, the simplest being the Participants block. Add this to a course, click on the link and you get a list of participants, sorted by most recent access. It’s easy to see from this when students last logged onto the course. If it’s a few weeks ago then you know that no matter how good your content is, it’s not being viewed.

You can get a more detailed view of what’s being viewed through the course participation reports and the site wide stats.  All of these give you a quick overview of just how well your site is being used. A course may not look impressive, but it could be getting the traffic. It’s the number of hits that counts.

Are those resources being used?

There could be a number of reasons for all that traffic of course, including the fact that a member of staff is simply telling students to log on. This is not necessarily a bad thing: a text book is no less good a learning resource simply because students are instructed to use it.

Hit counts – whether driven by teachers, driven by interesting content, driven by whatever – are the measure of a successful Moodle implementation. Full stop.
… but that’s not the full story, of course.

Because now you have to ask yourself this: is your Moodle effective?  And now you have to start looking at achievement…

YASnippet and Babel

Org-mode allows you to use Babel. As it says in the manual:
Babel is Org-mode’s ability to execute source code within Org-mode documents

Here’s a bit of Java, wrapped up in Babel

#+BEGIN_SRC java :classname example
    public class example
    {
            public static void main (String args [])
            {
                System.out.println("Go Babel!");
            }
    }
#+END_SRC

Put the point in the block and

C-c '      to edit the code
C-c C-c     to run the code

In the past, I never used Babel as often as I should, mainly because I could never quite remember the syntax.

Then I had the idea of adding Babel to YASnippet.  I added the following to my org-mode snippets:

# -*- mode: snippet -*-
# name: jbabel
# key: jbabel
# --
#+BEGIN_SRC java :classname $1
    public class $1
    {
            public static void main (String args [])
            {
                System.out.println("$0");
            }
    }
#+END_SRC

… and now I just have to type jbabel and hit tab to have my Babel block ready to go.

It works with ditaa too. As I could never quite remember all the codes when I needed them, I just put a few of ones I used most frequently in a YASnippet example:

# -*- mode: snippet -*-
# name: ditaa babel
# key: dbabel
# --
#+begin_src ditaa :file $1.png
/-----------------\
| Things to do    |        +-----+
| cGRE            |    |{s}  |
| o Cut the grass *-+----->|     |
| o Buy jam       |    |     |
| o Fix car       |    +-----+
| o Make website  |
\-----------------/
#+end_src

And here’s what it looks like when converted (if you’re reading this on Google+, you might want to head over to my website: TonyBallantyne.com to see the image)
dit

HTML, DOT and Non Turing Complete Languages

I’ve written elsewhere about why I think students should learn textual programming.  One point worth restating is that in my experience it isn’t the syntax that causes students problems when learning to program, it’s the structures.

So why not teach students languages where the confusing structures don’t exist?  And by confusing structures, I mean loops and branches, these are confusing enough for beginners.

Let’s stop there for a moment.  The fact that you’re reading this blog means you’re probably a competent programmer.  You’re probably thinking that there’s nothing very difficult about looping and branching, these are basic concepts, and of course they are.  If you don’t understand these, you can’t program.  And that’s the point I’m trying to make.  Some students will struggle with the concept of a simple loop to print out the numbers from one to ten.  Many more students will struggle to apply that concept of a loop to problems, for example to realise that a simple password entry procedure requires a loop.

I think that it’s a good idea to avoid loops and branches when students begin coding.  Non Turing Complete Languages such as HTML and DOT give students a chance to learn syntax and to get a feel for coding environments whilst getting immediate visual feedback on what they’ve done.   I think that DOT is a great place to start, it’s a real world language with a definite use, one that can be of benefit to most users.  I’ve written more about DOT here.  Follow the link to my Dot and Graphviz Tutorial.

Deleting Whitespace

A whole workout on deleting whitespace? It’s worth it…

You might want to start by enabling whitespace mode: M-x whitespace-mode

Let’s start with closing the gap between lines…

M-^      Join a line with the previous line
C-x C-o       Delete white space after current line up to next line.

What’s great about the above two commands is that the point can be anywhere on the line when you call them.

The next two commands aren’t quite so quick to use, the point needs to be in the whitespace you’re trying to delete.

M-SPACE   Delete all spaces but one between two characters
M-\            Delete all whitespace between two characters

Don’t forget the rectangle commands:

C-x r k      Kills the rectangle between the point and the mark.

Find out more about how to use that command in this workout.
Lastly, removing line breaks. Use

C-M-%  query replace regex
Use C-q C-m or C-q C-j to find the line breaks.

Sending email from Emacs

Sending email from Emacs is remarkably easy for Linux users. The following works for >=Emacs 24; it assumes you have a Gmail account.

1) Open Emacs and hit C-x m to bring up the unsent mail buffer
2) Write a test email and hit C-c C-c to send
3) At the prompts, choose SMTP and then enter smtp.googlemail.com for server.
4) Enter username and password
5) Say yes to save password to ~/.authinfo authentication file.
6) And that's it.  It really is that easy.

If you follow the above process you will see that the following are added to your .emacs file

1: '(send-mail-function (quote smtpmail-send-it))
2: '(smtpmail-smtp-server "smtp.googlemail.com")
3: '(smtpmail-smtp-service 25))

If you’ve saved the password you’ll see that the following has been written to the ~/.authinfo file.

machine smtp.googlemail.com login username port 25 password mypassword

If you’re worried about having that information stored as plaintext, Emacs will read from a ~/.authoinfo.gpg file, if you have GPG installed.

Recently, Gmail has updated its security policies to only accept logins from secure apps. You may have to disable this setting in order to access the account. Given this, and also how much is attached to a Gmail account nowadays, you may want to set up a spare Gmail account just for the purposes of sending email.

Reading Gmail

Setting up Emacs to read Gmail via Gnus isn’t that much harder. However, given the multimedia nature of so many emails nowadays, I don’t find this feature very useful anymore.
What I do find useful is being able to send emails from Emacs. This means I can quickly fire off an email without leaving the editor and thus breaking my workflow.
You can find out more about sending and reading email at http://www.emacswiki.org/emacs/CategoryMail

Elpa, org-mode and Invalid function: org-with-silent-modifications

Like many people, I’ve had problems installing org-mode using elpa, resulting in the well known error

Invalid function: org-with-silent-modifications

This is usually due to not following the installation instructions:

When installing from ELPA, please do so from a fresh Emacs session where no org function has been called.

I’ve encountered this problem a few times on Windows installations, each time through forgetting the above advice. The solution was straightforward, go to (home)/emacs.d/elpa and delete the org file, temporarily rename the .emacs file so that you’re restarting Emacs to a completely fresh session (or start a fresh emacs without any customization with emacs -q -thanks to iNecas).  After that org-mode installs without a hitch.

And then I tried to do the same on Linux.  Same error, same attempted solution.

This time it didn’t work.  I wasted half on hour on this until I tried a complete reboot of the PC.  This time it worked.  The lesson is, when it says fresh Emacs session, it means a completely fresh Emacs session.

Why We Need to Define the Difference between Coding and Programming

A quick search on the Internet suggests that the majority of people say there is no difference between the two terms.

Well, I’m going to suggest a difference: from now on I’m saying that programming is the general term, and that coding refers specifically to text based programming.

It’s quite straightforward: you program your digital video recorder, dishwasher or home alarm system. you code in Java, Python or C++

It’s a useful distinction. It allows you to distinguish between programming in languages such as Scratch, and coding in languages such as Logo.

The National Curriculum in England requires pupils to “use two or more programming languages, at least one of which is textual”, obviously recognizing the importance of coding.

Why is coding so important?

From the standpoint of the professional, it’s important because that’s how you get things done. Programming languages are too restrictive, you’re restricted to the functions built into the language. All the jobs are in coding.

But I believe there’s an important pedagogical reason: coding gives students a better understanding of how computers work. Coding means that students learn syntax and structure. The syntax of coding can be off-putting, it’s an extra thing to learn and it can be difficult for low literacy students. But my experience is that it’s not the syntax that students struggle with.

It’s programming structure that students need to understand. Visual programming languages such as Scratch give the appearance that students are learning. They can produce impressive programs very quickly, but do they really understand what’s going on?

My experience suggests no. It’s not until students begin coding that they really understand structure.

A Successful Moodle Implementation

What makes a successful school Moodle implementation?

Quite simply: consistency.

A typical school will contain a number of different departments (English, Maths, Science, French, Art etc). Teaching staff are notorious for their enthusiasm, they are capable of populating a Moodle implementation with any number of courses within a matter of weeks.   …and that’s when the trouble starts.

Left unchecked, there will be as many types of course as there are teachers. More, in fact. Moodle beginners seem to have a fondness for making a course for every eventuality, so I’ve seen lists of courses something like the following

GCSE Chemistry Year 10 Molecules
GCSE Chemistry Year 10 Reactions (Ms Jones)
GCSE Chemistry Year 10 Reactions (Mr Smith)
GCSE Chemistry
GCSE Chemistry Year 10

The courses are invariably unused. No surprise, the students don’t know where they’re supposed to be looking.

It’s far better, of course, to set up one course called GCSE Chemistry and put all the resources there. That may be obvious to you, it won’t be obvious to teachers.

If you want a clear, consistent structure you have to work for it. You need to give examples of good structure and to constantly monitor what’s going on Moodle and to (politely) ask for changes when they’re needed.

If you don’t, you’ll end up with loads of resources that aren’t actually being visited.  Great for showing off to headteachers and governors, no real use otherwise.