示例#1
0
#    each.
#
# This script assumes that the course and assignments have 
# already been setup and that no submissions have been made.
# Preexisting submissions will result in a fatal error (so it
# is best to do this cleanly and/or wipe the assignment on
# codepost.io and restart)

if(len(sys.argv) != 3):
  print("usage: cse_handin_assignment_name codepost_assignment_id")  
  exit(1)

assignmentDir = config.handinPath+sys.argv[1]+"/"
assignmentId = int(sys.argv[2])

codepost.configure_api_key(config.codePostApiKey)

gradingAssignment = course.getAssignment()
s = course.assignmentToString(gradingAssignment)
print(s)

csv = course.assignmentToCSV(gradingAssignment)
f = open(sys.argv[1]+".csv", "w")
f.write(csv)
f.close()

def pushAssignments(gradingAssignment):
    for grader,groups in gradingAssignment.items():
        for g in groups:
            s = g.members[0]
            path = assignmentDir+s.cseLogin+"/"
示例#2
0
import codepost
import csv
import random
codepost.configure_api_key("4c94d9d338cefd5e8e08ec3cef7a93f011ebb8bd")
ASSIGNMENT_NAME = 'Hello'

if __name__ == "__main__":
    # COS126 S2021
    course = codepost.course.list_available()[1]
    roster = codepost.roster.retrieve(id=course.id)
    graders = roster.graders
    assignment = course.assignments.by_name(ASSIGNMENT_NAME)

    # For each grader, randomly select a submission and output as a list
    selected_submissions = []
    for grader in graders:
        submission_link = 'https://codepost.io/code/'
        submissions = assignment.list_submissions(grader=grader)
        num_of_submissions = len(submissions)
        if num_of_submissions > 0:
            rand_id = random.randint(0, num_of_submissions - 1)
            submission_id = submissions[rand_id].id
            submission_link += str(submission_id)
            selected_submissions.append(submission_link)
        else:
            selected_submissions.append(submission_link)

    # Write to a csv file
    with open('graders/' + ASSIGNMENT_NAME + '_grader.csv', 'w',
              newline='') as csvfile:
        writer = csv.writer(csvfile)
示例#3
0
#       it will produce more accurate similarity scores.
#
#    This script does the following:
#       1. Gathers all the submissions of <assignmentName> and saves them in a temp directory,
#           in the format /tmp/<submissionID>_<students/*
#       2. Sends the submissions to Moss along with any optional Moss arguments provided.
#       3. Prints the Moss result link to the console.

import argparse
import codepost
import subprocess
import os
import shutil

#################### Constants -- PLEASE EDIT THESE ########################################
codepost.configure_api_key("<YOUR API KEY HERE>")
courseName = "<YOUR CODEPOST COURSE NAME HERE>"
coursePeriod = "<YOUR CODEPOST COURSE PERIOD HERE>"

##################### Argument Parsing ######################################################
parser = argparse.ArgumentParser(description='Working with Moss!')
parser.add_argument('assignmentName', help='Assignment Name')
parser.add_argument('-m', '--m', nargs='*', help='Optional moss arguments')
args = parser.parse_args()


##################### Helper Functions ######################################################
# get the assignment from codePost based on the couseName, coursePeriod, and assignmentName
def getAssignment(courseName, coursePeriod, assignmentName):
    courses = codepost.course.list_available(name=courseName,
                                             period=coursePeriod)
示例#4
0
#!/usr/local/bin/python3

# Imports
import codepost
from helpers import parse_test_output, find_function_definition

# Set some required variables
course_name = '<COURSE NAME>'
course_period = '<COURSE PERIOD>'
assignment_name = '<ASSIGNMENT NAME>'

test_output_file = 'tests.txt'
student_code_file = 'homework.py'

codepost.configure_api_key(api_key='<YOUR API KEY>')

###################################################################################################

# try to find course
course_list = codepost.course.list_available(name=course_name,
                                             period=course_period)
if len(course_list) == 0:
    raise Exception("Couldn't find course with name %s and period %s" %
                    (course_name, course_period))
this_course = course_list[0]

# try to find assignment
this_assignment = this_course.assignments.by_name(name=assignment_name)
if this_assignment is None:
    raise Exception(
        "ERROR: couldn't find assignment with name %s in specified course" %
示例#5
0
import os
import argparse
import sys

import codepost

codepost.configure_api_key("YOUR API KEY")

##################### Argument Parsing ######################################################
parser = argparse.ArgumentParser(
    description='Download codePost submissions to a local folder.')

parser.add_argument('course_name', help='Name of codePost course')
parser.add_argument('course_period', help='Name of codePost period')
parser.add_argument('assignment', help='Name of codePost assignment')

args = parser.parse_args()

OUTPUT_DIRECTORY = args.assignment

_cwd = os.getcwd()
_upload_dir = os.path.join(_cwd, OUTPUT_DIRECTORY)

##################### Download submissions  ################################################

course_obj_list = codepost.course.list_available(name=args.course_name,
                                                 period=args.course_period)
if len(course_obj_list) != 1:
    errorMessage = "Could not find a course with name={} and period={}.".format(
        args.course_name, args.course_period)
    raise ValueError(errorMessage)
示例#6
0
from __future__ import absolute_import

import codepost as _codepost

import pylifttk

SECTION_NAME = "codePost"

config = pylifttk.get_local_config(section=SECTION_NAME,
                                   template={
                                       SECTION_NAME: {
                                           "api_key": str,
                                       },
                                   })

_codepost.configure_api_key(config["api_key"], override=True)

# Import top-level methods
from pylifttk.codepost.macros import *