Wednesday 28 May 2014

Making Google Forms even more awesome.

Im sure that most educators will have discovered Google Forms and thought "Wow, that will be useful", and a few more of you may even have given it a go.
They are great for creating simple small question and answer survey type resources, but soon become very limited when you try to scale it up.
As part of our GCSE Computing course, I want to use unit tests to measure how effectively each topic has been taught and learnt. If I grab a handful of past GCSE papers and create similar questions for each topic, then I should be able to accurately assess whether each group I teach has a high enough understanding to get a good grade in their final exam.
Unfortunately, you soon end up with this:

The main issue that I have with this is how limited it is to edit text. You cannot add line breaks, emphasise text, add sections of text that are information rather than questions etc. Even worse, the text above each question is used in the spreadsheet of responses:

Its such a shame, but obviously we are trying to push the limits with what Google had in mind when they created forms.
Ive seen methods described where you open the page source for the live form and add that to your page, which allows you to improve the appearance slightly but more importantly gave me an idea as to how we can tweak things a whole lot more.
Step 1 - create your form, only add brief details for each question such as "Question 1a" etc.

Ive also added a basic theme.

Step 2 - view the live form and "View Source" - copy all of the text from the source.

Step 3 - open your favourite text editor (I use Notepad++), and paste the source code in.

Step 4 - save the file to your google drive, with a .htm extension. Save the file into a newly created folder, and share the folder as "Public on the web":


You can now view your form, but it doesnt look very good at this stage (Click on the file, then "Open", and then "Preview"):


This is how the form looks before we start tinkering:

There are a few issues!

Look at the code and search for the first question, in this form I see:
<div dir="ltr" class="ss-item  ss-grid"><div class="ss-form-entry">
<label class="ss-q-item-label" for="entry_1166053878"><div class="ss-q-title">1a
</div>
Im going to leave this exactly like that , but add a new <div> tag before it with my more verbose question, including line breaks, bold sections, in fact any HTML decoration I want.

The "Grid" style questions already use a table as layout, so lets add a border to improve the layout.

Change this:
<table border="0" cellpadding="5" cellspacing="0"><thead><tr><td class="ss-gridnumbers ss-gridrow-leftlabel"></td>

To this:
<table border="1" cellpadding="5" cellspacing="0"><thead><tr><td class="ss-gridnumbers ss-gridrow-leftlabel"></td>

Each question will have this text:
<div class="required-message">This is a required question</div>

Search for and remove all occurrences.

"Paragraph text" questions appear in a small box, change this:
<textarea name="entry.1737392296" rows="8" cols="0" class="ss-q-long" id="entry_1737392296" dir="auto" aria-label="1c Automatic update  "></textarea>


To this:
<textarea name="entry.1737392296" rows="8" cols="80" class="ss-q-long" id="entry_1737392296" dir="auto" aria-label="1c Automatic update  "></textarea>

This will just make the box wider on the screen. You can also adjust "rows" if you wish.

Basically, thats it, you may see other bits of text that you dont like - if you are on a domain, and have set it so that you have to be logged in, then you will see your email address at the top of the page. Remove the tag. Ive also changed the background colour in the css at the top of the page. Here is my final form:

Obviously, there is a lot more that you can do, but this technique opens up Google forms to be a far more useful tool for creating tests and exams. Combine it with Flubaroo or some formulae to search for key words and you have a self marking set of re-usable tests.

Sunday 16 March 2014

The Research Process

Im sure that we all find it hard to teach students how to approach any research tasks when they have controlled assessment to do.
I found this great resource which may help:
http://www.educatorstechnology.com/2014/03/an-excellent-guide-on-teaching-students.html

Friday 23 August 2013

Running a web server on a Raspberry Pi

I've been quite frustrated in my attempts to get anything connected to my Raspberry Pi, mainly because it usually involves using a programming language that I only know the basics of, or some obscure application library that isn't very well documented.
As always, back to basics! I've decided to install a web server with PHP and MYSQL, then take it from there - these are tools that I am very proficient in and it will removes the unknowns from the equation. As I expected, this is very easy but I will take it slowly and assume that you are inexperienced. Please feel free to ask questions, point out errors or just generally comment.
Apache is a very popular web server that will let your Raspberry Pi run as a web server which means you will be able to access web pages that have been written and are stored on the Pi.
The web pages are usually written in HTML, but you can add a lot of functionality to the web server by adding another popular programming language called PHP.
Its also good to be able to use a database to store information about any systems that you create on the server.

Step 1 Install Raspbian on your Raspberry Pi.

