From 9eeb96b2b97cbc667ebe3f9be0217326c5d32cbf Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Tue, 28 Aug 2012 15:57:51 +0200 Subject: [PATCH] HotPotatoes tests correction for branch 1.9.x - ref #5359 --- main/exercice/showinframes.php | 21 +++++++++++---------- main/inc/lib/document.lib.php | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/main/exercice/showinframes.php b/main/exercice/showinframes.php index 138bdfe0c3..59dc26e6f1 100644 --- a/main/exercice/showinframes.php +++ b/main/exercice/showinframes.php @@ -30,9 +30,10 @@ $time = $_REQUEST['time']; /** * Read content */ +$user_id = api_get_user_id(); $full_file_path = $document_path.$doc_url; -my_delete($full_file_path.$_user['user_id'].'.t.html'); -$content = ReadFileCont($full_file_path.$_user['user_id'].'.t.html'); +my_delete($full_file_path.$user_id.'.t.html'); +$content = ReadFileCont($full_file_path.$user_id.'.t.html'); if ($content == '') { @@ -47,12 +48,12 @@ if ($content == '') { " SaveScoreVariable = 1;\n". " if (C.ie)\n". " {\n". - " document.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n". + " document.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score=\"+Score;\n". " //window.alert(Score);\n". " }\n". " else\n". " {\n". - " window.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n". + " window.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score=\"+Score;\n". " }\n". " }\n". "}\n". @@ -66,16 +67,16 @@ if ($content == '') { $newcontent = str_replace($prehref, $posthref, $newcontent); - if (CheckSubFolder($full_file_path.$_user['user_id'].'.t.html') == 0) { + if (CheckSubFolder($full_file_path.$user_id.'.t.html') == 0) { $newcontent = ReplaceImgTag($newcontent); } } else { - //my_delete($full_file_path.$_user['user_id'].'.t.html'); + //my_delete($full_file_path.$user_id.'.t.html'); $newcontent = $content; } -WriteFileCont($full_file_path.$_user['user_id'].'.t.html', $newcontent); +WriteFileCont($full_file_path.$user_id.'.t.html', $newcontent); /* $prehref="javascript:void(0);"; $posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; @@ -87,7 +88,7 @@ WriteFileCont($full_file_path.$_user['user_id'].'.t.html', $newcontent); */ $doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url)); -// echo $document_web_path.$doc_url.$_user['user_id'].'.t.html'; +// echo $document_web_path.$doc_url.$user_id.'.t.html'; // exit; // Adjustung the header's height according to the current visual theme. @@ -138,7 +139,7 @@ if ($origin!='learnpath') { ?> - + <body> <p>This page uses frames, but your browser doesn't support them. @@ -151,7 +152,7 @@ if ($origin!='learnpath') { } else { ?> <script type='text/javascript'> - s='<?php echo $document_web_path.$doc_url.$_user['user_id']; ?>.t.html?time=<?php echo Security::remove_XSS($time); ?>'; + s='<?php echo $document_web_path.$doc_url.$user_id; ?>.t.html?time=<?php echo Security::remove_XSS($time); ?>'; //document.write(s); window.location=s; </script> diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 59eddf1c05..4c7829ae2b 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -1166,7 +1166,8 @@ class DocumentManager { //When using hotpotatoes files, new files are generated in the hotpotatoe folder, if user_id=1 does the exam a new html file will be generated: hotpotatoe.html.(user_id).t.html //so we remove that string in order to find correctly the origin file if (strpos($doc_path, 'HotPotatoes_files')) { - $doc_path = substr($doc_path, 0, strlen($doc_path) - 8); +// $doc_path = substr($doc_path, 0, strlen($doc_path) - 8); + $doc_path = substr($doc_path, 0, strlen($doc_path) - 7 - strlen(api_get_user_id())); } if (!in_array($file_type, array('file','folder'))) {