Liste de projects STAF-18 (EVA) déposées
\n";
}
// ----------------------------- XML Comparison
function is_parent ($maman) {
global $stack;
global $pointer;
if ($pointer == 0) {
return FALSE;
}
if ($stack[$pointer-1] == $maman) {
return TRUE;
}
else {
return FALSE;
}
}
// ----------------------------- contents
// for each thing we want to do we define a function
class Results {
var $tot_completion_days;
var $tot_man_days;
var $wp_completion;
var $project_title;
var $names;
var $spec_approval;
var $n_problems = 0;
var $open_problems = 0;
var $problems_with_answers = 0;
var $problems_with_comments = 0;
var $audits = "";
function do_planning($attrs) {
global $stack, $astack;
global $pointer, $apointer, $current;
if ( ($current == "planning") && is_parent ("workpackage")) {
$completion = $attrs["completion"];
$man_days = $attrs["man-days"];
// echo "DEBUG: attrs = $attrs, completion = $completion, man_days= $man_days
\n";
if ($man_days) {
$this->wp_completion[] = $completion;
if ( $man_days != "") {
$this->tot_man_days += $man_days;
$this->tot_completion_days += $man_days * $completion / 100;
};
}
else {
$this->wp_completion[] = "MANQUE";
}
}
}
function do_names ($attrs) {
global $current;
if ($current == "contact-info") {
$noms = $attrs["first-name"] . " " . $attrs["family-name"] . "";
if ($noms) { $this->names = $this->names . $noms; };
$work_url = $attrs["work-url"];
if ($work_url) {
$this->names = $this->names . "(Page travaux) ";
} ;
// echo "DEBUG: noms = $noms, work_url = $work_url
\n";
}
}
function do_spec_approval ($attrs) {
global $current;
if ($current == "specification") {
$approval = $attrs["approval"];
if ($approval) {
$this->spec_approval = "Avis de l'enseignant sur la spécification: $approval";
}
else {
$this->spec_approval = "Avis de l'enseignant sur la spécification: manquant (probablement pas bon!)";
}
}
}
function do_audits ($attrs) {
global $current;
if ($current == "audit") {
$eval = $attrs["eval"];
if ($eval) {
$date = $attrs["mod-day"] . "/" . $attrs["mod-month"] . "/" . $attrs["mod-year"];
$this->audits = $date . "=>" . $this->audits . $eval ;
}
}
}
function do_problems ($attrs) {
global $current;
if ($current == "problem") {
$this->n_problems += 1;
$approval = $attrs["open"];
if ($approval) {
$this->open_problems += 1;
}
}
if ($current == "solution") {
$this->problems_with_answers += 1;
}
if ( ($current == "teacher-comments") && is_parent ("problem")) {
$this->problems_with_comments += 1;
}
}
function set_title ($title) {
$this->project_title = $title;
}
// dump out the results
function print_results () {
// title
echo "Titre: " . $this->project_title . "
\n";
// Auteurs
echo "Auteurs: " . $this->names . "
";
// Specification approval
echo $this->spec_approval . "
\n" ;
// Avancement (faudrait faire une fonction pour cela)
echo "Avancement: ";
printf ("%01.2f", $this->tot_completion_days / $this->tot_man_days * 100);
echo "% (" . $this->tot_completion_days . " jours sur " . $this->tot_man_days .")
\n";
echo "WPs: ";
$i = 1;
while ( list ($junk, $wp) = each ( $this->wp_completion ) ) {
echo "WP_$i: $wp % ";
$i++;
}
echo "
\n";
// Audits
if ($this->audits) {
echo "Audits: " . $this->audits . "
\n";
}
// Problems
echo "Problèmes " . $this->n_problems .
", ouverts=" . $this->open_problems .
", solutions=" . $this->problems_with_answers .
", commentaires=" . $this->problems_with_comments;
}
}
// ----------------------------- The 3 XML Parser functions
// grab current element and push it onto the stack
// push its attributs on the astack
function startElement($parser, $name, $attrs) {
global $stack, $astack;
global $pointer, $apointer, $current;
global $results;
$pointer = push ($stack, $name) -1 ;
$apointer = push ($astack, $attrs) -1 ;
// the current element
$current = $name;
// show_stack("\nPUSH ". $current . " stack=\n");
// Extract data
$results->do_planning($attrs);
$results->do_names($attrs);
$results->do_spec_approval($attrs);
$results->do_problems ($attrs);
$results->do_audits ($attrs);
}
// pop off the element from the stack
// pop off the attributes from the astack
function endElement($parser, $name) {
global $pointer, $apointer;
global $stack, $astack, $current;
pop ($stack);
pop ($astack);
$pointer = $pointer - 1;
$apointer = $apointer - 1;
$current = FALSE;
// show_stack("
\nPOPPED stack=\n");
}
function characterData($parser, $data) {
global $pointer, $apointer;
global $stack, $astack, $current;
global $results;
if ( ($current == "title") && is_parent ("project"))
{
$results->set_title($data);
}
}
function parse_xml($file) {
global $results;
// -------------------- XML Parser INITS
// create the XML Parser, a new one for each filep
$xml_parser = xml_parser_create("ISO-8859-1");
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
// echo "DEBUG: file = $file";
if (!($fp = fopen($file, "r"))) {
die( "could not open XML input");
}
else {
// init per-file global vars
$wp_count = 0;
}
while ($data = fread($fp, 50000)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf( "XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
// close file and free parser
fclose($fp);
xml_parser_free($xml_parser);
}
// ----------------------- File stats:
function print_file_stats($file) {
$file_info = stat($file);
echo "[ ";
echo "uid=$file_info[4], ";
$gid = $file_info[5];
echo "gid=$gid, ";
echo "size=$file_info[7], ";
$date = $file_info[9];
$unix_date = time();
setlocale ("LC_TIME", "fr");
$date_string = (strftime("%A, %d %B %Y, %H:%M", $date));
echo "dernière modif=$date_string";
echo "]
\n\n ";
if ($gid==1) echo "ATTENTION: Fichier sous édition par DKS! Attendez un peu ...
\n";
}
// ----------------------- Main routine:
if ($projfile)
// to call like ?projfile=file.xml
{
print_file_stats($project_dir.$projfile);
// init array that will hold results
$results = new Results;
// some XML file contents
parse_xml($project_dir.$projfile);
}
else
{
// The standard routine
// gets the files from the xml upload directory
$handle=opendir($project_dir);
// echo "Directory handle: $handle\n";
echo "Projets déposés dans le répertoire : $xml_path
\n";
// read the files into an array
$files = array();
while ($file = readdir($handle)) {
$files[] = $file;
}
closedir($handle);
// sort them in alphabetical order
sort($files);
reset($files);
while ( list ($junk, $file) = each ($files) ) {
$pieces = explode(".", $file);
if ($pieces[1] == "xml") {
// List files
$xml_url = $xml_path . $file;
$url = $xml_servlet . "?URL=" . $xml_url . "&xslURL=" . $style_sheet;
echo "
$file\n";
$url = $xml_servlet . "?URL=" . $xml_url . "&xslURL=" . $style_sheet3;
echo "[Results]: \n";
// file stats
print_file_stats($project_dir.$file);
// init the Results class
$results = new Results;
// Analyse the file
parse_xml($project_dir.$file);
// print the results
$results->print_results ();
}
else {
// echo "Useless file: $file
\n\n";
}
}
}
?>
Gestion de projets |
Retour à STAF-18
D.K.S.