exercise_import.php 2.6 KB

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