#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, os.path, stat, sys

ex_no = 'project'

students = [
  ('Jasmin', 'blanchette', 'jbe248@vu.nl'),

#  ('Wouter', 'broziuswf', 'wbs820@student.vu.nl'),
#  ('Björn', 'fischerbo', 'bfr250@student.vu.nl'),
#  ('Per Fuchs', 'fuchsp', 'pfs250@student.vu.nl'),
#  ('Sarah', 'gerwensamvan', 'sgn274@student.vu.nl'),
#  ('Freddy', 'greeffakgde', 'fgf240@student.vu.nl'),
#  ('Sarthak', 'guptas', 'sga520@student.vu.nl'),
#  ('Simon', 'heijungss', 'shs308@student.vu.nl'),
#  ('Bas', 'heuvelbvanden', 'bvl290@student.vu.nl'),
#  ('Koen', 'kahlmank', 'kkn530@student.vu.nl'),
#  ('Axel', 'koolhaasae', 'aks283@student.vu.nl'),
#  ('Dimitris', 'koutsoulisd', 'dks224@student.vu.nl'),
#  ('Jana', 'leiblej', 'jle243@student.vu.nl'),
#  ('Georgi', 'nakovgl', 'gnv300@student.vu.nl'),
#  ('Marta', 'rozekm', 'mrk201@student.vu.nl'),
#  ('Tex', 'schönlanktaf', 'tex.schonlank@gmail.com'),
#  ('Jacob', 'sonnenbergja', 'jsg790@student.vu.nl'),
#  ('Kieke', 'swagerkee', 'ksr890@student.vu.nl'),
#  ('Michael', 'vasseurmcj', 'mvr320@student.vu.nl'),
#  ('Luc', 'veldhuisjf', 'jvs275@student.vu.nl'),
#  ('Marcus', 'vriesmkde', 'mvs386@student.vu.nl'),
#  ('Robin', 'wielrrvander', 'rwl440@student.vu.nl'),
#  ('Chao', 'zhangc', 'czg250@student.vu.nl'),
#  ('Siying', 'zhangs', 'szg380@student.vu.nl'),
#  ('Kjell', 'zijlemakerka', 'kzr290@student.vu.nl'),
  ]

homework_dir = os.path.dirname(os.path.abspath(__file__)) + \
  '/../marking/' + ex_no + '/'

for (first_name, lean_file_base, email) in students:
  lean_file_pattern = homework_dir + lean_file_base + '_*.lean'
  lean_file_name = homework_dir + lean_file_base + '.lean'
  os.system ('mv ' + lean_file_pattern + ' ' + lean_file_name + ' 2> /dev/null')

  email = first_name + ' <' + email + '>'

  if os.path.isfile(lean_file_name):
    print ('SEND ' + first_name + ' ' + lean_file_base + ' ' + email + ' ' + lean_file_name)
    os.system ('./send.py "' + email + '" "[LV] ' + ex_no + '_homework marking (look for ZZZ below)" ' + lean_file_name)
  else:
    print ('ERROR: Cannot find ' + lean_file_name)
