<commit_before><? require('include/init.php');
check_isset_array($_GET, 'callback', 'week_id', 'student_id');
// Now, the magic happens ...
$assignments = array();
$cursor = mysql_query_safe(<<<EOT
SELECT agenda_id, notitie_id, lesuur, (
	SELECT afkorting FROM vak WHERE vak_id = (
		SELECT vak_id FROM grp2vak WHERE grp2vak_id = (
			SELECT grp2vak_id FROM grp2vak2agenda WHERE agenda_id = agenda.`agenda_id`
		)
	)
) AS vak, (
	SELECT `text` FROM notities WHERE `notitie_id`=agenda.notitie_id
) AS `text` FROM agenda WHERE agenda_id IN (
	SELECT agenda_id FROM grp2vak2agenda WHERE grp2vak_id IN (
		SELECT grp2vak_id FROM grp2vak WHERE grp_id IN (
			SELECT grp_id FROM ppl2grp WHERE ppl_id = (
				SELECT ppl_id FROM ppl WHERE login="%s" LIMIT 1
			)
		)
	)
) AND `week`="%s" ORDER BY dag, lesuur
EOT
, mysql_escape_safe($_GET['student_id']), 
mysql_escape_safe($_GET['week_id']));

$assignments = array();

while ($row = mysql_fetch_array($cursor)) {
	$tag_cursor = mysql_query_safe('SELECT tag FROM tags WHERE 
tag_id IN (SELECT tag_id FROM tags2notities WHERE notitie_id=%s)', 
mysql_escape_safe($row['notitie_id']));
	$tags = array();
	while ($tag_row = mysql_fetch_array($tag_cursor)) {
		$tags[] = $tag_row['tag'];
	}
	if ($row['dag'] != $d) {
		if ($day) $assignments["${d}"] = $day;
		$day = array();
		$d = $row['day'];
	}
	if ($row['lesuur'] != $i) {
		if ($lesson) $day["{$i}"] = $lesson;
		$lesson = array();
		$i = $row['lesuur'];
	}
	$lesson[] = array(
		'id' => $row['notitie_id'],
		'text' => $row['text'],
		'tags' => $tags,
		'subject' => $row['vak']
	);
}
$assignments["{$i}"] = $lesson;

?>
<?= $_GET['callback'] ?>(<?= json_encode($assignments) ?>);
<commit_msg>Hotfix `api_export.php`.<commit_after><? require('include/init.php');
check_isset_array($_GET, 'callback', 'week_id', 'student_id');
// Now, the magic happens ...
$assignments = array();
$cursor = mysql_query_safe(<<<EOT
SELECT agenda_id, notitie_id, lesuur, dag, (
	SELECT afkorting FROM vak WHERE vak_id = (
		SELECT vak_id FROM grp2vak WHERE grp2vak_id = (
			SELECT grp2vak_id FROM grp2vak2agenda WHERE agenda_id = agenda.`agenda_id`
		)
	)
) AS vak, (
	SELECT `text` FROM notities WHERE `notitie_id`=agenda.notitie_id
) AS `text` FROM agenda WHERE agenda_id IN (
	SELECT agenda_id FROM grp2vak2agenda WHERE grp2vak_id IN (
		SELECT grp2vak_id FROM grp2vak WHERE grp_id IN (
			SELECT grp_id FROM ppl2grp WHERE ppl_id = (
				SELECT ppl_id FROM ppl WHERE login="%s" LIMIT 1
			)
		)
	)
) AND `week`="%s" ORDER BY dag, lesuur
EOT
, mysql_escape_safe($_GET['student_id']), 
mysql_escape_safe($_GET['week_id']));

$assignments = array();

while ($row = mysql_fetch_array($cursor)) {
	$tag_cursor = mysql_query_safe('SELECT tag FROM tags WHERE 
tag_id IN (SELECT tag_id FROM tags2notities WHERE notitie_id=%s)', 
mysql_escape_safe($row['notitie_id']));
	$tags = array();
	while ($tag_row = mysql_fetch_array($tag_cursor)) {
		$tags[] = $tag_row['tag'];
	}
	if ($row['dag'] != $d) {
		if ($day) $assignments["{$d}"] = $day;
		$day = array();
		$d = $row['dag'];
	}
	if ($row['lesuur'] != $i) {
		if ($lesson) $day["{$i}"] = $lesson;
		$lesson = array();
		$i = $row['lesuur'];
	}
	$lesson[] = array(
		'id' => $row['notitie_id'],
		'text' => $row['text'],
		'tags' => $tags,
		'subject' => $row['vak']
	);
}
if ($lesson) $day["{$i}"] = $lesson;
if ($day) $assignments["{$d}"] = $day;

?>
<?= $_GET['callback'] ?>(<?= json_encode($assignments) ?>);

{'fraction_non_alphanumeric': 0.19103086779266162, 'fraction_numerical': 0.007571345369831101, 'mean_word_length': 4.942906574394463, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4842171', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1409, 'n_words': 312}