showinframes.php 4.5 KB

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