1
0
forked from bikol/ZAPO-2018L
ZAPO-2018L/scripts/check_reviews.sh
2019-02-24 11:52:40 +01:00

42 lines
853 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`
if [ "$SCORE" = "0" ] || [ "$SCORE" = "1" ] || [ "$SCORE" = "2" ]; then
SUM=$((SUM+SCORE))
else
echo "Wrong score"
VALID=0
fi
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 [ "$VALID" = "1" ]; then
echo "\nYour reviews are valid !"
else
echo "\nYour reviews are NOT VALID !"
fi