<?PHP
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Free Web Based Training System                           |
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Plate-forme de téléformation gratuite et en open source  |
// +----------------------------------------------------------------------------|
// | Copyright (C) 2001-2003  Anéma Formation  <http://www.anema.fr/>           |
// +----------------------------------------------------------------------------+
// |           Developer : Georges CALDEIRA <gcaldeira@anemalab.org>            |
// +----------------------------------------------------------------------------+
// |              Infos on project <http://anemalab.org/>                       |
// +----------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify       |
// | it under the terms of the GNU General Public License as published by       |
// | the Free Software Foundation; either version 2 of the License, or          |
// | (at your option) any later version.                                        |
// |                                                                            |
// | This program is distributed in the hope that it will be useful,            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
// | GNU General Public License for more details.                               |
// |                                                                            |
// | You should have received a copy of the GNU General Public License          |
// | along with this program; if not, write to the Free Software                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   |
// +----------------------------------------------------------------------------+

/**
* Gestion de la page accueil pour un module
*
* @author		Georges Caldeira <gcaldeira@anemalab.org>
* @package		GaneshaStagiaire
*/
	/**
	* include des fichiers + verification de la cnx
	*/
	include_once("anema.inc.php");

	debugf(__FILE__);

/*
	if ( $gusertype != STAGIAIRE ) {
		PageErreur();
	    exit()      ;
	}
*/	

	if ( !isset($HTTP_GET_VARS['groupe']) || !isset($HTTP_GET_VARS['module'])){
		PageErreur();
	    exit()      ;
	}
	$groupe	= $HTTP_GET_VARS['groupe'] ;
	$module = $HTTP_GET_VARS['module'] ;
		

	if (! $ClsFormation->ModuleIsValid($module,$guserid,$groupe) ) {
		PageErreur();
		exit ()		;
	}

	if ( ($chap = $ClsTracking->updateg($connexion)) > 0 ) {
		$url = HTTP_STAGIAIRE."p_tracking".$ext."?connexion=".$connexion ;
		$url.= "&module=".$module."&chapitre=".$chap."&groupe=".$groupe."&affiche=1" ;
		location($url);
		exit();
	}

	InitPageHtmlNoCache();

	// Modif SP1 : Recuperation des valeurs uniquement pour les stagiaires. 
	if ( $gusertype == STAGIAIRE ) {
		$ret = $ClsFormation->Read($guserid,$module,$groupe);
		$avance		= $ret['avancement'];
		$datedebut	= $ret['datedebut']	;
		$datefin	= $ret['datefin']	;
		$presentiel = $ret['presentiel'];
	} else {
		$avance		= 0 ;
		$datedebut	= 0 ;
		$datefin	= 0 ;
		$presentiel	= 0 ;
	}
	// Fin Patch 3

	$ret  = $ClsChapitre->readIdQuizz($module)	;
	$nb = $ret['cnt'] ;
	$nb2 = $ClsTracking->NbChapterTracked($guserid,$module,$groupe);
	$pourcent = ($nb==0?0:number_format(($nb2/$nb) * 100, 2, ",", ""))	;
	$lgko = (100 - $pourcent)	;

	Title(CSS($ClsModule->Title($module)));
	Info_Module($module);
	BR();
	SubTitle($st_titre['avance']);
	BR();
	print ("&nbsp;&nbsp;".$st_texte['testfait']."&nbsp;: <i>&nbsp;".$nb2."/".$nb."</i>")	;
	print('     <img src="'.HTTP_IMAGES.'space.gif" width="10" height="10">')				;
	print('     <img src="'.HTTP_IMAGES.'ok.gif" width="'.$pourcent.'" height="10"><img src="'.HTTP_IMAGES.'ko.gif" width="'.$lgko.'" height="10">  '.$pourcent.'%')	;
	
	//if ( $nb2 > 0 ) {
		BR(2);
		SubTitle($st_titre['dresult'])	;
		print ('<table>')				;
		for ( $i=0; $i<$ret['cnt']; $i++ ) {
			    $moy = $ClsTracking->Moyenne($guserid,$module,$ret[$i],$groupe) ;
				$titre = $ClsChapitre->Title($module,$ret[$i])	;
				$moy = number_format($moy, 2, ",", "")	;
				$moy = ereg_replace ( ',00','',$moy )	;
				$lgko = 100 - $moy	;
				print ('<tr>');
				print ('  <td>&nbsp;&nbsp;- '.$titre.' </td>');				
				print ('  <td><img align="absmiddle" src="'.HTTP_IMAGES.'space.gif" width="10" height="10">')	;
				print ('  <img src="'.HTTP_IMAGES.'ok.gif" width="'.$moy.'" height="10"><IMG src="'.HTTP_IMAGES.'ko.gif" width="'.$lgko.'" height="10">  '.$moy.'%</td>')	;
				print ('</tr>');
		}
		print ('</table>');
	//} //else print ("<BR><I>&nbsp;&nbsp;&nbsp;&nbsp; - Pas de résultats disponibles - </I><BR>");
	
	BR(2);
	SubTitle($st_titre['historique'])	;
	print ('<br>&nbsp;&nbsp;'.$st_texte['histoscore'].' : <a class="student"  href="p_tracking'.$ext.'?connexion='.$connexion.'&affiche=1&module='.$module.'&groupe='.$groupe.'" onMouseOver="window.status=\'Détails\';return true;" onMouseOut="window.status=\'Ganesha '.VERSION.'\';return true;">'.$st_texte['details'].'</a>')			;
	BR(2);
	Footer();
	ClosePageHtml();

?>