From b40461f518108fdde10bcd187a66ce99f0da42ff Mon Sep 17 00:00:00 2001 From: mikaelGusse Date: Tue, 10 Dec 2024 10:56:21 +0200 Subject: [PATCH 1/2] Change radar docker cont settings --- docker/rootfs/srv/radar-cont-settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/rootfs/srv/radar-cont-settings.py b/docker/rootfs/srv/radar-cont-settings.py index 6898f58..1a89399 100644 --- a/docker/rootfs/srv/radar-cont-settings.py +++ b/docker/rootfs/srv/radar-cont-settings.py @@ -15,7 +15,7 @@ }, } -PROVIDERS['a+'].update({'host': 'http://plus:8000'}) +PROVIDERS['a+'].update({'host': 'http://localhost:8000'}) CACHES = { 'default': { From 6c1eea948c4a3d7a9d4afdc0ac6cdbb6c8badb25 Mon Sep 17 00:00:00 2001 From: mikaelGusse Date: Wed, 18 Dec 2024 16:35:38 +0200 Subject: [PATCH 2/2] Improve radar development experience - Add new shell script to send submissions to the service in local development without A+ - Add documentation about the shell script to doc/DEVELOPMENT.md - Add missing packages to requirements.txt --- doc/DEVELOPMENT.md | 8 +++++ requirements.txt | 3 +- run_loadsubmissions.sh | 78 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100755 run_loadsubmissions.sh diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index b197479..4efa9ea 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -42,3 +42,11 @@ Useful testing actions: button at top "Recompare all..." needs to be clicked to feed new submissions for matching. Tip: create empty file `radar/local_settings.py` in order to get rid of extra warnings. + +Note: The root folder contains the script "run_loadsubmission.sh" which correctly distributes submission files in a manner which Radar is happy with. To use the script for testing do the following: + +1. Download submission zip file from A+ for example and unzip it. +2. `./run_loadsubmissions.sh ${directory_with_submissions} {course}/{exercise} 1`
+ This goes through the directory, places each submission into it's own folder and creates a subfolder inside there to put the submission in. After this folder distribution is done, it runs the manage.py loadsubmissions command for each submission. The last variable is the delay, which determines how long we should wait between sending submissions to the service +3. Wait until the script finishes +4. Run `python manage.py matchsubmissions {course}/exercise` and the submissions should be matched. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 47054e8..91b702e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ git+https://github.com/apluslms/django-lti-login.git@3.3.0#egg=django-lti-login= git+https://github.com/apluslms/django-essentials.git@1.6.0#egg=django-essentials==1.6.0 git+https://github.com/apluslms/a-plus-client.git@v1.3.0#egg=a_plus_client git+https://github.com/apluslms/greedy-string-tiling.git@v0.13.0 -aplus-auth ~= 0.2.3 \ No newline at end of file +aplus-auth ~= 0.2.3 +django-debug-toolbar \ No newline at end of file diff --git a/run_loadsubmissions.sh b/run_loadsubmissions.sh new file mode 100755 index 0000000..9ba4a11 --- /dev/null +++ b/run_loadsubmissions.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Function to print usage +usage() { + echo "Usage: $0 " + echo "Example: $0 /path/to/source coursec e1 5" + exit 1 +} + +# Check if exactly four arguments were supplied +if [ "$#" -ne 4 ]; then + usage +fi + +# Define the source directory, course name, exercise name, and delay +SRC_DIR=$1 +COURSE_NAME=$2 +EXERCISE_NAME=$3 +DELAY=$4 + +# Check if the supplied source directory is valid +if [ ! -d "$SRC_DIR" ]; then + echo "Error: $SRC_DIR is not a directory" + usage +fi + +# Initialize counter +INDEX=1 +SHOULD_MOVE_FILES=false + +# Check if files are already distributed +for SUBDIR in "$SRC_DIR"/*; do + if [ -d "$SUBDIR/ex2" ]; then + SHOULD_MOVE_FILES=false + break + else + SHOULD_MOVE_FILES=true + fi +done + +# Move files if not already distributed +if $SHOULD_MOVE_FILES; then + echo "Distributing files..." + for FILE in "$SRC_DIR"/*; do + if [ -f "$FILE" ]; then + # Create the index and ex2 directories + DEST_DIR="$SRC_DIR/$INDEX/ex2" + mkdir -p "$DEST_DIR" + + # Move the file to the destination directory + mv "$FILE" "$DEST_DIR" + + # Increment the counter + INDEX=$((INDEX + 1)) + fi + done + echo "Files have been distributed." +else + echo "Files are already distributed." +fi + +# Execute the custom Python command for each distributed folder with delay +for SUBDIR in "$SRC_DIR"/*; do + if [ -d "$SUBDIR/ex2" ]; then + DEST_DIR="$SUBDIR/ex2" + COMMAND="python manage.py loadsubmissions $COURSE_NAME/$EXERCISE_NAME $DEST_DIR" + echo "Running command for $DEST_DIR" + echo "Command: $COMMAND" + + # Execute the command + eval $COMMAND + + # Wait for the specified delay before continuing to the next one + sleep $DELAY + fi +done + +echo "Commands executed successfully for all folders."