On Fri, 2009-04-10 at 02:34 -0700, herr.klein...@googlemail.com wrote: > Thanks Malcom. > > All right lets see if i could put my real problem simpler. Lets say > you are the tutor of a programming course and you want to check the > programming assignments semi-automatically. > So you would set up a Task to which a student can submit a solution. > If the solution is accepted depends on various tests. For example does > the program compute the right output to a given input, is everything > well formated and right commented, is every occurrence of the students > name deleted from the code so that a reviewer that might know the > student can grade unbiased, etc. > These test are configureable for every assignment that uses them. > Every Test inherits a common interface(eg. run_test()) from the > abstract test base class. > Now the first step is to assign a bunch of tests to an assignment. > This is problematic because different tests are different classes/ > tables. A task could have one test trough a generic foreign link, but > again only one. You could probably do with one more level of indirection here. Assignments can contain a one-to-many to a model that contains a generic relation to the right type of test.
class Task(models.Model): ... class Attempt(models.Model): task = models.ForeignKey(Task) content_type = models.ForeignKey(ContentType) object_id = models.IntegerField() test = models.GenericForeignKey() The test / content_type / object_id collection point to your various test classes. You can then run through them with: for attempt in task.attempt_set.all(): attempt.test.run_test(...) [...] > I hope that makes it a bit clearer. > > Cage = Task > Animals = Tests > walk = run_test() > > I think my analogy wasn't that bad. Whatever. When I said I couldn't understand it, I wasn't just making idle conversation. It wasn't at all clear what were classes or models in your original description. This time around, you talked about concrete models and assigning something to something else using many-to-many relations and so forth. It may well have made sense to you, but that's the least of concerns when asking for help. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---