-
Notifications
You must be signed in to change notification settings - Fork 6
/
evaluateLabs_wrapup.sh
executable file
·93 lines (76 loc) · 2.68 KB
/
evaluateLabs_wrapup.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
#!/bin/bash
if [ "$1" == "-h" ]; then
echo "Evaluate ANM labs.";
echo "Usage:"
echo "$1 <labfolder>"
echo "Labfolder contains the downloaded folder from Its learning."
exit
fi
myBasedir=$(pwd)
logType=1
#timestr=$(date +%Y-%m-%d_%H%M)
#feedbackFile="$myBasedir/Feedback".$timestr."log"
myRootDir=$1
source Wrapup/supportfunc
#logIt "Feedback will be in $feedbackFile"
for student in $myRootDir/*
do
logIt "Checking $student in $myRootDir"
logIt " "
logIt "-begin-student- "
logIt " "
##Find the archive
archives=$(ls "$student"/*.tar.gz | wc -l )
if [ "$archives" != "1" ]; then
logIt "Missing archive, or too many"
logIt "Missing archive (tar.gz) or too many files submitted"
logIt "You should submit one archive (<coursecode>-<userid>.tar.gz, see lab assignment for details."
logIt "Your submission contained "
logIt $(ls -la *.tar.gz)
continue;
fi
archivename=$(ls "$student"/*.tar.gz)
logIt "One archive found, $archivename."
userid=$(basename "$archivename" .tar.gz)
array=(${userid//-/ })
classid=${array[0]}
userid=${array[1]}
logIt "Class and UserId (based on archive name) => $classid and $userid"
# tar -zxvf *.tar.gz
bname=$(echo "$classid-$userid")
builddir=$(mktemp -t -d ANM-XXXX )
fullpath="$archivename"
logIt "Extracting Archive ($archivename) into $builddir ."
logIt "Going into $builddir ."
cd $builddir
tar -zxvf "$fullpath" > unpack.log
fcount=$(ls | wc -l)
if (( $fcount > 2 )); then
logIt "Folder contains too many files ($fcount), should just have one folder and the unpack.log."
logIt "Generating feedback, then aborting this student."
## Generate feedback log
logIt "Your submitted archive did not contain the right information, it should just be a folder <coursecode>-<userid>, see lab assignment for details."
subfiles=$(ls -la | grep -v 'unpack.log')
logIt "$subfiles"
cd ..
# rm -rf $builddir
continue;
fi
logIt "Copying reference db.conf"
cp -v "$myBasedir/Wrapup/db.conf" "$builddir/"
logIt "Entering user folder, $classid-$userid . "
logIt "Calling: $myBasedir/Wrapup/checkMe.sh '$classid-$userid' '$builddir/mylog' 2"
$myBasedir/Wrapup/checkMe.sh "$classid-$userid" "$builddir/mylog" 2
logIt "Returned from test. "
sleep 1
status=$(grep -i "Missing" "$builddir/mylog" | wc -l)
logIt "There were $status 'Missing' items."
status=$(grep -i "Error" "$builddir/mylog" | wc -l)
logIt "There were $status 'Error' items."
## Assignments done
logIt "Preparing $builddir that we can read it"
chmod -R ag+rwx $builddir
logIt " "
logIt "-end-student- "
logIt " "
done