コード例 #1
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def saveattendance():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    if request.form['absent'] != '':
        abss = request.form['absent'].strip().split('_')
    else:
        abss = []
    if request.form['late'] != '':
        lats = request.form['late'].strip().split('_')
    else:
        lats = []
    if request.form['excused'] != '':
        excs = request.form['excused'].strip().split('_')
    else:
        excs = []
    if request.form['exlates'] != '':
        exlates = request.form['exlates'].strip().split('_')
    else:
        exlates = []
    date = request.form['date'].strip()
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.setMassAttendance( (nameParts[0], nameParts[1], nameParts[2] ),
                    term, abss, lats, excs, exlates, date )
    return "done"
コード例 #2
0
    def get_from_keyword(word, n):
        conn = db()
        ts = []
        ps = []

        query = '''SELECT * FROM "Thread" WHERE "Heading" like '%''' + word + \
            '''%' AND "Site" = 0 AND "NumPosts" < 200 ORDER BY "NumPosts" DESC'''
        threads = conn.run_query(query)

        for thread in threads:
            ts.append(thread[0])

        for t in ts:
            posts = conn.get_posts_from_thread(t)
            added = 0
            for post in posts:
                if len(ps) < n and len(post[1]) > 200:
                    ps.append(post)
                    added += 1
            if len(ps) >= n:
                break

        conn.close_connection()

        return ps
コード例 #3
0
def saveattendance():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    if request.form['absent'] != '':
        abss = request.form['absent'].strip().split('_')
    else:
        abss = []
    if request.form['late'] != '':
        lats = request.form['late'].strip().split('_')
    else:
        lats = []
    if request.form['excused'] != '':
        excs = request.form['excused'].strip().split('_')
    else:
        excs = []
    if request.form['exlates'] != '':
        exlates = request.form['exlates'].strip().split('_')
    else:
        exlates = []
    date = request.form['date'].strip()
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.setMassAttendance((nameParts[0], nameParts[1], nameParts[2]), term,
                           abss, lats, excs, exlates, date)
    return "done"
コード例 #4
0
    def run_query():
        """
        Get threads that each key actor has been involved with across a number of relevant forums
        """
        conn = db()

        forums = [
            107, 326, 44, 176, 186, 277, 46, 203, 48, 205, 374, 299, 92, 106,
            10, 103, 91, 126, 339, 43, 114, 47, 113, 120, 70, 170, 4, 308
        ]
        for forum in forums:
            for user in get_threads.get_actors():
                query = 'SELECT DISTINCT t."IdThread", t."Heading", t."NumPosts", t."Author" FROM "Post" p INNER JOIN "Thread" t ON p."Thread" = t."IdThread" WHERE t."Author" = ' + \
                    str(user) + ' AND t."Forum" = ' + str(forum) + ';'
                records = conn.run_query(query)

                for r in records:
                    print(r)

                with open("threads.data", "a", encoding='utf8') as f:
                    for r in records:
                        f.write(
                            str(r[0]) + ' | ' + str(r[1]) + ' | ' + str(r[2]) +
                            ' | ' + str(r[3]) + '\n')

        conn.close_connection()
コード例 #5
0
def arrangeRandom():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'

    cls = mydb.getClass((nameParts[0], nameParts[1], nameParts[2]), term)
    students = cls[0]['students']
    for i in range(100):
        s1 = students[randint(0, len(students) - 1)]
        s2 = students[randint(0, len(students) - 1)]
        r = s1['row']
        c = s1['col']
        s1['row'] = s2['row']
        s1['col'] = s2['col']
        s2['row'] = r
        s2['col'] = c
        mydb.setSeat((nameParts[0], nameParts[1], nameParts[2]), term,
                     s1['id'], s1['row'], s1['col'])
        mydb.setSeat((nameParts[0], nameParts[1], nameParts[2]), term,
                     s2['id'], s2['row'], s2['col'])
    return json.dumps(cls[0])
