<?php


	// appel du script de connexion
	require ('connect/mysqli_connect.php');


	/*
	// On récupère le timestamp du dernier enregistrement

	*/
	// Récupération des données 
	$etudiant=3;
	$epreuve="E42A";
	
 $sql='SELECT eval_note.*	
				FROM eval_note,eval_liste
				WHERE eval_note.numEval=eval_liste.numEval
				AND eval_liste.epreuveEval="'.$epreuve.'" AND numEtudiant='.$etudiant.' ORDER BY numEval;';	

	
	
	$result = mysqli_query ($dbcon, $sql)or die(mysqli_error($dbcon));
	$nb_ligne = mysqli_num_rows($result); //compte le nombre de lignes
	$i=0;
	
	while ($row = mysqli_fetch_array($result, MYSQLI_BOTH))
	{
		$tabeval[$i]=$row;
		for ($n=1;$n<7;$n++)
		{
			$note[$i][$n]=$tabeval[$i][$n+2];
		}
		$Eval[$i]=$tabeval[$i]['numEval'];
		$xlibelle[$i]='SP-'.$Eval[$i];
		$i++;
	}
	for ($n=1;$n<7;$n++)
	{
		$moyenne[$n] = array_sum($note[$n])/count($note[$n]);
		echo "<br/><br/>MOyenne Critère $n : <B>$moyenne[$n]</B>";
	}
		
/*
	// CHERCHE nom ETUTDIANT selectionné
	$sql = "SELECT  nomact FROM acteur WHERE numAct=$etudiant;";
	$result = mysqli_query ($dbcon, $sql)or die(mysqli_error($dbcon));
	$nb_ligne = mysqli_num_rows($result); 	
	if ($nb_ligne ==0)
	{
		$erreur[]="Etudiant non trouvé contacter l'admin";
	}
	elseif ($nb_ligne !==1)
	{
		$erreur[]="Identifiants multiples : contacter l\'admin";
	}
	else
	{
		while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
		{
			$Etudiant1=$row;
			echo $Etudiant1;
		}
	
	
*/
echo json_encode($note,JSON_NUMERIC_CHECK);


?>	

<script type="text/javascript">
	// // TRANSFORME DONNéés PHP en variable Java
		var etudiant = <?php echo json_encode($etudiant,JSON_NUMERIC_CHECK) ?>;
		var eval = <?php echo json_encode($Eval,JSON_NUMERIC_CHECK) ?>;
		var xlibelle = <?php echo json_encode($xlibelle) ?>;
		var note = <?php echo json_encode($note,JSON_NUMERIC_CHECK) ?>;

		/*var note2 = <?php echo json_encode($note2,JSON_NUMERIC_CHECK) ?>;
		var note3 = <?php echo json_encode($note3,JSON_NUMERIC_CHECK) ?>;
		var note4 = <?php echo json_encode($note4,JSON_NUMERIC_CHECK) ?>;
		var note5 = <?php echo json_encode($note5,JSON_NUMERIC_CHECK) ?>;
		var note6 = <?php echo json_encode($note6,JSON_NUMERIC_CHECK) ?>;
		var note7 = <?php echo json_encode($note7,JSON_NUMERIC_CHECK) ?>;*/
</script>



<!DOCTYPE html>
<html lang=fr>
	<head>
		<title>graph RECAP FINAL</title>
		<meta charset=utf-8>
		<meta name=viewport content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="nogstyle.css">
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
			<script src="http://code.highcharts.com/highcharts.js" type="text/javascript"></script>
			<script src="http://code.highcharts.com/modules/exporting.js" type="text/javascript"></script>
			<script type="text/javascript">
			
			function creationserie(tableau)		// Crée les séries de données ?
			{
		 		var sortie = [];
		 		for (var i = 0; i < eval.length;i++)
		 		 {
		 			sortie[i] = [i, tableau[i]];	// x et y ?
				}
		 		return sortie;
			}
			
			
			$(function() {
				$('#container').highcharts({
					title: {
						text: 'Récap',
						x: -20 //center
					},
					subtitle: {
						text: 'passpro',
						x: -20
					},
						xAxis: {
							categories: xlibelle,
					//		tickInterval: 1,
							startOnTick: true,
							},
						
						yAxis: {
							title: {
								text: 'Notes'
							},
							plotLines: [{
								value: 3,
								width: 2,
								color: '#f5b8c9'
							}]
						},
						
					 tooltip: {
        				formatter: function ()
        				 {
            			var s = '<b>' + this.x + '</b>';
            			$.each(this.points, function () {
                		s += '<br/>' + this.series.name + ': ' +this.y ;
            });

            return s;
        },
        shared: true
    },
						
						legend: {
							layout: 'vertical',
							align: 'right',
							verticalAlign: 'middle',
							borderWidth: 0
						},
						
						series: [
						{
							name: 'Note1',
							data: creationserie(note[1])
						},
					{
							name: 'Note2',
							data: creationserie(note[2])
						},
						{
							name: 'Note3',
							data: creationserie(note[3])
						},
						{
							name: 'Note4',
							data: creationserie(note[4])
						},
						{
							name: 'Note5',
							data: creationserie(note[5])
						},
						{
							name: 'Note6',
							data: creationserie(note[6])
						},
						{
							name: 'Note7',
							data: creationserie(note[7])
						},
						
						]
					});
				});

		</script>
	</head>
	<body>
		<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
		<script type="text/javascript">
	/*	alert('Hello world');
			alert(note [1][1]);*/
		</script>/
			;
		

	</body>