Example #1
0
 // 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";
 } elseif (eregi("1 received", $result[1])) {
     $estado = "OK";
 } else {
     $estado = "Fatal error trying to print, printer is unknown";
 }
 if ($estado != "OK") {
     print_error($estado);
 }
 $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, $printer);
         if (!$rsg) {
             // Send directly to printer
             print_error('Fatal error trying to print');
         }
         $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;
             }
Example #2
0
 function validation($data, $files)
 {
     global $CFG;
     // echo date("M-d-Y - h:m:s",time());
     $errors = array();
     /*
     		$date = usertime ( time () );
     		
     		$today = new DateTime ();
     		$today->setTimestamp ( $date );
     		
     		$examdate = new DateTime ();
     		$examdate->setTimestamp ( $data ['examdate'] );
     		
     		$mindiff = 2;
     		if (isset ( $CFG->emarking_minimumdaysbeforeprinting )) {
     			$mindiff = intval ( $CFG->emarking_minimumdaysbeforeprinting );
     		}
     		
     		$dw = date ( "w", $examdate->getTimestamp () );
     		$dh = date ( "G", $examdate->getTimestamp () );
     		$dwt = date ( "w", $today->getTimestamp () );
     		
     		$diasRestantes = $dw - $dwt;
     		
     		if ($diasRestantes < 2) {
     			$a = new stdClass ();
     			$a->mindays = $mindiff;
     			$errors ['examdate'] = get_string ( 'examdateinvalid', 'mod_emarking', $a );
     			return $errors;
     		}
     		
     		// Sundays are forbidden, saturdays from 6am to 9pm
     		if ($dw == 0 || ($dw == 6 && ($dh < 6 || $dh > 15))) {
     			$a = new stdClass ();
     			$a->mindays = $mindiff;
     			$errors ['examdate'] = get_string ( 'examdateinvalid', 'mod_emarking', $a );
     			return $errors;
     		}*/
     /*
      * $printdate = clone $examdate; $diff = 0; while ( $diff < $mindiff ) { $printdate->modify ( '-24 hour' ); $dw = date ( "w", $printdate->getTimestamp () ); if ($dw == 0) $dw = 7; if ($dw < 6) $diff ++; } $diff = $printdate->diff ( $today ); if ($diff->invert == 1) { } else { $a = new stdClass(); $a->mindays = $mindiff; $errors ['examdate'] = get_string('examdateinvalid','mod_emarking', $a ); }
      */
     if ($CFG->emarking_enableprintingrandom) {
         if ($data["printrandom"] == 1) {
             $rs = emarking_get_groups_for_printing($data["course"]);
             $result = array();
             foreach ($rs as $r) {
                 $result[] = $r;
             }
             if (empty($result)) {
                 $errors['printrandom'] = get_string('printrandominvalid', 'mod_emarking');
                 return $errors;
             }
         }
     }
     return $errors;
 }