-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradescript
More file actions
executable file
·69 lines (60 loc) · 2.18 KB
/
gradescript
File metadata and controls
executable file
·69 lines (60 loc) · 2.18 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
dir=/home/plank/cs302/Labs/LabA
ge="$dir/Gradescript-Examples"
if [ $# -ne 1 ]; then
echo 'usage: gradescript problem_number (1-100)' >&2
exit 1
fi
if [ "$1" -gt 0 -a "$1" -le 100 ]; then
enum=`echo $1 | awk '{ printf "%03d\n", $1 }'`
else
echo 'usage: gradescript problem_number (1-100)' >&2
exit 1
fi
program=worddice
if [ ! -f $program ]; then
echo "Problem $enum is incorrect."
echo ""
echo "Your program $program does not exist."
exit 0
fi
rm -f tmp-$enum-test-stdout.txt tmp-$enum-test-stderr.txt tmp-$enum-correct-stdout.txt tmp-$enum-correct-stderr.txt
$dir/$program $ge/D$enum.txt $ge/W$enum.txt > tmp-$enum-correct-stdout.txt 2> tmp-$enum-correct-stderr.txt
./$program $ge/D$enum.txt $ge/W$enum.txt > tmp-$enum-test-stdout.txt 2> tmp-$enum-test-stderr.txt
call="./$program $ge/D$enum.txt $ge/W$enum.txt"
err=`diff tmp-$enum-correct-stderr.txt tmp-$enum-test-stderr.txt | wc | awk '{ print $1 }'`
out=`$dir/grader $ge/D$enum.txt tmp-$enum-test-stdout.txt tmp-$enum-correct-stdout.txt | wc | awk '{ print $1 }'`
if [ $out != 0 -o $err != 0 ]; then
echo "Problem $enum is incorrect."
echo ""
if [ $out != 0 ]; then
echo "Your standard output fails on the grading script."
fi
if [ $err != 0 ]; then
echo "Your standard error does not match the correct one."
fi
echo ""
echo "TEST:"
echo ""
echo "$call"
echo ""
echo "FILES:"
echo ""
echo "Your standard output is in tmp-$enum-test-stdout.txt."
echo "Your standard error is in tmp-$enum-test-stderr.txt."
echo ""
echo "The correct standard output is in tmp-$enum-correct-stdout.txt."
echo "The correct standard error is in tmp-$enum-correct-stderr.txt."
echo ""
echo "Here is the grade script on your output:"
echo ""
$dir/grader $ge/D$enum.txt tmp-$enum-test-stdout.txt tmp-$enum-correct-stdout.txt
echo ""
echo "Look at correct files and your files, perhaps run 'diff -y' on them, and figure out your mistake."
echo "Please remember to delete this files when you are finished."
else
echo "Problem $enum is correct."
echo ""
echo "Test: $call"
rm -f tmp-$enum-test-stdout.txt tmp-$enum-test-stderr.txt tmp-$enum-correct-stdout.txt tmp-$enum-correct-stderr.txt
fi