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')
# -*- 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')