コード例 #6
0
def noncrime_dataset(n, save=False, load=False, string=False):
    """
    Produces a dataset of noncrime posts, or loads it from a file
    """
    def load_dataset():
        with open('nc.data', 'rb') as f:
            X = pickle.load(f)
        np.random.shuffle(X)
        return X

    pt = process_text_s if string else process_text

    conn = db()

    if load:
        return load_dataset()

    posts = []
    for post in conn.get_noncrime_posts(n):
        processed = pt(post[0])
        if len(processed) > 10:
            p = (processed, -1)
            posts.append(p)
    print(len(posts))
    conn.close_connection()
    X = np.stack(posts)

    if save:
        with open('nc.data', 'wb') as f:
            pickle.dump(X, f)

    np.random.shuffle(X)
    return X
コード例 #7
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def getassignments():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    assignments = mydb.getAssignments((nameParts[0],nameParts[1],nameParts[2]), term)
    return json.dumps( assignments )
コード例 #8
0
def collect_unlabelled_data(forum, number, string=False):
    conn = db()
    posts = []
    pt = process_text_s if string else process_text
    for post in conn.get_posts_from_forum(forum, number):
        p = (pt(post[0]), -1)
        posts.append(p)
    conn.close_connection()
    return posts
コード例 #9
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def getinfo(): 
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    student = mydb.getStudent((nameParts[0], nameParts[1], nameParts[2] ), term, request.form['sid'])
    return json.dumps(student['students'])
コード例 #10
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def changegrade():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    grades = json.loads(request.form['grades'].strip())
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    student = mydb.changeGrade((nameParts[0], nameParts[1], nameParts[2] ), term, request.form['sid'].strip(), request.form['atype'].strip(), grades)
    return json.dumps(student['students'])
コード例 #11
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def removestudent():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.removeStudent((nameParts[0], nameParts[1], nameParts[2]),term,
                        request.form['sid'].strip())
    return "done"
コード例 #12
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def createassignmenttypr():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    atname = request.form['atname'].strip()
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.addAssignmentType((nameParts[0], nameParts[1], nameParts[2]),term,
                           atname)
    return 'done'
コード例 #13
0
def removestudent():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.removeStudent((nameParts[0], nameParts[1], nameParts[2]), term,
                       request.form['sid'].strip())
    return "done"
コード例 #14
0
def getassignments():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    assignments = mydb.getAssignments(
        (nameParts[0], nameParts[1], nameParts[2]), term)
    return json.dumps(assignments)
コード例 #15
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def seated():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.setSeated( (nameParts[0], nameParts[1], nameParts[2]), term,
                  request.form["seated"].strip(),
                  request.form['rows'].strip(), request.form['cols'].strip())
    return "seated set"
コード例 #16
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def getbackupcsv():
    clsn = request.args.get('classname')
    term = request.args.get('term')
    nameParts = clsn.split("-")    
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    backup = mydb.getBackupCSV((nameParts[0], nameParts[1], nameParts[2]), term)
    response = make_response( backup )
    response.headers['Content-Disposition'] = 'attachment; filename=' + clsn + '-' + term + '-' + str(datetime.date.today()) + '.csv'
    return response
コード例 #17
0
def getinfo():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    student = mydb.getStudent((nameParts[0], nameParts[1], nameParts[2]), term,
                              request.form['sid'])
    return json.dumps(student['students'])
コード例 #18
0
def seated():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.setSeated((nameParts[0], nameParts[1], nameParts[2]), term,
                   request.form["seated"].strip(),
                   request.form['rows'].strip(), request.form['cols'].strip())
    return "seated set"
コード例 #19
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def savegradeoptions():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    option = request.form['option'].strip()
    mydb = db.db()

    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    
    mydb.saveGradeOptions((nameParts[0], nameParts[1], nameParts[2]),term, option)
    return "done";
コード例 #20
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def backupreset():
    backup = request.files['backupfile']
    backup = backup.read()
    backup = json.loads(backup)
    clsn = backup['code'] + "-" + backup['section'] + '-' + backup['period']
    nameParts = clsn.split("-")    
    term = backup['term']
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.resetFromBackup(backup)
    return render_template("classview.html", clsname = clsn,trm = term )
コード例 #21
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def getallbackupcsv():
    teacher = session['teacher']
    term = request.args.get('term')
    mydb = db.db();
    classes = mydb.getClasses(teacher, term)
    backup = ''
    for c in classes:
        backup+= mydb.getBackupCSV(c, term) + '\n\n'

    response = make_response( backup )
    response.headers['Content-Disposition'] = 'attachment; filename=' + teacher + '-' + term + '-' + str(datetime.date.today()) + '.csv'
    return response
コード例 #22
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def changeweights():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    weights =  json.loads(request.form['weights'].strip())
    mydb = db.db()

    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.changeWeights((nameParts[0], nameParts[1], nameParts[2]),term,
                        weights)
    return "done"
コード例 #23
0
def createassignmenttypr():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    atname = request.form['atname'].strip()
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.addAssignmentType((nameParts[0], nameParts[1], nameParts[2]), term,
                           atname)
    return 'done'
コード例 #24
0
def changegrade():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    grades = json.loads(request.form['grades'].strip())
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    student = mydb.changeGrade((nameParts[0], nameParts[1], nameParts[2]),
                               term, request.form['sid'].strip(),
                               request.form['atype'].strip(), grades)
    return json.dumps(student['students'])
コード例 #25
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def backupallreset():
    backups = request.files['backupfile']
    backups = backups.read().strip().split('\n')    
    mydb = db.db()
    for b in backups:
        backup = json.loads(b)
        clsn = backup['code'] + "-" + backup['section'] + '-' + backup['period']
        nameParts = clsn.split("-")    
        term = backup['term']
        if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
            return 'false'
        mydb.resetFromBackup(backup)
    return render_template("selectclass.html", term = CURRENT_TERM)
コード例 #26
0
def changeweights():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    weights = json.loads(request.form['weights'].strip())
    mydb = db.db()

    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.changeWeights((nameParts[0], nameParts[1], nameParts[2]), term,
                       weights)
    return "done"
コード例 #27
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def getassignment():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    try:
        assignment = mydb.getAssignment((nameParts[0],nameParts[1],nameParts[2]), term,
                                     request.form['aname'].strip())
        return json.dumps( assignment )
    except:
        return '{"grades":[]}'
コード例 #28
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def gettoday():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    a = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'absent')
    l = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'late')
    e = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'excused')
    el = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'exlate')
    d = {'absent':a, 'late':l, 'excused':e, 'exlate':el}
    return json.dumps(d)
コード例 #29
0
def backupreset():
    backup = request.files['backupfile']
    backup = backup.read()
    backup = json.loads(backup)
    clsn = backup['code'] + "-" + backup['section'] + '-' + backup['period']
    nameParts = clsn.split("-")
    term = backup['term']
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.resetFromBackup(backup)
    return render_template("classview.html", clsname=clsn, trm=term)
コード例 #30
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def deletegrades():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    ids = json.loads(request.form['ids'])
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    print ids
    mydb.deleteAssignment( (nameParts[0], nameParts[1], nameParts[2] ),
                           term, ids,
                           request.form['aname'].strip(), request.form['atype'].strip()); 
    return "done"
コード例 #31
0
def backupallreset():
    backups = request.files['backupfile']
    backups = backups.read().strip().split('\n')
    mydb = db.db()
    for b in backups:
        backup = json.loads(b)
        clsn = backup['code'] + "-" + backup['section'] + '-' + backup['period']
        nameParts = clsn.split("-")
        term = backup['term']
        if session['teacher'] != mydb.getTeacher(
            (nameParts[0], nameParts[1], nameParts[2]), term):
            return 'false'
        mydb.resetFromBackup(backup)
    return render_template("selectclass.html", term=CURRENT_TERM)
コード例 #32
0
def deletegrades():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    ids = json.loads(request.form['ids'])
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    print ids
    mydb.deleteAssignment((nameParts[0], nameParts[1], nameParts[2]), term,
                          ids, request.form['aname'].strip(),
                          request.form['atype'].strip())
    return "done"
コード例 #33
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def saveinfo():
    print request.form
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    student = mydb.saveInfo((nameParts[0], nameParts[1], nameParts[2]),
                            term,
                            request.form['sid'].strip(), request.form['nick'].strip(),
                            request.form['id'].strip(), request.form['email'].strip(),
                            request.form['stuyid'].strip(), request.form['hr'].strip())
    return json.dumps(student['students'])
コード例 #34
0
def savegradeoptions():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    option = request.form['option'].strip()
    mydb = db.db()

    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'

    mydb.saveGradeOptions((nameParts[0], nameParts[1], nameParts[2]), term,
                          option)
    return "done"
コード例 #35
0
def getallbackupcsv():
    teacher = session['teacher']
    term = request.args.get('term')
    mydb = db.db()
    classes = mydb.getClasses(teacher, term)
    backup = ''
    for c in classes:
        backup += mydb.getBackupCSV(c, term) + '\n\n'

    response = make_response(backup)
    response.headers[
        'Content-Disposition'] = 'attachment; filename=' + teacher + '-' + term + '-' + str(
            datetime.date.today()) + '.csv'
    return response
コード例 #36
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def addstudent():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.addStudent( (nameParts[0], nameParts[1], nameParts[2] ),term,
                     request.form['first'].strip(), request.form['last'].strip(),
                     request.form['nick'].strip(), request.form['sid'].strip(), 
                     request.form['email'].strip(), int(request.form['row'].strip()),
                     int(request.form['col'].strip() ), request.form['stuyid'].strip(),
                     request.form['hr'].strip());
    return "done"
コード例 #37
0
def getassignment():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    try:
        assignment = mydb.getAssignment(
            (nameParts[0], nameParts[1], nameParts[2]), term,
            request.form['aname'].strip())
        return json.dumps(assignment)
    except:
        return '{"grades":[]}'
コード例 #38
0
def getbackupcsv():
    clsn = request.args.get('classname')
    term = request.args.get('term')
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    backup = mydb.getBackupCSV((nameParts[0], nameParts[1], nameParts[2]),
                               term)
    response = make_response(backup)
    response.headers[
        'Content-Disposition'] = 'attachment; filename=' + clsn + '-' + term + '-' + str(
            datetime.date.today()) + '.csv'
    return response
コード例 #39
0
def saveinfo():
    print request.form
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    student = mydb.saveInfo(
        (nameParts[0], nameParts[1], nameParts[2]), term,
        request.form['sid'].strip(), request.form['nick'].strip(),
        request.form['id'].strip(), request.form['email'].strip(),
        request.form['stuyid'].strip(), request.form['hr'].strip())
    return json.dumps(student['students'])
コード例 #40
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def savegrades():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    g = json.loads(request.form['grades'].strip())
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'

    mydb.setMassGrades( (nameParts[0], nameParts[1], nameParts[2] ),
                        term,
                        request.form['aname'].strip(), request.form['atype'].strip(), 
                        request.form['apublic'].strip(),
                        float(request.form['points'].strip()), g);
    return "done"
コード例 #41
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def loadclass():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    
    markUsage( session['teacher'] )
    cls = mydb.getClass( (nameParts[0], nameParts[1], nameParts[2] ), term )
    try:
        mydb.resizeClass( (nameParts[0], nameParts[1], nameParts[2] ),
                          term, request.form["rows"].strip(), request.form["cols"].strip())
    except KeyError:
        pass
    return json.dumps( cls[0] )
コード例 #42
0
def savegrades():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    g = json.loads(request.form['grades'].strip())
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'

    mydb.setMassGrades((nameParts[0], nameParts[1], nameParts[2]), term,
                       request.form['aname'].strip(),
                       request.form['atype'].strip(),
                       request.form['apublic'].strip(),
                       float(request.form['points'].strip()), g)
    return "done"
コード例 #43
0
def addstudent():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.addStudent((nameParts[0], nameParts[1], nameParts[2]), term,
                    request.form['first'].strip(),
                    request.form['last'].strip(), request.form['nick'].strip(),
                    request.form['sid'].strip(), request.form['email'].strip(),
                    int(request.form['row'].strip()),
                    int(request.form['col'].strip()),
                    request.form['stuyid'].strip(), request.form['hr'].strip())
    return "done"
コード例 #44
0
def get_db_records():
    """
    Gets the posts needed to train the word embedding models from a set of relevant forums
    """
    conn = db()
    records = []
    forums = [4, 10, 46, 48, 92, 107, 114, 170, 186, 222, 293, 248, 167, 262]
    for forum in forums:
        query = 'SELECT p."Content" FROM "Post" p INNER JOIN "Thread" t ON p."Thread" = t."IdThread" WHERE p."Site" = 0 AND LENGTH(p."Content") > 200 AND t."Forum" =' + str(
            forum) + 'LIMIT 10000'
        records.extend([r[0] for r in conn.run_query(query)])
        print("Collected: " + str(forum))
    query = 'SELECT p."Content" FROM "Post" p INNER JOIN "Thread" t ON p."Thread" = t."IdThread" WHERE p."Site" = 0 AND LENGTH(p."Content") > 200 AND t."Forum" = 25 LIMIT 10000'
    records.extend([r[0] for r in conn.run_query(query)])

    conn.close_connection()
    return records
コード例 #45
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def transferstudent():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    targetClsn = request.form['targetclass'].strip()
    targetParts = targetClsn.split('-')
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    spot = mydb.openSpot((targetParts[0],targetParts[1],targetParts[2]), term)
    if spot:
        mydb.transfer((nameParts[0],nameParts[1],nameParts[2]),
                      (targetParts[0],targetParts[1],targetParts[2]),
                      term, request.form['sid'].strip())
        return "done"
    else:
        return "false"
コード例 #46
0
def loadclass():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'

    markUsage(session['teacher'])
    cls = mydb.getClass((nameParts[0], nameParts[1], nameParts[2]), term)
    try:
        mydb.resizeClass((nameParts[0], nameParts[1], nameParts[2]), term,
                         request.form["rows"].strip(),
                         request.form["cols"].strip())
    except KeyError:
        pass
    return json.dumps(cls[0])
コード例 #47
0
def gettoday():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    a = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]),
                                 term, request.form['date'].strip(), 'absent')
    l = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]),
                                 term, request.form['date'].strip(), 'late')
    e = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]),
                                 term, request.form['date'].strip(), 'excused')
    el = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]),
                                  term, request.form['date'].strip(), 'exlate')
    d = {'absent': a, 'late': l, 'excused': e, 'exlate': el}
    return json.dumps(d)
コード例 #48
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def reseat():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    id1 = request.form["id1"].strip()
    row1= request.form["row1"].strip()
    col1 = request.form["col1"].strip()
    id2 = request.form["id2"].strip()
    row2= request.form["row2"].strip()
    col2 = request.form["col2"].strip()
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.setSeat( (nameParts[0], nameParts[1], nameParts[2] ), term, 
                  id1, row1, col1)
    mydb.setSeat( (nameParts[0], nameParts[1], nameParts[2] ), term, 
                  id2, row2, col2)
    return "done"
コード例 #49
0
def transferstudent():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    targetClsn = request.form['targetclass'].strip()
    targetParts = targetClsn.split('-')
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    spot = mydb.openSpot((targetParts[0], targetParts[1], targetParts[2]),
                         term)
    if spot:
        mydb.transfer((nameParts[0], nameParts[1], nameParts[2]),
                      (targetParts[0], targetParts[1], targetParts[2]), term,
                      request.form['sid'].strip())
        return "done"
    else:
        return "false"
コード例 #50
0
def reseat():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    id1 = request.form["id1"].strip()
    row1 = request.form["row1"].strip()
    col1 = request.form["col1"].strip()
    id2 = request.form["id2"].strip()
    row2 = request.form["row2"].strip()
    col2 = request.form["col2"].strip()
    mydb = db.db()

    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'

    mydb.setSeat((nameParts[0], nameParts[1], nameParts[2]), term, id1, row1,
                 col1)
    mydb.setSeat((nameParts[0], nameParts[1], nameParts[2]), term, id2, row2,
                 col2)
    return "done"
