1
0
forked from bikol/ZAPO-2018L
ZAPO-2018L/scripts/check_reviews.sh

42 lines
869 B
Bash
Raw Normal View History

2018-09-28 09:59:26 +02:00
#/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage 'scripts/check_reviews.sh <task> <index_number>'"
exit 1
fi
TASK=$1
STUDENT=$2
VALID=1
SUM=0
for f in $TASK/reviews/$STUDENT/review-*.md; do
SCORE=`head -n1 $f | cut -d':' -f2 | xargs`
SUM=$((SUM+SCORE))
SL=`grep "# Strengths / Mocne strony" $f -A3 | grep "^\\*" | wc -l`
WL=`grep "# Weaknesses / Słabe strony" $f -A3 | grep "^\\*" | wc -l`
if [ "$SL" != "3" ] || [ "$WL" != "3" ]; then
echo "Wrong number of remarks."
VALID=0
fi
WRONG=`grep "^\\*[[:space:]]*$" $f | wc -l`
if [ "$WRONG" != "0" ]; then
echo "Review contain empty remark"
VALID=0
fi
done
if [ "$SUM" != "10" ]; then
printf "Total number of points for reviews (%d) is greater then 10.\n" $SUM
VALID=0
fi
if [ "$VALID" = "1" ]; then
echo "\nYour reviews are valid !"
else
echo "\nYour reviews are NOT VALID !"
fi