$htmlout .= '<select name="exercise" onchange="this.form.submit()">'; $htmlout .= '<option value="0">' . get_string('allstring', 'mootyper') . '</option>'; foreach ($exes as $x) { if ($se == $x['id']) { $htmlout .= '<option value="' . $x['id'] . '" selected="true">' . $x['exercisename'] . '</option>'; } else { $htmlout .= '<option value="' . $x['id'] . '">' . $x['exercisename'] . '</option>'; } } $htmlout .= '</select>'; $htmlout .= '</td></tr>'; } if ($des == -1) { $des = 0; } $grds = get_typer_grades_adv($mootyper->id, $se, $us, $orderBy, $des); if ($grds != FALSE) { if ($des == -1 || $des == 1) { $lnkAdd = "&desc=0"; } else { $lnkAdd = "&desc=1"; } $arrTextAdds = array(); $arrTextAdds[2] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[4] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[5] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[6] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[7] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[8] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[9] = '<span class="arrow-s" style="font-size:1em;"></span>'; $arrTextAdds[10] = '<span class="arrow-s" style="font-size:1em;"></span>';
<?php function array_to_csv_download($array, $filename = "export.csv", $delimiter = ";") { header('Content-Type: application/csv'); header('Content-Disposition: attachement; filename="' . $filename . '";'); header("Pragma: no-cache"); header("Expires: 0"); $f = fopen('php://output', 'w'); $headings = array(get_string('student', 'mootyper'), get_string('vmistakes', 'mootyper'), get_string('timeinseconds', 'mootyper'), get_string('hitsperminute', 'mootyper'), get_string('fullhits', 'mootyper'), get_string('precision', 'mootyper'), get_string('timetaken', 'mootyper'), get_string('wpm', 'mootyper')); fputcsv($f, $headings, $delimiter); foreach ($array as $gr) { $fields = array($gr->firstname . ' ' . $gr->lastname, $gr->mistakes, $gr->timeinseconds . ' s', $gr->hitsperminute, $gr->fullhits, $gr->precisionfield . '%', date('d. M Y G:i', $gr->timetaken), $gr->wpm); fputcsv($f, $fields, $delimiter); } fclose($f); } require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/lib.php'; require_once dirname(__FILE__) . '/locallib.php'; $m_id = optional_param('mootyperid', 0, PARAM_INT); $m_is_exam = optional_param('isexam', 0, PARAM_INT); if ($m_is_exam) { $grds = get_typergradesfull($m_id, 2, 0); } else { $grds = get_typer_grades_adv($m_id, 0, 0, 2, 0); } array_to_csv_download($grds, get_string('gradesfilename', 'mootyper'));