PaferaPy Async 0.1
ASGI framework focused on simplicity and efficiency
Loading...
Searching...
No Matches
studylist.py
Go to the documentation of this file.
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
4import time
5
6from pafera.validators import *
7
8import pafera.db
10
11import apps.learn.card
13
14# *********************************************************************
16 """The studylist contains every problem that a student needs to know
17 and keeps track of how fast the student answers them. Problems that
18 require more time or were answered incorrectly will be repeated more
19 often so that the student can get a better grasp on them.
20 """
21
22 _dbfields = {
23 'rid': ('INTEGER PRIMARY KEY', 'NOT NULL',),
24 'classid': ('INT', 'NOT NULL', BlankValidator()),
25 'userid': ('INT', 'NOT NULL', ),
26 'problemid': ('INT', 'NOT NULL', ),
27 'score': ('INT', 'NOT NULL DEFAULT 0',),
28 'results': ('DICT', "NOT NULL DEFAULT ''",),
29 'flags': ('INT', 'NOT NULL DEFAULT 0',),
30 }
31 _dbindexes = ()
32 _dblinks = []
33 _dbdisplay = ['classid', 'userid', 'courseid', 'problemid', 'reviewscore']
34 _dbflags = 0
35
36 # -------------------------------------------------------------------
37 def __init__(self):
38 super().__init__()
39
40 # -------------------------------------------------------------------
41 def GetProblems(self, g, numproblems = 6):
42 problemids = [
43 x.problemid
44 for x in g.db.Find(
45 learn_studylist,
46 'WHERE classid = ? AND userid = ?',
47 [
48 self.classid,
49 self.userid,
50 ],
51 fields = 'problemid',
52 orderby = 'score',
53 limit = numproblems,
54 )
55 ]
56
57 return apps.learn.problem.GetAllProblems(g, [], apps.learn.card.CARD_LINK_PROBLEM, problemids)
58
The studylist contains every problem that a student needs to know and keeps track of how fast the stu...
Definition: studylist.py:15
def GetProblems(self, g, numproblems=6)
Definition: studylist.py:41
def __init__(self)
Initialize all fields at creation like a good programmer should.
Definition: studylist.py:37
Base class for all database models.
Definition: modelbase.py:20
Throws an exception on blank values.
Definition: validators.py:43
Definition: db.py:1