|
@@ -1946,7 +1946,7 @@ class learnpath
|
|
|
error_log('New LP - In learnpath::get_last()', 0);
|
|
|
}
|
|
|
//This is just in case the lesson doesn't cointain a valid scheme, just to avoid "Notices"
|
|
|
- if ($this->index > 0) {
|
|
|
+ if (count($this->ordered_items) > 0) {
|
|
|
$this->index = count($this->ordered_items) - 1;
|
|
|
return $this->ordered_items[$this->index];
|
|
|
}
|
|
@@ -3400,7 +3400,7 @@ class learnpath
|
|
|
}
|
|
|
|
|
|
// Fixed issue BT#1272 - If the item type is a Chamilo Item (quiz, link, etc), then change the lp type to thread it as a normal Chamilo LP not a SCO.
|
|
|
- if (in_array($lp_item_type, array('quiz', 'document', 'link', 'forum', 'thread', 'student_publication'))) {
|
|
|
+ if (in_array($lp_item_type, array('quiz', 'document', 'final_item', 'link', 'forum', 'thread', 'student_publication'))) {
|
|
|
$lp_type = 1;
|
|
|
}
|
|
|
|
|
@@ -5598,6 +5598,11 @@ class learnpath
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ // Detect if type is FINAL_ITEM to set path_id to SESSION
|
|
|
+ if ($arrLP[$i]['item_type'] == TOOL_LP_FINAL_ITEM) {
|
|
|
+ $_SESSION['pathItem'] = $arrLP[$i]['path'];
|
|
|
+ }
|
|
|
+
|
|
|
if (($i % 2) == 0) {
|
|
|
$oddClass = 'row_odd';
|
|
|
} else {
|
|
@@ -5613,7 +5618,11 @@ class learnpath
|
|
|
if (file_exists('../img/lp_' . $icon_name . '.gif')) {
|
|
|
$icon = Display::return_icon('lp_'.$icon_name.'.gif');
|
|
|
} else {
|
|
|
- $icon = Display::return_icon('folder_document.gif');
|
|
|
+ if ($arrLP[$i]['item_type'] === TOOL_LP_FINAL_ITEM) {
|
|
|
+ $icon = Display::return_icon('certificate.png');
|
|
|
+ } else {
|
|
|
+ $icon = Display::return_icon('folder_document.gif');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5648,13 +5657,15 @@ class learnpath
|
|
|
|
|
|
if ($is_allowed_to_edit) {
|
|
|
if (!$update_audio || $update_audio <> 'true') {
|
|
|
- $move_icon .= '<a class="moved" href="#">';
|
|
|
- $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
|
|
|
- $move_icon .= '</a>';
|
|
|
+ if ($arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
|
|
|
+ $move_icon .= '<a class="moved" href="#">';
|
|
|
+ $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
|
|
|
+ $move_icon .= '</a>';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// No edit for this item types
|
|
|
- if (!in_array($arrLP[$i]['item_type'], array('sco', 'asset'))) {
|
|
|
+ if (!in_array($arrLP[$i]['item_type'], array('sco', 'asset', 'final_item'))) {
|
|
|
if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module'))) {
|
|
|
$edit_icon .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit_item&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '&path_item=' . $arrLP[$i]['path'] . '" class="btn btn-default">';
|
|
|
$edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
|
|
@@ -6146,7 +6157,6 @@ class learnpath
|
|
|
|
|
|
if (!is_dir($filepath)) {
|
|
|
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
|
|
|
- $dir = '/';
|
|
|
}
|
|
|
|
|
|
$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
|
|
@@ -6263,7 +6273,6 @@ class learnpath
|
|
|
WHERE c_id = ".$course_id." AND id = " . intval($item_id);
|
|
|
$res = Database::query($sql);
|
|
|
$row = Database::fetch_array($res);
|
|
|
-
|
|
|
switch ($row['item_type']) {
|
|
|
case 'dokeos_chapter' :
|
|
|
case 'dir' :
|
|
@@ -6287,7 +6296,7 @@ class learnpath
|
|
|
doc.c_id = $course_id AND
|
|
|
lp.id = " . intval($item_id);
|
|
|
$res_step = Database::query($sql);
|
|
|
- $row_step = Database :: fetch_array($res_step);
|
|
|
+ $row_step = Database :: fetch_array($res_step, 'ASSOC');
|
|
|
$return .= $this->display_manipulate($item_id, $row['item_type']);
|
|
|
$return .= $this->display_document_form('edit', $item_id, $row_step);
|
|
|
break;
|
|
@@ -6306,6 +6315,22 @@ class learnpath
|
|
|
$return .= $this->display_manipulate($item_id, $row['item_type']);
|
|
|
$return .= $this->display_link_form('edit', $item_id, $row);
|
|
|
break;
|
|
|
+ case TOOL_LP_FINAL_ITEM :
|
|
|
+ $_SESSION['finalItem'] = true;
|
|
|
+ $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
|
|
|
+ $sql = "SELECT lp.*, doc.path as dir
|
|
|
+ FROM " . $tbl_lp_item . " as lp
|
|
|
+ LEFT JOIN " . $tbl_doc . " as doc
|
|
|
+ ON doc.id = lp.path
|
|
|
+ WHERE
|
|
|
+ lp.c_id = $course_id AND
|
|
|
+ doc.c_id = $course_id AND
|
|
|
+ lp.id = " . intval($item_id);
|
|
|
+ $res_step = Database::query($sql);
|
|
|
+ $row_step = Database :: fetch_array($res_step, 'ASSOC');
|
|
|
+ $return .= $this->display_manipulate($item_id, $row['item_type']);
|
|
|
+ $return .= $this->display_document_form('edit', $item_id, $row_step);
|
|
|
+ break;
|
|
|
case 'dokeos_module' :
|
|
|
if (isset ($_GET['view']) && $_GET['view'] == 'build') {
|
|
|
$return .= $this->display_manipulate($item_id, $row['item_type']);
|
|
@@ -6358,26 +6383,30 @@ class learnpath
|
|
|
// Get all the links.
|
|
|
$links = $this->get_links();
|
|
|
|
|
|
- // Get al the student publications.
|
|
|
+ // Get all the student publications.
|
|
|
$works = $this->get_student_publications();
|
|
|
|
|
|
- // Get al the forums.
|
|
|
+ // Get all the forums.
|
|
|
$forums = $this->get_forums(null, $course_code);
|
|
|
|
|
|
+ // Get the final item form (see BT#11048) .
|
|
|
+ $finish = $this->getFinalItemForm();
|
|
|
+
|
|
|
$headers = array(
|
|
|
Display::return_icon('folder_document.png', get_lang('Documents'), array(), ICON_SIZE_BIG),
|
|
|
Display::return_icon('quiz.png', get_lang('Quiz'), array(), ICON_SIZE_BIG),
|
|
|
Display::return_icon('links.png', get_lang('Links'), array(), ICON_SIZE_BIG),
|
|
|
Display::return_icon('works.png', get_lang('Works'), array(), ICON_SIZE_BIG),
|
|
|
Display::return_icon('forum.png', get_lang('Forums'), array(), ICON_SIZE_BIG),
|
|
|
- Display::return_icon('add_learnpath_section.png', get_lang('NewChapter'), array(), ICON_SIZE_BIG)
|
|
|
+ Display::return_icon('add_learnpath_section.png', get_lang('NewChapter'), array(), ICON_SIZE_BIG),
|
|
|
+ Display::return_icon('certificate.png', get_lang('Certificate'), [], ICON_SIZE_BIG),
|
|
|
);
|
|
|
|
|
|
echo Display::display_normal_message(get_lang('ClickOnTheLearnerViewToSeeYourLearningPath'));
|
|
|
$chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item');
|
|
|
echo Display::tabs(
|
|
|
$headers,
|
|
|
- array($documents, $exercises, $links, $works, $forums, $chapter), 'resource_tab'
|
|
|
+ array($documents, $exercises, $links, $works, $forums, $chapter, $finish), 'resource_tab'
|
|
|
);
|
|
|
|
|
|
return true;
|
|
@@ -7654,10 +7683,10 @@ class learnpath
|
|
|
|
|
|
//POSITION
|
|
|
for ($i = 0; $i < count($arrLP); $i++) {
|
|
|
- if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
|
|
|
- if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
|
|
|
+ if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id || $arrLP[$i]['item_type'] == TOOL_LP_FINAL_ITEM) {
|
|
|
+ if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'] || $action == 'add') {
|
|
|
$s_selected_position = $arrLP[$i]['id'];
|
|
|
- elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
|
|
|
+ }
|
|
|
$arrHide[$arrLP[$i]['id']]['value'] = get_lang('After') . ' "' . $arrLP[$i]['title'] . '"';
|
|
|
}
|
|
|
}
|
|
@@ -7669,6 +7698,7 @@ class learnpath
|
|
|
$padding = isset($value['padding']) ? $value['padding']: 20;
|
|
|
$position->addOption($value['value'], $key, 'style="padding-left:' . $padding . 'px;"');
|
|
|
}
|
|
|
+
|
|
|
$position->setSelected($s_selected_position);
|
|
|
|
|
|
if (is_array($arrLP)) {
|
|
@@ -7689,7 +7719,7 @@ class learnpath
|
|
|
$arrHide = array();
|
|
|
|
|
|
for ($i = 0; $i < count($arrLP); $i++) {
|
|
|
- if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
|
|
|
+ if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
|
|
|
if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
|
|
|
$s_selected_position = $arrLP[$i]['id'];
|
|
|
elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
|
|
@@ -7702,7 +7732,7 @@ class learnpath
|
|
|
if (!$no_display_add) {
|
|
|
$item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
|
|
|
$edit = isset($_GET['edit']) ? $_GET['edit'] : null;
|
|
|
- if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $edit == 'true')) {
|
|
|
+ if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) {
|
|
|
if (isset ($_POST['content']))
|
|
|
$content = stripslashes($_POST['content']);
|
|
|
elseif (is_array($extra_info)) {
|
|
@@ -8250,7 +8280,7 @@ class learnpath
|
|
|
// Commented the message cause should not show it.
|
|
|
//$lang = get_lang('TitleManipulateModule');
|
|
|
break;
|
|
|
-
|
|
|
+ case TOOL_LP_FINAL_ITEM :
|
|
|
case TOOL_DOCUMENT :
|
|
|
// Commented the message cause should not show it.
|
|
|
//$lang = get_lang('TitleManipulateDocument');
|
|
@@ -8324,7 +8354,7 @@ class learnpath
|
|
|
$return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
|
|
|
}
|
|
|
|
|
|
- if ($item_type == TOOL_DOCUMENT ) {
|
|
|
+ if ($item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM) {
|
|
|
$document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);
|
|
|
$return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
|
|
|
}
|
|
@@ -10755,6 +10785,125 @@ EOD;
|
|
|
return $forumId;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Check and obtain the lp final item if exist
|
|
|
+ *
|
|
|
+ * @return array lp items
|
|
|
+ */
|
|
|
+ private function getFinalItem()
|
|
|
+ {
|
|
|
+
|
|
|
+ if (empty($this->items)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($this->items as $item) {
|
|
|
+ if ($item->type !== 'final_item') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the LP Final Item Template
|
|
|
+ *
|
|
|
+ * @return html
|
|
|
+ */
|
|
|
+ private function getFinalItemTemplate()
|
|
|
+ {
|
|
|
+ return file_get_contents(api_get_path(SYS_CODE_PATH) . 'newscorm/final_item_template/template.html');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the LP Final Item Url
|
|
|
+ *
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ private function getSavedFinalItem()
|
|
|
+ {
|
|
|
+ $finalItem = $this->getFinalItem();
|
|
|
+ $doc = DocumentManager::get_document_data_by_id($finalItem->path, $this->cc);
|
|
|
+
|
|
|
+ return file_get_contents($doc['absolute_path']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the LP Final Item form
|
|
|
+ *
|
|
|
+ * @return html
|
|
|
+ */
|
|
|
+ public function getFinalItemForm()
|
|
|
+ {
|
|
|
+ $finalItem = $this->getFinalItem();
|
|
|
+ $title = '';
|
|
|
+ $content = '';
|
|
|
+
|
|
|
+ if ($finalItem) {
|
|
|
+ $title = $finalItem->title;
|
|
|
+ $buttonText = get_lang('Save');
|
|
|
+ $content = $this->getSavedFinalItem();
|
|
|
+ } else {
|
|
|
+ $buttonText = get_lang('LPCreateDocument');
|
|
|
+ $content = $this->getFinalItemTemplate();
|
|
|
+ }
|
|
|
+
|
|
|
+ $courseInfo = api_get_course_info();
|
|
|
+ $result = $this->generate_lp_folder($courseInfo);
|
|
|
+ $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
|
|
|
+ ];
|
|
|
+
|
|
|
+ $url = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
|
|
|
+ 'type' => 'document',
|
|
|
+ 'lp_id' => $this->lp_id
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $form = new FormValidator('final_item', 'POST', $url);
|
|
|
+ $form->addText('title', get_lang('Title'));
|
|
|
+ $form->addButtonSave($buttonText);
|
|
|
+ $form->addHtml('<div class="alert alert-info">Variables :</br></br> <b>((certificate))</b> </br> <b>((skill))</b></div>');
|
|
|
+ $renderer = $form->defaultRenderer();
|
|
|
+ $renderer->setElementTemplate('<div class="editor-lp"> {label}{element}</div>', 'content_lp');
|
|
|
+ $form->addHtmlEditor('content_lp', null, null, true, $editorConfig, true);
|
|
|
+ $form->addHidden('action', 'add_final_item');
|
|
|
+ $form->addHidden('path', isset($_SESSION['pathItem']) ? $_SESSION['pathItem'] : '');
|
|
|
+ $form->addHidden('previous', $this->get_last());
|
|
|
+
|
|
|
+ $form->setDefaults(['title' => $title, 'content_lp' => $content]);
|
|
|
+
|
|
|
+ if ($form->validate()) {
|
|
|
+ $values = $form->exportValues();
|
|
|
+
|
|
|
+ $lastItemId = $this->get_last();
|
|
|
+
|
|
|
+ if (!$finalItem) {
|
|
|
+ $documentId = $this->create_document($this->course_info, $values['content_lp'], $values['title']);
|
|
|
+ $this->add_item(
|
|
|
+ 0,
|
|
|
+ $lastItemId,
|
|
|
+ 'final_item',
|
|
|
+ $documentId,
|
|
|
+ $values['title'],
|
|
|
+ ''
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ $this->edit_document($this->course_info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $form->returnForm();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!function_exists('trim_value')) {
|