[Edu-sig] idea to use inspect for python quiz question generation
Jurgis Pralgauskis
jurgis.pralgauskis at gmail.com
Sat Aug 31 16:04:24 CEST 2013
Hi,
I want to make big question-base of basic algirthms' for CS101
and I thought how to describe them in Python
https://code.google.com/p/algorithm-quiz/source/browse/IDEAS.draft.txt
def's would be question templates
and params would make the variations
So the code would be pure Python (so easy to find/get examples ;)
Now the headache is how to convert the py code to Moodle format?
On each call of the question-def I want,
to replace parameters in source with their values,
and then to catch the output (as it is (usually) the answer)
seems inspect + sys.settrace (on calls) could do?
http://docs.python.org/3/library/inspect.html#inspect.getsource
http://docs.python.org/3/library/inspect.html#inspect.getargvalues
http://pymotw.com/2/sys/tracing.html
and output could be catched probably
http://coreygoldberg.blogspot.com/2009/05/python-redirect-or-turn-off-stdout-and.html
or via print redirect to file
I am not much experienced with this area...
Maybe Roberge or others could help - put on the right/best way? :)
--
Jurgis Pralgauskis
tel: 8-616 77613;
Don't worry, be happy and make things better ;)
http://galvosukykla.lt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20130831/0d31e49d/attachment.html>
More information about the Edu-sig
mailing list