exercise_import.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  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. * @deprecated
  8. */
  9. require '../../inc/global.inc.php';
  10. //SECURITY CHECK
  11. if (api_is_platform_admin()) {
  12. api_not_allowed();
  13. }
  14. require_once 'exercise_import.inc.php';
  15. //SQL table name
  16. $tbl_exercise = Database::get_course_table(TABLE_QUIZ_TEST);
  17. $tbl_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
  18. $tbl_rel_exercise_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  19. // tool libraries
  20. //Tool title
  21. $nameTools = get_lang('ImportExercise');
  22. $interbredcrump[] = array('url' => '../exercise.php', 'name' => get_lang('Exercises'));
  23. // EXECUTE COMMAND
  24. $cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import');
  25. switch ($cmd) {
  26. case 'show_import':
  27. $display = '<p>'
  28. . get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.') . '<br>'
  29. . '</p>'
  30. . '<form enctype="multipart/form-data" action="" method="post">'
  31. . '<input name="cmd" type="hidden" value="import" />'
  32. . '<input name="uploadedExercise" type="file" /><br><br>'
  33. . get_lang('Import exercise') . ' : '
  34. . '<input value="' . get_lang('Ok') . '" type="submit" /> '
  35. . claro_html_button( $_SERVER['PHP_SELF'], get_lang('Cancel'))
  36. . '<br><br>'
  37. . '<small>' . get_lang('Max file size') . ' : 2&nbsp;MB</small>'
  38. . '</form>';
  39. break;
  40. case 'import':
  41. //include needed librabries for treatment
  42. $result_log = import_exercise($_FILES['uploadedExercise']['name']);
  43. //display the result message (fail or success)
  44. $dialogBox = '';
  45. foreach ($result_log as $log) {
  46. $dialogBox .= $log.'<br>';
  47. }
  48. break;
  49. }
  50. // DISPLAY
  51. include api_get_path(SYS_INC_PATH) . '/header.inc.php';
  52. // Tool introduction
  53. // TODO: These settings to be checked when it is possible.
  54. Display::display_introduction_section(
  55. TOOL_QUIZ,
  56. array(
  57. 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
  58. 'CreateDocumentDir' => '../../..'.api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/',
  59. 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
  60. )
  61. );
  62. // Display Forms or dialog box(if needed)
  63. if (isset($dialogBox)) {
  64. echo Display::display_normal_message($dialogBox, false);
  65. }
  66. if (isset($display)) {
  67. echo $display;
  68. }
  69. include api_get_path(SYS_INC_PATH) . '/footer.inc.php';