~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: dcoles
  • Date: 2008-08-18 04:52:54 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1022
Tutorials: Now inspects active status of a problem attempt before counting it 
towards your mark for this semester or showing it as a 'partially completed' 
question. This allows problems attempts to be 'removed' without actually 
loosing the history of a students attempts (for possible access in the future).

Show diffs side-by-side

added added

removed removed

Lines of Context:
603
603
    UNION
604
604
        (SELECT problemid, loginid, date, text FROM problem_attempt
605
605
         AS problem_attempt (problemid, loginid, date, text)
606
 
         WHERE loginid = %d AND problemid = %d)
 
606
         WHERE loginid = %d AND problemid = %d AND active)
607
607
    )
608
608
    AS _
609
609
    ORDER BY date DESC
640
640
        # Will return an empty table if the problem has never been
641
641
        # successfully completed.
642
642
        query = """SELECT COUNT(*) FROM problem_attempt
643
 
    WHERE loginid = %d AND problemid = %d AND date <=
 
643
    WHERE loginid = %d AND problemid = %d AND active AND date <=
644
644
        (SELECT date FROM problem_attempt
645
 
            WHERE loginid = %d AND problemid = %d AND complete = TRUE
 
645
            WHERE loginid = %d AND problemid = %d AND complete AND active
646
646
            ORDER BY date ASC
647
647
            LIMIT 1);""" % (loginid, problemid, loginid, problemid)
648
648
        if dry: return query
658
658
            # completed.
659
659
            # Return the total number of attempts, and False for success.
660
660
            query = """SELECT COUNT(*) FROM problem_attempt
661
 
    WHERE loginid = %d AND problemid = %d;""" % (loginid, problemid)
 
661
    WHERE loginid = %d AND problemid = %d AND active;""" % (loginid, problemid)
662
662
            result = self.db.query(query)
663
663
            count = int(result.getresult()[0][0])
664
664
            return (False, count)