When using this grader, the PL must declare a script inside a key 'evaluator'. This script have access to every variable declared in the PL and its 'before' script. It should declare a variable 'grade' which should contain a tuple (int, feedback) where int is the grade between [0, 100].""" missing_grade_stderr = """\ 'evaluator' did not declare the variable 'grade'. The script have access to every variable declared in the PL and its 'before' script. It should declare a variable 'grade' which should contain a tuple (int, feedback) where int is the grade between [0, 100].""" if __name__ == "__main__": if len(sys.argv) < 5: msg = ("Sandbox did not call grader properly:\n" + "Usage: python3 grader.py [input_json] [output_json] [answer_file] [feedback_file]") print(msg, file=sys.stderr) sys.exit(1) from pltest_doc import PlRunner dic = get_context() if "pltest" not in dic and "pltest1" not in dic: print("No pltest neither pltest1-n defined change template", file=sys.stderr) sys.exit(1) if 'stopfirsterror' in dic: stop=bool(dic['stopfirsterror']) else: stop=False student = get_answers()['answer'] outstr="" if "pltest" in dic: pltest = dic['pltest'] tester = PlRunner(student,pltest) a, b = tester.runpltest(1) else: a,b= True, ""
if taboos: feedback = "These words are disallowed an cannot be used: " + str( taboos) sandboxio.output(-1, feedback) tests = grader.run_tests() if tests: grade, feedback = cls.parse_tests_result(tests) sandboxio.output(grade, feedback) junit = grader.run_junit() if junit: grade, feedback = junit feedback = ( "<pre><code>%s</code></pre>" % feedback.replace("[36m", "").replace("[34m", "").replace( "[32m", "").replace("[31m", "").replace("[0m", "")) sandboxio.output(grade, feedback) print( "Both of the keys 'stdout_tests' and 'junit' are missing. At least one must be " "present for the Grader to be able to grade the student's answer.", file=sys.stderr) sys.exit(1) if __name__ == "__main__": answers = sandboxio.get_answers() context = sandboxio.get_context() Grader.grade(context, answers)