Jul 10
Last night I was working on determining how long a user had been logged into a PHP application but was having a problem with subtracting timestamps and this is how I solved it.
I was storing two timestamps (as a UNIX timestamp) in the database. One designating the date-time the user logged into the application and the other the date-time of the last activity the user performed. Because I was using UNIX timestamps, which are just the number of seconds sine the UNIX epoch, I subtracted one from the other and used that difference as the input to the PHP function date().
I couldn’t for the life of me work out why the date function was saying that I was logged in for an hour longer than I should have been and it was driving me crazy. It turns out that the reason was that my timezone locale setting in PHP is ‘Europe/London’ and that this causes the date function to adjust for British Summer Time (GMT + 1) thus when I used my timestamp difference in the date() function it translated the difference into a readable format but also added an extra hour.
The solution is to use gmdate() which is identical to the date() function except that the time returned is in Grenwich Mean Time format.
Nov 21
I’ve done quite a bit of work on the project (see the progress page) but I wasn’t sure what to document first because the application is going to store all the information in a MySQL database I thought I’d talk about the structure of the base (or most important) tables.
Questions
The application is going to revolve around questions so there obviously needs to be a table to store some of the details of each question. Each question will need an ID it will have some question text, it will also have a correct answer.
Read the rest of this entry »
Nov 06
This is the XML document type definition I’ve come up with for the KQuestion project. The latest version will also be available at (klkl.co.uk/Kquestion/kquestion.dtd). Note: Although its not clear on this page (because of word wrapping) normally everything between each pair of < & > is on one line but it is clear in the above link.
Read the rest of this entry »
Oct 23
This post follows the multiple choice question theme. I’ve spent quite a bit of time working on how to go about parsing an XML file using PHP. I had to pay particular attention to the structure of the XML file with reference to which elements appeared where and which were repeated but in different orders throughout the document.
I’m the sort who likes to learn by doing and having a play with things. I read a basic php xml parsing tutorial on sitepoint written by Kevin Yank (PHP and XML: Parsing RSS 1.0) it explains the process pretty well so if you want to know the specifics of creating the parser object I recommend you read that brief tutorial or consult the php manual.
Read the rest of this entry »
Oct 09
One of my objectives for Kquestion is for it to be able to parse and generate an XML of multiple choice questions. That’s because I think typing the questions into a template will be a lot quicker than using the application, however, both methods should be available. I’m going talk about the different formats of multiple choice question and then in another post how I’ve implemented them in XML and then talk about the document type definition created for the format.
Isolated single questions
This type of question consists of question text and a list of possible answers. They are isolated in that the question and the answers are used only once.
Read the rest of this entry »
Oct 09
XML is used to store Information about something in a logical format. Information is data that has meaning and that meaning can be represented in XML via its structure. A well written XML schema should be easy to understand and follow. Data should be stored within elements (sometimes referred to as tags) whereas information about the data (metadata) should be stored in attributes.
Below is the XML structure I devised to contain the information about the different questions types discussed in my ‘Multiple Choice Question Formats‘ post. I will refer to the element that contains the different question types as the question type element but in reality the name of the question type element will change depending on the question type.
Read the rest of this entry »
Oct 07
Currently a friend and I are developing a php based multiple choice question application that will hopefully help me and others study for exams etc. This blog will document the progress of and any thoughts about the project.
Recent Comments