aiken.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code for Aiken import integration.
  5. *
  6. * @package chamilo.exercise
  7. *
  8. * @author Ronny Velasquez <ronny.velasquez@beeznest.com>
  9. * @author César Perales <cesar.perales@gmail.com> Updated function names and import files for Aiken format support
  10. */
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. api_protect_course_script(true);
  13. $lib_path = api_get_path(LIBRARY_PATH);
  14. $main_path = api_get_path(SYS_CODE_PATH);
  15. // including additional libraries
  16. require_once $main_path.'exercise/export/aiken/aiken_import.inc.php';
  17. require_once $main_path.'exercise/export/aiken/aiken_classes.php';
  18. // section (for the tabs)
  19. $this_section = SECTION_COURSES;
  20. // access restriction: only teachers are allowed here
  21. if (!api_is_allowed_to_edit(null, true)) {
  22. api_not_allowed();
  23. }
  24. // the breadcrumbs
  25. $interbreadcrumb[] = [
  26. 'url' => 'exercise.php?'.api_get_cidreq(),
  27. 'name' => get_lang('Tests'),
  28. ];
  29. $is_allowedToEdit = api_is_allowed_to_edit(null, true);
  30. // import file
  31. if ((api_is_allowed_to_edit(null, true))) {
  32. if (isset($_POST['submit'])) {
  33. $id = aiken_import_file($_FILES['userFile']);
  34. if (is_numeric($id) && !empty($id)) {
  35. header('Location: admin.php?'.api_get_cidreq().'&exerciseId='.$id);
  36. exit;
  37. }
  38. }
  39. }
  40. // display header
  41. Display::display_header(get_lang('Import Aiken quiz'), 'Exercises');
  42. // display Aiken form
  43. aiken_display_form();
  44. // display the footer
  45. Display::display_footer();