Пример #1
0
def storeAssignmentTime(assignment, user):
    if not sawSolution(assignment, user):
        from web.utils import sendmail
        sendmail('*****@*****.**', 
                 '*****@*****.**',
                 'Student: %s read solutions for %s' % (user, assignment),
                 'Student: %s read solutions for %s at %s' % (user, assignment, strftime("%Y/%m/%d %H:%M:%S", localtime())))

    (conn, cursor) = getDbCursor(getUserDb(user))
    print 'store', assignment, user
    conn.execute('insert into solution_times values("%s", %s);' % (assignment,
                                                                  str(int(time() * 1000))))
    conn.commit()
    cursor.close()
Пример #2
0
def getUserDb(user):
    db_file = join('student_database', user + '.db')
    if exists(join('dbs',db_file)):
        #print "user file exists", user
        return db_file

    print exists(db_file), db_file

    from web.utils import sendmail
    sendmail('*****@*****.**', 
             '*****@*****.**',
             'New student: %s' % (user),
             '%s has join cs61as' % (user))
    
    (conn, cursor) = getDbCursor(db_file)
    cursor.execute('CREATE TABLE visits_times(login TEXT, chapter_id INTEGER, timestamp INTEGER);')
    cursor.execute('CREATE TABLE quiz_times(login TEXT, chapter_id INTEGER, timestamp INTEGER);')
    cursor.execute('CREATE TABLE visits(login TEXT, chapter_id INTEGER);')
    cursor.execute('CREATE TABLE SPECIAL_FLAG(login TEXT, SPECIAL_FLAG TEXT);')
    cursor.execute('CREATE TABLE solution_times(assignment TEXT, timestamp INTEGER);')
    conn.commit()
    cursor.close()
    return db_file