On Thu, Jul 26, 2012 at 12:13 AM, jw <[email protected]> wrote:
> Hi,
>
> my question is about the following query. I'm planning to program an
> e-learning software. For this I use three tables to select the cards to
> learn for today.
> Table "cards" contains the question, "userCard" contains the progress for
> the special student (lastTimeLearned as a multiplicator for the calculating
> of the next time to learn), "subject" contains the name of the subject and
> groupCard contains the answer for the special group.
>
> 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))))
> ).select(db.userCard.id,db.card.id,
> left=db.userCard.on((db.userCard.card_id == db.card.id)))
>
> I would like to select in this query all the cards for a specific student
> in a choosen subject, with the answers of his learnGroup (groupCard) and
> only the cards he doesn't learned today. I try to use the left outer join,
> because there are cards, the user learns them for the first time.
> I tried many hours to find a correct query but now i feel desperate.
>
> The other thing is the '1' in the timedelta. I get the exception, that it
> is not allowed to use a field in timedelta.
>
from datetime import date, timedelta
& (db.userCard.lastTimeLearned < (date.today() - timedelta(days=1)))
Can somebody please help me?
> P.S.: Sory for my english!
>
> --
>
>
>
>
--