Thank you Massimo. The second problem is solved by Niphlod: https://groups.google.com/d/msg/web2py/zryvpiFwWgI/RvmphEN7VzAJ
On Wednesday, July 25, 2012 3:43:01 PM UTC+2, jw wrote: > > Hi! > > I'm trying to develop a E-Learning-System. The idea is to give the student > a bunch of cards to learn every day. > Therefore I have a table 'cards' which includes only the answer. > Table 'userCard' includes the date when the user learnt the card the last > time and in which stage (multiplier for the timedelta) the card is for this > special user. > Table 'subject' holds the name of the subject and table 'studyGroup' hold > the name of the studyGroup of the student. > > To get the cards for the day for this student in a special subject with > the answers for his studyGroup and with only the cards he didnt learn the > last days I tried the following select: > > groupCards = db((db.groupCards.card_id == db.card.id) \ > & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \ > & (session.chosenSubject_id == db.card.subject_id) > & (db.userCard.stage <= 5) \ > & (db.userCard.lastTimeLearned < (datetime.date.today() - datetime > .timedelta(days=(1)))) > & ((datetime.date.today()) <= db.userCard.lastTimeLearned) > ).select(db.userCard.ALL, left=db.userCard.on((db.userCard.card_id > == db.card.id))) > > > I used the left outer join to include the cards, he never learned before. > The userCards are created later if they don't exist. > > Now I have the problem, that I have userCard before and in the select. In > the select, it seems, that I can't do the both querys and without them > before select, there is no card selected at all. > > The other problem is, that in timedelta, I would like to change the '1' > with db.userCard.stage, but I only get the exception, that I can't use a > field in timedelta. > > Any idea? > > P.S.: Sorry for my english ;o) > --

