Skip to content

Commit

Permalink
Merge pull request #57 from mikaelGusse/master
Browse files Browse the repository at this point in the history
Improve development experience of Radar
  • Loading branch information
mikaelGusse authored Dec 18, 2024
2 parents 30b26d6 + 3932148 commit a7ed1d3
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
8 changes: 8 additions & 0 deletions doc/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`<br>
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.
2 changes: 1 addition & 1 deletion docker/rootfs/srv/radar-cont-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
}

PROVIDERS['a+'].update({'host': 'http://plus:8000'})
PROVIDERS['a+'].update({'host': 'http://localhost:8000'})

CACHES = {
'default': {
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ git+https://github.com/apluslms/[email protected]#egg=django-lti-login=
git+https://github.com/apluslms/[email protected]#egg=django-essentials==1.6.0
git+https://github.com/apluslms/[email protected]#egg=a_plus_client
git+https://github.com/apluslms/[email protected]
aplus-auth ~= 0.2.3
aplus-auth ~= 0.2.3
django-debug-toolbar
78 changes: 78 additions & 0 deletions run_loadsubmissions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash

# Function to print usage
usage() {
echo "Usage: $0 <source_directory> <course_name> <exercise_name> <delay_in_seconds>"
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."

0 comments on commit a7ed1d3

Please sign in to comment.