示例#1
0
from autograder import InteractiveTest, Autograder
public_inputs = [["1", "2", "3", "4", "5", ""],
                 ["1", "2", ""],
                 ["32", "22", "123", "99", "2", ""]
                 ]
private_inputs = [["12", "22", ""],
                  ["-10", "-22", "-3", "-48", "-5", ""],
                  ["22", "12", ""],
                  ["0", "0", "0", "1", ""]]
tests = InteractiveTest.create_batch("ta_two_largest", "two_largest3", public_inputs, private_inputs)
Autograder().run(tests)
示例#2
0
from autograder import FunctionTest, Autograder
pub_inputs = [(1729, ), (356, )]
priv_inputs = [(5000, ), (12345678, ), (1, ), (0, )]
tests = FunctionTest.create_batch("ta_digital_root", "digital_root",
                                  "digital_root", pub_inputs, priv_inputs)
autograder = Autograder()
autograder.run(tests)
示例#3
0
}

q3 = {
    'name': 'Q3',
    'prefix': 'q3',
    'key': 'Eval_AverageReturn',
    'thresh': 150,
    'weight': 1 / 4
}

q4a = {
    'name': 'Q4a',
    'prefix': 'q4_search',
    'key': 'Eval_AverageReturn',
    'thresh': 150,
    'weight': 1 / 8
}
q4b = {
    'name': 'Q4b',
    'prefix': 'q4',
    'key': 'Eval_AverageReturn',
    'thresh': 170,
    'weight': 1 / 8
}

HW2_scheme = [q1_1a, q1_1b, q1_1c, q1_2a, q1_2b, q1_2c, q2, q3, q4a, q4b]

if __name__ == '__main__':
    autograder = Autograder(HW2_scheme, make_visible=False)
    autograder.process_submission()
示例#4
0
def main():
    """
    Main entrypoint for autograder
    """

    cwd = os.getcwd()
    sys.path.append(cwd)
    tmp_folder = os.path.join(cwd, 'tmp')
    student_src_dir = os.path.join(tmp_folder, 'src')
    build_dir = os.path.join(tmp_folder, 'build')
    replacements_dir = os.path.join(os.path.dirname(cwd), 'replacements')
    test_dir = os.path.join(tmp_folder, 'test')

    # copy student code from /autograder/submission to a temp folder
    if os.path.exists(tmp_folder):
        shutil.rmtree(tmp_folder)
    if TEST_ENV:
        shutil.copytree('/home/ubuntu/autograder/submission/', student_src_dir)
    else:
        shutil.copytree('/autograder/submission/', student_src_dir)

    if os.path.exists(replacements_dir):
        recursive_copy_with_overwrite(replacements_dir, student_src_dir)

    os.mkdir(build_dir)

    # copy googletest cases into tmp folder
    copy_dir_if_exists('../tests', test_dir)

    # create new autograder object from config
    autograder = Autograder("../autograder_config.yml", student_src_dir, build_dir, test_dir)

    # try to compile student code -- results are in autograder.compiler.results
    autograder.compiler.compile()
    if DEBUG:
        print("Failed to compile: {}".format(autograder.compiler.get_failures()))
        print(autograder.compiler.results)
    with open(os.path.join(tmp_folder, 'compile_commands.json'), 'w+') as outfile:
        json.dump(autograder.compiler.compile_commands, outfile)

    # run linter
    if autograder.linter:
        autograder.linter.run()
        if DEBUG:
            print(autograder.linter.results)

    # run style check
    if autograder.stylecheck:
        autograder.stylecheck.run()
        if DEBUG:
            print(autograder.stylecheck.results)

    # run test cases (get json output from googletest)
    autograder.tester.set_skip(autograder.compiler.get_failures())
    autograder.tester.run_test()
    if DEBUG:
        print(autograder.tester.results)

    if TEST_ENV:
        outfile_path = '/home/ubuntu/autograder/results/results.json'
    else:
        outfile_path = '/autograder/results/results.json'

    # create json object with overall results and write to results directory
    with open(outfile_path, 'w+') as outfile:
        outfile.write(autograder.make_json())