#!/usr/bin/php $l1) { if ($idx == 0 && $legenda1[$idx] == '' && $legenda2[$idx] == 'Leerlingcode') $leerlingnummer_gevonden = 1; if ($legenda1[$idx] == 'Vakken') { //echo("vak ${legenda2[$idx]}\n"); $vak = $legenda2[$idx]; if ($vak == 'kcv') continue; if ($vak == 're') continue; if ($vak == 'vip') continue; if ($vak == 'netl') continue; if ($vak == 'lo') continue; if ($vak == 'maat') continue; if ($vak == 'mt') continue; if ($vak == 'fd') continue; // niemand heeft fd if ($vak == 'anw') continue; if ($vak == 'doub') continue; // aangevinkt als doublant if ($vak == 'wisd') continue; if ($vak == 'kualg') continue; if ($vak == 'ckv') continue; if ($vak == 'gtc') $vak = 'grkc'; if ($vak == 'ltc') $vak = 'lakc'; $legenda_vak[$vak] = $idx; } else if ($legenda1[$idx] == 'Profielen') { //echo("profiel ${legenda2[$idx]}\n"); $legenda_profiel[$legenda2[$idx]] = $idx; } } if (!$leerlingnummer_gevonden) die("leerlingnummer niet in kolom 0?!?!?\n"); //print_r($vakken); //print_r($paketten); while (($row = fgetcsv($fp))) { $vakken = array (); $profielen = array (); foreach ($legenda_vak as $vak => $idx) { if (!($type = $row[$idx])) continue; /* remove question mark */ if (preg_match('/^(\w+)\?$/', $type, $matches)) { $type = $matches[1]; } if (!isset($vakken[$type])) $vakken[$type] = array (); $vakken[$type][] = $vak; } foreach ($legenda_profiel as $profiel => $idx) { if (!($type = $row[$idx])) continue; /* remove question mark */ if (preg_match('/^(\w+)\?$/', $type, $matches)) { $type = $matches[1]; } if (!isset($profielen[$type])) $profielen[$type] = array (); $profielen[$type][] = $profiel; } /* als opl niet HAVO, dan checken of dit een gymnasium of atheneumleerling betreft */ /* gymnasium heeft grkc of lakc in het gemeenschappelijke deel */ if ($opl != 'H') { if (count($vakken['gem']) != 2) { echo("-------leerling met te weinig vakken in gemeenschappelijk deel---------\n"); continue; } if (in_array('lakc', $vakken['gem']) || in_array('grkc', $vakken['gem'])) $opl = 'G'; else $opl = 'A'; } //print_r($vakken); //print_r($profielen); $pakket = array ('gem' => '', 'pv' => '', 'vd' => '', 'xv' => ''); ksort($vakken, SORT_NATURAL); foreach ($vakken as $type => $list) { if (!isset($pakket[$type])) die("onbekend soort vak\n"); natcasesort($list); $pakket[$type] = implode('-', $list); } if ($pakket['vd'] == '') { $pakket['vd'] = $pakket['xv']; $pakket['xv'] = ''; } // sommige leerlingen hebben meer dan 1 vak staan bij keuzevak if (count($res = explode('-', $pakket['vd'])) > 1) { $pakket['xv'] = $res[1]; $pakket['vd'] = $res[0]; } // sommige leerlingen hebben meer dan 1 vak staan bij extra vak if (count($res = explode('-', $pakket['xv'])) > 1) { $pakket['xv'] = $res[0]; } if (isset($profielen['dp'])) $profiel = substr($profielen['dp'][0], 1); else if (isset($profielen['pk'])) $profiel = $profielen['pk'][0]; else if (isset($profielen['pka'])) $profiel = $profielen['pka'][0]; else if (isset($profielen['pkg'])) $profiel = $profielen['pkg'][0]; $pakket_string = ''; if ($pakket['gem'] != '') $pakket_string .= 'G-'.$pakket['gem']; else die("impossible\n"); if ($pakket['pv'] != '') $pakket_string .= ',P-'.$pakket['pv']; else die("impossible\n"); if ($pakket['vd'] != '') $pakket_string .= ',V-'.$pakket['vd']; else die("impossible\n"); if ($pakket['xv'] != '') $pakket_string .= ',X-'.$pakket['xv']; $pakket_id = db_single_field(<<$profiel<-\n"); } } //print_r(fgetcsv($fp)); fclose($fp); ?>