I arent going to document this as there are hundreds of guides and I will only echo what has already been said. For the record, I used NOOBS (New out of the box software) to install it, then allowed SSH access and used MobaXTerm to access the graphical interface. (This isnt important, you can just as easily do this straight from a normal monitor view)

Step 2 Install Apache, PHP and MYSQL

On the desktop of Raspbian you will see an icon saying "LX Terminal". Click on that and then type this:

sudo apt-get update

The command "sudo" means "run this instruction as an administrator," which in linux is a user called "root".
The apt-get update part tells Raspbian to make sure that all its records of available software are up to date. You will see it trundle off and check lots of things, just leave it alone until you see a coloured command prompt starting "Pi@..."
The next command to type is:

sudo apt-get install apache2 php5 mysql-server

This instructs Raspbian to install the web server (Apache2), PHP version 5 and mysql-server. This will take five minutes or more, its fascinating to read the things that flash by on your screen, all very clever but once you have seen it a couple of dozen times, the delay is just an inconvenience!
You will be asked to set a password for mysql. Make this a secure, complex password and also make sure that you remember it!

Step 3 - Install phpmyadmin

You will now have a web server running (we will check it later) and we could start to add web pages. I've always used a great utility called phpmyadmin which lets you look after any databases running on Apache very easily.
Type this command:

sudo apt-get install phpmyadmin

Again, this takes a while. You will be asked for the MySQL password (the one you specified in step 2) and also for another password which you will use to log on to phpmyadmin once it is installed.

I usually install a GUI interface that is great for controlling a web server, its called webmin. This guide will tell you how to do it, but it isn't essential by any means!

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=6096

Step 4 - check it all works.

Type this command:

ifconfig

Into the terminal window, and Raspbian will tell you lots of information about how it connects to the network.
Look for  a line that starts "inet addr", followed by an IP address such as 192.168.1.210
This is the IP address of your Raspberry Pi. On any other computer on your network, open a browser and type this IP address into the main URL box. You should see a page that says "It works" - well done!
You can also use "http://192.168.1.200/phpmyadmin" to open the phpmyadmin window. It will ask you for the password that you entered in Step3 (nb, not step 2!)

Any web pages for your web server are stored on your raspberry Pi at /var/www
You should see a file there already called "index,html"

If you have come this far, well done! You will now need to work out how you can edit pages on your server and make it do something useful - watch our for future updates when I will be detailing various methods.

Tuesday 20 August 2013

Frustrations and good luck

I dont really want to get distracted today - I need a solid day of coding development to work out how I can make the Raspberry Pi do the things I need it to do to control Pondnet.
Last night, after a successful day of re-jigging existing electrical systems to run by remote control, I went to turn the lights on but they wouldn't work. After checking wiring this morning I found that the power supply unit wasn't working. Its a sealed unit, all the components are sealed in resin and its a chunky "brick". As you can see there is an ominous crack on the side of the case so its either let water in or some connection inside has moved and is no longer connected.
Its rated at 12v 30va so I had a look around my spares box for a replacement unit. The only one that I found was a Netgear one rated at 15v but needs must! It won't fit in the box very easily but at least it doesn't involve any more money!
And then I remembered an old set of lights we had bought for our garden seat and stopped using. Luckily it uses exactly the same connector and is 12v 30va so is perfect. Unlike the pond light unit, it isn't a resin filled unit so I will need to enclose it somehow, probably just by keeping it in the distribution box.
Great, now I can devote some day to coding - pass the coffee and turn the Chemical Brothers up loud!

Pondnet is born!

A bit more progress, had a few things to do so it's been slower than I wished. 
I made a complete hash of fitting the solenoid valve, I managed to not only fit it backwards but also the wrong way round so the box lid would have to face the wall. After some head scratching, I had another go! The valve is a spare part from a washing machine and costs less than a fiver, but does run on mains voltage so has to be used with great care. 
I fitted it inside a ip66 container which means it is certified to remain waterproof when used outside. Its a simple case of connecting a washing machine hose as the input and a hose to the pond as the output. Control is via the two spade contacts. Ive fitted everything inside mains conduit, including the pipes so it's safe and quite neat. 

All the mains devices are now terminated with plugs which go into a distribution board inside an ip50 box (the lower number is because the water proof rating is different mainly due to the large cable entry hole). The pump, ultraviolet, air pump, pond lights and water valve can now all be remote controlled. There is enough room inside the box for my raspberry Pi, power supply and possibly an arduino. 

Tomorrow's job will be to get the Pi to control these remote control sockets via a 433mhz transmitter, then I can think about how the web interface can run. Ive ordered a temperature sensor, which runs on from a single gpio line, and an Ultrasonic Sensor which I can get to measure the water level, it needs two gpio lines.

