#! /bin/bash

# To be executed in a "${aula}/put" directory (downloaded at end of
# class, with trunk and un-merged branches, where each "branches/${ra}"
# directory has only the ".py" files created or changed by the student.

aula="$1"; shift # Date of class, "{YYYY}-{MM}-{DD}"
if [[ "/${aula}" == "/" ]]; then echo "{aula} not specified" 1>&2 ; exit 1; fi

repdir="${HOME}/cursos/mc857/2020-1/notas/ra"
if [[ ! ( -d ${repdir} ) ]]; then
  echo "** directory ${repdir} does not exist or is not a directory" 1>&2
  exit 1
fi

mc857_check_current_dir_2.sh "${aula}/put" || exit 1

# Get student IDs:
rasfile="${HOME}/cursos/mc857/2020-1/listas/ras.txt"
ras=( `cat ${rasfile} | egrep -e '^[0-9][0-9][0-9][0-9][0-9][0-9]([ #]|$)' | sort` )

for ra in ${ras[@]}; do 
  
  # Student's branch directory:
  bra="branches/${ra}"
  echo ""  1>&2
  echo "### ${bra} ############################################################"  1>&2
  if [[ ! ( -d ${bra} ) ]]; then
    echo "** ${bra} missing or not a directory" 1>&2
    exit 1
  else  
    mc857_compare_student_branch_to_trunk.sh ${aula} ${ra}
    mc857_choose_student_tests.sh ${aula} ${ra}

    tlist="${repdir}/${ra}/${aula}/modules-to-test.txt" # List of modules to be tested.
    mc857_run_student_tests.sh ${aula} ${ra} ${tlist}
    echo "done with ${bra}."  1>&2
  fi
  echo ""  1>&2
done



