-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecuteGrader.sh
166 lines (159 loc) · 4.99 KB
/
executeGrader.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#! /bin/bash
cd /grader
MOD1_PART1_ID="zTjsC"
MOD1_PART2_ID="QGf0N"
MOD2_PART1_ID="y0VHn"
MOD2_PART2_ID="mEOEF"
MOD3_PART1_1_ID="2xj63"
MOD3_PART1_2_ID="In7Bo"
MOD3_PART2_ID="p6Yhk"
MOD4_PART1_ID="3YwBB"
MOD4_PART2_ID="gjuKe"
MOD5_PART1_ID="IEm7C"
MOD5_PART2_ID="pmzXG"
MOD5_PART3_ID="16fSM"
do_unzip () {
7z e -ozipfile /shared/submission/$1 > /dev/null
if [ ! $? -eq 0 ]; then
if [ $2 = true ]; then
echo "{\"fractionalScore\": 0.0, \"feedback\": \"Zipfile unreadable. The grader does not support certain types of compression, most notably .rar files; please use a different type of compression.\"}"
exit 0
fi
else
if [ $2 = false ]; then
echo "{\"fractionalScore\": 0.0, \"feedback\": \"Incorrect submission format - please check the submission instructions and try again.\"}"
exit 0
fi
fi
}
while [ $# -gt 1 ]
do
key="$1"
case $key in
partId)
PARTID="$2"
shift
;;
userId)
USERID="$2"
shift
;;
filename)
ORIGINAL_FILENAME="$2"
shift
;;
esac
shift
done
if [ "$PARTID" == "$MOD1_PART1_ID" ] || [ "$PARTID" == "$MOD1_PART2_ID" ]; then
if [ "$PARTID" == "$MOD1_PART1_ID" ]; then
FILENAME="document.CountGrader"
else
FILENAME="document.FleschGrader"
fi
GRADER_DIRECTORY=mod1
do_unzip mod1.zip true
cd zipfile
if [ ! -f "BasicDocument.java" ]; then
cd *
rm -rf __MACOSX > /dev/null
fi
cp * /grader/"$GRADER_DIRECTORY"/document/
cd /grader/"$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 document/*.java 2>errorfile
elif [ "$PARTID" == "$MOD2_PART1_ID" ] || [ "$PARTID" == "$MOD2_PART2_ID" ]; then
if [ "$PARTID" == "$MOD2_PART1_ID" ]; then
GRADER_DIRECTORY=mod2/part1
FILENAME="document.EfficientDocumentGrader"
else
GRADER_DIRECTORY=mod2/part2
FILENAME="document.DocumentBenchmarking"
fi
do_unzip mod2.zip true
cd zipfile
if [ ! -f "EfficientDocument.java" ]; then
rm -rf __MACOSX > /dev/null
cd *
fi
cp * /grader/"$GRADER_DIRECTORY"/document/
cd /grader/"$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 -sourcepath document document/*.java 2>errorfile
elif [ "$PARTID" == "$MOD3_PART1_1_ID" ]; then
GRADER_DIRECTORY=mod3/part1
FILENAME="textgen.MyLinkedListGrader"
do_unzip MyLinkedList.java false
cp /shared/submission/MyLinkedList.java "$GRADER_DIRECTORY"/textgen
cd "$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 -cp .:/usr/share/java/junit4.jar textgen/*.java 2>errorfile
elif [ "$PARTID" == "$MOD3_PART1_2_ID" ]; then
GRADER_DIRECTORY=mod3/part1
FILENAME="mod3part1.py"
do_unzip MyLinkedListTester.java false
cp /shared/submission/MyLinkedListTester.java "$GRADER_DIRECTORY"/textgen
cd "$GRADER_DIRECTORY"
python "$FILENAME"
exit 0
elif [ "$PARTID" == "$MOD3_PART2_ID" ]; then
GRADER_DIRECTORY=mod3/part2
FILENAME="textgen.MarkovTextGeneratorGrader"
do_unzip MarkovTextGeneratorLoL.java false
cp /shared/submission/MarkovTextGeneratorLoL.java "$GRADER_DIRECTORY"/textgen
cd "$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 textgen/*.java 2>errorfile
elif [ "$PARTID" == "$MOD4_PART1_ID" ]; then
GRADER_DIRECTORY=mod4/part1
FILENAME="spelling.DictionaryGrader"
do_unzip mod4part1.zip true
cd zipfile
if [ ! -f "DictionaryLL.java" ]; then
rm -rf __MACOSX > /dev/null
cd *
fi
cp * /grader/mod4/part1/spelling
cd /grader/"$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 spelling/*.java 2>errorfile
elif [ "$PARTID" == "$MOD4_PART2_ID" ]; then
GRADER_DIRECTORY=mod4/part2
FILENAME="spelling.TrieGrader"
do_unzip mod4part2.zip true
cd zipfile
if [ ! -f "AutoCompleteDictionaryTrie.java" ]; then
rm -rf __MACOSX > /dev/null
cd *
fi
cp * /grader/"$GRADER_DIRECTORY"/spelling
cd /grader/"$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 spelling/*.java 2>errorfile
elif [ "$PARTID" == "$MOD5_PART1_ID" ] || [ "$PARTID" == "$MOD5_PART2_ID" ]; then
if [ "$PARTID" == "$MOD5_PART1_ID" ]; then
GRADER_DIRECTORY=mod5/part1
else
GRADER_DIRECTORY=mod5/part2
fi
FILENAME="spelling.NearbyWordsGrader"
do_unzip NearbyWords.java false
cp /shared/submission/NearbyWords.java "$GRADER_DIRECTORY"/spelling
cd "$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 spelling/*.java 2>errorfile
elif [ "$PARTID" == "$MOD5_PART3_ID" ]; then
GRADER_DIRECTORY=mod5/part3
FILENAME="spelling.WPTreeGrader"
do_unzip WPTree.java false
cp /shared/submission/WPTree.java "$GRADER_DIRECTORY"/spelling
cd "$GRADER_DIRECTORY"
javac -encoding ISO-8859-1 spelling/*.java 2>errorfile
else
echo "{ \"fractionalScore\": 0.0, \"feedback\":\"No partID matched: "$PARTID"\" }"
exit 1
fi
if [ ! $? -eq 0 ]; then
cp errorfile /grader
python /grader/compile_error.py
exit 0
fi
java "$FILENAME" > extra.out 2> err.out
if [ -s output.out ]; then
cat output.out
else
echo "{ \"fractionalScore\": 0.0, \"feedback\":\"Program terminated unexpectedly. Make sure you aren't including the graders with your submission or calling System.exit().\" }"
fi