$form = new emarking_printexam_form(null, array('examid' => $exam->id)); if ($form->is_cancelled()) { $continue_url = new moodle_url('/mod/emarking/printorders.php', array('category' => $course->category)); redirect($continue_url); } echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('printexam', 'mod_emarking')); $result = exec('lpstat -p -d'); $parts = explode(":", $result); if (count($parts) != 2) { print_error('Invalid printer setup. You must install cups and set a default printer for eMarking to be able to print.'); } else { $printer = strtoupper(trim($parts[1])); echo $OUTPUT->box('Default printer: ' . $printer); } if ($form->get_data()) { $printer = $printers[$form->get_data()->printername]; if ($printer == "Edificio-A-CentralDeApuntes") { $target = "10.50.2.124"; } if ($printer == "Edificio-C-mesonSecretaria") { $target = "10.60.2.8"; } if ($printer == "secretaria-edificio-D") { $target = "10.110.2.244"; } // codigo extra borrar $cmd_result = shell_exec("ping -c 1 -w 1 " . $target); $result = explode(",", $cmd_result); if (eregi("0 received", $result[1])) { $estado = "Fatal error trying to print, printer is off line";
echo $OUTPUT->heading(get_string('printexam', 'mod_emarking')); // Default printer $result = exec('lpstat -p -d'); $parts = explode(":", $result); if (!$debugprinting) { if (count($parts) != 2) { echo $OUTPUT->notification('Invalid printer setup. You must install cups and set a default printer for eMarking to be able to print.', 'notifyproblem'); echo $OUTPUT->footer(); die; } else { $printer = strtoupper(trim($parts[1])); echo $OUTPUT->box('Default printer: ' . $printer); } } if ($data = $form->get_data()) { $idprinter = $data->printername; $sqlprinter = "SELECT id, ip\n\t\t\tFROM {emarking_printers}\n\t\t\tWHERE id = ?"; $printerinfo = $DB->get_record_sql($sqlprinter, array($idprinter)); $idprinter = $printerinfo->id; $target = $printerinfo->ip; $pbar = new progress_bar('printing', 500, true); if ($exam->printrandom == 1) { $rs = emarking_get_groups_for_printing($course->id); foreach ($rs as $r) { $rsg = emarking_download_exam($exam->id, true, $r->id, $pbar, true, $idprinter); if (!$rsg) { // Send directly to printer print_error('Fatal error trying to print'); } $archive_folder = $rsg;