Category Archives: code

Plone, Drupal, Moodle and ATutor

I’m overdue for an update here on what I’ve been working on.  My current project is a web application for collaboratively sharing, critiquing and improving question items for homeworks and quizzes. Basically a wiki question bank, but more socially-oriented.

In my last post, I was working on Plone and the ECQuiz module of eduComponents.  After a few months I abandoned Plone and never looked back. Plone’s going through a big transition right now and it’s hard to be a newcomer to its scene.  I wish Plone and eduComponents developers well.

I switched my platform to Drupal and its Quiz module. Drupal has an amazing community.  It’s hard to measure a community, but a handy data point is that the Drupal group on Facebook has 3500 members, compared to Plone’s 500.  This Quiz module has an active forum, an IRC channel, and a longish history.

While the Quiz community is strong, its design is lacking for my purposes.  It began 3 years ago as a simple module and has been pulled and contorted over the years to suit different needs.  This is arguably the best way for an open source module to evolve.  Thanks to big contributions from Matt Butcher, the module got some big improvements in Quiz 3.0.  For example, there is now an object-oriented type system for question types so new ones can be added more easily.  (Unfortunately, Drupal data schemas don’t have inheritance like PHP objects do so data properties of the base class have to be included in each subclass.  Unless someone wants to hack around that.)  And now Sivaji is making yet more improvements for Quiz 4.x, as part of his winning GSoC proposal.  Quiz 4.0 will be a polished set of improvements at the end of this summer.

I’ve been exploring the potential for Quiz to take a leap forward by drawing in code from PHP-based learning management systems.  I began with Moodle and hammered its import/export code into Quiz to allow it to handle many more formats.  I was happy having materialized the possibility for re-use in open source, but overall pretty turned off by Moodle’s spaghetti codebase.  Maybe if you’re a longtime Moodle developer it all seems clean and clear, but that wasn’t my experience.  So I’ve kept looking.

ATutor looks promising.  It’s a leaner codebase and looks so far to be a clean design.  It also has much better support for standards, which is important for my question bank in order to interoperate with other systems.  After skimming the source code I realized I would need the db schemas to wrap my head around it so I installed the whole thing on my laptop.  Wow, that was easy.  I just moved the folder within my MAMP htdocs, navigated to it in my browser, and the rest was clicking through web forms.  (There was one step where I had to make a directory manually, but the directions were explicit enough for anybody.)  Thanks ATutor developers, and Happy Canada Day.

I may post again with an assessment.  Please reply in the comments if you’d like to hear this (and why would also help).

MySQL with Python on Mac

This entry will be more technical than most, keying of the “open” and “research” more than “education”.

In an analysis I’m working on, I’m going to be munging the data all sorts of ways and the graphical statistics environment I’ve been using (JMP) is going to be painful for me to use. Particularly because it updates state and it’s hard to remember how I got there. I’ve had great success on a project recently using GNU Make to process the data from raw to beautiful and I want to try that here.

In my other project, the raw data is in XML so I got handy with Python and an XML processor. In this project, my raw data is in a MySQL database. I thought that would be as straightforward, but it hasn’t been. That may be due more to using a Mac this time around though (as opposed to Windows and Linux previously).

In any event, here is what I had to do to get the MySQL-python on my MacBook Pro. I hope this saves someone else the trouble. In the end, I made an .egg, so if you want to skip the rest you can just download that: MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg

First I had to get setuptools working. I noticed had two versions of Python installed, Leopard’s and MacPorts’, and decided to remove the MacPorts one to keep things clean. (Incidentally, I regret ever making use of MacPorts. I’ve much rather have built binaries ala Fink.) Once I had setuptools working I thought I could install the MySQL driver with simply,

easy_install MySQL-python

Unfortunately, that fails with a compile error,

In file included from /usr/local/mysql/include/mysql.h:47,                 from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
error: Setup script exited with error: command 'gcc' failed with exit status 1

Fortunately I found a blog that provided a workaround,
Install MySQL server from mysql.com
Download and unpack the MySQLdb package (download URL here)
Fix the path to mysql_config, either by editing setup-posix.py (editing mysql_config.path value) or adding /usr/local/mysql/bin/ to your PATH. (i.e. export PATH=$PATH:/usr/local/mysql/bin/)
In the folder run python setup.py clean and python setup.py build

At this point you’ll probably get this error,

/usr/include/sys/types.h:92: error: duplicate ‘unsigned’/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers

To get around this, edit _mysql.c to change

#define uint unsigned int
to

#define /* uint unsigned int */
Then build again. You’ll probably see this warning,

ld: warning in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not of required architecture
ld: warning in /usr/local/mysql/lib/libmysqlclient_r.dylib, file is not of required architecture
ld: warning in /usr/local/mysql/lib/libmygcc.a, file is not of required architecture

I ignored them and haven’t encountered any problems. I’m on a 32-bit Intel Mac though. If you’re on 64-bit, this blog post may be able to help.

Run sudo python setup.py install to install.

Then I ran this code to test. Once I knew it was working, I tried to find a way to share the binary. I was able to build a binary .egg with python setup.py bdist_egg, which made MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg

I’d like to upload it to the PyPi record, having registered and set up my .pypirc file, but I don’t have permission. After writing this, I will contact to package index owner, Andy Dustman, and see if he can include it. If he does, then the simple command I was expecting at first should work for 32-bit Mac users now on.

easy_install MySQL-python

And until then, this negligibly longer command should work,

easy_install http://www.cs.cmu.edu/%7Etaleahma/projects/misc/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg