def syncAssignment(gradesourceId, taId): conn = MySQLdb.connect(host = "localhost", user = "******", passwd = "root", db = "ta") cursor = conn.cursor() sql = """SELECT sc.*, st.gs_name FROM scores sc LEFT JOIN students st ON st.id = sc.student_id WHERE assignment_id = '%s' AND st.dropped = 0 """ % taId cursor.execute(sql) scores = {} while True: row = fetchOneAssoc(cursor) if row == None: break print colored(row['score'], 'green'), row['gs_name'] scores[row['gs_name']] = row['score'] g = Gradesource('qpleple', getpass()) g.importScores(scores, gradesourceId, gradesourceName = True) cursor.close() conn.commit() conn.close()
def temp(csvPath, col): config = utils.getConfig() reader = csv.reader(open(csvPath, 'rU'), delimiter=',') data = [{'name': "{0[0]}, {0[1]}".format(row), 'score': row[col], 'pid': row[2]} for row in reader if row[col] not in [0, '0', '-', '']] utils.check("Data: ", data) g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd']) g.importScoresBy(data, 'pid')
def uploadClickerScores(csvPath, col): config = utils.getConfig() reader = csv.reader(open(csvPath, 'rU'), delimiter=',') # Fields: 0:LN, 1:FN, 2:id, >2:scores data = [{'name': '%s, %s' % (row[0], row[1]), 'score': row[col], 'pid': row[2]} for row in reader if row[col] not in [0, '0', '-', '']] utils.check("Clicker data: ", data) g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd']) g.importScoresBy(data, 'pid')
def uploadMoodleQuizScores(): config = utils.getConfig() m = Moodle(config['moodleLogin'], config['moodlePasswd']) _, scores = m.getScores(config['moodleCourseId']) # Fields: 0:FN, 1:LN, 2:pid, 3:inst, 4:dpt, 5:email, 6:total, 7:score data = [{'name': '%s, %s' % (row[1], row[0]), 'score': row[7], 'pid': row[2], 'email': row[5]} for row in scores if row[7] not in [0, '0', '-', '']] utils.check("Moodle data: ", data) g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd']) g.importScoresBy(data, 'pid')
def importGradesourceNamesInMySQL(mysqlClassId): config = utils.getConfig() g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd']) infos = g.studentsInfo() db = torndb.Connection("localhost", "ta", user = "******", password = "******") for name, info in infos.items(): sql = "SELECT id FROM students WHERE gs_name = %s AND pid = %s AND email = %s" if not db.get(sql, name, info['pid'], info['email']): sql = "INSERT INTO students (gs_name, pid, email, class_id) VALUES (%s, %s, %s, %s)" db.execute(sql, name, info['pid'], info['email'], mysqlClassId) cprint("%s not found, inserting" % name, 'green') else: print "%s found, doing nothing" % name
def getFeedback(reportId, column): gradesource = Gradesource('quentin', getpass('Gradesource password: '******'Emails', emails) moodle = Moodle('qpleple', getpass('Moodle password: '******'Feedback', feedback) GSnames = gradesource.matchNames(feedback.keys(), emails.keys()) data = {} for name, content in feedback.items(): # print '%s %s %s' % (name, colored(email, 'blue'), colored(content, 'green')) # answer = raw_input() data[name] = { 'email': emails[GSnames[name]], 'feedback': content, } utils.check('Feedback', data) return data
# -*- coding: utf-8 -*- import re, sys, csv, pickle from termcolor import colored, cprint from gradesource import Gradesource import utils # Read the CSV files for grades csvPath = sys.argv[1] lines = list(csv.reader(open(csvPath, 'rU'), delimiter = ',')) first_line = lines[0] # ignore 1st line and lines starting by '#' (unregistered clickers) lines = [l for l in lines[1:] if l[0][0] != '#'] # Ask for the column to pick in theh file for col, title in enumerate(first_line): print colored(col, 'green') + ' ' + title pid_col = int(raw_input(colored('PID column ? ', 'green'))) score_col = int(raw_input(colored('Score column ? ', 'green'))) # Keep only lines with non-zero score lines = [l for l in lines if l[score_col] not in [0, '0', '-', '']] data = [{'score': l[score_col], 'pid': l[pid_col]} for l in lines] # Ask for the assessment to upload the grade config = utils.getConfig() g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd']) g.importScoresBy(data, 'pid')