#!/bin/bash
if [ $# -ne 2 ] ; then
   echo "Usage: $0 <assignment> <term>"
   echo "Eg. $0 a06 1149"
   exit 1
fi

ASSN=$1
TERM=$2

QUESTIONS=`ls ~/marking/$ASSN/test.0/in`

#Create the categories for correctness based on the testing folders found for autotests
#Also creates equal ranges for levels with remainder of equal division placed on lower levels
for i in $QUESTIONS; do
  if [ "$i" != "options.ss" ] ; then
    NUMTESTS=`ls ~/marking/$ASSN/test.0/in/$i | wc -l`
    RANGE=$[(NUMTESTS - 1) / 4]
    EXTRA=$[(NUMTESTS - 1) % 4] #good luck extending this
    LVL_0_RANGE=$([ $EXTRA -ge 1 ] && echo $[$RANGE + 1] || echo $RANGE)
    LVL_1_RANGE=$([ $EXTRA -ge 2 ] && echo $[$LVL_0_RANGE + $RANGE + 1] || echo $[$LVL_0_RANGE + $RANGE])
    LVL_2_RANGE=$([ $EXTRA -ge 3 ] && echo $[$LVL_1_RANGE + $RANGE + 1] || echo $[$LVL_1_RANGE + $RANGE])
    LVL_3_RANGE=$[$LVL_2_RANGE + $RANGE]
    FAILMSG="of $NUMTESTS tests passed or banned functions used."
    TESTMSG="of $NUMTESTS tests passed."
    echo "$i:Correctness,1,Very Poor,Weak,Passable,Good,Excellent,0-$LVL_0_RANGE $FAILMSG,$[$LVL_0_RANGE + 1]-$LVL_1_RANGE $TESTMSG,$[$LVL_1_RANGE + 1]-$LVL_2_RANGE $TESTMSG,$[$LVL_2_RANGE + 1]-$LVL_3_RANGE $TESTMSG,$NUMTESTS $TESTMSG"
  fi
done

cat ~/u/argemmel/automation/general-rubric.csv