I have written a number of quizzes that are generated by a program based in their Moodle user ID. This means that each student receives their own version of a problem. I use it in labs and it encourages student discussion as students show their peers how to go about solving the problem rather than just supplying the answer (which they can't do since each answer is different).
It is hard to describe without an example, and so, an example: I teach an algorithms module and as part of that module, students learn about graphs. Here is an example question on depth first search. You will have to log in to see it, but I can give you a gist of the question without logging in...
Each student is asked to indicate the order in which the nodes of a graph will be visited by depth first search. And each student is given a different graph; here is an example graph: http://toodle.computing.dcu.ie/dyngraph/graph/77_7_3_.3.png
The url indicates that this graph is a static image, but actually it is generated on the fly using a computer program. There are four numbers separated by three underscores. The first number, 77, is a seed. Changing this gives you a different graph. The second number is the number of nodes, third number is the maximum number of outgoing nodes and the final number is a number between 0 and 1 which is the probability that one node will be connected to another (subject to the previous number's constraint).
So, I can now pose a general problem on graphs and each student gets a different version of the problem and it hugely encourages discussion in computer labs. These problems are also automatically marked.
I want to adapt the Moodle Quiz plugin so that I can easily incorporate python code in the description and the solution of the problem. I know that some plugins already exist, but they look as if they provide far more than I need.
I simply want to supply the quiz with the URL of a Python program which will generate the html text of the problem based on a user ID and course ID and also provide a mark for the student response. I just wanted to know if anyone else has done similar work in the past or if anyone has recommendations on how to proceed.
I really am not a PHP person and find it hard to write code in PHP. Also much of the useful open source software (such as the software to draw graphs) already exists in Python.
Thanks for reading this far and for any suggestions,
Thank you Tim.
Those plugins look very useful.
OK, I actually hacked the shortanswer plugin and now I can get the userid, courseid and question name. I was hoping to also get the question category.
The question object does have a category field, but at the moment it is just an number, it doesn't have the actual question category.
Once I have userid, courseid, question category and question name, I can pass that to a url which will return a question specification or an answer as required.
The following is a section of the output when I use print_object with the question object (note that the category value is not the category):
$cat_id = $this->category;
$query = $DB->get_record_sql('select name from mdl_question_categories where id="' . $cat_id . '"');
Thanks for posting Charlie, that should work but you should consider something like
Then it will work if someone has a prefix other than mdl.
I suspect most people most of the time leave the default mdl_ but it is nice to cover unusual situations.
It's good to see an elegant approach.