From 9922d5f027faa484ba747ebf1d44ced5097ca6a8 Mon Sep 17 00:00:00 2001 From: Georg Schwarz Date: Thu, 19 Sep 2024 16:28:26 +0200 Subject: [PATCH 1/2] Use "ex" prefix for exercise id parameter --- README.md | 2 +- ci/run_grading.sh | 10 +++++----- grading.py | 18 +++++++----------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b08685c..6231d75 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Use [venv](https://docs.python.org/3/library/venv.html) to manage a virtual envi To run the automated grading, first activate the virtual env, then execute grading.py with an optional work directory as first argument. 1. `source env/bin/activate` -2. `python grading.py ` +2. `python grading.py `, e.g. `python grading.py ex1` # Use with CI To use the automated grading feedback in student repositories in MADE, use the GitHub Actions workflow in`ci/grading-feedback.yml`. It sets up a GitHub action with Python 11 and Jayvee and then executes `./run_grading.sh`. diff --git a/ci/run_grading.sh b/ci/run_grading.sh index b21cce2..40e07c7 100755 --- a/ci/run_grading.sh +++ b/ci/run_grading.sh @@ -1,8 +1,8 @@ cd grading pip install -r requirements.txt -python grading.py 1 "../main" 2>&1 | stdbuf -oL tee feedback-ex1.txt -python grading.py 2 "../main" 2>&1 | stdbuf -oL tee feedback-ex2.txt -python grading.py 3 "../main" 2>&1 | stdbuf -oL tee feedback-ex3.txt -python grading.py 4 "../main" 2>&1 | stdbuf -oL tee feedback-ex4.txt -python grading.py 5 "../main" 2>&1 | stdbuf -oL tee feedback-ex5.txt \ No newline at end of file +python grading.py ex1 "../main" 2>&1 | stdbuf -oL tee feedback-ex1.txt +python grading.py ex2 "../main" 2>&1 | stdbuf -oL tee feedback-ex2.txt +python grading.py ex3 "../main" 2>&1 | stdbuf -oL tee feedback-ex3.txt +python grading.py ex4 "../main" 2>&1 | stdbuf -oL tee feedback-ex4.txt +python grading.py ex5 "../main" 2>&1 | stdbuf -oL tee feedback-ex5.txt \ No newline at end of file diff --git a/grading.py b/grading.py index 0d3f45b..033b75d 100644 --- a/grading.py +++ b/grading.py @@ -68,17 +68,13 @@ def gradeExercise( print("Missing argument.\nUsage: python grading.py ") exit(1) -try: - exerciseId = int(sys.argv[1]) -except ValueError: - print("The argument provided is not an integer.") - exit(1) +exerciseId = sys.argv[1] if len(sys.argv) > 2: os.chdir(sys.argv[2]) match (exerciseId): - case 1: + case "ex1": gradeExercise( 1, buildExercise1Rubric, @@ -86,7 +82,7 @@ def gradeExercise( "airports.sqlite", "airports", ) - case 2: + case "ex2": gradeExercise( 2, buildExercise2Rubric, @@ -94,7 +90,7 @@ def gradeExercise( "trees.sqlite", "trees", ) - case 3: + case "ex3": gradeExercise( 3, buildExercise3Rubric, @@ -102,7 +98,7 @@ def gradeExercise( "goodsTransportedByTrain.sqlite", "goods", ) - case 4: + case "ex4": gradeExercise( 4, buildExercise4Rubric, @@ -110,7 +106,7 @@ def gradeExercise( "temperatures.sqlite", "temperatures", ) - case 5: + case "ex5": gradeExercise( 5, buildExercise5Rubric, @@ -119,7 +115,7 @@ def gradeExercise( "stops", ) case _: - print(f"No grading found for exercise with id {exerciseId}") + print(f"No grading found for submission with id {exerciseId}") From db78244a7e254fab60a6ac68985385acfaa8dfc8 Mon Sep 17 00:00:00 2001 From: Georg Schwarz Date: Thu, 19 Sep 2024 16:36:48 +0200 Subject: [PATCH 2/2] Check whether files exist for PW submissions --- ci/run_grading.sh | 10 ++++++++- grading.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/ci/run_grading.sh b/ci/run_grading.sh index 40e07c7..5758318 100755 --- a/ci/run_grading.sh +++ b/ci/run_grading.sh @@ -5,4 +5,12 @@ python grading.py ex1 "../main" 2>&1 | stdbuf -oL tee feedback-ex1.txt python grading.py ex2 "../main" 2>&1 | stdbuf -oL tee feedback-ex2.txt python grading.py ex3 "../main" 2>&1 | stdbuf -oL tee feedback-ex3.txt python grading.py ex4 "../main" 2>&1 | stdbuf -oL tee feedback-ex4.txt -python grading.py ex5 "../main" 2>&1 | stdbuf -oL tee feedback-ex5.txt \ No newline at end of file +python grading.py ex5 "../main" 2>&1 | stdbuf -oL tee feedback-ex5.txt + +python grading.py pw2 "../main" 2>&1 | stdbuf -oL tee feedback-pw2.txt +python grading.py pw3 "../main" 2>&1 | stdbuf -oL tee feedback-pw3.txt +python grading.py pw4 "../main" 2>&1 | stdbuf -oL tee feedback-pw4.txt +python grading.py pw5 "../main" 2>&1 | stdbuf -oL tee feedback-pw5.txt +python grading.py pw6 "../main" 2>&1 | stdbuf -oL tee feedback-pw6.txt +python grading.py pw7 "../main" 2>&1 | stdbuf -oL tee feedback-pw7.txt +python grading.py pw8 "../main" 2>&1 | stdbuf -oL tee feedback-pw8.txt \ No newline at end of file diff --git a/grading.py b/grading.py index 033b75d..50a723f 100644 --- a/grading.py +++ b/grading.py @@ -64,8 +64,28 @@ def gradeExercise( print("") print(feedback) + +def gradeProjectWork( + pwNumber, expectedFiles +): + print(f"[INFO] Preparing feedback for PROJECT WORK {pwNumber}:") + print( + "[INFO] If this project work does not need to be submitted yet, you can ignore all output after this." + ) + + for expectedFile in expectedFiles: + print(f"\tLooking for file {expectedFile}.") + if not os.path.isfile(expectedFile): + print(f"\t[ERROR] Could not find file: {expectedFile}") + break + + print(f"\t[SUCCESS] Found file: {expectedFile}.") + + print("\t[INFO] That's all we can currently offer as quick feedback for this project work. The rest is manual grading at the end of the semester.") + + if len(sys.argv) < 1: - print("Missing argument.\nUsage: python grading.py ") + print("Missing argument.\nUsage: python grading.py ") exit(1) exerciseId = sys.argv[1] @@ -114,6 +134,41 @@ def gradeExercise( "gtfs.sqlite", "stops", ) + case "pw2": + gradeProjectWork( + 2, + ["project/project-plan.md"], + ) + case "pw3": + gradeProjectWork( + 3, + ["project/pipeline.sh"], + ) + case "pw4": + gradeProjectWork( + 4, + ["project/data-report.pdf"], + ) + case "pw5": + gradeProjectWork( + 5, + ["project/tests.sh"], + ) + case "pw6": + gradeProjectWork( + 6, + [".github/workflows/data-pipeline.yml"], + ) + case "pw7": + gradeProjectWork( + 7, + ["project/analysis-report.pdf"], + ) + case "pw8": + gradeProjectWork( + 8, + ["project/slides.pdf"], + ) case _: print(f"No grading found for submission with id {exerciseId}")