I am really excited to be part of this incredibly cool idea - excited enough that setting up and playing around with CSS, HTML, and PHP was my afternoon yesterday. The past ten months really have been my most intense in terms of learning programming. Though I've found plenty of interesting projects to take up my time outside of teaching, the Global Physics Problem Database, and whatever elements I can contribute to it, is probably the challenge that I'm most buzzed about taking up.
For those unaware of what I'm talking about, check out these posts from John Burk (here and here)on the conversations and ideas that have been tossed around for the past couple of weeks. I find I am routinely generating skills-based questions for my students frequently, and if there was a reliable site, NOT blocked by the GFW, that I could easily use with my students for this purpose, I'd get a lot of use out of it. Furthermore, one of the highlighted goals of the project is to document its making so that others, including those with limited experience in web applications, can learn how it is being built. I consider myself one of those novices - my web experience has been limited to a three week effort in the Udacity course on web applications engineering. Not exactly enough background to design the next ed-tech innovation to receive millions of dollars, but luckily there are many talented people in this group from whom I can learn.
The bulk of my time yesterday was spent installing the PHP framework Laravel on my laptop. Despite Andy Rundquist's excellent screencast on doing this on Windows, I was booted from my Ubuntu partition at the time, and said to myself "Why not make things difficult and install it on Linux, the structure of which you still haven't figured out?"
I learned exactly what I wanted to learn - more details about how the Linux filesystem works, where things are located, etc. The tricks I had to make before getting the Laravel default page to work:
- In addition to placing the Laravel directory in the /var/www directory, I had to play around with the permissions for that directory so that Apache & PHP could manipulate those files. I kept getting a 'Laravel failed to open stream: Permission denied" error. The solution I found here worked, but may not have been what I should have done. Oh well - it worked, and it's a local installation, so I'm not so worried about security at this point.
- I needed to manually install php5-mcrypt because it isn't included in the regular installation of php5. Mom, did you know that?
- I did see the Laravel default page pop up at this point - success! I was playing around with suggested code from the documentation but was having trouble getting anything other than this page to load. I spent an hour just on this issue, staring in disbelief at the pages of Laravel documentation and a number of tutorials (like this one)that told me how easy it was to get started, even for a beginner. Then I found a page with the trick: the local host address needed to include index.php in it in order to run any functions I put into /application/routes.php file. Oops.Once I got to this point I was ready to play a bit more. The dog woke me up early, and I have trouble falling back asleep once there's any light on the horizon, so I picked up where I had left off with Codeacademy's courses on CSS. I'm capturing the excitement of learning this stuff for the first time, so for those that have known this for a long time, I apologize if what I am about to say is either painfully obvious or painfully understated.
CSS is the bomb.
I've also never used PHP before, but as I expected, there's enough information out on the web to get a basic idea pretty quickly with the programming knowledge I already have. While the whole Laravel framework is written in PHP itself, the thing that I really like about it is how seamlessly it integrates into HTML code. Here is the code I wrote to generate the list of options at the top of the page, as well as include a welcome message:
Why am I tickled pink by this?
The variables I defined at the top of the code are filled in by the PHP code that appears later in the HTML. If the person loading this page is somehow classified as a student by the variable 'user_type', then that person will see this:
Depending on the user, the content of that menu will change, as can the functionality of each link. I had no idea how easy it was for the page to change what it looks like with a simple addition of PHP code. In the case of the physics problem database, the values of those variables that correspond to the username, the user_type, and the question_text are going to be coming from the database being designed for the project. At the moment, I don't really know how to get that information into the page through PHP, but I know the reason Laravel was chosen was to help make this process as easy as possible.
Again, for those more experienced, I understand that this might seem obvious. I've always wondered exactly how it was that web servers provided different web pages at the same address depending on whether you've logged in, what privileges you have, etc. I remember how cool I thought I was lurking around in web server directories and looking at different HTML files that you normally couldn't access unless you were logged in, which I wasn't - this was before this was identified as the ridiculously obvious security flaw that it was. I understood the idea of cookies and caching, but never took any time to understand exactly how it worked.
Now that I've seen behind the curtain, I'm pumped.
Enough for now though - off to work on end of the year comments. One week is left, consisting of classes, giving final exams, grading final exams, and wrapping up loose ends before returning to the US for some good times with family and friends. Oh, and PHP.
My PHP file can be found at https://gist.github.com/2862463 .