Saturday 3 August 2013

Setting up a Raspberry Pi to run "Headless"

On my last post I described how frustrating I had found the whole process of setting up my Raspberry Pi. I have had quite a few questions about the method I eventually used, so I am going to go through the eventual method I used in a bit more detail.

Initial Set Up.

This was much harder for me because of the issues in getting my monitor to work.
Plug in a USB keyboard, USB mouse, Ethernet cable and an SD card that has been freshly formatted and has a new uncompressed copy of NOOBS on it.
The two issues I faced here were that I had used a power supply that wasn't compatible (no idea why!) and I couldn't get the display to work. The green light closest to the sound jack socket was flashing in a steady on/off pattern, which I think means that there isn't enough power being delivered (I cant find out if this is the case though, if you have a link to any descriptions, please email me)

Im using a fairly standard VGA-HDMI lead as shown here.
The instructions for this lead mention that you may have to edit a config.txt file to get it to work. With the NOOBS software, this wasn't necessary, plugging a normal VGA lead (With ALL the pins in place, some have pin 9 missing which just adds extra problems)
The problem for me was that when I used a full VGA lead, my monitor displayed a message that I couldn't turn off saying that the resolution was incorrect. When I used a VGA lead with pin 9 missing, the monitor turned itself off after a short while. I spent quite a few hours trying to get this to work properly, in hindsight this was a waste of time!
The NOOBS software lets you choose which OS to install, I picked Raspbian.
After the OS has installed and the Raspberry Pi has rebooted, you will see a configuration menu. Choose the option to enable SSH access and remember to set this as the default. (Ive seen this option in a couple of different places, so I arent going to be precise - its always clearly marked)
Next, we need to get the IP address of the Raspberry Pi. Simply type:
ifconfig
This will display a lot of information, but on the first few lines it will say what the "Inet Addr" is. It will be something like 192.168.1.85
On your PC, download and install Putty and XMing. Double click on Xming to set it running and then open Putty.
Type in the IP address for your Raspberry and then click "Open".
You will be asked for a username which is "Pi" and a password which is "Raspberry"
Next we have to start the graphical interface for Raspbian, which we do by typing:
startlxde
Hopefully, your PC will now open a window in XMing that shows the graphical interface for the Raspberry Pi.
Once you have set this up, you can unplug the keyboard, mouse and monitor from the Raspberry and access it directly from your PC which is I have found to be much simpler.
Good luck, persevere and don't hesitate to get in touch with me if you have any problems.

Wednesday 31 July 2013

Raspberry Pi frustrations

I was really excited when we were given a Raspberry Pi at school to "do whatever you want" with. I was even more excited when we were given five more by OCR!
I didn't really get much chance to do anything with them until this week. We had bought some HDMI-VGA leads which promised to work properly with the Pi and I had checked the many videos out there on how to set them up.
I had a good clearout at home a few weeks ago, and had thrown out an old keyboard because I had a much better one to use, but of course it is a wireless keyboard so wouldn't work with the Pi.
A new keyboard cost me a full fiver from PC World, and then I plugged everything and booted up.
A red and green LED came on and it all looked good. The green LED flashed on and off and then... nothing!
After much searching through the web for help (and finding none, couldnt find out what a flashing green LED meant, just what the patterns of flashing meant), I unplugged everything and tried again. This time, I swapped to another power supply (same 1.2A rating), and my screen flashed and the other three LEDs came on and it looked to be doing something.
I'm sure it was busy, but I had no idea what it was doing because my monitor was blank.
I knew that I probably had to edit a config.txt file on the SD card, but as I was using NOOBS it was hidden in a partition and I couldn't see it on my Windows laptop.
After several hours of trying every trick I could find on the web, I changed monitor leads from the standard blue D plug VGA lead to a much older lead that had pin 9 missing (which is used to power the EEPROM in the monitor for plug and play purposes)
Success! The display eventually came on and I was able to install Raspbian and get the Pi to boot. The monitor kept going to sleep, and it took a few changes to the settings to get it all running, and even then I had an annoying reminder on the display nagging me to change the screen resolution.
I am no stranger to these kinds of issues, but I can see that this would be really frustrating for an inexperienced user.
Anyway, I went into the settings on the Pi and enabled SSH, then loaded Putty and Xming. You can find the IP address of the Pi by typing:
ifconfig
And then use this to connect to the Pi with Putty, fairly standard and easy to do.
Start Xming, then load Putty and connect to the Pi.
Once you have a Telnet session (in the Putty window), type
startlxde
This should open a window which lets you see and use the Pi desktop.
At long last, I can start to play!