From 45161a379e6aad8787dc7dec6124c438d21f504c Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Thu, 12 Sep 2024 09:15:39 -0400 Subject: [PATCH] Use a log file to write error log --- docs/source/usage/graders/examples/addition.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/usage/graders/examples/addition.py b/docs/source/usage/graders/examples/addition.py index 830149ed..f3cd7964 100644 --- a/docs/source/usage/graders/examples/addition.py +++ b/docs/source/usage/graders/examples/addition.py @@ -2,9 +2,13 @@ import importlib.util import sys +import traceback from collections.abc import Callable +from pathlib import Path student_code_path: str = sys.argv[2] +username: str = sys.argv[3] +log_file = Path(sys.argv[4]) test_cases = ( (1, 2), @@ -40,8 +44,9 @@ def import_module(modname: str = "student_submission", func_name="add_num") -> C try: spec.loader.exec_module(submission) except Exception: - # this traceback could provide sensitive information, so we don't provide it + # this traceback could provide sensitive information, so we don't provide it to students print("Could not test submission, an exception was raised while initializing.") + log_file.write_text(f"Student {username} import error:\n\n" + traceback.format_exc()) # it's not our fault so we exit 0 sys.exit(0)