diff --git a/public/main/gradebook/lib/be/learnpathlink.class.php b/public/main/gradebook/lib/be/learnpathlink.class.php index e6422c3446..f8e6142eff 100644 --- a/public/main/gradebook/lib/be/learnpathlink.class.php +++ b/public/main/gradebook/lib/be/learnpathlink.class.php @@ -161,7 +161,7 @@ class LearnpathLink extends AbstractLink if (!api_is_allowed_to_edit() || null == $this->calc_score(api_get_user_id())) { $url .= '&action=view&lp_id='.$this->get_ref_id(); } else { - $url .= '&action=build&lp_id='.$this->get_ref_id(); + $url .= '&action=add_item&lp_id='.$this->get_ref_id(); } return $url; diff --git a/public/main/inc/lib/pear/HTML/QuickForm.php b/public/main/inc/lib/pear/HTML/QuickForm.php index e3611b30b5..dfcc9f5b2e 100644 --- a/public/main/inc/lib/pear/HTML/QuickForm.php +++ b/public/main/inc/lib/pear/HTML/QuickForm.php @@ -359,6 +359,10 @@ class HTML_QuickForm extends HTML_Common } } + /** + * @param string $elementName + * @param string $defaultValue + */ public function setDefault($elementName, $defaultValue) { if (!$this->elementExists($elementName)) { diff --git a/public/main/lp/LearnPathItemForm.php b/public/main/lp/LearnPathItemForm.php index a47e93f251..ffc98c64e1 100644 --- a/public/main/lp/LearnPathItemForm.php +++ b/public/main/lp/LearnPathItemForm.php @@ -2,18 +2,23 @@ /* For licensing terms, see /license.txt */ +use Chamilo\CoreBundle\Framework\Container; +use Chamilo\CourseBundle\Entity\CDocument; use Chamilo\CourseBundle\Entity\CLpItem; -use ChamiloSession as Session; +/** + * Class LearnPathItemForm + */ class LearnPathItemForm { public static function setForm(FormValidator $form, $action, learnpath $lp, CLpItem $lpItem) { $itemId = $lpItem->getIid(); - $item_title = $lpItem->getTitle(); - $item_description = $lpItem->getDescription(); - $parent = $lpItem->getParentItemId(); - $item_type = $lpItem->getItemType(); + $itemTitle = $lpItem->getTitle(); + $itemDescription = $lpItem->getDescription(); + $parentItemId = $lpItem->getParentItemId(); + $itemType = $lpItem->getItemType(); + $previousItemId = $lpItem->getPreviousItemId(); $arrLP = $lp->getItemsForForm(); $lp->tree_array($arrLP); @@ -29,9 +34,6 @@ class LearnPathItemForm case 'edit': $form->addHeader(get_lang('Edit')); - /*if (isset($data['id'])) { - $defaults['directory_parent_id'] = $data['id']; - }*/ self::setItemTitle($form); break; @@ -42,7 +44,6 @@ class LearnPathItemForm break; } - $id = $lpItem->getIid(); $arrHide = []; $count = count($arrLP); $sections = []; @@ -63,6 +64,7 @@ class LearnPathItemForm } } + // Parent $parentSelect = $form->addSelect( 'parent', get_lang('Parent'), @@ -76,7 +78,7 @@ class LearnPathItemForm $arrHide = []; for ($i = 0; $i < $count; $i++) { - if ($arrLP[$i]['id'] != $id && 'dir' != $arrLP[$i]['item_type']) { + if ($arrLP[$i]['id'] != $itemId && 'dir' !== $arrLP[$i]['item_type']) { $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; } } @@ -102,29 +104,23 @@ class LearnPathItemForm $sectionCount++; } - if (!empty($itemId)) { - $parentSelect->setSelected($parent); - } else { - $parent_item_id = Session::read('parent_item_id', 0); - $parentSelect->setSelected($parent_item_id); - } + $parentSelect->setSelected($parentItemId); if (is_array($arrLP)) { reset($arrLP); } $arrHide = []; - // POSITION + + // Position for ($i = 0; $i < $count; $i++) { - if (($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $itemId) || + if (($arrLP[$i]['parent_item_id'] == $parentItemId && $arrLP[$i]['id'] != $itemId) || TOOL_LP_FINAL_ITEM == $arrLP[$i]['item_type'] ) { $arrHide[$arrLP[$i]['id']]['value'] = get_lang('After').' "'.$arrLP[$i]['title'].'"'; } } - $selectedPosition = $lpItem ? $lpItem->getPreviousItemId() : 0; - $position = $form->addSelect( 'previous', get_lang('Position'), @@ -135,7 +131,7 @@ class LearnPathItemForm $position->addOption(get_lang('First position'), 0); foreach ($arrHide as $key => $value) { - $padding = isset($value['padding']) ? $value['padding'] : 20; + $padding = $value['padding'] ?? 20; $position->addOption( $value['value'], $key, @@ -143,17 +139,72 @@ class LearnPathItemForm ); } - $position->setSelected($selectedPosition); + $position->setSelected($previousItemId); if (is_array($arrLP)) { reset($arrLP); } - $form->setDefault('title', $item_title); - $form->setDefault('description', $item_description); + if (TOOL_LP_FINAL_ITEM == $itemType) { + $parentSelect->freeze(); + $position->freeze(); + } + + // Content + if (in_array($itemType, [TOOL_DOCUMENT, TOOL_LP_FINAL_ITEM], true)) { + $repo = Container::getDocumentRepository(); + /** @var CDocument $document */ + $document = $repo->find($lpItem->getPath()); + + if ($document) { + $editorConfig = [ + 'ToolbarSet' => 'LearningPathDocuments', + 'Width' => '100%', + 'Height' => '500', + 'FullPage' => true, + // 'CreateDocumentDir' => $relative_prefix, + //'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', + //'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/'.$relative_path, + ]; + + if ('add_item' === $action) { + $text = get_lang('Add this document to the course'); + } + + if ('edit_item' === $action) { + $text = get_lang('Save document'); + } + + $form->addButtonSave(get_lang('Save'), 'submit_button'); + + if ($document->getResourceNode()->hasEditableContent()) { + $form->addHidden('document_id', $document->getIid()); + $renderer = $form->defaultRenderer(); + $renderer->setElementTemplate(' {label}{element}', 'content_lp'); + + $form->addElement('html', '
'); + $form->addHtmlEditor('content_lp', null, null, true, $editorConfig, true); + $form->addElement('html', '
'); + + $content = $lp->display_document( + $document, + false, + false + ); + $form->setDefault('content_lp', $content); + } + } + } + + if ($form->hasElement('title')) { + $form->setDefault('title', $itemTitle); + } + if ($form->hasElement('description')) { + $form->setDefault('description', $itemDescription); + } $form->addHidden('id', $itemId); - $form->addHidden('type', $item_type); + $form->addHidden('type', $itemType); $form->addHidden('post_time', time()); $form->addHidden('path', $lpItem->getPath()); } diff --git a/public/main/lp/learnpath.class.php b/public/main/lp/learnpath.class.php index 6247f5ce56..f55cb1a150 100644 --- a/public/main/lp/learnpath.class.php +++ b/public/main/lp/learnpath.class.php @@ -3315,7 +3315,7 @@ class learnpath if ($this->get_lp_session_id() == api_get_session_id()) { $html .= '

'; $html .= '
'; - $html .= "". + $html .= "". Display::returnFontAwesomeIcon('street-view').get_lang('Overview').""; $html .= "". Display::returnFontAwesomeIcon('pencil').get_lang('Edit').""; @@ -5899,7 +5899,7 @@ class learnpath $default_content = null; $elements = []; $return_audio = null; - $iconPath = api_get_path(SYS_CODE_PATH).'img/'; + $iconPath = api_get_path(SYS_PUBLIC_PATH).'img/'; $mainUrl = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq(); $countItems = count($arrLP); @@ -5947,7 +5947,7 @@ class learnpath $title_cut = cut($arrLP[$i]['title'], self::MAX_LP_ITEM_TITLE_LENGTH); } // Link for the documents - if ('document' === $arrLP[$i]['item_type'] || TOOL_READOUT_TEXT == $arrLP[$i]['item_type']) { + if ('document' === $arrLP[$i]['item_type'] || TOOL_READOUT_TEXT === $arrLP[$i]['item_type']) { $url = $mainUrl.'&action=view_item&mode=preview_document&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id; $title_cut = Display::url( $title_cut, @@ -5961,7 +5961,7 @@ class learnpath } // Detect if type is FINAL_ITEM to set path_id to SESSION - if (TOOL_LP_FINAL_ITEM == $arrLP[$i]['item_type']) { + if (TOOL_LP_FINAL_ITEM === $arrLP[$i]['item_type']) { Session::write('pathItem', $arrLP[$i]['path']); } @@ -6224,7 +6224,7 @@ class learnpath ['class' => 'btn btn-default'] ); if ('final_item' != $arrLP[$i]['item_type']) { - $move_item_icon = Display::url( + /*$move_item_icon = Display::url( Display::return_icon( 'move.png', get_lang('Move'), @@ -6233,7 +6233,7 @@ class learnpath ), $url.'&action=move_item', ['class' => 'btn btn-default'] - ); + );*/ } $audio_icon = Display::url( Display::return_icon( @@ -6903,7 +6903,7 @@ class learnpath } if ($show_actions) { - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); } $return .= '
'; @@ -6992,23 +6992,21 @@ class learnpath case 'asset': case 'sco': if (isset($_GET['view']) && 'build' === $_GET['view']) { - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_item_form( $lpItem, - get_lang('Edit the current section').' :', 'edit' ); } else { $return .= $this->display_item_form( $lpItem, - get_lang('Edit the current section').' :', 'edit_item' ); } break; case TOOL_DOCUMENT: case TOOL_READOUT_TEXT: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); if (TOOL_DOCUMENT === $itemType) { $return .= $this->display_document_form('edit', $lpItem); } @@ -7023,7 +7021,7 @@ class learnpath $repo = Container::getLinkRepository(); $link = $repo->find($path); } - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_link_form('edit', $lpItem, $link); break; case TOOL_LP_FINAL_ITEM: @@ -7038,7 +7036,7 @@ class learnpath lp.iid = ".$item_id; $res_step = Database::query($sql); $row_step = Database::fetch_array($res_step, 'ASSOC'); - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_document_form('edit', $item_id, $row_step); break; case TOOL_QUIZ: @@ -7046,11 +7044,11 @@ class learnpath $repo = Container::getExerciseRepository(); $resource = $repo->find($path); } - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_quiz_form('edit', $lpItem, $resource); break; case TOOL_HOTPOTATOES: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_hotpotatoes_form('edit', $item_id, $row); break; case TOOL_STUDENTPUBLICATION: @@ -7058,7 +7056,7 @@ class learnpath $repo = Container::getStudentPublicationRepository(); $resource = $repo->find($path); } - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_student_publication_form('edit', $lpItem, $resource); break; case TOOL_FORUM: @@ -7066,7 +7064,7 @@ class learnpath $repo = Container::getForumRepository(); $resource = $repo->find($path); } - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_forum_form('edit', $lpItem, $resource); break; case TOOL_THREAD: @@ -7074,7 +7072,7 @@ class learnpath $repo = Container::getForumPostRepository(); $resource = $repo->find($path); } - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_thread_form('edit', $lpItem, $resource); break; } @@ -7124,7 +7122,6 @@ class learnpath ]; echo Display::return_message(get_lang('Click on the [Learner view] button to see your learning path'), 'normal'); - //$dir = $this->display_item_form('dir', get_lang('EnterDataAdd section'), 'add_item'); $dir = $this->displayNewSectionForm(); $selected = isset($_REQUEST['lp_build_selected']) ? (int) $_REQUEST['lp_build_selected'] : 0; @@ -7282,178 +7279,10 @@ class learnpath return '
'.$form->returnForm().'
'; } - /** - * Addition of Hotpotatoes tests. - * - * @param string $action - * @param int $id Internal ID of the item - * @param string $extra_info - * - * @return string HTML structure to display the hotpotatoes addition formular - */ - public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '') - { - $course_id = api_get_course_int_id(); - $uploadPath = DIR_HOTPOTATOES; - - if (0 != $id && is_array($extra_info)) { - $item_title = stripslashes($extra_info['title']); - $item_description = stripslashes($extra_info['description']); - } elseif (is_numeric($extra_info)) { - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); - - $sql = "SELECT * FROM $TBL_DOCUMENT - WHERE - c_id = $course_id AND - path LIKE '".$uploadPath."/%/%htm%' AND - iid = ".(int) $extra_info." - ORDER BY iid ASC"; - - $res_hot = Database::query($sql); - $row = Database::fetch_array($res_hot); - - $item_title = $row['title']; - $item_description = $row['description']; - - if (!empty($row['comment'])) { - $item_title = $row['comment']; - } - } else { - $item_title = ''; - $item_description = ''; - } - - $parent = 0; - if (0 != $id && is_array($extra_info)) { - $parent = $extra_info['parent_item_id']; - } - - $arrLP = $this->getItemsForForm(); - $legend = ''; - if ('add' == $action) { - $legend .= get_lang('Adding a test to the course'); - } elseif ('move' == $action) { - $legend .= get_lang('Move the current test'); - } else { - $legend .= get_lang('Edit the current test'); - } - if (isset($_GET['edit']) && 'true' == $_GET['edit']) { - $legend .= Display:: return_message( - get_lang('Warning ! ! !').' ! '.get_lang('Warning ! ! !EditingDocument') - ); - } - $legend .= ''; - - $return = '
'; - $return .= $legend; - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - - if ('move' != $action) { - $return .= ''; - $return .= ''; - $return .= ''; - $return .= ''; - $id_prerequisite = 0; - if (is_array($arrLP) && count($arrLP) > 0) { - foreach ($arrLP as $key => $value) { - if ($value['id'] == $id) { - $id_prerequisite = $value['prerequisite']; - break; - } - } - - $arrHide = []; - for ($i = 0; $i < count($arrLP); $i++) { - if ($arrLP[$i]['id'] != $id && 'dir' != $arrLP[$i]['item_type']) { - $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; - } - } - } - } - - $return .= ''; - $return .= ''; - $return .= ''; - $return .= '
'; - $return .= ''; - $return .= '
'; - $return .= ''; - $return .= '
 
'; - - if ('move' == $action) { - $return .= ''; - $return .= ''; - } - - if (is_numeric($extra_info)) { - $return .= ''; - } elseif (is_array($extra_info)) { - $return .= ''; - } - $return .= ''; - $return .= ''; - $return .= '
'; - - return $return; - } - /** * Return the form to display the forum edit/add option. * * @param CLpItem $lpItem - * @param int $id ID of the lp_item if already exists - * @param string $extra_info * * @throws Exception * @@ -7468,7 +7297,7 @@ class learnpath ); LearnPathItemForm::setForm($form, $action, $this, $lpItem); - if ('add' == $action) { + if ('add' === $action) { $form->addButtonSave(get_lang('Add forum to course'), 'submit_button'); } else { $form->addButtonSave(get_lang('Edit the current forum'), 'submit_button'); @@ -7522,7 +7351,6 @@ class learnpath */ public function display_item_form( $lpItem, - $title = '', $action = 'add_item' ) { $item_type = $lpItem->getItemType(); @@ -7534,37 +7362,6 @@ class learnpath $form->addButtonSave(get_lang('Save section'), 'submit_button'); - //assets can't be modified - //$item_type == 'asset' || - if (('sco' == $item_type) && ('html' == $extension || 'htm' == $extension)) { - if ('sco' == $item_type) { - $form->addElement( - 'html', - '' - ); - } - $renderer = $form->defaultRenderer(); - $renderer->setElementTemplate( - '
      {label}
{element}', - 'content_lp' - ); - - $relative_prefix = ''; - $editor_config = [ - 'ToolbarSet' => 'LearningPathDocuments', - 'Width' => '100%', - 'Height' => '500', - 'FullPage' => true, - 'CreateDocumentDir' => $relative_prefix, - //'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/scorm/', - //'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().$item_path_fck, - ]; - - $form->addElement('html_editor', 'content_lp', '', null, $editor_config); - $content_path = api_get_path(SYS_COURSE_PATH).api_get_course_path().$item_path_fck; - $defaults['content_lp'] = file_get_contents($content_path); - } - return $form->returnForm(); } @@ -7631,14 +7428,11 @@ class learnpath */ public function display_document_form($action = 'add', $lpItem = null) { - $_course = api_get_course_info(); - if (empty($lpItem)) { return ''; } - $item_title = $lpItem->getTitle(); - $item_description = $lpItem->getDescription(); + $_course = api_get_course_info(); $item_type = $lpItem->getItemType(); $form = new FormValidator( @@ -7677,106 +7471,8 @@ class learnpath } $showButton = false; - if ('move' !== $action) { - $arrHide = []; - /*for ($i = 0; $i < $count; $i++) { - if ($arrLP[$i]['id'] != $itemId && 'dir' !== $arrLP[$i]['item_type'] && - TOOL_LP_FINAL_ITEM !== $arrLP[$i]['item_type'] - ) { - $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; - } - }*/ - - //$edit = isset($_GET['edit']) ? $_GET['edit'] : null; - $repo = Container::getDocumentRepository(); - /** @var CDocument $document */ - $document = $repo->find($lpItem->getPath()); - if (TOOL_DOCUMENT == $item_type || TOOL_LP_FINAL_ITEM == $item_type) { - /*if (isset($_POST['content'])) { - $content = stripslashes($_POST['content']); - } else { - $content = $this->display_document( - $lpItem->getPath(), - false, - false - ); - }*/ - - ///if (!$no_display_edit_textarea) { - // We need to calculate here some specific settings for the online editor. - // The calculated settings work for documents in the Documents tool - // (on the root or in subfolders). - // For documents in native scorm packages it is unclear whether the - // online editor should be activated or not. - - // A new document, it is in the root of the repository. - /* if (is_array($extra_info) && 'new' !== $extra_info) { - // The document already exists. Whe have to determine its relative path towards the repository root. - $relative_path = explode('/', $extra_info['dir']); - $cnt = count($relative_path) - 2; - if ($cnt < 0) { - $cnt = 0; - } - $relative_prefix = str_repeat('../', $cnt); - $relative_path = array_slice($relative_path, 1, $cnt); - $relative_path = implode('/', $relative_path); - if (strlen($relative_path) > 0) { - $relative_path = $relative_path.'/'; - } - } else { - $result = $this->generate_lp_folder($_course); - $relative_path = api_substr($result['dir'], 1, strlen($result['dir'])); - $relative_prefix = '../../'; - }*/ - $editorConfig = [ - 'ToolbarSet' => 'LearningPathDocuments', - 'Width' => '100%', - 'Height' => '500', - 'FullPage' => true, - // 'CreateDocumentDir' => $relative_prefix, - 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', - //'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/'.$relative_path, - ]; - if ('add_item' === $action) { - $text = get_lang('Add this document to the course'); - } - - if ('edit_item' === $action) { - $text = get_lang('Save document'); - } - - $form->addButtonSave(get_lang('Save'), 'submit_button'); - - if ($document->getResourceNode()->hasEditableContent()) { - $form->addHidden('document_id', $document->getIid()); - $showButton = true; - $renderer = $form->defaultRenderer(); - $renderer->setElementTemplate(' {label}{element}', 'content_lp'); - - $form->addElement('html', '
'); - $form->addHtmlEditor('content_lp', null, null, true, $editorConfig, true); - $form->addElement('html', '
'); - - $content = $this->display_document( - $document, - false, - false - ); - $defaults['content_lp'] = $content; - } - //} - } elseif ($lpItem) { - $form->addButtonSave(get_lang('Save document'), 'submit_button'); - $return = $this->display_document($document, true, true, true); - $form->addElement('html', $return); - } - } - - if (TOOL_LP_FINAL_ITEM == $item_type) { - $parentSelect->freeze(); - $position->freeze(); - } + $form->addButtonSave(get_lang('Save document'), 'submit_button'); if ($showButton) { $form->addButtonSave(get_lang('Save document'), 'submit_button'); @@ -7787,7 +7483,6 @@ class learnpath $form->addElement('hidden', 'path', $extra_info['path']); }*/ $form->addElement('hidden', 'type', TOOL_DOCUMENT); - $form->setDefaults($defaults); return $form->returnForm(); } @@ -8216,15 +7911,14 @@ class learnpath * * @return string */ - public function display_manipulate(CLpItem $lpItem) + public function displayItemMenu(CLpItem $lpItem) { - $course_code = api_get_course_id(); $item_id = $lpItem->getIid(); $audio = $lpItem->getAudio(); $itemType = $lpItem->getItemType(); $path = $lpItem->getPath(); - $return = '
'; + $return = '
'; $audio_player = null; // We display an audio player if needed. if (!empty($audio)) { @@ -8280,7 +7974,7 @@ class learnpath $url.'&action=delete_item' ); - if (in_array($itemType, [TOOL_DOCUMENT, TOOL_LP_FINAL_ITEM, TOOL_HOTPOTATOES])) { + /*if (in_array($itemType, [TOOL_DOCUMENT, TOOL_LP_FINAL_ITEM, TOOL_HOTPOTATOES])) { $documentData = DocumentManager::get_document_data_by_id($path, $course_code); if (empty($documentData)) { // Try with iid @@ -8299,7 +7993,7 @@ class learnpath if (isset($documentData['absolute_path_from_document'])) { $return .= get_lang('File').': '.$documentData['absolute_path_from_document']; } - } + }*/ $return .= '
'; @@ -8330,7 +8024,7 @@ class learnpath lp_id = ".$this->lp_id." AND parent_item_id = 0 ORDER BY display_order ASC"; - $res_zero = Database::query($sql); + Database::query($sql); $i = 0; $list = $this->getItemsForForm(true); @@ -8415,7 +8109,7 @@ class learnpath switch ($itemType) { case 'dir': case 'asset': - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_item_form( $lpItem, get_lang('Move the current section'), @@ -8424,7 +8118,7 @@ class learnpath ); break; case TOOL_DOCUMENT: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_document_form('move', $lpItem); break; case TOOL_LINK: @@ -8433,27 +8127,27 @@ class learnpath $repo = Container::getLinkRepository(); $link = $repo->find($path); } - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_link_form('move', $lpItem, $link); break; case TOOL_HOTPOTATOES: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_link_form('move', $lpItem, $row); break; case TOOL_QUIZ: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_quiz_form('move', $lpItem, $row); break; case TOOL_STUDENTPUBLICATION: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_student_publication_form('move', $lpItem, $row); break; case TOOL_FORUM: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_forum_form('move', $lpItem, $row); break; case TOOL_THREAD: - $return .= $this->display_manipulate($lpItem); + $return .= $this->displayItemMenu($lpItem); $return .= $this->display_forum_form('move', $lpItem, $row); break; } @@ -9059,10 +8753,11 @@ class learnpath { $return = '
    '; $return .= '
  • '; + /* $return .= Display::return_icon('works_new.gif'); $return .= ' '. get_lang('Add the Assignments tool to the course').''; - $return .= '
  • '; + $return .= '';*/ require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; $works = getWorkListTeacher(0, 100, null, null, null); diff --git a/public/main/lp/lp_add_audio.php b/public/main/lp/lp_add_audio.php index 71d214fe1f..4423f031fa 100644 --- a/public/main/lp/lp_add_audio.php +++ b/public/main/lp/lp_add_audio.php @@ -37,7 +37,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$learnpath_id&".api_get_cidreq(), 'name' => $lp->getNameNoTags(), ]; diff --git a/public/main/lp/lp_add_item.php b/public/main/lp/lp_add_item.php index c5e98892c3..b9e04e1008 100644 --- a/public/main/lp/lp_add_item.php +++ b/public/main/lp/lp_add_item.php @@ -18,7 +18,7 @@ api_protect_course_script(); $isStudentView = isset($_REQUEST['isStudentView']) ? $_REQUEST['isStudentView'] : null; $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0; $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null; -$type = isset($_GET['type']) ? $_GET['type'] : null; +$type = isset($_GET['type']) ? $_GET['type'] : 'step'; $action = isset($_GET['action']) ? $_GET['action'] : null; $is_allowed_to_edit = api_is_allowed_to_edit(null, false); @@ -94,7 +94,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$lpId&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$lpId&".api_get_cidreq(), 'name' => $learnPath->getNameNoTags(), ]; @@ -212,101 +212,46 @@ if (in_array($message, ['ItemUpdated'])) { echo Display::return_message(get_lang($message)); } -if (isset($new_item_id) && is_numeric($new_item_id)) { - switch ($type) { - case 'dir': - echo $learnPath->display_manipulate($new_item_id, $_POST['type']); - echo Display::return_message( - get_lang('Add sectionCreated'), - 'confirmation' - ); - break; - case TOOL_LINK: - echo $learnPath->display_manipulate($new_item_id, $type); - echo Display::return_message( - get_lang('The new link has been created'), - 'confirmation' - ); - break; - case TOOL_STUDENTPUBLICATION: - echo $learnPath->display_manipulate($new_item_id, $type); - echo Display::return_message( - get_lang('The new assignment has been created'), - 'confirmation' - ); - break; - case TOOL_QUIZ: - echo $learnPath->display_manipulate($new_item_id, $type); - echo Display::return_message( - get_lang('The test has been added to the course'), - 'confirmation' - ); - break; - case TOOL_DOCUMENT: - echo Display::return_message( - get_lang('The rich media page/activity has been added to the course'), - 'confirmation' - ); - echo $learnPath->display_item($lpItem); - break; - case TOOL_FORUM: - echo $learnPath->display_manipulate($new_item_id, $type); - echo Display::return_message( - get_lang('A new forum has now been created'), - 'confirmation' - ); - break; - case 'thread': - echo $learnPath->display_manipulate($new_item_id, $type); - echo Display::return_message( - get_lang('A new forum thread has now been created'), - 'confirmation' - ); - break; - } -} else { - switch ($type) { - case 'dir': - echo $learnPath->display_item_form( - $type, - get_lang('EnterDataAdd section') - ); - break; - case TOOL_DOCUMENT: - if (isset($_GET['file']) && is_numeric($_GET['file'])) { - echo $learnPath->display_document_form('add', 0, $_GET['file']); - } else { - echo $learnPath->display_document_form('add'); - } - break; - /*case 'hotpotatoes': - echo $learnPath->display_hotpotatoes_form('add', 0, $_GET['file']); - break;*/ - case TOOL_QUIZ: - echo Display::return_message( - get_lang('Exercise can\'t be edited after being added to the Learning Path'), - 'warning' - ); - echo $learnPath->display_quiz_form('add', 0, $_GET['file']); - break; - case TOOL_FORUM: - echo $learnPath->display_forum_form('add', 0, $_GET['forum_id']); - break; - case 'thread': - echo $learnPath->display_thread_form('add', 0, $_GET['thread_id']); - break; - case TOOL_LINK: - echo $learnPath->display_link_form('add'); - break; - case TOOL_STUDENTPUBLICATION: - $extra = isset($_GET['file']) ? $_GET['file'] : null; - echo $learnPath->display_student_publication_form('add', 0, $extra); - break; - case 'step': - $learnPath->display_resources(); - break; - } -} +$learnPath->display_resources(); +/* +switch ($type) { + case 'dir': + echo $learnPath->display_item_form( + $type + ); + break; + case TOOL_DOCUMENT: + if (isset($_GET['file']) && is_numeric($_GET['file'])) { + echo $learnPath->display_document_form('add', 0, $_GET['file']); + } else { + echo $learnPath->display_document_form('add'); + } + break; + case 'hotpotatoes': + echo $learnPath->display_hotpotatoes_form('add', 0, $_GET['file']); + break; + case TOOL_QUIZ: + echo Display::return_message( + get_lang('Exercise can\'t be edited after being added to the Learning Path'), + 'warning' + ); + echo $learnPath->display_quiz_form('add', 0, $_GET['file']); + break; + case TOOL_FORUM: + echo $learnPath->display_forum_form('add', 0, $_GET['forum_id']); + break; + case 'thread': + echo $learnPath->display_thread_form('add', 0, $_GET['thread_id']); + break; + case TOOL_LINK: + echo $learnPath->display_link_form('add'); + break; + case TOOL_STUDENTPUBLICATION: + echo $learnPath->display_student_publication_form('add', 0, $extra); + break; + case 'step': + break; +}*/ echo '
