Course Management Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
925 B

#!/bin/bash
[ -z "$COURSE" ] && echo "Needs a COURSE set" && exit 1
LIM=0
TOT=0
CNT_ZERO=0
CNT_LIM=0
while getopts ":l:" opt; do
case $opt in
l)
LIM=$OPTARG
;;
\?)
echo "Invalid option: $OPTARG" && exit 1
;;
:)
echo "Needs argument: $OPTARG" && exit 1
;;
esac
done
shift $((OPTIND - 1))
while read USER; do
echo -n "$USER: "
for assn in $*; do
echo -ne "\x1b[36m$assn:\x1b[0m"
NUM=`find /course/$COURSE/assn/$USER/$assn -type f -not -name '.*' | wc -l`
TOT=$(( TOT + 1 ))
if [ $NUM -eq 0 ]; then
CNT_ZERO=$(( CNT_ZERO + 1 ))
echo -ne "\x1b[1;31m"
elif [ $NUM -lt $LIM ]; then
CNT_LIM=$(( CNT_LIM + 1 ))
echo -ne "\x1b[1;33m"
fi
echo "$NUM"
echo -ne "\x1b[0m"
done
done
echo -e "\x1b[1;34m----- $TOT processed, \x1b[33m$(( CNT_LIM + CNT_ZERO )) below limit, \x1b[31m$CNT_ZERO at zero, \x1b[32m$(( TOT - (CNT_LIM + CNT_ZERO) )) satisfactory. \x1b[34m-----\x1b[0m"