Advertisement
tpaper

StatGenerator 0.01 beta

Feb 12th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 37.72 KB | None | 0 0
  1. <?php
  2.  
  3. //Exams Stats generator
  4. //Started on: 4 feb 2015 21:15
  5. //First version (0.5 beta) finisher on: 5 feb 2015 20:41
  6.  
  7. //Enrico Ronconi <enrico.ronconi@yahoo.it>
  8.  
  9. function connect(&$MYSQL) {
  10.   global $verbose;
  11.   //Default connection settings
  12.   $MYSQL_host = 'localhost';
  13.   $MYSQL_username = 'php';
  14.   $MYSQL_password = 'cqc4psB7eLBeDdHH';
  15.   $MYSQL_database = 'polimi';
  16.  
  17.   if($verbose) echo("Trying to connect to $MYSQL_host MySQl database using user $MYSQL_username (db: $MYSQL_database)...\n");
  18.   $MYSQL = @new mysqli($MYSQL_host, $MYSQL_username, $MYSQL_password, $MYSQL_database); //Start connection
  19.  
  20.   if($MYSQL->connect_error) die('Error while connection (Errno: '.$MYSQL->connect_errno.' - '.$MYSQL->connect_error.")!\nAborted\n"); echo("Succesfully connected!\n");
  21.  
  22.   $MYSQL->set_charset("utf8");
  23.  
  24. }
  25.  
  26. function close_connection(&$MYSQL) {
  27.   $MYSQL->close();
  28. }
  29.  
  30. function exec_query($query,&$obj) {
  31.   global $db,$verbose;
  32.  
  33.   if($verbose) echo("Exec $query\n");
  34.  
  35.   $obj = $db->query($query);
  36.  
  37.   if($obj){
  38.   if($verbose) echo("Success!\n");
  39.   return False;
  40.   } else {
  41.   echo("Error ".$db->errno." - ".$db->error."\n");
  42.   return True;
  43.   }
  44. }
  45.  
  46. function get_students_number($exam) {
  47.   global $db, $result_table, $info_table, $matr_field_name, $sex_field, $examid_field, $retired_field;
  48.  
  49.   //General
  50.   if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam",$x)) return False;
  51.   $total = $x->fetch_row(); $x->close(); $total = intval($total[0]);
  52.  
  53.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0",$x)) return False;
  54.   $male = $x->fetch_row(); $x->close(); $male = intval($male[0]);
  55.  
  56.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1",$x)) return False;
  57.   $female = $x->fetch_row(); $x->close(); $female = intval($female[0]);
  58.  
  59.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL",$x)) return False;
  60.   $unknown = $x->fetch_row(); $x->close(); $unknown = intval($unknown[0]);
  61.  
  62.   $general = array($total, $male, $female, $unknown);
  63.  
  64.   //Assenti/Ritirati
  65.   if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam AND `$retired_field` = 1",$x)) return False;
  66.   $total = $x->fetch_row(); $x->close(); $total = intval($total[0]);
  67.  
  68.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$retired_field` = 1" ,$x)) return False;
  69.   $male = $x->fetch_row(); $x->close(); $male = intval($male[0]);
  70.  
  71.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$retired_field` = 1",$x)) return False;
  72.   $female = $x->fetch_row(); $x->close(); $female = intval($female[0]);
  73.  
  74.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$retired_field` = 1",$x)) return False;
  75.   $unknown = $x->fetch_row(); $x->close(); $unknown = intval($unknown[0]);
  76.  
  77.   $retired = array($total, $male, $female, $unknown);
  78.  
  79.   return array($general,$retired);  
  80. }
  81.  
  82. function get_students_result($exam) {
  83.   global $db, $verbose, $result_table, $info_table, $matr_field_name, $sex_field, $examid_field, $retired_field, $passed_vote, $vote_field, $exam_info_table, $examinfo_id_field, $debit_field, $all_votes;
  84.  
  85.   //Passed
  86.   if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam AND `$vote_field` >= $passed_vote",$x)) return False;
  87.   $total = $x->fetch_row(); $x->close(); $total = intval($total[0]);
  88.  
  89.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$vote_field` >= $passed_vote",$x)) return False;
  90.   $male = $x->fetch_row(); $x->close(); $male = intval($male[0]);
  91.  
  92.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$vote_field` >= $passed_vote",$x)) return False;
  93.   $female = $x->fetch_row(); $x->close(); $female = intval($female[0]);
  94.  
  95.   if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$vote_field` >= $passed_vote",$x)) return False;
  96.   $unknown = $x->fetch_row(); $x->close(); $unknown = intval($unknown[0]);
  97.  
  98.   $passed = array($total, $male, $female, $unknown);
  99.  
  100.   //Debit
  101.  
  102.   if(exec_query("SELECT `$debit_field` FROM `$exam_info_table` WHERE `$examinfo_id_field` = $exam",$x)) return False;
  103.   $allow_debit = $x->fetch_row(); $x->close(); $allow_debit = $allow_debit[0];
  104.  
  105.   if(is_null($allow_debit)) {
  106.     if($verbose) echo("No debits allowed!\n");
  107.     $debit = NULL;
  108.   } else {
  109.     $debit_vote = intval($allow_debit);  
  110.  
  111.     if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam AND `$vote_field` < $passed_vote AND `$vote_field` >= $debit_vote",$x)) return False;
  112.     $total = $x->fetch_row(); $x->close(); $total = intval($total[0]);
  113.    
  114.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$vote_field` < $passed_vote AND `$vote_field` >= $debit_vote",$x)) return False;
  115.     $male = $x->fetch_row(); $x->close(); $male = intval($male[0]);
  116.    
  117.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$vote_field` < $passed_vote AND `$vote_field` >= $debit_vote",$x)) return False;
  118.     $female = $x->fetch_row(); $x->close(); $female = intval($female[0]);
  119.    
  120.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$vote_field` < $passed_vote AND `$vote_field` >= $debit_vote",$x)) return False;
  121.     $unknown = $x->fetch_row(); $x->close(); $unknown = intval($unknown[0]);
  122.  
  123.     $debit = array($total, $male, $female, $unknown, $debit_vote);
  124.   }
  125.  
  126.   if(exec_query("SELECT `$all_votes` FROM `$exam_info_table` WHERE `$examinfo_id_field` = $exam",$x)) return False;
  127.   $i_have_all_votes = $x->fetch_row(); $x->close(); $i_have_all_votes = intval($i_have_all_votes[0]);
  128.  
  129.   if($i_have_all_votes) {
  130.     //Rejected
  131.     if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam AND `$vote_field` < $passed_vote",$x)) return False;
  132.     $total = $x->fetch_row(); $x->close(); $total = intval($total[0]);
  133.    
  134.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$vote_field` < $passed_vote",$x)) return False;
  135.     $male = $x->fetch_row(); $x->close(); $male = intval($male[0]);
  136.    
  137.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$vote_field` < $passed_vote",$x)) return False;
  138.     $female = $x->fetch_row(); $x->close(); $female = intval($female[0]);
  139.    
  140.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$vote_field` < $passed_vote",$x)) return False;
  141.     $unknown = $x->fetch_row(); $x->close(); $unknown = intval($unknown[0]);
  142.    
  143.     $rejected = array($total, $male, $female, $unknown);
  144.   } else {
  145.     if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam AND `$vote_field` IS NULL AND `$retired_field` = 0",$x)) return False;
  146.     $total = $x->fetch_row(); $x->close(); $total = intval($total[0]);
  147.    
  148.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$vote_field` IS NULL AND `$retired_field` = 0",$x)) return False;
  149.     $male = $x->fetch_row(); $x->close(); $male = intval($male[0]);
  150.    
  151.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$vote_field` IS NULL AND `$retired_field` = 0",$x)) return False;
  152.     $female = $x->fetch_row(); $x->close(); $female = intval($female[0]);
  153.    
  154.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$vote_field` IS NULL AND `$retired_field` = 0",$x)) return False;
  155.     $unknown = $x->fetch_row(); $x->close(); $unknown = intval($unknown[0]);
  156.    
  157.     $rejected = array($total, $male, $female, $unknown);
  158.   }
  159.  
  160.   return array($passed,$debit,$rejected);
  161.  
  162. }
  163.  
  164. function get_exam_info($exam) {
  165.   global $db, $all_votes, $exam_info_table, $examinfo_id_field, $debit_field, $exam_subject_field, $exam_date_field, $exam_course_field, $exam_type_field, $exam_oral_field, $date_format;
  166.  
  167.   if(exec_query("SELECT `$exam_subject_field`,DATE_FORMAT(`$exam_date_field`,\"$date_format\"),`$exam_course_field`,`$exam_type_field`,`$exam_oral_field`,`$debit_field`,DATE_FORMAT(`$exam_date_field`,\"%d%m%y\") FROM `$exam_info_table` WHERE `$examinfo_id_field` = $exam",$x)) return False;
  168.   $total = $x->fetch_row(); $x->close(); return $total;
  169. }
  170.  
  171. function get_average($exam) {
  172.   global $db, $result_table, $info_table, $matr_field_name, $sex_field, $examid_field, $retired_field, $passed_vote, $vote_field, $all_votes, $exam_info_table, $examinfo_id_field;
  173.  
  174.   //Passed
  175.   if(exec_query("SELECT AVG(`$vote_field`) FROM `$result_table` WHERE `$examid_field` = $exam AND `$vote_field` >= $passed_vote",$x)) return False;
  176.   $total = $x->fetch_row(); $x->close(); $total = floatval($total[0]);
  177.  
  178.   if(exec_query("SELECT AVG(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$vote_field` >= $passed_vote",$x)) return False;
  179.   $male = $x->fetch_row(); $x->close(); $male = floatval($male[0]);
  180.  
  181.   if(exec_query("SELECT AVG(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$vote_field` >= $passed_vote",$x)) return False;
  182.   $female = $x->fetch_row(); $x->close(); $female = floatval($female[0]);
  183.  
  184.   if(exec_query("SELECT AVG(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$vote_field` >= $passed_vote",$x)) return False;
  185.   $unknown = $x->fetch_row(); $x->close(); $unknown = floatval($unknown[0]);
  186.  
  187.   $passed = array($total, $male, $female, $unknown);
  188.  
  189.   //Global average
  190.   if(exec_query("SELECT `$all_votes` FROM `$exam_info_table` WHERE `$examinfo_id_field` = $exam",$x)) return False;
  191.   $i_have_all_votes = $x->fetch_row(); $x->close(); $i_have_all_votes = intval($i_have_all_votes[0]);
  192.  
  193.   if($i_have_all_votes) {
  194.     if(exec_query("SELECT AVG(`$vote_field`) FROM `$result_table` WHERE `$examid_field` = $exam AND `$vote_field` IS NOT NULL",$x)) return False;
  195.     $total = $x->fetch_row(); $x->close(); $total = floatval($total[0]);
  196.    
  197.     if(exec_query("SELECT AVG(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0 AND `$vote_field` IS NOT NULL",$x)) return False;
  198.     $male = $x->fetch_row(); $x->close(); $male = floatval($male[0]);
  199.    
  200.     if(exec_query("SELECT AVG(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1 AND `$vote_field` IS NOT NULL",$x)) return False;
  201.     $female = $x->fetch_row(); $x->close(); $female = floatval($female[0]);
  202.    
  203.     if(exec_query("SELECT AVG(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL AND `$vote_field` IS NOT NULL",$x)) return False;
  204.     $unknown = $x->fetch_row(); $x->close(); $unknown = floatval($unknown[0]);
  205.    
  206.     $general = array($total, $male, $female, $unknown);
  207.   } else {
  208.     $general = NULL;
  209.   }
  210.  
  211.   if(exec_query("SELECT MIN(`$vote_field`) FROM `$result_table` WHERE `$examid_field` = $exam",$x)) return False;
  212.   $total = $x->fetch_row(); $x->close(); $total = floatval($total[0]);
  213.  
  214.   if(exec_query("SELECT MIN(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0",$x)) return False;
  215.   $male = $x->fetch_row(); $x->close(); $male = floatval($male[0]);
  216.  
  217.   if(exec_query("SELECT MIN(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1",$x)) return False;
  218.   $female = $x->fetch_row(); $x->close(); $female = floatval($female[0]);
  219.  
  220.   if(exec_query("SELECT MIN(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL",$x)) return False;
  221.   $unknown = $x->fetch_row(); $x->close(); $unknown = floatval($unknown[0]);
  222.  
  223.   $min = array($total, $male, $female, $unknown);
  224.  
  225.   if(exec_query("SELECT MAX(`$vote_field`) FROM `$result_table` WHERE `$examid_field` = $exam",$x)) return False;
  226.   $total = $x->fetch_row(); $x->close(); $total = floatval($total[0]);
  227.  
  228.   if(exec_query("SELECT MAX(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 0",$x)) return False;
  229.   $male = $x->fetch_row(); $x->close(); $male = floatval($male[0]);
  230.  
  231.   if(exec_query("SELECT MAX(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` = 1",$x)) return False;
  232.   $female = $x->fetch_row(); $x->close(); $female = floatval($female[0]);
  233.  
  234.   if(exec_query("SELECT MAX(`$vote_field`) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name`) WHERE `$examid_field` = $exam AND `$info_table`.`$sex_field` IS NULL",$x)) return False;
  235.   $unknown = $x->fetch_row(); $x->close(); $unknown = floatval($unknown[0]);
  236.  
  237.   $max = array($total, $male, $female, $unknown);  
  238.  
  239.   return array($general,$passed,$min,$max);
  240.  
  241. }
  242.  
  243. function halp_pls() {
  244.   echo('Exam stats generator V 0.5 Beta
  245. Enrico Ronconi <ronconi.enrico@yahoo.it> student @ Politecnico di Milano (IT)
  246.  
  247. OPTIONS:
  248.  REQUIRED:
  249.     -i  --info-table="name"     Table wich contents the info about the students.
  250.     -r  --result-table="table name" Table wich contents the exams results.
  251.     -e  --exams-info-table="table name" Table wich contents the info about the exams.
  252.     -t  --target-exam           Specify the exam to analyze. You can compare
  253.                     exams result by inserting more than one exam ID
  254.                     separated using ","
  255.                     Examples:
  256.                       --target-exam="2"
  257.                       --target-exam="2,4,5".
  258.  
  259.  OPTIONAL:
  260.     -o  --filename="name"       Specify an output filename (Omit .pdf)
  261.                     (Default: "ddmmyy_subject")
  262.     --date-format="format"      Date format, refer to mysql DATE_FORMAT() manpage
  263.                     (Default: "%W %d %M %Y").
  264.     --course-name="name"        Specify a different course name instead of using
  265.                     the one indicated in the exam-info-table.
  266.     --skip-graph            Don\'t create the graph.
  267.     --make-only-latex-source    Create only latex source without compiling it.
  268.     --keepfiles         Keep intermediate files (pdflatex aux file,
  269.                     gnuplot files, latex source, etc.).
  270.     -h  --help              Show this help.
  271.     -v  --verbose           Verbose mode.
  272. ');
  273.   die();
  274.  
  275. }
  276.  
  277. function main($argv) {
  278.   $options = getopt("i:r:e:t:hvo:",array("info-table:","result-table:","exams-info-table:","target-exam:","date-format:","course-name:","help","verbose","skip-graph","keepfiles","make-only-latex-source","filename"));
  279.  
  280.   if(array_key_exists('h',$options) OR array_key_exists('help',$options)) halp_pls();
  281.   if(@is_null($options['i']) AND @is_null($options['info-table'])) die("Pleas specify the table that contents the information about the students!\nTry the option -h for more informations\nAborted\n");
  282.   if(@is_null($options['r']) AND @is_null($options['result-table'])) die("Pleas specify the table that contents the results of the exam(s)!\nTry the option -h for more informations\nAborted\n");
  283.   if(@is_null($options['e']) AND @is_null($options['exams-info-table'])) die("Pleas specify the table that contents the infos about the exams!\nTry the option -h for more informations\nAborted\n");
  284.   if(@is_null($options['t']) AND @is_null($options['target-exam'])) die("Pleas specify the target exam(s)!\nTry the option -h for more informations\nAborted\n");
  285.  
  286.   global $matr_field_name; $matr_field_name = 'Matricola';
  287.   global $sex_field; $sex_field = 'HaveFiga';
  288.   global $name_field; $name_field = 'Nome';
  289.   global $examid_field; $examid_field = 'ID_Esame';
  290.   global $retired_field; $retired_field = 'Ritirato';
  291.   global $vote_field; $vote_field = 'Voto';
  292.  
  293.   global $debit_field; $debit_field = 'Soglia_debito';
  294.   global $all_votes; $all_votes = 'Voti_bocciati';
  295.   global $examinfo_id_field; $examinfo_id_field = 'ID';
  296.   global $exam_subject_field; $exam_subject_field = 'Materia';
  297.   global $exam_date_field; $exam_date_field = 'Data';
  298.   global $exam_course_field; $exam_course_field = 'Corso';
  299.   global $exam_type_field; $exam_type_field = 'Tipo';
  300.   global $exam_oral_field; $exam_oral_field = 'Orale';
  301.  
  302.   global $date_format; $date_format = '%W %d %M %Y';
  303.  
  304.   if(array_key_exists('date-format',$options)) $date_format = $options['date-format'];
  305.  
  306.   global $db;
  307.   global $verbose; $verbose = 0;
  308.   if(array_key_exists('v',$options) OR array_key_exists('verbose',$options)) $verbose = 1;
  309.  
  310.   global $passed_vote; $passed_vote = 18;
  311.  
  312.   global $info_table;
  313.   global $result_table;
  314.   global $exam_info_table;
  315.   global $columns;
  316.  
  317.   global $delete_files; if(array_key_exists('keepfiles',$options)) $delete_files = 0; else $delete_files = 1;
  318.   global $compile_latex; if(array_key_exists('make-only-latex-source',$options)) $compile_latex = 0; else $compile_latex = 1;
  319.  
  320.   $info_table = @$options['i'].@$options['info-table'];
  321.   $result_table = @$options['r'].@$options['result-table'];
  322.   $exam_info_table = @$options['e'].@$options['exams-info-table'];
  323.   $columns = explode(",",@$options['t'].@$options['target-exams']);
  324.  
  325.   if(count($columns) == 0) die("Pleas specify at least one column that contents the results of the exam!\nAborted\n");
  326.   if(count($columns) > 1) die("Sorry, the multiple column examination has not been implemented yet!\nAborted\n");
  327.  
  328.   echo("I will examinate the result table ".$result_table." using the info from the table ".$info_table."!\nThe following exams will be examinated: ".implode($columns,", ")."\n\n");
  329.  
  330.   connect($db);
  331.  
  332.   $n = get_students_number($columns[0]);
  333.   $i = get_exam_info($columns[0]);
  334.   $r = get_students_result($columns[0]);
  335.   $a = get_average($columns[0]);
  336.  
  337.   if(array_key_exists('course-name',$options)) $i[2] = $options['course-name'];
  338.  
  339.   $filename = compose_name($i);
  340.  
  341.   if((array_key_exists('filename',$options) AND !@is_null($options['filename'])) OR (array_key_exists('o',$options) AND !@is_null($options['o']))) {
  342.     $filename = @$options['filename'].@$options['o'];
  343.     echo("Warning: you changed the output filename to $filename
  344. The program will delete all files that match the regexp \"$filename.*\" and \"graph_$filename*\"!
  345.  
  346. Are you sure? (Y/N)
  347. ");
  348.     $in = readline();
  349.     if($in != "Y" AND $in != 'y') die("Interruped\n");
  350.     }
  351.  
  352.   $name = compose_name($i);
  353.   if(array_key_exists('skip-graph',$options)) $grap_filename = NULL; else {
  354.     $grap_filename = create_graph(
  355.     array(partitionate_votes($columns[0],0),partitionate_votes($columns[0],1),partitionate_votes($columns[0],NULL)),
  356.     $filename
  357.     );
  358.   }
  359.  
  360.   if($n && $i && $r && $a) generate_latex($filename,$n,$r,$a,$i,$grap_filename);
  361.  
  362.   close_connection($db);
  363.  
  364.  
  365. }
  366.  
  367. function compose_name($i) {
  368.   return str_replace(array(" ","'",'"'),"_",$i[0]." ".$i[6]);
  369. }
  370.  
  371. function generate_latex($filename,$numbers,$results,$averages,$infos,$graph_tex_file = NULL) {
  372.   $p = array($numbers[0][0]-$numbers[1][0],$numbers[0][1]-$numbers[1][1],$numbers[0][2]-$numbers[1][2],$numbers[0][3]-$numbers[1][3]);
  373.   global $verbose, $delete_files, $compile_latex;
  374.   $debit_rows = '';
  375.   if (!is_null($results[1])){
  376.     $debit_rows = '
  377.    \ii Di cui: &&&&&&\\\\
  378.     \iii Promossi senza debito:     & \q{'.$results[0][0].'}            & \z{'.perc($results[0][0],$p[0]).'}            & \q{'.$results[0][1].'}                & \z{'.perc($results[0][1],$p[1]).'}            & \q{'.$results[0][2].'}            & \z{'.perc($results[0][2],$p[2]).'}            \\\\
  379.     \iii Promossi con debito:       & \q{'.$results[1][0].'}            & \z{'.perc($results[1][0],$p[0]).'}            & \q{'.$results[1][1].'}                & \z{'.perc($results[1][1],$p[1]).'}            & \q{'.$results[1][2].'}            & \z{'.perc($results[1][2],$p[2]).'}            \\\\
  380.    ';
  381.   }
  382.   $graph_code = '';
  383.   if($graph_tex_file){
  384.     $graph_code = '
  385.    \begin{figure}[h]
  386.             \include{'.$graph_tex_file.'}
  387.    \end{figure}
  388.    ';
  389.   }
  390.   $global_avg = '';
  391.   if (!is_null($averages[0])) {
  392.     $global_avg = 'Voto complessivo medio       & \q{'.r($averages[0][0]).'}                & ---                                   & \q{'.r($averages[0][1]).'}                & ---                                   & \q{'.r($averages[0][2]).'}                    & ---                                   \\\\';
  393.   }
  394.   $keeplog = 0;
  395.   $orale = 'prova scritta'; if($infos[4]) $orale = 'esame orale';
  396.   $pdflatex_options = '-interaction=nonstopmode';
  397.   $source_name = $filename.".tex";
  398.   $latexsource =
  399. '
  400. \documentclass{article}
  401. \usepackage[italian]{babel}
  402. \usepackage[T1]{fontenc}
  403. \usepackage[utf8]{inputenc}
  404. \usepackage{booktabs}
  405. \usepackage[margin=2cm]{geometry}
  406. \usepackage{multirow}
  407. \usepackage{graphicx}
  408. \usepackage{epstopdf}
  409. \usepackage{xcolor,colortbl}
  410.  
  411. \newcommand{\q}[1]{\texttt{#1}}
  412. \newcommand{\z}[1]{\texttt{#1\%}}
  413. \newcommand{\ii}[0]{\hspace{3mm}}
  414. \newcommand{\iii}{\hspace{6mm}}
  415.  
  416. \begin{document}
  417.  %Title
  418.  
  419.  \begin{center}
  420.   {\Large Statistiche sull\'esame di '.$infos[0].' di '.$infos[1].' }
  421.  
  422.   \vspace{2mm}
  423.   {\large Tipo: '.$infos[3].' ('.$orale.') - Corso di ingegneria '.$infos[2].'}
  424.  
  425.   \vspace{5mm}
  426.  
  427.   \begin{tabular}{l|rr|rr|rr}
  428.   \toprule
  429.                     & \multicolumn{2}{c|}{Totale}                                                   & \multicolumn{2}{c|}{Uomini}                                                   & \multicolumn{2}{c}{Donne}                                                         \\\\
  430.                     & Assoluto                      & Rapporto                              & Assoluto                      & Rapporto                              & Assoluto                          & Rapporto                              \\\\
  431.    \midrule
  432.    
  433.     Iscritti all\'esame         & \q{'.$numbers[0][0].'}                & ---                                   & \q{'.$numbers[0][1].'}                & ---                                   & \q{'.$numbers[0][2].'}                    & ---                                   \\\\
  434.     Assenti o ritirati          & \q{'.$numbers[1][0].'}                & ---                                   & \q{'.$numbers[1][1].'}                & ---                                   & \q{'.$numbers[1][2].'}                    & ---                                   \\\\
  435.     Presenti                & \q{'.($numbers[0][0]-$numbers[1][0]).'}       & \z{'.perc($numbers[0][0]-$numbers[1][0],$p[0]).'}         & \q{'.($numbers[0][1]-$numbers[1][1]).'}       & \z{'.perc($numbers[0][1]-$numbers[1][1],$p[1]).'}         & \q{'.($numbers[0][2]-$numbers[1][2]).'}           & \z{'.perc($numbers[0][2]-$numbers[1][2],$p[2]).'}             \\\\
  436.    Di cui: &&&&&&\\\\
  437.     \ii \color{red} Promossi        & \color{red} \q{'.($results[0][0] + $results[1][0]).'} & \color{red} \z{'.perc(($results[0][0] + $results[1][0]),$p[0]).'} & \color{red} \q{'.($results[0][1] + $results[1][1]).'} & \color{red} \z{'.perc($results[0][1] + $results[1][1],$p[1]).'}   & \color{red} \q{'.($results[0][2] + $results[1][2]).'}     & \color{red} \z{'.perc($results[0][2] + $results[1][2],$p[2]).'}   \\\\
  438.    '.$debit_rows.'
  439.     \ii Bocciati            & \q{'.($results[2][0] - $results[1][0]).'}     & \z{'.perc(($results[2][0] - $results[1][0]),$p[0]).'}         & \q{'.($results[2][1] - $results[1][1]).'}     & \z{'.perc($results[2][1] - $results[1][1],$p[1]).'}           & \q{'.($results[2][2] - $results[1][2]).'}         & \z{'.perc($results[2][2] - $results[1][2],$p[2]).'}           \\\\
  440.    
  441.    \midrule
  442.     Voto più alto          & \q{'.r($averages[3][0]).'}                & ---                                   & \q{'.r($averages[3][1]).'}                & ---                                   & \q{'.r($averages[3][2]).'}                    & ---                                   \\\\
  443.     Voto sufficiente medio      & \q{'.r($averages[1][0]).'}                & ---                                   & \q{'.r($averages[1][1]).'}                & ---                                   & \q{'.r($averages[1][2]).'}                    & ---                                   \\\\
  444.    '.$global_avg.'
  445.     Voto più basso         & \q{'.r($averages[2][0]).'}                & ---                                   & \q{'.r($averages[2][1]).'}                & ---                                   & \q{'.r($averages[2][2]).'}                    & ---                                   \\\\
  446.    
  447.    
  448.    \bottomrule
  449.   \end{tabular}
  450.  '.$graph_code.'
  451.  \end{center}
  452.  
  453. \end{document}
  454. ';
  455.  
  456.   if($verbose) echo("Writing latex source on $source_name...\n");
  457.   if (file_put_contents($source_name,$latexsource) == False) {echo ("Error while writing on file $filename!\npdf export aborted\n"); eliminate_garbage_files(NULL,$filename); return 1;}
  458.   if($verbose) echo("Latex source has been wrote succesfully on $source_name\n");
  459.  
  460.   if ($compile_latex) {
  461.     if($verbose) echo("Trying to compile latex source using pdflatex...\n");
  462.     system("pdflatex -interaction=nonstopmode $source_name >>/dev/null 2>>/dev/null",$code);
  463.     if ($code) {echo("There was an error during the execution of pdflatex (exit code: $code)\nTry to compile $source_name manually or check the log file!\npdf export aborted\n"); return 1;}
  464.     echo("Succesfully wrote $filename.pdf!\n");
  465.   }
  466.  
  467.   if ($delete_files AND $compile_latex) eliminate_garbage_files($filename.".pdf",$filename);
  468.  
  469.   if ($delete_files) exec("rm --interactive=never graph_$filename* >> /dev/null 2>>/dev/null");
  470.  
  471.  
  472.   return 0;
  473. }
  474.  
  475. function partitionate_votes($exam, $sex, $intervals = 9, $maxvote = 30, $minvote = NULL, $upper_bound = NULL){
  476.   global $db, $result_table, $info_table, $matr_field_name, $sex_field, $examid_field, $retired_field, $passed_vote, $vote_field, $all_votes, $exam_info_table, $examinfo_id_field;
  477.   $incr = $maxvote/$intervals;
  478.   $votes = array();
  479.  
  480.   if($sex === 1) $sex = "`$sex_field` = 1";
  481.   if($sex === 0) $sex = "`$sex_field` = 0";
  482.   if($sex === NULL) $sex = "`$sex_field` IS NULL";
  483.  
  484.   if(is_null($minvote)){
  485.     if(exec_query("SELECT MIN(`$vote_field`) FROM `$result_table` WHERE `$examid_field` = $exam",$x)) return False;
  486.     $minvote = $x->fetch_row(); $x->close(); $minvote = floatval($minvote[0]);
  487.   }
  488.   if(is_null($upper_bound)){
  489.     if(exec_query("SELECT MAX(`$vote_field`) FROM `$result_table` WHERE `$examid_field` = $exam",$x)) return False;
  490.     $upper_bound = $x->fetch_row(); $x->close(); $upper_bound = floatval($upper_bound[0]);
  491.   }
  492.  
  493.   if(exec_query("SELECT COUNT(*) FROM `$result_table` WHERE `$examid_field` = $exam AND `$retired_field` = 0",$x)) return False;
  494.   $tot = $x->fetch_row(); $x->close(); $tot = floatval($tot[0]);
  495.  
  496.  
  497.   for($i=0;($i+1)*$incr<=$maxvote;$i++){
  498.     $left_bound = round($i*$incr);
  499.     $right_bound = round($i*$incr+$incr)-1;
  500.     if($right_bound+1 == $maxvote) $right_bound = $right_bound+1;
  501.     $name = $left_bound." -- ".$right_bound;
  502.     if($left_bound == 0 AND $minvote < 0) {$left_bound = $minvote; $name = $left_bound." -- ".$right_bound;}
  503.     if($right_bound == $maxvote AND $maxvote < $upper_bound) {$right_bound = $upper_bound; $name = $left_bound." -- 30L";};
  504.     array_push($votes,array($name,$left_bound,$right_bound,0));
  505.   }
  506.   foreach($votes as &$interval) {
  507.     if(exec_query("SELECT COUNT(*) FROM (`$result_table` JOIN `$info_table` ON `$result_table`.`$matr_field_name` = `$info_table`.`$matr_field_name` ) WHERE `$examid_field` = $exam AND `$vote_field` >= $interval[1] AND `$vote_field` <= $interval[2] AND $sex",$x)) return False;
  508.     $temp = $x->fetch_row(); $x->close(); $interval[3] = round(floatval($temp[0])/floatval($tot)*100,2);
  509.   }
  510.   return $votes;
  511. }
  512.  
  513. function eliminate_garbage_files($keepthis,$basename){
  514.   global $delete_files;
  515.   if(is_null($keepthis) == False) {
  516.     exec("mv $keepthis keepthis >> /dev/null 2>>/dev/null");
  517.   }
  518.   if ($delete_files) exec("rm --interactive=never $basename* >> /dev/null 2>>/dev/null");
  519.   if(is_null($keepthis) == False) {
  520.     exec("mv keepthis $keepthis >> /dev/null 2>>/dev/null");
  521.   }
  522. }
  523.  
  524. function r($x){ return number_format(round($x,1),1); }
  525.  
  526. function perc($x,$y){
  527.   return number_format(round(floatval($x)/floatval($y)*100.0,1),1);
  528. }
  529.  
  530. function get_string_data($x) {
  531.   $ret_val = '';
  532.   foreach($x as $y){
  533.     $ret_val = $ret_val."$y[0];$y[3]\n";
  534.   }
  535.   return $ret_val;
  536. }
  537.  
  538. function create_graph($votes,$filename){
  539.   global $verbose, $delete_files;
  540.  
  541.   if($verbose) echo("Writing male data on file '$filename.male'...\n");
  542.   if (file_put_contents("$filename.male",get_string_data($votes[0])) == False) {echo ("Error while writing on file '$filename.male'!\nGraph creation aborted\n"); eliminate_garbage_files(NULL,$filename); return 1;}
  543.   if($verbose) echo("Male data has been succesfully wrote on file '$filename.male'\n");
  544.  
  545.   if($verbose) echo("Writing female data on file '$filename.female'...\n");
  546.   if (file_put_contents("$filename.female",get_string_data($votes[1])) == False) {echo ("Error while writing on file '$filename.female'!\nGraph creation aborted\n"); eliminate_garbage_files(NULL,$filename); return 1;}
  547.   if($verbose) echo("Female data has been succesfully wrote on file '$filename.female'\n");
  548.  
  549.   if($verbose) echo("Writing NULL sex data on file '$filename.unkw'...\n");
  550.   if (file_put_contents("$filename.unkw",get_string_data($votes[2])) == False) {echo ("Error while writing on file '$filename.unkw'!\nGraph creation aborted\n"); eliminate_garbage_files(NULL,$filename); return 1;}
  551.   if($verbose) echo("NULL sex data has been succesfully wrote on file '$filename.unkw'\n");
  552.    
  553.   $graph_size_x = "17.00cm";
  554.   $graph_size_y = "14.00cm";
  555.   $gnuplot_file_name = $filename.".plt";
  556.   $graph_file_name = "graph_".$filename.".tex";
  557.   $gnuplot_settings = '
  558.  set terminal epslatex    leveldefault color blacktext \
  559.   dashed dashlength 1.0 linewidth 1.0 butt noclip \
  560.   nobackground \
  561.   palfuncparam 2000,0.003 \
  562.   input size '.$graph_size_x.' , '.$graph_size_y.' "" 11  fontscale 1.0
  563. set output "'.$graph_file_name.'"
  564. unset clip points
  565. set clip one
  566. unset clip two
  567. set bar 1.000000 front
  568. set border 31 front linetype -1 linewidth 1.000
  569. set timefmt z "%d/%m/%y,%H:%M"
  570. set zdata
  571. set timefmt y "%d/%m/%y,%H:%M"
  572. set ydata
  573. set timefmt x "%d/%m/%y,%H:%M"
  574. set xdata
  575. set timefmt cb "%d/%m/%y,%H:%M"
  576. set timefmt y2 "%d/%m/%y,%H:%M"
  577. set y2data
  578. set timefmt x2 "%d/%m/%y,%H:%M"
  579. set x2data
  580. set boxwidth 0.75 absolute
  581. set style fill   solid 0.50 border lt 1
  582. set style rectangle back fc  lt -3 fillstyle   solid 1.00 border lt -1
  583. set style circle radius graph 0.02, first 0, 0
  584. set style ellipse size graph 0.05, 0.03, first 0 angle 0 units xy
  585. set dummy x,y
  586. set format x "% g"
  587. set format y "% g"
  588. set format x2 "% g"
  589. set format y2 "% g"
  590. set format z "% g"
  591. set format cb "% g"
  592. set format r "% g"
  593. set angles radians
  594. set grid nopolar
  595. set grid xtics nomxtics ytics nomytics noztics nomztics \
  596. nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
  597. set grid layerdefault   linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000
  598. set raxis
  599. set key title ""
  600. set key inside left top vertical Right noreverse enhanced autotitles box linetype -1 linewidth 1.000
  601. set key noinvert samplen 4 spacing 1 width 0 height 0
  602. set key maxcolumns 0 maxrows 0
  603. set key noopaque
  604. unset label
  605. unset arrow
  606. set style increment default
  607. unset style line
  608. unset style arrow
  609. set style histogram rowstacked title  offset character 0, 0, 0
  610. unset logscale
  611. set offsets 0, 0, 0, 0
  612. set pointsize 1
  613. set pointintervalbox 1
  614. set encoding default
  615. unset polar
  616. unset parametric
  617. unset decimalsign
  618. set view 60, 30, 1, 1
  619. set samples 100, 100
  620. set isosamples 10, 10
  621. set surface
  622. unset contour
  623. set clabel \'%8.3g\'
  624. set mapping cartesian
  625. set datafile separator ";"
  626. unset hidden3d
  627. set cntrparam order 4
  628. set cntrparam linear
  629. set cntrparam levels auto 5
  630. set cntrparam points 5
  631. set size ratio 0 1,1
  632. set origin 0,0
  633. set style data histograms
  634. set style function lines
  635. set xzeroaxis linetype -2 linewidth 1.000
  636. set yzeroaxis linetype -2 linewidth 1.000
  637. set zzeroaxis linetype -2 linewidth 1.000
  638. set x2zeroaxis linetype -2 linewidth 1.000
  639. set y2zeroaxis linetype -2 linewidth 1.000
  640. set ticslevel 0.5
  641. set mxtics default
  642. set mytics default
  643. set mztics default
  644. set mx2tics default
  645. set my2tics default
  646. set mcbtics default
  647. set xtics border in scale 1,0.5 mirror rotate by -45  offset character 0, 0, 0 autojustify
  648. set xtics  norangelimit
  649. set xtics   ()
  650. set ytics border in scale 1,0.5 mirror norotate  offset character 0, 0, 0 autojustify
  651. set ytics autofreq  norangelimit
  652. set ztics border in scale 1,0.5 nomirror norotate  offset character 0, 0, 0 autojustify
  653. set ztics autofreq  norangelimit
  654. set nox2tics
  655. set noy2tics
  656. set cbtics border in scale 1,0.5 mirror norotate  offset character 0, 0, 0 autojustify
  657. set cbtics autofreq  norangelimit
  658. set rtics axis in scale 1,0.5 nomirror norotate  offset character 0, 0, 0 autojustify
  659. set rtics autofreq  norangelimit
  660. set title "Distribuzione dei voti"
  661. set title  offset character 0, 0, 0 font "" norotate
  662. set timestamp bottom
  663. set timestamp ""
  664. set timestamp  offset character 0, 0, 0 font "" norotate
  665. set rrange [ * : * ] noreverse nowriteback
  666. set trange [ * : * ] noreverse nowriteback
  667. set urange [ * : * ] noreverse nowriteback
  668. set vrange [ * : * ] noreverse nowriteback
  669. set xlabel ""
  670. set xlabel  offset character 0, 0, 0 font "" textcolor lt -1 norotate
  671. set x2label ""
  672. set x2label  offset character 0, 0, 0 font "" textcolor lt -1 norotate
  673. set xrange [ * : * ] noreverse nowriteback
  674. set x2range [ -3.29471 : 12.2948 ] noreverse nowriteback
  675. set ylabel ""
  676. set ylabel  offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
  677. set y2label ""
  678. set y2label  offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
  679. set yrange [ * : * ] noreverse nowriteback
  680. set y2range [ -4.47918 : 25.9092 ] noreverse nowriteback
  681. set zlabel ""
  682. set zlabel  offset character 0, 0, 0 font "" textcolor lt -1 norotate
  683. set zrange [ * : * ] noreverse nowriteback
  684. set cblabel ""
  685. set cblabel  offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
  686. set cbrange [ * : * ] noreverse nowriteback
  687. set zero 1e-08
  688. set lmargin  -1
  689. set bmargin  -1
  690. set rmargin  -1
  691. set tmargin  -1
  692. set locale "it_IT.UTF-8"
  693. set pm3d explicit at s
  694. set pm3d scansautomatic
  695. set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean
  696. set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB
  697. set palette rgbformulae 7, 5, 15
  698. set colorbox default
  699. set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault
  700. set style boxplot candles range  1.50 outliers pt 7 separation 1 labels auto unsorted
  701. set loadpath
  702. set fontpath
  703. set psdir
  704. #set fit noerrorvariables noprescale
  705.  
  706. set xlabel "Fascia di voti"
  707. set ylabel "Distribuzione relativa percentuale"
  708.  
  709. plot \
  710. "'.$filename.'.female" using 2:xtic(1) title "Donne" fs noborder solid 0.4 lc rgbcolor "red" , \
  711. "'.$filename.'.male" using 2:xtic(1) title "Uomini" fs noborder solid 0.4 lc rgbcolor "blue", \
  712. "'.$filename.'.unkw" using 2:xtic(1) title "NULL" fs noborder solid 0.4 lc rgbcolor "black"
  713.  
  714. set output
  715. ';
  716.   if($verbose) echo("Writing gnuplot file on $gnuplot_file_name...\n");
  717.   if (file_put_contents($gnuplot_file_name,$gnuplot_settings) == False) {echo ("Error while writing on file $gnuplot_file_name!\nGraph creation aborted\n"); eliminate_garbage_files(NULL,$filename); return 1;}
  718.   if($verbose) echo("Gnuplot file has been succesfully wrote on $gnuplot_file_name\n");
  719.  
  720.  
  721.   if($verbose) echo("Trying to exec gnuplot...\n");
  722.   system("gnuplot $gnuplot_file_name >>/dev/null 2>>/dev/null",$code);
  723.   if ($code) {echo("There was an error during the execution of gnuplot (exit code: $code)\nTry to analyze $gnuplot_file_name manually\nGraph creation aborted\n"); return 1;}
  724.   echo("Succesfully created $graph_file_name!\n");
  725.  
  726.   if ($delete_files) system("rm --interactive=never $filename*  >>/dev/null 2>>/dev/null");
  727.  
  728.   return "graph_".$filename;
  729.  
  730. }
  731.  
  732. main($argv);
  733. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement