Dokeos PHP Cross Reference Learning Management Systems

Source: /main/exercice/export/exercise_import.php - 125 lines - 3453 bytes - Summary - Text - Print

   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  if ( api_is_platform_admin() ) api_not_allowed();
  16  
  17  //DECLARE NEEDED LIBRARIES
  18  
  19  require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
  20  require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
  21  
  22  require_once  'exercise_import.inc.php';
  23  include_once  '../exercise.class.php';
  24  include_once  '../question.class.php';
  25  include_once  'qti/qti_classes.php';
  26  
  27  //SQL table name
  28  
  29  $tbl_exercise              = Database::get_course_table(TABLE_QUIZ_TEST);
  30  $tbl_question              = Database::get_course_table(TABLE_QUIZ_QUESTION);
  31  $tbl_rel_exercise_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  32  
  33  // tool libraries
  34  
  35  include_once  '../exercise.class.php';
  36  
  37  //Tool title
  38  
  39  $nameTools = get_lang('ImportExercise');
  40  
  41  //bredcrump
  42  
  43  $interbredcrump[]= array ('url' => '../exercise.php','name' => get_lang('Exercises'));
  44  
  45  //----------------------------------
  46  // EXECUTE COMMAND
  47  //----------------------------------
  48  
  49  $cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import');
  50  
  51  switch ( $cmd )
  52  {
  53      case 'show_import' :
  54      {
  55          $display = '<p>'
  56          .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.') . '<br>'
  57          .            '</p>'
  58          .            '<form enctype="multipart/form-data" action="" method="post">'
  59          .            '<input name="cmd" type="hidden" value="import" />'
  60          .            '<input name="uploadedExercise" type="file" /><br><br>'
  61          .            get_lang('Import exercise') . ' : '
  62          .            '<input value="' . get_lang('Ok') . '" type="submit" /> '
  63          .            claro_html_button( $_SERVER['PHP_SELF'], get_lang('Cancel'))
  64          .            '<br><br>'
  65          .            '<small>' . get_lang('Max file size') . ' :  2&nbsp;MB</small>'
  66          .            '</form>';
  67      }
  68      break;
  69  
  70      case 'import' :
  71      {
  72          //include needed librabries for treatment
  73  
  74          $result_log = import_exercise($_FILES['uploadedExercise']['name']);
  75         
  76          //display the result message (fail or success)
  77  
  78          $dialogBox = '';
  79  
  80          foreach ($result_log as $log)
  81          {
  82              $dialogBox .= $log . '<br>';
  83          }
  84  
  85      }
  86      break;
  87  }
  88  
  89  //----------------------------------
  90  // FIND INFORMATION
  91  //----------------------------------
  92  
  93  //empty!
  94  
  95  //----------------------------------
  96  // DISPLAY
  97  //----------------------------------
  98  
  99  include api_get_path(INCLUDE_PATH) . '/header.inc.php';
 100  
 101  //display title
 102  
 103  
 104  // Tool introduction
 105  // TODO: These settings to be checked when it is possible.
 106  Display::display_introduction_section(TOOL_QUIZ, array(
 107          'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
 108          'CreateDocumentDir' => '../../../courses/'.api_get_course_path().'/document/',
 109          'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
 110      )
 111  );
 112  
 113  
 114  //Display Forms or dialog box(if needed)
 115  
 116  if ( isset($dialogBox) ) echo Display::display_normal_message($dialogBox,false);
 117  
 118  //display content
 119  
 120  if (isset($display) ) echo $display;
 121  
 122  //footer display
 123  
 124  include api_get_path(INCLUDE_PATH) . '/footer.inc.php';
 125  ?>

title

Description

title

Description

title

Description

title

title

Body