Source for file hotpotatoes.php
Documentation is available at hotpotatoes.php
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
* Code for Hotpotatoes integration.
* @package dokeos.exercise
* @version $Id: hotpotatoes.php 13477 2007-10-12 12:20:24Z elixir_inter $
// name of the language file that needs to be included
$language_file = 'exercice';
include('../inc/global.inc.php');
$finish = (!empty($_POST['finish'])? $_POST['finish']: 0);
$imgcount = (!empty($_POST['imgcount'])? $_POST['imgcount']: null);
$fld = (!empty($_POST['fld'])? $_POST['fld']: null);
include_once(api_get_path(LIBRARY_PATH). 'fileUpload.lib.php');
include_once(api_get_path(LIBRARY_PATH). 'document.lib.php');
$interbreadcrumb[]= array ("url"=> "./exercice.php", "name"=> get_lang('Exercices'));
$baseServDir = $_configuration['root_sys'];
$baseServUrl = $_configuration['url_append']. "/";
$uploadPath = "/HotPotatoes_files";
// if user is allowed to edit
include("hotpotatoes.lib.php");
//disable document parsing(?) - obviously deprecated
$enableDocumentParsing= false;
{//if the directory doesn't exist
//create the "HotPotatoes" directory
$doc_id = add_document($_course, '/HotPotatoes_files','folder',0,'HotPotatoes Files');
//update properties in dbase (in any case)
//make invisible(in any case) - why?
// if finish is set; it's because the user came from this script in the first place (displaying hidden "finish" field)
if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
//if(($is_allowedToEdit) )
$nameTools = get_lang('HotPotatoesTests');
//moved this down here as the upload handling functions give output
if (isset ($_POST['submit']))
//check that the submit button was pressed when the button had the "Download" value
//This should be updated to "upload" here and on the button, and it would be better to
// check something else than a string displayd on a button
/** el kell tarolni <- english please */
include_once(api_get_path(LIBRARY_PATH). 'fileManage.lib.php');
/*======================================
FILEMANAGER BASIC VARIABLES DEFINITION
======================================*/
include_once(api_get_path(LIBRARY_PATH). "pclzip/pclzip.lib.php");
//@todo: this value should be moved to the platform admin section
$maxFilledSpace = 100000000;
if (!isset ($finish)) {$finish = 0;}
//if the size is not defined, it's probably because there has been an error or no file was submitted
if(!$_FILES['userFile']['size'])
if ($enableDocumentParsing==true)
{ $enableDocumentParsing=false;
if(preg_match('/\.zip$/i',$_FILES['userFile']['name'])){
//if it's a zip, allow zip upload
{ //generate new test folder if on first step of file upload
@mkdir($document_sys_path. $uploadPath. "/". $fld);
$perm = octdec(!empty($perm)? $perm: '0770');
chmod ($document_sys_path. $uploadPath. "/". $fld,$perm);
$doc_id = add_document($_course, '/HotPotatoes_files/'. $fld,'folder',0,$fld);
{ //it is not the first step... get the filename directly from the system params
$filename = $_FILES['userFile']['name'];
/*if (treat_uploaded_file($_FILES['userFile'], $document_sys_path,
$uploadPath."/".$fld, $maxFilledSpace, $unzip))*/
$allow_output_on_success = false;
if (handle_uploaded_document($_course,$_FILES['userFile'],$document_sys_path,$uploadPath. "/". $fld,$_user['user_id'],null,null,$maxFilledSpace,$unzip,'',$allow_output_on_success))
$imgparams = $_POST['imgparams'];
{ $imgcount = $imgcount- 1; }
$dialogBox .= $filename. " ". get_lang('NameNotEqual');
my_delete($document_sys_path. $uploadPath. "/". $fld. "/". $filename);
if ($imgcount== 0) // all image uploaded
{ //if we are (still) on the first step of the upload process
// get number and name of images from the files contents
GetImgParams("/". $filename,$document_sys_path. $uploadPath. "/". $fld,$imgparams,$imgcount);
if ($imgcount== 0) //there is no img link, so finish the upload process
else //there is still one or more img missing
{ $dialogBox .= get_lang('DownloadEnd'); }
$query = "UPDATE $dbTable SET comment='$newComment' WHERE path=\"". $uploadPath. "/". $fld. "/". $filename. "\"";
//$dialogBox .= get_lang('NoImg');
{ $enableDocumentParsing=true; $oke=0;}
{ /** ok -> send to main exercises page */
header("Location: exercice.php");
$interbreadcrumb[]= array("url" => "exercice.php","name" => get_lang('Exercices'));
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<td width="50%"><h3> <?php echo $nameTools; ?></h3></td>
<td width="50%" align="right">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
if ($finish== 2) //if we are in the img upload process
while(list ($key,$string)= each($imgparams))
$dialogBox.= $string. "; ";
echo "<td>\n<!-- dialog box -->\n \n</td>\n";
echo "<td>\n<!-- dialog box -->\n \n</td>\n";
/*--------------------------------------
--------------------------------------*/
echo "<!-- upload -->\n",
"<td align=\"left\" height=\"150\" style=\"background-image: url('../img/hotpotatoes.jpg'); background-repeat: no-repeat; background-position: 600px;\" valign=\"middle\">\n",
"<form action=\"". api_get_self(). "\" method=\"post\" enctype=\"multipart/form-data\" >\n",
"<input type=\"hidden\" name=\"uploadPath\" value=\"\">\n",
"<input type=\"hidden\" name=\"fld\" value=\"$fld\">\n",
"<input type=\"hidden\" name=\"imgcount\" value=\"$imgcount\">\n",
"<input type=\"hidden\" name=\"finish\" value=\"$finish\">\n";
/*if ($finish==0){ echo get_lang('DownloadFile');}
else {echo get_lang('DownloadImg');}
"<input type=\"file\" name=\"userFile\">\n",
"<input type=\"submit\" name=\"submit\" value=\"".get_lang('Send')."\"><br/>\n";*/
echo '<input type="file" name="userFile">';
echo '<input type="submit" name="submit" value="'. get_lang('Send'). '">';
//include("exercice.php");
header("Location: exercice.php");
|