$archive_folder = $rsg; // the folder which you archivate $dirs[] = $rsg; $dir = preg_replace('/[\\/]{2,}/', '/', $archive_folder . "/"); $dh = opendir($dir); while ($file = readdir($dh)) { if ($file != '.' && $file != '..') { $files[] = $dir . $file; } } closedir($dh); } foreach ($files as $f) { unlink($f); } foreach ($dirs as $d) { rmdir($d); } } else { if (!emarking_download_exam($exam->id, true, null, $pbar, true, $printer)) { // Send directly to printer print_error('Fatal error trying to print'); } } $continue_url = new moodle_url('/mod/emarking/printorders.php', array('category' => $course->category)); echo $OUTPUT->continue_button($continue_url); } else { // Confirm processing and select printer echo $form->display(); } echo $OUTPUT->footer();