dokeos-exercise
[ class tree: dokeos-exercise ] [ index: dokeos-exercise ] [ all elements ]

Source for file exercise_import.php

Documentation is available at exercise_import.php

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

Documentation generated on Thu, 12 Jun 2008 13:25:48 -0500 by phpDocumentor 1.4.1