1
0
DAPO-2018Z/scripts/check_reviews.sh

42 lines
869 B
Bash
Executable File

#/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