#!/bin/csh -f

set i=1
set max_test_nr=17
set total=0
set grade_file=grade.txt

if (-e ${grade_file}) then
    rm -f ${grade_file}
endif
echo "" > ${grade_file}
echo "**************" >> ${grade_file}
echo " Score for P1" >> ${grade_file}
echo "**************" >> ${grade_file}
echo "" >> ${grade_file}
echo "" >> ${grade_file}

while (${i} <= ${max_test_nr} )
  
    ./test.csh $i
    if ($status != 0) then
       echo "Test ${i}: 0 / 5" >> ${grade_file}
    else
       echo "Test ${i}: 5 / 5" >> ${grade_file}
       set total=`expr ${total} + 5`
    endif
    set i=`expr ${i} + 1`
end

echo "" >> ${grade_file}
echo "" >> ${grade_file}
echo "----------------" >> ${grade_file}
echo "Total  : ${total} / `expr ${max_test_nr} \* 5`" >> ${grade_file}
echo "----------------" >> ${grade_file}
