<?php require_once 'Processus.class.php'; Processus::startQuizScriptAndViewCreatedProcess($_GET['quiz-id'], "omr.sh");
public static function startQuizScriptAndViewCreatedProcess($quiz_id, $script) { global $quiz_bin_dir; $q = Quiz::getQuizById($quiz_id); if ($q->hasRunningProcess()) { echo "<html><head><title>Erreur</title></head><body>Erreur: un processus est déjà actif pour ce quiz.<br><br>"; global $quiz; $quiz = $q; doMainMenu(); echo "</body></html>"; return; } $p = Processus::createBackgroundProcess($q, $quiz_bin_dir . $script . " " . $q->getName()); sleep(1); // Pour éviter d'avoir une erreur indiquant que les fichiers de log ne sont pas encore créés. TODO: A remplacer par quelque chose de mieux. echo "<html><head><title>Redirection vers la visualisation de la sortie du processus</title>"; echo "<meta http-equiv=\"REFRESH\" content=\"0; URL=./view_process_progress.php?quiz-id=" . $quiz_id . "\">"; echo "</head><body>Redirection</body></html>"; }
<?php require_once 'Processus.class.php'; Processus::startQuizScriptAndViewCreatedProcess($_GET['quiz-id'], "create_students_file_from_scans_infos.sh");
<?php require_once 'Processus.class.php'; require_once 'Quiz.class.php'; require_once 'quiz_common.php'; $quiz = Quiz::getQuizById($_GET['quiz-id']); $page_title = 'Processus terminés'; include 'header.php'; ?> <ul> <?php $processes = Processus::getAllProcesses($quiz); foreach ($processes as $pid => $processus) { echo "<li><a href=\"view_process_progress.php?quiz-id=" . $quiz->getId() . "&pid=" . $processus->getPid() . "\">" . str_replace($quiz_bin_dir, "", $processus->getCommand()); if ($processus->getStartTime() != 0) { echo " (Started at " . date('d/m/Y H:i:s', $processus->getStartTime()) . " with PID " . $processus->getPid(); if ($processus->getEndTime() != 0) { echo " - Duration: " . ($processus->getEndTime() - $processus->getStartTime()) . " seconds)"; } else { echo ")"; } } else { echo " (PID " . $processus->getPid() . ")"; } echo "</a></li>"; } ?> </ul> <br> <?php doMainMenu();
<?php require_once 'Processus.class.php'; Processus::startQuizScriptAndViewCreatedProcess($_GET['quiz-id'], "correct_quiz.sh");
/** * Get current size (x and y) of the window. * * @access public * @return array */ public static function getSize() { if (OS_WIN) { $modecon = explode("\n", ltrim(Processus::execute('mode con'))); $_y = trim($modecon[2]); preg_match('#[^:]+:\\s*([0-9]+)#', $_y, $matches); $y = (int) $matches[1]; $_x = trim($modecon[3]); preg_match('#[^:]+:\\s*([0-9]+)#', $_x, $matches); $x = (int) $matches[1]; return array('x' => $x, 'y' => $y); } // Fix "tput: No value for $TERM and no -T specified" if (isset($_SERVER['TERM'])) { $prefix = "TERM={$_SERVER['TERM']}"; } else { $prefix = ''; } $cmd = "{$prefix} tput cols && {$prefix} tput lines"; $tput = Processus::execute($cmd, false); if (!empty($tput)) { list($x, $y) = explode("\n", $tput); return array('x' => intval($x), 'y' => intval($y)); } // DECSLPP. echo "[18t"; // Read \033[8;y;xt. fread(STDIN, 4); // skip \033, [, 8 and ;. $x = null; $y = null; $handle =& $y; do { $char = fread(STDIN, 1); switch ($char) { case ';': $handle =& $x; break; case 't': break 2; default: if (false === ctype_digit($char)) { break 2; } $handle .= $char; } } while (true); if (null === $x || null === $y) { return array('x' => 0, 'y' => 0); } return array('x' => (int) $x, 'y' => (int) $y); }
<?php require_once 'Processus.class.php'; Processus::startQuizScriptAndViewCreatedProcess($_GET['quiz-id'], "prepare_correction.sh");
<?php require_once 'Processus.class.php'; Processus::startQuizScriptAndViewCreatedProcess($_GET['quiz-id'], "fetch_scans_from_mail.sh"); ?>
<?php require_once 'Processus.class.php'; Processus::startQuizScriptAndViewCreatedProcess($_GET['quiz-id'], "correct_images_rotation.sh");
/** * Restore previous interaction options. * * @access public * @return void */ public static function restoreInteraction() { if (null === self::$_old) { return; } Processus::execute('stty ' . self::$_old); return; }