more progress

When Mood Music
2013-04-19 19:16:00

OK, I’ve got as far as test 2 and History/culture lesson 2 – that’s enough to demonstrate my web-programming, ahem, skills. In place of language lesson 3, there’s a page exhorting students to buy the dead-tree-format dictionary and take the course for real.

Test 2 uses AJAX/JSN to pull the questions out of the database. This is un-necessarily complex for this context, but possibly worthwhile if I was to have lots of questions, and a script that pulled 20 random questions from this pile. Of course, the actual reason for using AJAX/JSON is to get the marks available for doing so.

it’s taken me until now to deal with the situation where a student has passed test 1, but then logs out and returns at a later date. To prevent non-linear progress, the list of lessons in the left sidebar had no links to actual lessons, apart from lesson 1. Then a student would have to go to lesson 1, then from there to test 1, and could only proceed to history/culture lesson 1 by passing test 1 (or by hacking the URL). Access to lesson 2 was only from history/culture lesson 1, and so on.

I realised today that the list of lessons needed to be augmented such that links would be in place if the student had passed relevant lessons. So it was fairly simple to make the side-bar code a PHP file (it had been a single HTML file, included into every relevant page) and then include PHP nuggets calling PHP scripts that echoed enlarged fonts, with links if relevant scores in the DB were >19. (Yes, PHP’s woeful arithmetic bug struck again. Using if (score=20) didn’t work yet again.

(Aarrgghh, I’ve just realised if (score==20) may well have worked! If so, I apologise to PHP!)

So just the admin functions (contact us, amend and delete accounts) to go…

Disappointment

When Mood Music
2013-04-15 15:22:00 blah News Quiz

I’m very disappointed that we didn’t finish the Touro yesterday. Here’s the cyclemeter map of where we got to. (The full route is here.)

After fighting our way up long slopes, in parts an inch deep with rain, and trying to stay on while ever-present but gusty wind did its best to stop us, we’d just started the descent to Crosslee (about 19 miles, 2 hours 20 minutes) when a marshal-car caught up with us. The marshal strongly advised us to turn back – due to flooding and wind, the long route was closed, a river was threatening to burst its banks at Traquair, a rider had been blown off his or her bike and we still had the biggest (and presumably most gusty) ascent ahead of us.

We were both soaked through and shivering, and neither of us were enjoying the ride. My gloves were sodden from rain running down my sleeves, gusty wind meant I couldn’t stay clipped in and visibility was pretty poor. So we made the logically correct but emotionally incorrect decision to turn back. The return to the Gordon Arms was fairly swift (the sun even tried to come out) but cold. We stopped there for about half an hour, enjoying chat with other riders, basking in front of the log fire and wringing out sodden kit.

We were offered a lift back to Peebles but by then the rain had abated slightly and we wanted to ‘finish’ under our own steam. The final 12 miles were lovely – the sun came out, it was warm enough to ride without gloves and I enjoyed pelting downhill through through 4-inch deep floods (Elly didn’t like this).

Back at Peebles High School, spectators were applauding finishers – I don’t know how to describe how fraudulent this felt. We skulked away fairly soon back to our hotel for tea and dry clothes. Both of us cried – we had trained for 4 months, made all that effort for what felt like nothing. The sadness is just about gone and we’ve promised ourselves we’ll go back and do the route so that we can feel we were delayed, not beaten.

We weren’t the only ones advised not to finish – there were already about 40 timing chips in the DNF pile by the time we got back to Peebles, and another Lifescycler wrote ‘I bailed after almost coming to grief on a climb’ (There are other comments here and here [Facebook].) Other Lifescyclers did finish, one despite 4 punctures and another who ‘came off and went underwater at one point…’

In all, we did 38 miles at an average speed of 9·8 mph.

Ah well, Tour de Forth and other sportives beckon…

UPDATE
Thanks so much to Lifescyclers tonight for positive talk and encouragement – now feeling ‘well, we gave it a good shot … and we’ll be back to beat it!’

Here’s some photos (all blagged from Facebook)

border=0 border=0
Andy and his dream-machine conditions en route
border=0 border=0
flooding en route floods at Traquair – yeehah!
border=0 border=0
conditions at finish
border=0 border=0
Bruce ‘finishing’ Bruce and Elly ‘finishing’

progress is for the weak

When Mood Music
2013-04-12 23:54:00

Many websites use databases. And databases use special characters to do things, such as mark the ends of input. For example, a website might use PHP code to look in a table of registered users. If this code doesn’t include suitable protection, nasty people can do nasty things by including the special characters in their input. (See here for examples.)

Fortunately, PHP provides ways to sanitise input by replacing such nasty characters with harmless equivalents. Unfortunately, I can’t get them to work.

My first obstacle was that my test called a piece of javascript to assemble the student’s answers into a string of name-value pairs: answer00=students_answer&answer01=students_answer&…, then tack this onto the URL of the PHP script which handled these answers. The PHP script then used GET to pull the data from the augmented URL, decode this string into separate variables, one per answer. Removing nasty input in javascript looks fiendishly complex.

So I wanted to send the answers straight to the PHP code. My way around doing this was to make my test a form, and accept the ugliness thereof. The javascript piece could go (it was an echo of a technique used in the registration step to admonish when incomplete data was given), so long as I made the test POST its answers straight to the PHP code.

It should, then, have been straightforward to sanitise the input by adapting the examples given at php.net. Several hours of out-of-cheese errors later, I wimped out. Despite the sanitised versions looking exactly as they should (so “text’ became “text’), my answer-processing code choked every time. My approach became let’s assume my website will never be attacked, so the only character I have to worry about is because Klingon uses loads of them!

PHP provides a function that removes any set of characters from a ‘victim’ string – and the result is guaranteed to be a string. So subjecting each answer to removal of would suffice. Eventually I had code that did just this. (It’s unbelievable how many typos can be made in repeating $escapedq00 = str_replace ($search, $replace, $q00); 20 times, even when using copy and paste!

So I can now sanitise answers enough for this classroom exercise. I freely admit, both here and in my code, that it’s jsut not good enough for real life. But I can now move on to the rest of the MoSCoW list. Hurrah! No more out-of-cheese errors, and the webTribble is untroubled.

progress

When Mood Music
2013-04-12 01:05:00

update to previous report

More progress but blindingly slow. I am in deep loathing of PHP:

One of my functions gets a number of rows from a MySQL database. A number of rows can only be zero or a positive integer, depending on the SQL select instruction used. My select instruction narrows this range to 0 or 1, depending on whether a question has been answered correctly. And I’ve echoed both results to screen, many, many times – always 0 for an incorrect answer and 1 for a correct answer

So I should be able to do
if ($numrows = 1) {
$score++;  //update the student’s score

But that doesn’t work. This does:
if ($numrows > 0) {
$score++;  //update the student’s score

That cost me over 4 hours of hair-pulling.

Clumsy code
My code is pretty clumsy, I think. To mark a test of 20 questions:

  1. I set up two 1-D arrays, each of 20 elements. The first contains the student’s answers. The second contains text strings which are the same as the column headings in a MySQL table called wrongright.
  2. For each question, I compare the student’s answer (dragged back out of the first array) with the value dragged from a correct_answers table – this drag uses the contents of the second array. If the answer is correct (this is where the above moan happens),
    1. a variable for the student’s score for this test is incremented by 1
    2. ‘1’ is written to the the MySQL table, in the row for this test and the column for the question being processed.

    If the answer is incorrect, ‘0’ is written.

  3. When all the questions have been processed, the student’s final score is written to a students table, in the row for the current student and the column for this test.
  4. If the final score is greater than 19 (cos again normal integer arithmetic fails), the PHP code exits by sending an HTML page which congratulates the student. Otherwise the PHP code exits by sending an HTML page which tells the student he or she has failed the test.
  5. The ‘you have failed’ page contains many PHP nuggets.
    1. Most just include bits of HTML which are common to all pages – so if I decide to change one of these features, I only need to change one bit of code
    2. The first serious nugget calls the student’s screen name from session storage.
    3. The next calls a script to list the questions answered incorrectly. This code again has two arrays. The first is contains text strings which are the same as the column headings in wrongright. The second has text strings ‘question 01’, … ‘question 20’. For each question, if the relevant field in wrongright contains ‘0’, the relevant bit from the second array is called. So the student is told something like ‘You got the following questions wrong: question 01, question 07, question 20’.
    4. The next calls a script to retrieve this student’s score from the table of students. So the student is told ‘You scored $score out of 20.’
    5. The final one gives the student some feedback. It drags the score back from the table of students, then echoes an epithet back to the HTML page:
      • score < 20, epithet=” Not bad for a human. Miserable for a member of an intelligent species.”
      • score < 18, epithet= ” You must study harder.”
      • score < 15, epithet=” You must study much harder.”
      • score < 10, epithet=” petaQ! (Look it up.)”
      • score < 5), epithet=” You are a miserable excuse for a lobeless Ferengi.”

      This uses a chain of if statements because of my problems with PHP’s integer arithmetic. (It would be so much cleaner to use a switch statement.)

 

MoSCoW
Must

  • Find a way of sanitising input so that apostrophes don’t stuff up my code
  • Write appropriately sanitised answers. (The ‘correct’ answers are currently ‘A’, ‘B’, … , ‘T’)
  • Write history/culture lesson 1 and an unmarked history/culture assignment.

Should

  • language lesson 2
  • test 2
  • history/culture lesson 2 and its unmarked history/culture assignment.
  • A nice ‘you have finished – your final score for the whole scheme was …’ finishing page.

Could

  • language lessons 3-6
  • test 3-6
  • history/culture lesson 3-6 and their unmarked history/culture assignment.

Won’t

  • negative marking – deducting points from the student’s total score
  • if the adjusted total score falls below a certain percentage, send the student back to the beginning
  • a ‘thermometer’ in the right sidebar representing the student’s progress

 

Fun bits

  • the epithets
  • Microsoft = (translating the parts of the word, tunHom [tun = ‘soft’, -Hom = diminutive]).
  • ****ing evil computer = De’wI’ mIgh jay’
  • my code traps ‘out of cheese’ errors (should a certain PHP nugget fail to make contact with the database). All error traps enable users to email the webTribble

 

spinning the word away

When Mood Music
2013-04-11 12:13:00 smug Another brick in the wall (extended vocal mix) – the pink boyz

For all you Facebookers, have a look here.

Last night’s class was stowed out, and someone new to spinning needed a bike right in front of the instructor. So muggins here went on one of the bikes on the stage next to the instructor. You can see the difference between Andy (the instructor) and me, especially at ‘running’. But the exposure meant I couldn’t slack off at all – intense fun!

progress

When Mood Music
2013-04-08 16:15:00

I’m working away at my Web Design and Development coursework.

Achievements so far

  • Registration works. If you omit any of the required data, it will ask you, for example, Are you as ashamed of your town or city as humans should be of their history?
    • I’d like the Address line 2 field to be optional, but the moan-mechanism kicks in if it’s omitted, so the workaround is to make it required.
    • I’d like the ‘register me’ thing to be styled text, not a button – but this is well down the list of requirements.
  • Logging in and out work.
    • I’d like the ‘log out’ thing to be styled text too – again nowhere near a priority.
  • The footer pages (FAQ, site-use policy, etc) are full of in-character text, while being vaguely useful.
  • There are functional ‘mailto’s where relevant. OK, I know I should use forms to avoid spam but who said this site would ever go properly live?
  • Errors where the site doesn’t correctly link to the database are trapped by automatically going to appropriate error-message pages, including opportunities to go back to refreshed versions of the recalcitrant pages or to email the webTribble. He or she will be too busy, ahem, making the Tribble with one back to reply, of course.
  • Lesson 1 is created. I’ve not yet worked out a way to prevent students from jumping straight to level 6. Currently I have one piece of code for the list of lessons – I guess each lesson will need its own code with the same text but omitting ‘forbidden’ links.
  • I’m slightly dreading writing the tests – I fear a combination of AJAX and goodness knows what else will be needed to make these pages mark themselves. As for keeping a running total of honour points – aarrgghh!
  • And if you resort to emailing the webTribble from the FAQ page, after all the work I’ve put into it, the email will have an automatic subject I am as stupid as Deanna Troi.

Here’s my bug/things to do list.
Green = squished
Orange = unsquished or not yet attempted, low priority
Red = unsquished or not yet attempted, high priority

  1. need line 2 of address to be optional
  2. sort error messages
  3. correct sideboxes
  4. language & culture lessons
  5. normal lesson 1
  6. normal lessons 2-5
  7. culture and history lessons
  8. test 1
  9. tests 2-5
  10. thermometer of honour points
  11. E-K dictionary
  12. K-E dictionary
  13. registered needs screen name
  14. sort what happens when duplicate accounts attempted
  15. login and assimilate me should be styled text, not buttons

Ah but I’m learning and having fun – can’t be bad!

cycle news

When Mood Music
2013-04-07 17:43:00

Less than a week until Tour o’ the Borders! Are you as excited as I am at the prospect of cycling 50 miles through pretty hills? Why not?

Anyway, we did a couple of laps of Arthur’s Seat, combined with a wee shopping trip this morning. We’ve not found time to check out the route but I’m fairly confident of finishing in about 5 hours’ cycling time. (We start at 9:30 and must finish by 4pm, so we have 6·5 hours and so must average 7·7mph.)

As I’ve probably moaned about already, the second USB-WERK is on its way back to the vendor so currently I have no way of taking power from Lev’s hub-dynamo to jPhone. I have a couple of options:

  • yesterday I ordered an alternative product called LightCharge
  • if all else fails, I now have a stem-bag which just has room for the external USB battery.
border=0 border=0 border=0
jPhone strapped to LifeProof handlebar-
mount to allow charge door to open
jPhone properly in Lifeproof
handlebar-mount
charging external battery

Oh, and I now have cellphone-tipped liner gloves so I don’t need to freeze while operating jPhone en route. These fit just nicely under my Sealskinz winter gloves. Come the summer (and it can’t come soon enough!), I think they’ll work well with my gel cycling mitts.

Come to think of it, I have more pairs of gloves than footwear:

  1. neoprene sailing gloves (blue, no brand)
  2. fleece gloves (blue, Thinsulate), attached to fleece top
  3. fleece gloves (black, Craghoppers)
  4. gel cycling mitts (red & black, Specialised)
  5. mountain-biking outer gloves (black, grey, brown, SixSixOne)
  6. winter cycling gloves (black, Sealskinz)
  7. supposedly warm (but in practice not) microwaveable gloves (red, black & grey, Alago)
  8. liner gloves, which once had cellphone tips (black, no brand)
  9. liner gloves (black, Gore)
  10. liner gloves with cellphone tips (black, North Face)

 

marked – addendum

When Mood Music
2013-04-06 15:06:00 calm News Now Show, 4 Jan 2013

Cast your mind back to this, in which I moaned about late delivery of marks. Well, the lecturer in question emailed on Thursday 4th

Feedback sheets are now in the school office – you can pick up anytime.

Here’s mine. As far as I can make out, it says

Mission statement Words like sufficient are a bit weak for a mission statement 4/5
Numerical measurements Not sure about the last one 4·5/5
Navigation map & storyboards Extra marks for detail
Well done, nicely presented and annotated
10/10
Visual style Well done, extremely detailed 5/5
TOTAL 23·5/25

Cycling news 2

When Mood Music
2013-04-02 22:24:00 calm none

Following on from the previous report, here’s the cyclemeter map of Monday’s cycle: Arran’s north loop. (I’ve no idea why the map doesn’t show the journey back across the String to Brodick.) Total distance 37·82 miles, at an average speed of 10·86 mph. (The true average will be very slightly higher because I started cyclemeter and then put gloves back before moving off – it was far too cold to cycle without gloves.)

We stopped briefly at

  • the florist just north of Brodick
  • Sannox cemetary to vist Elly’s mum and dad
  • Lochranza (toilet break)
  • Machrie (our second attempt to visit Elly’s friend’s tea-room – no joy thanks to the snow which had stopped everything on Arran’s west side the previous week)

The wind which had helped us up the Boguille (the hill between Sannox and Lochranza) was against us on the west coast – it varied between bracing and horrendous. It didn’t get any better going up the String (the road that crosses Arran east-west), but it made the drop down the String back onto Brodick more interesting. I’m slightly disappointed that I didn’t break my personal downhill speed-record but there were too many cars and cross-gusts to let go of the brakes – or perhaps I’m just a wimp.

Cycling in brilliant sunshine, yet with freezing wind and snow either side of the road was weirdly beautiful. I wish I’d taken more photos…

Here’s some pix from the weekend (click the thumbnails to get full-size views).

Views from Lochranza
view view view

steamed-up camera (Machrie no-tea-room)
steamed-up steamed-up

Lev at Machrie
Lev

Peacock at our hotel
peacock

Marked

When Mood Music
2013-03-31 17:47:00 pissed off posh-hotel muzak

I received the following today:

Dear Student
Your coursework 1 mark today is x%. You can pick up the mark sheet from the school office on Tuesday 16 April – sorry it’s a bit late but I’m not back in Edinburgh until then.

I’m underwhelmed – this communication is from a computing lecturer: one who appears to specialise in online things, even.

  • This mark was given just within the 3-week deadline. However, I believe this deadline is about giving full feedback – so far this has been in the form of annotated marks sheets. As you can see, these won’t be available within the 3-week window. Considering that courseworks 1 and 2 for this module are closely entwined (requirements here), receiving full feedback could make a large difference to the overall module mark. There’s less than 2 weeks from when the mark sheets will be available to when coursework 2 is due.
  • Obviously this lecturer isn’t cut off from email. If it’s possible for other lecturers to email mark sheets as PDFs then it’s possible for this lecturer too.
  • And if it was possible for one of my lecturers to continue supporting students and being an all-round decent chap despite a massive personal misfortune earlier this year, then it’s possible for this lecturer to find a scanner if he’s marked our submissions in dead-tree format. (A few lecturers insist on electronic submissions, partly to avoid wastes of paper and partly to use plagiarism-testing sites.)

By the way, in my case x = 94. This is for 25% of the module, so I have 23·5% so far. Here’s my submission and here’s the updated marks infographic.

It’s currently feeling a bit weird that after all this time, I’m only 53% through my MSc in terms of potential marks. By the end of this term I’ll be 67% through – and then the dissertation, which has to be finished by Christmas 2014 will account for the final third.