'; echo '
'; diff --git a/public/main/lp/lp_admin_view.php b/public/main/lp/lp_admin_view.php index 1adb2a17f1..1cb7096b14 100644 --- a/public/main/lp/lp_admin_view.php +++ b/public/main/lp/lp_admin_view.php @@ -45,7 +45,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$learnpath_id&".api_get_cidreq(), "name" => Security::remove_XSS($learnPath->getNameNoTags()), ]; $interbreadcrumb[] = [ diff --git a/public/main/lp/lp_controller.php b/public/main/lp/lp_controller.php index a72d250329..1055979956 100644 --- a/public/main/lp/lp_controller.php +++ b/public/main/lp/lp_controller.php @@ -833,19 +833,6 @@ switch ($action) { } } break; - case 'build': - if (!$is_allowed_to_edit) { - api_not_allowed(true); - } - if (!$lp_found) { - require 'lp_list.php'; - } else { - Session::write('refresh', 1); - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); - header('Location: '.$url); - exit; - } - break; case 'edit_item': if (!$is_allowed_to_edit) { api_not_allowed(true); diff --git a/public/main/lp/lp_edit.php b/public/main/lp/lp_edit.php index 9f1f0e87ef..e94d3587b8 100644 --- a/public/main/lp/lp_edit.php +++ b/public/main/lp/lp_edit.php @@ -32,7 +32,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=".$lpId.'&'.api_get_cidreq(), 'name' => $learnPath->getNameNoTags(), ]; diff --git a/public/main/lp/lp_edit_item.php b/public/main/lp/lp_edit_item.php index bdba43fb0f..dcc4e50132 100644 --- a/public/main/lp/lp_edit_item.php +++ b/public/main/lp/lp_edit_item.php @@ -61,7 +61,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$learnpath_id&".api_get_cidreq(), 'name' => $learnPath->getNameNoTags(), ]; $interbreadcrumb[] = [ diff --git a/public/main/lp/lp_edit_item_prereq.php b/public/main/lp/lp_edit_item_prereq.php index e51f195de0..49638f9a8e 100644 --- a/public/main/lp/lp_edit_item_prereq.php +++ b/public/main/lp/lp_edit_item_prereq.php @@ -47,7 +47,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$learnpath_id", + 'url' => api_get_self()."?action=add_item&lp_id=$learnpath_id", 'name' => $lp->getNameNoTags(), ]; $interbreadcrumb[] = [ @@ -87,10 +87,10 @@ echo '
'; echo '
'; echo '
'; if (isset($is_success) && true == $is_success) { - echo $lp->display_manipulate($lpItem); + echo $lp->displayItemMenu($lpItem); echo Display::return_message(get_lang('Prerequisites to the current learning object have been added.')); } else { - echo $lp->display_manipulate($lpItem); + echo $lp->displayItemMenu($lpItem); echo $lp->display_item_prerequisites_form($lpItem); } echo '
'; diff --git a/public/main/lp/lp_move_item.php b/public/main/lp/lp_move_item.php index f8afd46173..c78d34c1ba 100644 --- a/public/main/lp/lp_move_item.php +++ b/public/main/lp/lp_move_item.php @@ -60,7 +60,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$learnpath_id&".api_get_cidreq(), 'name' => $learnPath->getNameNoTags(), ]; $interbreadcrumb[] = [ diff --git a/public/main/lp/lp_subscribe_users.php b/public/main/lp/lp_subscribe_users.php index 75edf7023e..f183d6182b 100644 --- a/public/main/lp/lp_subscribe_users.php +++ b/public/main/lp/lp_subscribe_users.php @@ -36,7 +36,7 @@ $interbreadcrumb[] = [ ]; $interbreadcrumb[] = [ - 'url' => api_get_self().'?action=build&lp_id='.$oLP->get_id().'&'.api_get_cidreq(), + 'url' => api_get_self().'?action=add_item&lp_id='.$oLP->get_id().'&'.api_get_cidreq(), 'name' => $oLP->getNameNoTags(), ]; diff --git a/public/main/lp/lp_update_scorm.php b/public/main/lp/lp_update_scorm.php index cb094a47ad..86952637a1 100644 --- a/public/main/lp/lp_update_scorm.php +++ b/public/main/lp/lp_update_scorm.php @@ -33,7 +33,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$lpId&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$lpId&".api_get_cidreq(), 'name' => $lp->getNameNoTags(), ]; diff --git a/public/main/lp/lp_view_item.php b/public/main/lp/lp_view_item.php index 3c3429ee09..ecec4455e6 100644 --- a/public/main/lp/lp_view_item.php +++ b/public/main/lp/lp_view_item.php @@ -76,7 +76,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ - 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), + 'url' => api_get_self()."?action=add_item&lp_id=$learnpath_id&".api_get_cidreq(), 'name' => $lp->getNameNoTags(), ]; $interbreadcrumb[] = [