lastInsertID(); } else { return mdb2_single_val($db, "SELECT opm_id FROM opm WHERE llnr = '%q' AND text = '%q'", $llnr, $text); } assert(false); } function filter_hashToets($toets) { // haal de nepgroepen die beginnen met #Toets eruit return !preg_match('/#Toets/', $toets); } function fatsoeneer($file_id) { global $db; $toetsen = mdb2_query($db, "SELECT * FROM toetsen WHERE file_id = %i", $file_id); while ($toets = $toetsen->fetchRow(MDB2_FETCHMODE_ASSOC)) { if (!$toets['toets_afd']) continue; $grps = array_values(array_filter(explode(',', $toets['toets_grp']), 'filter_hashToets')); $loks = explode(',', $toets['toets_lok']); $survs = explode(',', $toets['toets_surv']); if (count($loks) == 1) continue; if (count($loks) > 1 && count($grps) == count($loks) && ( $toets['toets_surv'] == '' || count($survs) == count($loks))) { print_r($toets); print_r($grps); print_r($loks); print_r($survs); // deze toets is splitsbaar for ($i = 0; $i < count($loks); $i++) { $grp = $grps[$i]; $lok = $loks[$i]; if ($toets['toets_surv'] == '') $surv = ''; else $surv = $survs[$i]; echo("grp=$grp, lok=$lok, surv=$surv\n"); mdb2_exec($db, "INSERT INTO toetsen ( file_id, toets_formula, toets_date, toets_start, toets_end, toets_afd, toets_vak, toets_grp, toets_lok, toets_surv, toets_crap_id ) VALUES ( %i, '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', %i )", $file_id, $toets['toets_formula'], $toets['toets_date'], $toets['toets_start'], $toets['toets_end'], $toets['toets_afd'], $toets['toets_vak'], $grp, $lok, $surv, $toets['toets_crap_id']); } mdb2_exec($db, "DELETE FROM toetsen WHERE toets_id = %i", $toets['toets_id']); } } } ?>