[Zope] Newbie Questions
J. Cameron Cooper
jccooper@rice.edu
Mon, 13 Aug 2001 16:07:51 -0500
>
>
>Background: I want to build a multiple choice test
>framework. Everybody should be able to create a new account and them
>make tests. Some special people should be able to create new
>questions.
>
>Import and export of questions should be done using XML.
>
>I want to store the questions and the results of the testees in
>ZODB. How do I store data in it? The ZODB-Howto covers only the usage
>of ZODB without ZODB.
>
>
>How do I create a class "testee" and store it in ZODB?
>
>If I use a external method and a own database-file this would be no
>problem. But I think it is a performance problem if every request
>needs to open the external database again.
>
You don't need an external method to do DB work. Get a DB adapter and
use ZSQL methods on it. Zope will (hopefully) maintain a connection pool
with the DB server. Not that I'm advocating that you use an external RDBMS.
Of course, without knowing your exact plans I can only make broad
generalizations, but assuming that you want to have tests that people
take, that only a few people can alter these tests, and that all sorts
of people will be taking them, here's how I would do it:
o make a 'test' class. Do it with ZClasses or Python products
(preferred). It should store questions, probably in a dictionary,
possibly a Tiny Table, and be able to add, change, and delete them (give
this a special permission), and to render a test. Here you can put in
your XML importing as well; perhaps a 'test' object is associated with
an XMLDocument (or whatever the latest/greatest XML thingy is called)
and gathers its contents from the DOM tree of that XML thing.
o make a 'testresults' class, that holds the results of the test in
whatever detail you like. Maybe score, maybe the answers, maybe also
questions depending on if you anticipate the 'test' objects changing and
wheter or not you care. Make the 'test' evaluate a submitted test and
emit a 'testresults' object. Store this in a central folder or in a user
folder or something. This could be a 'takeabletest' which users add
wherever they want, associate with a 'test' and then take.
o store your 'tests' in a place where only authorized people can edit
them, and restrict 'modify test' permission to your admins. Let your
users know where the tests are (a link to a folder or a catalog query)
and they can take the tests. Exactly how that works depends on where you
store the data and what access you are giving your users (ZMI or web
page) but more than likely they test just shows up as taken.
This is the Zope way and should create a very flexible (and
redistributable) system, and it's not really a very complicated or
difficult proposal (although you should do a few example products first
to get used to the vagaries of developing Zope products.) If you don't
want to take the time to do it this way, you could also craft a less
flexible system out of folders, Python Scripts, and DTML Methods. (Hint:
store data in properties of folders.) But this isn't necessarily going
to be pretty, and it might even end up being as hard to do. It will
certainly take more effort in the long run.
--jcc
(with the community)