lp_update_scorm.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is a learning path creation and player tool in Chamilo - previously.
  5. *
  6. * @author Julio Montoya - Improving the list of templates
  7. *
  8. * @package chamilo.learnpath
  9. */
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. $this_section = SECTION_COURSES;
  12. api_protect_course_script();
  13. $allow = api_is_allowed_to_edit(null, true);
  14. $lpId = !empty($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0;
  15. if (!$allow || empty($lpId)) {
  16. api_not_allowed(true);
  17. }
  18. $lp = new learnpath(api_get_course_id(), $lpId, api_get_user_id());
  19. if (api_is_in_gradebook()) {
  20. $interbreadcrumb[] = [
  21. 'url' => Category::getUrl(),
  22. 'name' => get_lang('Assessments'),
  23. ];
  24. }
  25. $interbreadcrumb[] = [
  26. 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
  27. 'name' => get_lang('Learning paths'),
  28. ];
  29. $interbreadcrumb[] = [
  30. 'url' => api_get_self()."?action=build&lp_id=$lpId&".api_get_cidreq(),
  31. 'name' => $lp->getNameNoTags(),
  32. ];
  33. $form = new FormValidator(
  34. '',
  35. 'POST',
  36. api_get_self().'?'.api_get_cidreq().'&lp_id='.$lpId,
  37. '',
  38. [
  39. 'id' => 'upload_form',
  40. 'enctype' => 'multipart/form-data',
  41. ]
  42. );
  43. $form->addHeader(get_lang('Update file'));
  44. $form->addHtml(Display::return_message(get_lang('You must upload a zip file with the same name as the original SCORM file.')));
  45. $form->addLabel(null, Display::return_icon('scorm_logo.jpg', null, ['style' => 'width:230px;height:100px']));
  46. $form->addElement('hidden', 'curdirpath', '');
  47. $form->addElement('file', 'user_file', get_lang('SCORM or AICC file to upload'));
  48. $form->addRule('user_file', get_lang('Required field'), 'required');
  49. $form->addButtonUpload(get_lang('Upload'));
  50. if ($form->validate()) {
  51. $oScorm = new scorm();
  52. $manifest = $oScorm->import_package(
  53. $_FILES['user_file'],
  54. '',
  55. api_get_course_info(),
  56. true,
  57. $lp
  58. );
  59. if ($manifest) {
  60. Display::addFlash(Display::return_message(get_lang('Update successful')));
  61. }
  62. header('Location: '.api_get_path(WEB_CODE_PATH).'lp/lp_list.php?'.api_get_cidreq());
  63. exit;
  64. }
  65. $content = $form->returnForm();
  66. $tpl = new Template(null);
  67. $tpl->assign('content', $content);
  68. $tpl->display_one_col_template();