26CARD_LINK_PROBLEM = 0x1
27CARD_LINK_QUIZ_PROBLEM = 0x2
28CARD_LINK_TEST_PROBLEM = 0x3
29CARD_LINK_EXAM_PROBLEM = 0x4
39 """Represents a flashcard, which is the basic unit that the Pafera
40 Learning System is based upon.
42 A card can contain text, images, sounds, videos, markdown, HTML,
or
43 can serve
as containers
for other cards. Courses
and lessons are
44 all individual cards themselves, whereas problems are simply
45 defining a relationship between various cards.
47 Each card has one owner which can edit the contents of the card, but
48 you can assign multiple editors to help. In the case that someone
49 changes a card but
is not an owner
or editor, the system will use
50 a copy-on-change scheme to give them their own copy of the card
51 without changing the original card.
55 'rid': (
'INTEGER PRIMARY KEY',
'NOT NULL',),
56 'cardtype': (
'INT',
'NOT NULL',),
57 'image': (
'IMAGEFILE',
"NOT NULL DEFAULT ''",),
58 'sound': (
'SOUNDFILE',
"NOT NULL DEFAULT ''",),
59 'video': (
'VIDEOFILE',
"NOT NULL DEFAULT ''",),
60 'title': (
'TEXT',
"NOT NULL DEFAULT ''",),
61 'description': (
'TEXT',
"NOT NULL DEFAULT ''",),
62 'content': (
'MULTITEXT',
"NOT NULL DEFAULT ''",),
63 'markdown': (
'MULTITEXT',
"NOT NULL DEFAULT ''",),
64 'html': (
'MULTITEXT',
"NOT NULL DEFAULT ''",),
65 'ownerid': (
'INT',
'NOT NULL',),
66 'editors': (
'NEWLINELIST',
"NOT NULL DEFAULT ''",),
67 'flags': (
'INT',
'NOT NULL DEFAULT 0',),
70 _dblinks = [
'learn_card',
'learn_problem']
71 _dbdisplay = [
'title',
'content']
72 _dbflags = DB_TRACK_CHANGES | DB_TRACK_VALUES
80 """In order to facilitate teachers being able to create and sell
81 courses on our website, we check which cards a student is able to
82 see
and deny access to anyone who has
not joined the proper course.
84 This function updates allowed cards
for teachers
and students.
88 for r
in g.db.Linked(obj, learn_schoolclass, fields =
'rid'):
89 for course
in g.db.Linked(r, learn_card, fields =
'rid'):
95 cardids = sorted(set(cardids))
97 obj.Set(allowedcards = cardids)
103 """This function returns all child cards given a parent card.
107 for r
in g.db.Linked(card, learn_card, CARD_CHILD, fields =
'rid, flags'):
111 if not (r.flags & CARD_LESSON):
118 """This is a convenience function to get all titles for a given set
119 of cardids. Useful for selecting child cards.
125 'WHERE rid IN (' +
', '.join([
'?' for x
in lessonids]) +
')',
127 fields =
'rid, title'
129 lessontitles[ r.rid ] = r.title
Represents a flashcard, which is the basic unit that the Pafera Learning System is based upon.
def __init__(self)
Initialize all fields at creation like a good programmer should.
Base class for all database models.
def GetAllCards(g, card)
This function returns all child cards given a parent card.
def GetCardTitles(g, lessonids)
This is a convenience function to get all titles for a given set of cardids.
def UpdateAllowedCards(g, obj)
In order to facilitate teachers being able to create and sell courses on our website,...
def ToShortCode(val, chars='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_')
Turns a 32-bit value into a six character alphanumeric code.