<?php // $Id: adminhp.php,v 1.11 2005/07/10 13:33:22 yannoo Exp $
/*
==============================================================================
	Dokeos - elearning and course management software

	Copyright (c) 2004 Dokeos S.A.
	Copyright (c) 2003 Ghent University (UGent)
	Copyright (c) 2001 Universite catholique de Louvain (UCL)
	Copyright (c) Olivier Brouckaert

	For a full list of contributors, see "credits.txt".
	The full license can be read in "license.txt".

	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.

	See the GNU General Public License for more details.

	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
 *	HOTPOTATOES ADMINISTRATION
 *	@author Istvan Mandak
 *	@package dokeos.exercise
 */


include('exercise.class.php');
include('question.class.php');
include('answer.class.php');

include('exercise.lib.php');

$langFile='exercice';

include('../inc/claro_init_global.inc.php');

if(isset($_REQUEST["cancel"]))
{
	if($_REQUEST["cancel"]==get_lang('Cancel'))
	{
				header("Location: exercice.php");		
	}
}

//$is_courseAdmin = $_SESSION['is_courseAdmin'];
$newName = (!empty($_REQUEST['newName'])?$_REQUEST['newName']:'');
$hotpotatoesName = (!empty($_REQUEST['hotpotatoesName'])?$_REQUEST['hotpotatoesName']:'');

// answer types
define(UNIQUE_ANSWER,	1);
define(MULTIPLE_ANSWER,	2);
define(FILL_IN_BLANKS,	3);
define(MATCHING,		4);

// allows script inclusions
define(ALLOWED_TO_INCLUDE,1);

$is_allowedToEdit=$is_courseAdmin;

// document path
$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';

// picture path
$picturePath=$documentPath.'/images';

// audio path
$audioPath=$documentPath.'/audio';



// tables used in the exercise tool
//$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_test_question';
//$TBL_EXERCICES         = $_course['dbNameGlu'].'quiz_test';
//$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
//$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
//$TBL_DOCUMENT          = $_course['dbNameGlu']."document";
$TBL_EXERCICE_QUESTION		= Database::get_course_table(QUIZ_TEST_QUESTION_TABLE);
$TBL_EXERCICES								= Database::get_course_table(QUIZ_TEST_TABLE);
$TBL_QUESTIONS								= Database::get_course_table(QUIZ_QUESTION_TABLE);
$TBL_REPONSES									= Database::get_course_table(QUIZ_ANSWER_TABLE);
$TBL_DOCUMENT									= Database::get_course_document_table();
//$dbTable     = $_course['dbNameGlu']."document";
$dbTable												= $TBL_DOCUMENT;

if(!$is_allowedToEdit)
{
	api_not_allowed();
}

$interbredcrump[]=array("url" => "exercice.php","name" => get_lang('Exercices'));

$nameTools = get_lang('adminHP');

Display::display_header($nameTools,"Exercise");

require_once(api_get_path(SYS_PATH).'claroline/exercice/hotpotatoes.lib.php');

?>

<h4>
  <?php echo $nameTools; ?>
</h4>

<?php
if(isset($newName))
{
		if($newName!="")		
		{
			//alter database record for that test
			SetComment($hotpotatoesName,$newName);
			echo "<script language='Javascript' type='text/javascript'> window.location='exercice.php'; </script>";
		}		
}

echo "<form action=\"$PHP_SELF\" method='post' name='form1'>";
echo "<input type=\"hidden\" name=\"hotpotatoesName\" value=\"$hotpotatoesName\">";
echo "<input type=\"text\" name=\"newName\" value=\"";


$lstrComment = "";
$lstrComment = GetComment($hotpotatoesName);
if($lstrComment=="")
	$lstrComment = GetQuizName($hotpotatoesName,$documentPath);
if($lstrComment=="")
	$lstrComment = GetFileName($hotpotatoesName,$documentPath);

echo $lstrComment;	
echo "\" size=40>&nbsp;";
echo "<input type=\"submit\" name=\"submit\" value=\"".get_lang('Ok')."\">&nbsp;";
echo "<input type=\"button\" name=\"cancel\" value=\"".get_lang('Cancel')."\" onclick=\"javascript:document.form1.newName.value='';\">";

echo "</form>";

?>
<?php

Display::display_footer();

?>
