exercise_import.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php // $Id: $
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @copyright (c) 2001-2006 Universite catholique de Louvain (UCL)
  5. * @package chamilo.exercise
  6. * @author claro team <cvs@claroline.net>
  7. */
  8. /**
  9. * Code
  10. */
  11. require '../../inc/global.inc.php';
  12. //SECURITY CHECK
  13. if (api_is_platform_admin()) {
  14. api_not_allowed();
  15. }
  16. //DECLARE NEEDED LIBRARIES
  17. require_once 'exercise_import.inc.php';
  18. include_once '../exercise.class.php';
  19. include_once '../question.class.php';
  20. include_once 'qti/qti_classes.php';
  21. //SQL table name
  22. $tbl_exercise = Database::get_course_table(TABLE_QUIZ_TEST);
  23. $tbl_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
  24. $tbl_rel_exercise_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  25. // tool libraries
  26. include_once '../exercise.class.php';
  27. //Tool title
  28. $nameTools = get_lang('ImportExercise');
  29. //bredcrump
  30. $interbredcrump[] = array('url' => '../exercice.php', 'name' => get_lang('Exercises'));
  31. //----------------------------------
  32. // EXECUTE COMMAND
  33. //----------------------------------
  34. $cmd = (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show_import');
  35. switch ($cmd) {
  36. case 'show_import' :
  37. {
  38. $display = '<p>'
  39. .get_lang(
  40. 'Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.'
  41. ).'<br>'
  42. .'</p>'
  43. .'<form enctype="multipart/form-data" action="" method="post">'
  44. .'<input name="cmd" type="hidden" value="import" />'
  45. .'<input name="uploadedExercise" type="file" /><br><br>'
  46. .get_lang('Import exercise').' : '
  47. .'<input value="'.get_lang('Ok').'" type="submit" /> '
  48. .claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel'))
  49. .'<br><br>'
  50. .'<small>'.get_lang('Max file size').' : 2&nbsp;MB</small>'
  51. .'</form>';
  52. }
  53. break;
  54. case 'import' :
  55. {
  56. //include needed librabries for treatment
  57. $result_log = import_exercise($_FILES['uploadedExercise']['name']);
  58. //display the result message (fail or success)
  59. $dialogBox = '';
  60. foreach ($result_log as $log) {
  61. $dialogBox .= $log.'<br>';
  62. }
  63. }
  64. break;
  65. }
  66. //----------------------------------
  67. // FIND INFORMATION
  68. //----------------------------------
  69. //empty!
  70. //----------------------------------
  71. // DISPLAY
  72. //----------------------------------
  73. include api_get_path(INCLUDE_PATH).'/header.inc.php';
  74. //display title
  75. // Tool introduction
  76. // TODO: These settings to be checked when it is possible.
  77. Display::display_introduction_section(
  78. TOOL_QUIZ,
  79. array(
  80. 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
  81. 'CreateDocumentDir' => '../../../courses/'.api_get_course_path().'/document/',
  82. 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
  83. )
  84. );
  85. //Display Forms or dialog box(if needed)
  86. if (isset($dialogBox)) {
  87. echo Display::display_normal_message($dialogBox, false);
  88. }
  89. //display content
  90. if (isset($display)) {
  91. echo $display;
  92. }
  93. //footer display
  94. include api_get_path(INCLUDE_PATH).'/footer.inc.php';
  95. ?>