コード例 #51
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def changeAttendance():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    a = request.form['absent'].strip().split('_')
    l = request.form['late'].strip().split('_')
    e = request.form['excused'].strip().split('_')
    el = request.form['exlate'].strip().split('_')
    if a[0] == '':
        a = []
    if l[0] == '':
        l = []
    if e[0] == '':
        e = []
    if el[0] == '':
        el = []
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'
    mydb.changeAllAttendance((nameParts[0], nameParts[1], nameParts[2]),
                             term, request.form['sid'].strip(), a, l, e, el)
    return "done"
コード例 #52
0
    def build_dataset(keywords):
        """
        Gets threads that include a specific keyword and creates a command line interface to add them to the dataset or not
        """
        conn = db()

        keyword = "'.*(" + '|'.join(keywords) + ").*'"

        query = '''SELECT "IdThread" FROM "Thread" WHERE LOWER("Heading") ~ ''' + \
            keyword + ''' AND "Site" = 0 AND "NumPosts" < 200'''
        threads = conn.run_query(query)

        length = 0

        print(len(threads))
        for thread in threads:
            thread_id = thread[0]

            posts = conn.get_posts_from_thread(thread_id)

            for post in posts:
                pp = process_text(post[1])
                if len(pp) > 5:
                    print(remove_tags(post[1]))
                    add = input()

                    with open(keywords[0] + "_training.data", 'a+') as f:
                        if add == 'y':
                            f.write(str(post[0]) + '\n')

                    with open(keywords[0] + "_training.data", 'r') as f:
                        length = len(f.readlines())

                    if length > 500:
                        print("All done")
                    print(
                        "=================================================================================="
                        + str(length) + "\n")
コード例 #53
0
def changeAttendance():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    a = request.form['absent'].strip().split('_')
    l = request.form['late'].strip().split('_')
    e = request.form['excused'].strip().split('_')
    el = request.form['exlate'].strip().split('_')
    if a[0] == '':
        a = []
    if l[0] == '':
        l = []
    if e[0] == '':
        e = []
    if el[0] == '':
        el = []
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher(
        (nameParts[0], nameParts[1], nameParts[2]), term):
        return 'false'
    mydb.changeAllAttendance((nameParts[0], nameParts[1], nameParts[2]), term,
                             request.form['sid'].strip(), a, l, e, el)
    return "done"
コード例 #54
0
ファイル: app.py プロジェクト: jonalf/gradebook-open
def arrangeRandom():
    clsn = request.form["classname"].strip()
    term = request.form['term'].strip()
    nameParts = clsn.split("-")
    mydb = db.db()
    if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
        return 'false'

    cls = mydb.getClass( (nameParts[0], nameParts[1], nameParts[2] ), term )
    students = cls[0]['students']
    for i in range(100):
        s1 = students[randint(0, len(students)-1)]
        s2 = students[randint(0, len(students)-1)]
        r = s1['row']
        c = s1['col']
        s1['row'] = s2['row']
        s1['col'] = s2['col']
        s2['row'] = r
        s2['col'] = c
        mydb.setSeat( (nameParts[0], nameParts[1], nameParts[2]), term,
                      s1['id'], s1['row'], s1['col'])
        mydb.setSeat( (nameParts[0], nameParts[1], nameParts[2]), term,
                      s2['id'], s2['row'], s2['col'])
    return json.dumps( cls[0] )
コード例 #55
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def loadselect():
    teacher = session['teacher']
    mydb = db.db();
    return json.dumps( mydb.getAllClasses(teacher) )
コード例 #56
0
ファイル: app.py プロジェクト: zamansky/gradebook-open
def studentload():
    sdb = studentdb.studentdb()
    cdb = db.db()
    student = sdb.getStudent( session['user'] )
    sdb.getGrades( session['user'], CURRENT_TERM )
    return json.dumps(student)