6from pprint
import pprint
19ANSWER_ENABLE_COPY_PASTE = 0x04
24 """This class stores submitted student answers to show in the
25 classroom and keeps track of their scores. It has facilities
for
26 showing different prompts, putting students into groups,
and
27 purchasing helpful items.
31 'rid': (
'INTEGER PRIMARY KEY',
'NOT NULL',),
32 'classid': (
'INT',
'NOT NULL DEFAULT 0',),
34 'numright': (
'INT16',
'NOT NULL DEFAULT 0',),
35 'numwrong': (
'INT16',
'NOT NULL DEFAULT 0',),
36 'numstrikes': (
'INT16',
'NOT NULL DEFAULT 0',),
37 'scoreadded': (
'INT16',
'NOT NULL DEFAULT 0',),
38 'groupnum': (
'INT16',
'NOT NULL DEFAULT 0',),
39 'bonusscore': (
'INT16',
'NOT NULL DEFAULT 0',),
40 'score': (
'INT',
'NOT NULL DEFAULT 0',),
42 'answer': (
'MULTITEXT',
"NOT NULL DEFAULT ''",),
43 'prompt': (
'TEXT',
"NOT NULL DEFAULT ''",),
44 'promptdata': (
'DICT',
"NOT NULL DEFAULT ''",),
45 'items': (
'DICT',
"NOT NULL DEFAULT ''",),
46 'coderesult': (
'DICT',
"NOT NULL DEFAULT ''",),
47 'choices': (
'DICT',
"NOT NULL DEFAULT ''",),
48 'flags': (
'INT',
'NOT NULL DEFAULT 0',),
52 _dbdisplay = [
'classid',
'displayname',
'userid',
'numright',
'numwrong',
'numstrikes',
'answer']
61 """Recalculates the current score. Be sure to call db.Commit()
62 after you finish all calculations, or the updates won
't be saved
65 newscore = self.numright - self.numwrong + self.bonusscore
68 newscore -= 2 ** self.numstrikes
71 scoreadded = newscore - self.score,
77 """Adds up all of the homework scores from the last time that
78 class was in session and applies them to the current answer.
79 This
is automatically called by /learn/answerapi when a new
82 currenttime = time.time()
88 apps.learn.challenge.learn_challenge,
89 'WHERE classid = ? AND endtime < ?',
94 fields =
'endtime, challengetype, results',
95 orderby =
'endtime DESC',
97 if (r.challengetype == apps.learn.challenge.CHALLENGE_CLASSPARTICIPATION
99 and useridcode
in r.results
103 if r.results
and useridcode
in r.results:
104 homeworkscore += r.results[useridcode][4]
107 bonusscore = self.bonusscore + homeworkscore,
This class stores submitted student answers to show in the classroom and keeps track of their scores.
def UpdateScore(self)
Recalculates the current score.
def __init__(self)
Initialize all fields at creation like a good programmer should.
def AddHomeworkScores(self, g)
Adds up all of the homework scores from the last time that class was in session and applies them to t...
Base class for all database models.
def Set(self, **kwargs)
We use this method instead of direct attribute access in order to keep track of what values have been...
Throws an exception on blank values.
def ToShortCode(val, chars='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_')
Turns a 32-bit value into a six character alphanumeric code.