-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrgrade.sh
executable file
·56 lines (50 loc) · 1.46 KB
/
rgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Start grading in a randomly chosen, ungraded submission folder
[ $# != 0 ] && ACTION="$@" || ACTION="${SHELL:-bash}"
if [ "$(pgrep 'rgrade.sh')" != "$$" ]; then
echo "You are already grading this submission, please return to it:"
echo "$RGRADE_DIR"
exit 1
fi
# note: this returns a null-separated list of items
todo() {
find . -path "*/.todo" -print0 | sed -z 's:/.todo::'
}
DIR="$(todo | shuf -zn1)"
if [ -z "$DIR" ]; then
echo "It seems like you are not currently grading anything; do you want to start now?"
select reply in yes no; do
reply="${reply:-${REPLY,,}}"
if [ "${reply%%y*}" = "" ]; then
for dir in */; do
if [ "$dir" = "*/" ]; then
echo "... there is nothing here to grade!"
exit 1
fi
touch "${dir}.todo"
done
DIR="$(todo | shuf -zn1)"
break
else
echo "A wise choice."
exit
fi
done
fi
if [ -n "$DIR" ]; then
[ $# != 0 ] || echo "Type 'exit' to finish grading; use 'exit 1' to abort grading the current submission."
echo "Entering $DIR."
(cd "$DIR" && export RGRADE_DIR="`pwd`" && $ACTION) && rm -f "$DIR"/.todo
count="$(todo | grep -zc ".*")"
if [ "$count" = 0 ]; then
echo "Exiting $DIR. You have finally finished!"
else
echo "Exiting $DIR. Still $count to go..."
fi
else
(base64 -d | gunzip) <<-EOF
H4sIANgxkVsCA1WOMQrEMAwEe79icSMXkdRHXzHouoO0ae/xtxYkJAvGywyWBWwIHsBUeu+ixl6s
scz5cyrBFaEm8yUxNdTxTJFy7pzxTnBcK5UZ2O0WFojMkh9dmWJcZEXZvJi0xxJiarolb+Lje15i
AGM9aq+PheAPNske4ukAAAA=
EOF
fi