showinframes.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Istvan Mandak
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Code library for HotPotatoes integration.
  22. *
  23. * @author Istvan Mandak
  24. * @package dokeos.exercise
  25. ==============================================================================
  26. */
  27. /*
  28. -----------------------------------------------------------
  29. Included libraries
  30. -----------------------------------------------------------
  31. */
  32. include('../inc/global.inc.php');
  33. include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
  34. $time=time();
  35. require_once(api_get_path(SYS_PATH).'main/exercice/hotpotatoes.lib.php');
  36. // init
  37. $doc_url=urldecode($_GET['file']);
  38. $cid = $_course['official_code'];
  39. $_uid = $_SESSION['_uid'];
  40. $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
  41. $documentWebPath= api_get_path(WEB_COURSE_PATH).$_course['path']."/document";
  42. $origin = $_REQUEST['origin'];
  43. $learnpath_id = $_REQUEST['learnpath_id'];
  44. $learnpath_item_id = $_REQUEST['learnpath_item_id'];
  45. $time = $_REQUEST['time'];
  46. // read content
  47. $full_file_path = $documentPath.$doc_url;
  48. my_delete($full_file_path.$_uid.".t.html");
  49. $content = ReadFileCont($full_file_path.$_uid.".t.html");
  50. if ($content=="")
  51. {
  52. $content = ReadFileCont($full_file_path);
  53. $mit = "function Finish(){";
  54. $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
  55. "function mySaveScore() // This function included by Dokeos System\n".
  56. "{\n".
  57. " if (SaveScoreVariable==0)\n".
  58. " {\n".
  59. " SaveScoreVariable = 1;\n".
  60. " if (C.ie)\n".
  61. " {\n".
  62. " 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=$time&test=".$doc_url."&uid=".$_uid."&cid=".$cid."&score=\"+Score;\n".
  63. " //window.alert(Score);\n".
  64. " }\n".
  65. " else\n".
  66. " {\n".
  67. " 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=$time&test=".$doc_url."&uid=".$_uid."&cid=".$cid."&score=\"+Score;\n".
  68. " }\n".
  69. " }\n".
  70. "}\n".
  71. "// Must be included \n".
  72. "function Finish(){\n".
  73. " mySaveScore();";
  74. $newcontent = str_replace($mit,$js_content,$content);
  75. $prehref="<!-- BeginTopNavButtons -->";
  76. $posthref="<!-- BeginTopNavButtons --><!-- edited by Dokeos -->";
  77. $newcontent = str_replace($prehref,$posthref,$newcontent);
  78. if (CheckSubFolder($full_file_path.$_uid.".t.html")==0)
  79. { $newcontent = ReplaceImgTag($newcontent); }
  80. }
  81. else
  82. {
  83. //my_delete($full_file_path.$_uid.".t.html");
  84. $newcontent = $content;
  85. }
  86. WriteFileCont($full_file_path.$_uid.".t.html",$newcontent);
  87. /* $prehref="javascript:void(0);";
  88. $posthref=$rootWeb."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
  89. $newcontent = str_replace($prehref,$posthref,$newcontent);
  90. $prehref="class=\"GridNum\" onclick=";
  91. $posthref="class=\"GridNum\" onMouseover=";
  92. $newcontent = str_replace($prehref,$posthref,$newcontent);
  93. */
  94. $doc_url = GetFolderPath($doc_url).urlencode(GetFileName($doc_url));
  95. // echo $documentWebPath.$doc_url.$_uid.".t.html";
  96. // exit;
  97. ?>
  98. <html>
  99. <head>
  100. <title>Tests - Dokeos</title>
  101. </head>
  102. <?php
  103. if ($origin!='learnpath') {
  104. ?>
  105. <frameset rows="130,*" border="0" frameborder="no">
  106. <frame name="top" scrolling="no" noresize target="contents" src="testheaderpage.php?file=<?php echo urlencode($_GET['file']); ?>">
  107. <frame name="main" src="<?php echo $documentWebPath.$doc_url.$_uid.".t.html?time=$time"; ?>">
  108. <noframes>
  109. <body>
  110. <p>This page uses frames, but your browser doesn't support them.
  111. We suggest you try Mozilla, Firebird, Safari, Opera, or other browsers updated this millenium.
  112. </p>
  113. </body>
  114. </noframes>
  115. </frameset>
  116. <?php
  117. } else {
  118. ?>
  119. <script language='Javascript' type='text/javascript'>
  120. s='<?php echo $documentWebPath.$doc_url.$_uid; ?>.t.html?time=<?php echo $time; ?>';
  121. //document.write(s);
  122. window.location=s;
  123. </script>
  124. <?php
  125. }
  126. ?>
  127. </html>
  128. <?php
  129. //echo $full_file_path;
  130. //}
  131. //echo $uid;
  132. ?>