The Moodle code is a more-or-less standard quiz question module, though due to a deficiency in the Moodle 2 architecture I've also had to write a special quiz question "behaviour" module to install. These two modules are available from two git repositories ( https://github.com/trampgeek/
The student supplied code obviously has to be run in a sandbox that prevents unauthorised system calls and excessive use of memory or cpu time. The sandbox I use is pypy -- see http://doc.pypy.org/en/latest/
To avoid problems with constant stream of pypy updates, and to add a little bit of my own code as a front end, I've forked the base pypy distribution; my fork is available as a mercurial distribution at https://bitbucket.org/
Get the source from the Mercurial repository into a directory /usr/local/pypy-sandbox-4-
Install all the dependencies as per http://pypy.readthedocs.org/
cd /usr/local/pypy-sandbox-4-
python translate.py -O2 --sandbox
[After about half an hour] mv pypy-c /usr/local/pypy-sandbox-4-
One major issue should be mentioned: do you run SElinux? If so, there's an issue with running Python from the webserver (which is necessary to provide the front-end to pypy). It's a known Python/SELinux issue (e.g. seehttp://stackoverflow.com/
So -- too daunting for you? Let me know if you wish to proceed.
Notes that I am making on the install
this is all done on a ubuntu install with LAMP stack.all run from ~
sudo apt-get update
sudo apt-get install libssl0.9.8
sudo apt-get install gcc
sudo apt-get install python-codespeak-libsudo apt-get install python-ctypes
need to install
http://mercurial.selenic.com/downloads/
sudo apt-get install mercurial
and run
hg clone https://bitbucket.org/trampgeek/pypy-sandbox-4-pycode
sudo mv pypy-sandbox-4-pycode/ /usr/local/
cd /usr/local/pypy-sandbox-4-pycode/pypy/translator/goal
python translate.py -O2 --sandbox
wait half an hour to four fours for install
sudo mv pypy-c /usr/local/pypy-sandbox-4-pycode/pypy/translator/sandbox/pypy-sandbox
moodleinschools2.1 install from http://www.moodleinschools.org.nz/download
unzip the pycode downloads that are listed at bitbucket
pycode need to go into /moodle/question/type
the adaptive files need to go into /moodle/question/behaviour
I am amazed that I have now a working pycode when doing the unit tests Site Administration > Development > Unit Tests. You then enter "question/type/pycode" into the box "Only run tests in ...".
Note: I had this working at 2pm, but did not read the email from the developer correctly, which stated, You then enter "question/type/pycode" into the box "Only run tests in ...". Had I done this I would be further along the develop of questions.
One thing I have had to do is to install xdebug http://docs.moodle.org/dev/Profiling_PHP
The next thing is how to setup a quiz question, it looks simple enough, but I think I need to see an example of it.
Seeing examples of the questions and trying to get them working seem to be a bit of a challenge for me at the moment, looks like I may have to get started on learning python.
No comments:
Post a Comment