From 73985feb782a43e1aef7d369f26485932223651f Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 7 Apr 2016 17:18:39 -0500 Subject: [PATCH 01/14] Temp - refs #11048 --- main/inc/lib/document.lib.php | 5 + .../final_item_template/template.html | 15 +++ main/newscorm/learnpath.class.php | 112 +++++++++++++++++- main/newscorm/lp_add_item.php | 10 +- main/newscorm/lp_controller.php | 29 +++++ 5 files changed, 162 insertions(+), 9 deletions(-) create mode 100644 main/newscorm/final_item_template/template.html diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 0b4006e00b..392d25e1c6 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -6268,4 +6268,9 @@ class DocumentManager WHERE c_id = $courseId AND session_id = $sessionId AND tool = '".TOOL_DOCUMENT."'"; Database::query($sql); } + + public static function generateFinalItemDocument() + { + + } } diff --git a/main/newscorm/final_item_template/template.html b/main/newscorm/final_item_template/template.html new file mode 100644 index 0000000000..45d2bd56b6 --- /dev/null +++ b/main/newscorm/final_item_template/template.html @@ -0,0 +1,15 @@ + + + + TODO supply a title + + + + +
+ Congratulations! You have finished this learning path +
+ {{ certificate }} + {{ skills }} + + diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index a3338aad82..a3346c0ccc 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -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]; } @@ -5613,7 +5613,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'] === 'final_item') { + $icon = Display::return_icon('certificate.png'); + } else { + $icon = Display::return_icon('folder_document.gif'); + } } } @@ -6289,6 +6293,7 @@ class learnpath $res_step = Database::query($sql); $row_step = Database :: fetch_array($res_step); $return .= $this->display_manipulate($item_id, $row['item_type']); + var_dump($item_id, $row_step); $return .= $this->display_document_form('edit', $item_id, $row_step); break; case TOOL_LINK : @@ -6364,20 +6369,23 @@ class learnpath // Get al the forums. $forums = $this->get_forums(null, $course_code); + $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; @@ -10691,6 +10699,102 @@ EOD; return $forumId; } + private function getFinalItem() + { + if (empty($this->items)) { + return null; + } + + foreach ($this->items as $item) { + if ($item->type !== 'final_item') { + continue; + } + + return $item; + } + } + + private function getFinalItemTemplate() + { + $finalItem = $this->getFinalItem(); + + if (!$finalItem) { + return file_get_contents(api_get_path(SYS_CODE_PATH) . 'newscorm/final_item_template/template.html'); + } + + $doc = DocumentManager::get_document_data_by_id($finalItem->path, $this->cc); + + return file_get_contents($doc['absolute_path']); + } + + /** + * + * @return html + */ + public function getFinalItemForm() + { + $finalItem = $this->getFinalItem(); + $title = ''; + $content = ''; + + if ($finalItem) { + $title = $finalItem->title; + $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(get_lang('LPCreateDocument')); + $renderer = $form->defaultRenderer(); + $renderer->setElementTemplate('
 {label}{element}
', 'content'); + $form->addHtmlEditor('content', null, null, true, $editorConfig, true); + $form->addHidden('action', 'add_final_item'); + $form->addHidden('previous', $this->get_last()); + + $form->setDefaults(['title' => $title, 'content' => $content]); + + if ($form->validate()) { + $values = $form->exportValues(); + + $lastItemId = $this->get_last(); + + if (!$finalItem) { + $documentId = $this->create_document($this->course_info, $values['content'], $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')) { diff --git a/main/newscorm/lp_add_item.php b/main/newscorm/lp_add_item.php index 052b8cf240..4f7ed6cf24 100755 --- a/main/newscorm/lp_add_item.php +++ b/main/newscorm/lp_add_item.php @@ -267,7 +267,7 @@ if (isset($new_item_id) && is_numeric($new_item_id)) { case 'module': echo $learnPath->display_item_form($type, get_lang('EnterDataNewModule')); break; - case 'document': + case TOOL_DOCUMENT: if (isset($_GET['file']) && is_numeric($_GET['file'])) { echo $learnPath->display_document_form('add', 0, $_GET['file']); } else { @@ -277,20 +277,20 @@ if (isset($new_item_id) && is_numeric($new_item_id)) { case 'hotpotatoes': echo $learnPath->display_hotpotatoes_form('add', 0, $_GET['file']); break; - case 'quiz': + case TOOL_QUIZ: echo Display::display_warning_message(get_lang('ExerciseCantBeEditedAfterAddingToTheLP')); echo $learnPath->display_quiz_form('add', 0, $_GET['file']); break; - case 'forum': + 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 'link': + case TOOL_LINK: echo $learnPath->display_link_form('add', 0, $_GET['file']); break; - case 'student_publication': + case TOOL_STUDENTPUBLICATION: $extra = isset($_GET['file']) ? $_GET['file'] : null; echo $learnPath->display_student_publication_form('add', 0, $extra); break; diff --git a/main/newscorm/lp_controller.php b/main/newscorm/lp_controller.php index 220e9f7e9d..a9325249f2 100755 --- a/main/newscorm/lp_controller.php +++ b/main/newscorm/lp_controller.php @@ -364,6 +364,8 @@ if (isset($_POST['title'])) { } } +$redirectTo = null; + switch ($action) { case 'add_item': if (!$is_allowed_to_edit) { @@ -1385,6 +1387,29 @@ switch ($action) { 'lp_id' => $_SESSION['oLP']->lp_id ])); break; + case 'add_final_item': + var_dump($_POST, $_GET, $lp_found); + if (!$lp_found) { + Display::addFlash( + Display::return_message(get_lang('NoLPFound'), 'error') + ); + break; + } + + $_SESSION['refresh'] = 1; + + if (!isset($_POST['submit']) || empty($post_title)) { + break; + } + + $_SESSION['oLP']->getFinalItemForm(); + + $redirectTo = api_get_self() . '?' . http_build_query([ + 'action' => 'add_item', + 'type' => 'step', + 'lp_id' => intval($_SESSION['oLP']->lp_id) + ]); + break; default: if ($debug > 0) error_log('New LP - default action triggered', 0); require 'lp_list.php'; @@ -1395,3 +1420,7 @@ if (!empty($_SESSION['oLP'])) { $_SESSION['lpobject'] = serialize($_SESSION['oLP']); if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0); } + +if (!empty($redirectTo)) { + header("Location: $redirectTo"); +} From 046ca86376979d423407d96a9fe46c21d1739a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Fri, 8 Apr 2016 18:06:00 -0500 Subject: [PATCH 02/14] =?UTF-8?q?Finalizaci=C3=B3n=20Archivement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Resources/public/css/base.css | 9 ++ main/badge/issued.php | 9 ++ main/gradebook/lib/be/category.class.php | 2 +- main/inc/lib/api.lib.php | 1 + main/inc/lib/document.lib.php | 5 - .../final_item_template/template.html | 20 +-- main/newscorm/learnpath.class.php | 103 ++++++++++---- main/newscorm/lp_controller.php | 2 +- main/newscorm/lp_edit_item.php | 5 +- main/newscorm/lp_final_item.php | 127 ++++++++++++++++++ main/newscorm/lp_view.php | 2 +- main/newscorm/resourcelinker.inc.php | 3 + 12 files changed, 236 insertions(+), 52 deletions(-) create mode 100644 main/newscorm/lp_final_item.php diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index 1210daed6e..eb2042a429 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -5850,6 +5850,15 @@ a.sessionView { color: black !important; } +.skill-badge-img{ + width: 150px; + overflow: hidden; +} + +.text-light{ + color: #00CCFF; +} + #dropzone { position: relative; diff --git a/main/badge/issued.php b/main/badge/issued.php index abd32048ae..eb4327449b 100644 --- a/main/badge/issued.php +++ b/main/badge/issued.php @@ -59,6 +59,15 @@ $skillInfo = [ 'courses' => [] ]; +// Open Graph Markup +$htmlHeadXtra[] = " + + + + + +"; + $badgeAssertions = []; foreach ($userSkills as $userSkill) { diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 4a9cec84cd..b4bceaa2d5 100755 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -1950,7 +1950,7 @@ class Category implements GradebookItem $userHasSkills = false; if ($skillToolEnabled) { - if (!$category->getGenerateCertificates()) { + if ($category->getGenerateCertificates()) { $skill = new Skill(); $skill->add_skill_to_user( $user_id, diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 9b8186736c..7c1636a165 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -96,6 +96,7 @@ define('SURVEY_VISIBLE_PUBLIC', 2); // CONSTANTS defining all tools, using the english version /* When you add a new tool you must add it into function api_get_tools_lists() too */ define('TOOL_DOCUMENT', 'document'); +define('TOOL_LP_FINAL_ITEM', 'final_item'); define('TOOL_THUMBNAIL', 'thumbnail'); define('TOOL_HOTPOTATOES', 'hotpotatoes'); define('TOOL_CALENDAR_EVENT', 'calendar_event'); diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 392d25e1c6..0b4006e00b 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -6268,9 +6268,4 @@ class DocumentManager WHERE c_id = $courseId AND session_id = $sessionId AND tool = '".TOOL_DOCUMENT."'"; Database::query($sql); } - - public static function generateFinalItemDocument() - { - - } } diff --git a/main/newscorm/final_item_template/template.html b/main/newscorm/final_item_template/template.html index 45d2bd56b6..748cea54f6 100644 --- a/main/newscorm/final_item_template/template.html +++ b/main/newscorm/final_item_template/template.html @@ -1,15 +1,5 @@ - - - - TODO supply a title - - - - -
- Congratulations! You have finished this learning path -
- {{ certificate }} - {{ skills }} - - +
+ Congratulations! You have finished this learning path +
+((certificate))
+((skill)) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index a3346c0ccc..9ffc8495c2 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -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,14 @@ 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 +5621,7 @@ class learnpath if (file_exists('../img/lp_' . $icon_name . '.gif')) { $icon = Display::return_icon('lp_'.$icon_name.'.gif'); } else { - if ($arrLP[$i]['item_type'] === 'final_item') { + if ($arrLP[$i]['item_type'] === TOOL_LP_FINAL_ITEM) { $icon = Display::return_icon('certificate.png'); } else { $icon = Display::return_icon('folder_document.gif'); @@ -5652,13 +5660,15 @@ class learnpath if ($is_allowed_to_edit) { if (!$update_audio || $update_audio <> 'true') { - $move_icon .= ''; - $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); - $move_icon .= ''; + if ($arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) { + $move_icon .= ''; + $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); + $move_icon .= ''; + } } // 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 .= ''; $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY); @@ -6150,7 +6160,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); @@ -6267,7 +6276,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' : @@ -6291,9 +6299,8 @@ 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']); - var_dump($item_id, $row_step); $return .= $this->display_document_form('edit', $item_id, $row_step); break; case TOOL_LINK : @@ -6311,6 +6318,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']); @@ -7625,10 +7648,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'] . '"'; } } @@ -7640,6 +7663,7 @@ class learnpath $padding = isset($value['padding']) ? $value['padding']: 0; $position->addOption($value['value'], $key, 'style="padding-left:' . $padding . 'px;"'); } + $position->setSelected($s_selected_position); if (is_array($arrLP)) { @@ -7660,7 +7684,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']; @@ -7673,7 +7697,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)) { @@ -8202,7 +8226,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'); @@ -8276,7 +8300,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']; } @@ -10699,8 +10723,14 @@ 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; } @@ -10714,21 +10744,32 @@ EOD; } } + /** + * Get the LP Final Item Template + * + * @return html + */ private function getFinalItemTemplate() { - $finalItem = $this->getFinalItem(); - - if (!$finalItem) { - return file_get_contents(api_get_path(SYS_CODE_PATH) . 'newscorm/final_item_template/template.html'); - } + 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() @@ -10739,6 +10780,10 @@ EOD; if ($finalItem) { $title = $finalItem->title; + $buttonText = get_lang('Save'); + $content = $this->getSavedFinalItem(); + } else { + $buttonText = get_lang('LPCreateDocument'); $content = $this->getFinalItemTemplate(); } @@ -10764,14 +10809,16 @@ EOD; $form = new FormValidator('final_item', 'POST', $url); $form->addText('title', get_lang('Title')); - $form->addButtonSave(get_lang('LPCreateDocument')); + $form->addButtonSave($buttonText); + $form->addHtml('
Variables :

((certificate))
((skill))
'); $renderer = $form->defaultRenderer(); - $renderer->setElementTemplate('
 {label}{element}
', 'content'); - $form->addHtmlEditor('content', null, null, true, $editorConfig, true); + $renderer->setElementTemplate('
 {label}{element}
', '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' => $content]); + $form->setDefaults(['title' => $title, 'content_lp' => $content]); if ($form->validate()) { $values = $form->exportValues(); @@ -10779,7 +10826,7 @@ EOD; $lastItemId = $this->get_last(); if (!$finalItem) { - $documentId = $this->create_document($this->course_info, $values['content'], $values['title']); + $documentId = $this->create_document($this->course_info, $values['content_lp'], $values['title']); $this->add_item( 0, $lastItemId, diff --git a/main/newscorm/lp_controller.php b/main/newscorm/lp_controller.php index a9325249f2..07faaf65a6 100755 --- a/main/newscorm/lp_controller.php +++ b/main/newscorm/lp_controller.php @@ -368,6 +368,7 @@ $redirectTo = null; switch ($action) { case 'add_item': + if (!$is_allowed_to_edit) { api_not_allowed(true); } @@ -1388,7 +1389,6 @@ switch ($action) { ])); break; case 'add_final_item': - var_dump($_POST, $_GET, $lp_found); if (!$lp_found) { Display::addFlash( Display::return_message(get_lang('NoLPFound'), 'error') diff --git a/main/newscorm/lp_edit_item.php b/main/newscorm/lp_edit_item.php index b49b97fcf1..a1cf78ed52 100755 --- a/main/newscorm/lp_edit_item.php +++ b/main/newscorm/lp_edit_item.php @@ -153,7 +153,6 @@ echo $_SESSION['oLP']->build_action_menu(); echo '
'; echo '
'; - $path_item = isset($_GET['path_item']) ? $_GET['path_item'] : 0; $path_item = Database::escape_string($path_item); $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); @@ -183,6 +182,10 @@ if (isset($is_success) && $is_success === true) { echo $_SESSION['oLP']->display_item($_GET['id'], $msg); } else { echo $_SESSION['oLP']->display_edit_item($_GET['id']); + if (isset($_SESSION['finalItem'])) { + echo ''; + } + unset($_SESSION['finalItem']); } echo '
'; diff --git a/main/newscorm/lp_final_item.php b/main/newscorm/lp_final_item.php new file mode 100644 index 0000000000..23d7ef825f --- /dev/null +++ b/main/newscorm/lp_final_item.php @@ -0,0 +1,127 @@ +get_id(); +$link = LinkFactory::load(null, null, $lpId, null, $courseCode, $categoryId); +$downloadCertificateLink = ''; +$viewCertificateLink = ''; +$badgeLink = ''; + +if ($link) { + $cat = new Category(); + $catCourseCode = CourseManager::get_course_by_category($categoryId); + $show_message = $cat->show_message_resource_delete($catCourseCode); + + if ($show_message == '') { + if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) { + $certificate = Category::register_user_certificate( + $categoryId, + $userId + ); + if (isset($certificate['pdf_url']) && isset($certificate['certificate_link'])) { + $downloadCertificateLink .= Display::url(Display::returnFontAwesomeIcon('file-pdf-o') . + get_lang('DownloadCertificatePdf'), + $certificate['pdf_url'], + ['class' => 'btn btn-default'] + ); + $viewCertificateLink .= $certificate['certificate_link']; + $downloadCertificateLink = " +
+
+

".get_lang('NowDownloadYourCertificateClickHere')."

+
$downloadCertificateLink $viewCertificateLink
+
+
+ "; + } + + if (isset($certificate['badge_link'])) { + $skillRelUser = new SkillRelUser(); + $courseId = api_get_course_int_id(); + $userSkills = $skillRelUser->get_user_skills($userId, $courseId, $sessionId); + $skillList = ''; + + if ($userSkills) { + $skill = new Skill(); + foreach ($userSkills as $userSkill) { + $oneSkill = $skill->get($userSkill['skill_id']); + $skillList .= " +
+ "; + } + $badgeLink .= " +
+
+

".get_lang('AdditionallyYouHaveObtainedTheFollowingSkills')."

+ $skillList +
+
+ "; + } + } + + $currentScore = Category::getCurrentScore($userId, $categoryId, $courseCode, $sessionId, true); + Category::registerCurrentScore($currentScore, $userId, $categoryId); + } + } +} + +$documentInfo = DocumentManager::get_document_data_by_id( + $id, + $courseCode, + true, + $sessionId +); + +$finalItemTemplate = file_get_contents($documentInfo['absolute_path']); + +$finalItemTemplate = str_replace('((certificate))', $downloadCertificateLink, $finalItemTemplate); +$finalItemTemplate = str_replace('((skill))', $badgeLink, $finalItemTemplate); + +// Instance a new template : No page tittle, No header, No footer +$tpl = new Template(null, false, false); +$tpl->assign('content', $finalItemTemplate); +$tpl->display_one_col_template(); + diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index 91e9a04361..8ee602c7c5 100755 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -25,7 +25,6 @@ if ($lp_controller_touched != 1) { } require_once '../inc/global.inc.php'; - //To prevent the template class $show_learnpath = true; @@ -155,6 +154,7 @@ if (!isset($src)) { $_SESSION['oLP']->stop_previous_item(); $htmlHeadXtra[] = ''; $preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id); + if ($preReqCheck === true) { $src = $_SESSION['oLP']->get_link( 'http', diff --git a/main/newscorm/resourcelinker.inc.php b/main/newscorm/resourcelinker.inc.php index cbdd016df6..2dd3b0c224 100755 --- a/main/newscorm/resourcelinker.inc.php +++ b/main/newscorm/resourcelinker.inc.php @@ -1723,6 +1723,9 @@ function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_pa Session::write('openmethod',$openmethod); Session::write('officedoc',$officedoc); break; + case TOOL_LP_FINAL_ITEM: + $link .= api_get_path(WEB_CODE_PATH).'newscorm/lp_final_item.php?id='.$id.'&lp_id='.$learnpath_id; + break; case 'assignments': $link .= $main_dir_path.'work/work.php?origin='.$origin; break; From 9554dbf76feac837d6f34ca2fc7ae4842edc497d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Mon, 18 Apr 2016 17:51:37 -0500 Subject: [PATCH 03/14] Fix Twitter:card conflict with OpenGraph meta in user badge page - Refs #10992 --- main/badge/issued.php | 7 +++++ main/inc/lib/template.lib.php | 43 ++++++++++++++++++------------- main/newscorm/learnpath.class.php | 8 +++--- main/newscorm/lp_final_item.php | 4 +-- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/main/badge/issued.php b/main/badge/issued.php index eb4327449b..9d9caf30ad 100644 --- a/main/badge/issued.php +++ b/main/badge/issued.php @@ -59,8 +59,15 @@ $skillInfo = [ 'courses' => [] ]; + + // Open Graph Markup $htmlHeadXtra[] = " + diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 0bd0c2f65c..cd67c0c5d6 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -976,25 +976,32 @@ class Template $metaTitle = api_get_setting('meta_title'); if (!empty($metaTitle)) { $socialMeta .= '' . "\n"; - $socialMeta .= '' . "\n"; - $socialMeta .= '' . "\n"; - $metaDescription = api_get_setting('meta_description'); - if (!empty($metaDescription)) { - $socialMeta .= '' . "\n"; - } - $metaSite = api_get_setting('meta_twitter_site'); - if (!empty($metaSite)) { - $socialMeta .= '' . "\n"; - $metaCreator = api_get_setting('meta_twitter_creator'); - if (!empty($metaCreator)) { - $socialMeta .= '' . "\n"; + + // The following code is for user badge page if the twitter:card is enable + $userId = isset($_GET['user']) ? intval($_GET['user']) : 0; + $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0; + + if (!$userId && !$skillId) { + $socialMeta .= '' . "\n"; + $socialMeta .= '' . "\n"; + $metaDescription = api_get_setting('meta_description'); + if (!empty($metaDescription)) { + $socialMeta .= '' . "\n"; } - } - $metaImage = api_get_setting('meta_image_path'); - if (!empty($metaImage)) { - if (is_file(api_get_path(SYS_PATH) . $metaImage)) { - $path = api_get_path(WEB_PATH) . $metaImage; - $socialMeta .= '' . "\n"; + $metaSite = api_get_setting('meta_twitter_site'); + if (!empty($metaSite)) { + $socialMeta .= '' . "\n"; + $metaCreator = api_get_setting('meta_twitter_creator'); + if (!empty($metaCreator)) { + $socialMeta .= '' . "\n"; + } + } + $metaImage = api_get_setting('meta_image_path'); + if (!empty($metaImage)) { + if (is_file(api_get_path(SYS_PATH) . $metaImage)) { + $path = api_get_path(WEB_PATH) . $metaImage; + $socialMeta .= '' . "\n"; + } } } } diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 6e857d08f0..310fb7e012 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -5603,9 +5603,6 @@ class learnpath $_SESSION['pathItem'] = $arrLP[$i]['path']; } - - - if (($i % 2) == 0) { $oddClass = 'row_odd'; } else { @@ -6386,12 +6383,13 @@ 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( diff --git a/main/newscorm/lp_final_item.php b/main/newscorm/lp_final_item.php index 23d7ef825f..42e3727095 100644 --- a/main/newscorm/lp_final_item.php +++ b/main/newscorm/lp_final_item.php @@ -9,8 +9,8 @@ api_protect_course_script(true); $courseCode = api_get_course_id(); $userId = api_get_user_id(); $sessionId = api_get_session_id(); -$id = isset($_GET['id']) ? $_GET['id'] : 0; -$lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : 0; +$id = isset($_GET['id']) ? intval($_GET['id']) : 0; +$lpId = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : 0; if (!$id && !$lpId) { Display::display_warning_message(get_lang('FileNotFound')); From d9a04b6aba37dff5d6e2c6bb5cdc071ad7425d5e Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 20 Apr 2016 13:21:42 -0500 Subject: [PATCH 04/14] Update language terms --- main/lang/brazilian/trad4all.inc.php | 3 ++- main/lang/english/trad4all.inc.php | 6 ++++++ main/lang/french/trad4all.inc.php | 6 ++++++ main/lang/spanish/trad4all.inc.php | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/main/lang/brazilian/trad4all.inc.php b/main/lang/brazilian/trad4all.inc.php index 1b9f087ddd..4887daaa76 100644 --- a/main/lang/brazilian/trad4all.inc.php +++ b/main/lang/brazilian/trad4all.inc.php @@ -7418,7 +7418,7 @@ $FieldTypeLettersSpaces = "letras e espaços de texto"; $CronRemindCourseFinishedActivateTitle = "Enviar curso terminou notificação"; $FieldTypeAlphanumericSpaces = "caracteres alfanuméricos texto e espaços"; $CronRemindCourseFinishedActivateComment = "Se enviar um e-mail para os alunos quando seu curso (sessão) é acabados. Isto requer tarefas cron para ser configurado (ver/cron/diretório principal)."; -$ThanksForRegisteringToSite = "Obrigado por registrar em %s."; +$ThanksForRegisteringToSite = "Obrigado por registrar-se em %s."; $AllowCoachFeedbackExercisesTitle = "Permitir que os treinadores para comentar na avaliação de exercícios"; $AllowCoachFeedbackExercisesComment = "Permitir que os treinadores para editar o feedback durante a revisão de exercícios"; $PreventMultipleSimultaneousLoginTitle = "Impedir o login simultânea"; @@ -7558,4 +7558,5 @@ $NewLogoUpdated = "Novo logotipo carregado"; $CurrentLogo = "Logo atual"; $UpdateLogo = "Logotipo atualização"; $FollowedStudentBosses = "chefes de estudantes seguiram"; +$AccessData = "Dados de acesso"; ?> \ No newline at end of file diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 9f76f1a4e4..d867527b5e 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -7638,4 +7638,10 @@ $EnableForumAutoLaunch = "Enable forum auto-launch"; $NowDownloadYourCertificateClickHere = "You can now download your certificate by clicking here"; $AdditionallyYouHaveObtainedTheFollowingSkills = "Additionally, you have achieved the following skills"; $IHaveObtainedSkillXOnY = "I have achieved skill %s on %s"; +$AnotherAttempt = "Another attempt"; +$RemainingXAttempts = "Remaining %d attempts"; +$Map = "Map"; +$MyLocation = "My location"; +$ShowCourseInUserLanguage = "Show course in user's language"; +$AccessData = "Access data"; ?> \ No newline at end of file diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php index fc2aa8c646..42d365d830 100644 --- a/main/lang/french/trad4all.inc.php +++ b/main/lang/french/trad4all.inc.php @@ -7625,4 +7625,10 @@ $EnableForumAutoLaunch = "Activar l'auto-démarrage des forums"; $NowDownloadYourCertificateClickHere = "Télécharge ton certificat en cliquant ici"; $AdditionallyYouHaveObtainedTheFollowingSkills = "En plus, tu as acquis les compétences suivantes"; $IHaveObtainedSkillXOnY = "J'ai acquis la compétence %s sur %s"; +$AnotherAttempt = "Nouvelle tentative"; +$RemainingXAttempts = "%s tentatives restantes"; +$Map = "Carte"; +$MyLocation = "Ma position"; +$ShowCourseInUserLanguage = "Afficher les cours dans la langue de l'utilisateur"; +$AccessData = "Données d'accès"; ?> \ No newline at end of file diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index 700fc51b15..eb44d00ef8 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -7663,4 +7663,10 @@ $EnableForumAutoLaunch = "Activar auto-arranque de foro"; $NowDownloadYourCertificateClickHere = "Puedes descargar tu certificado haciendo clic aquí"; $AdditionallyYouHaveObtainedTheFollowingSkills = "Adicionalmente, has obtenido las competencias siguientes"; $IHaveObtainedSkillXOnY = "He logrado la competencia %s en %s"; +$AnotherAttempt = "Realizar otro intento"; +$RemainingXAttempts = "%s intentos restantes"; +$Map = "Mapa"; +$MyLocation = "Mi ubicación"; +$ShowCourseInUserLanguage = "Mostrar el curso en el idioma del usuario"; +$AccessData = "Datos de acceso"; ?> \ No newline at end of file From aeb1521fb73efbf63aef08ee4fa4e6c9c1092436 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 20 Apr 2016 14:20:31 -0500 Subject: [PATCH 05/14] Fix access to users list for admins: allow platform admin to enter open courses (visibility 2). There was apparently a condition allowing admins to enter all courses but the ones open to the platform - loosely refs BT#11108 --- main/inc/local.inc.php | 2 +- main/user/user.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index efcd190562..7641a99532 100755 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -1250,7 +1250,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { $courseCode, $session_id ); - if (isset($user_id) && $isUserSubscribedInCourse === true && !api_is_anonymous($user_id)) { + if (isset($user_id) && ($is_platformAdmin || $isUserSubscribedInCourse === true) && !api_is_anonymous($user_id)) { $is_allowed_in_course = true; } break; diff --git a/main/user/user.php b/main/user/user.php index ac798f6158..490135ba27 100755 --- a/main/user/user.php +++ b/main/user/user.php @@ -445,6 +445,7 @@ if (api_is_allowed_to_edit(null, true)) { } } +// $is_allowed_in_course is first defined in local.inc.php if (!$is_allowed_in_course) { api_not_allowed(true); } From 960a90abaa140578528eceb6687f20fded07df8e Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 20 Apr 2016 16:22:42 -0500 Subject: [PATCH 06/14] Add social share buttons to issued badge page - refs BT#11048 --- main/template/default/skill/issued.tpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main/template/default/skill/issued.tpl b/main/template/default/skill/issued.tpl index 334085f546..507b8434c4 100644 --- a/main/template/default/skill/issued.tpl +++ b/main/template/default/skill/issued.tpl @@ -36,6 +36,15 @@

{% endif %} +
+
{{ 'ShareWithYourFriends' | get_lang }}
+ + + + + + +
From befebd9f99725fdf294a619519bec9d4d22423b4 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 20 Apr 2016 16:23:02 -0500 Subject: [PATCH 07/14] Minor - Fix
- refs BT#11048 --- main/newscorm/final_item_template/template.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/newscorm/final_item_template/template.html b/main/newscorm/final_item_template/template.html index 748cea54f6..cc443a9ca4 100644 --- a/main/newscorm/final_item_template/template.html +++ b/main/newscorm/final_item_template/template.html @@ -1,5 +1,5 @@
Congratulations! You have finished this learning path
-((certificate))
+((certificate))
((skill)) From 658fb16d414a3c4ea7b0aca5e9a7d64f5ff811a6 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 20 Apr 2016 16:24:42 -0500 Subject: [PATCH 08/14] Move code block placed in the wrong condition in previous commit - Fix twitter:site meta not appearing in badges page - refs BT#11048 --- main/inc/lib/template.lib.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index cd67c0c5d6..7b407dee40 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -976,26 +976,31 @@ class Template $metaTitle = api_get_setting('meta_title'); if (!empty($metaTitle)) { $socialMeta .= '' . "\n"; + $metaSite = api_get_setting('meta_twitter_site'); + if (!empty($metaSite)) { + $socialMeta .= '' . "\n"; + $metaCreator = api_get_setting('meta_twitter_creator'); + if (!empty($metaCreator)) { + $socialMeta .= '' . "\n"; + } + } - // The following code is for user badge page if the twitter:card is enable + // The user badge page emits its own meta tags, so if this is + // enabled, ignore the global ones $userId = isset($_GET['user']) ? intval($_GET['user']) : 0; $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0; if (!$userId && !$skillId) { + // no combination of user and skill ID has been defined, + // so print the normal OpenGraph meta tags $socialMeta .= '' . "\n"; $socialMeta .= '' . "\n"; + $metaDescription = api_get_setting('meta_description'); if (!empty($metaDescription)) { $socialMeta .= '' . "\n"; } - $metaSite = api_get_setting('meta_twitter_site'); - if (!empty($metaSite)) { - $socialMeta .= '' . "\n"; - $metaCreator = api_get_setting('meta_twitter_creator'); - if (!empty($metaCreator)) { - $socialMeta .= '' . "\n"; - } - } + $metaImage = api_get_setting('meta_image_path'); if (!empty($metaImage)) { if (is_file(api_get_path(SYS_PATH) . $metaImage)) { From 54f1ccc787b52cc0b9234aba9a36bdf47b4e5c56 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 20 Apr 2016 16:25:31 -0500 Subject: [PATCH 09/14] Remove useless JS code added in previous commit - refs BT#11048 --- main/badge/issued.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main/badge/issued.php b/main/badge/issued.php index 9d9caf30ad..27d5fb6d2f 100644 --- a/main/badge/issued.php +++ b/main/badge/issued.php @@ -63,11 +63,6 @@ $skillInfo = [ // Open Graph Markup $htmlHeadXtra[] = " - From 1e092a112a96a6f8b7c0ca4bbb24bb2002f1b874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Wed, 20 Apr 2016 18:20:38 -0500 Subject: [PATCH 10/14] Fix LP Final Item show finished page to 100% --- main/newscorm/lp_final_item.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/main/newscorm/lp_final_item.php b/main/newscorm/lp_final_item.php index 42e3727095..74ba8e04ae 100644 --- a/main/newscorm/lp_final_item.php +++ b/main/newscorm/lp_final_item.php @@ -41,7 +41,7 @@ if ($link) { $categoryId, $userId ); - if (isset($certificate['pdf_url']) && isset($certificate['certificate_link'])) { + if (isset($certificate['pdf_url']) && isset($certificate['certificate_link']) && isset($certificate['badge_link'])) { $downloadCertificateLink .= Display::url(Display::returnFontAwesomeIcon('file-pdf-o') . get_lang('DownloadCertificatePdf'), $certificate['pdf_url'], @@ -56,9 +56,7 @@ if ($link) {
"; - } - if (isset($certificate['badge_link'])) { $skillRelUser = new SkillRelUser(); $courseId = api_get_course_int_id(); $userSkills = $skillRelUser->get_user_skills($userId, $courseId, $sessionId); @@ -100,6 +98,21 @@ if ($link) { "; } + + $documentInfo = DocumentManager::get_document_data_by_id( + $id, + $courseCode, + true, + $sessionId + ); + + $finalItemTemplate = file_get_contents($documentInfo['absolute_path']); + + $finalItemTemplate = str_replace('((certificate))', $downloadCertificateLink, $finalItemTemplate); + $finalItemTemplate = str_replace('((skill))', $badgeLink, $finalItemTemplate); + } else { + Display::display_warning_message(get_lang('LearnpathPrereqNotCompleted')); + $finalItemTemplate = ''; } $currentScore = Category::getCurrentScore($userId, $categoryId, $courseCode, $sessionId, true); @@ -108,18 +121,6 @@ if ($link) { } } -$documentInfo = DocumentManager::get_document_data_by_id( - $id, - $courseCode, - true, - $sessionId -); - -$finalItemTemplate = file_get_contents($documentInfo['absolute_path']); - -$finalItemTemplate = str_replace('((certificate))', $downloadCertificateLink, $finalItemTemplate); -$finalItemTemplate = str_replace('((skill))', $badgeLink, $finalItemTemplate); - // Instance a new template : No page tittle, No header, No footer $tpl = new Template(null, false, false); $tpl->assign('content', $finalItemTemplate); From ce3ab0c51a02a27d4a49848a6a541eaf2eb63025 Mon Sep 17 00:00:00 2001 From: Julio Date: Thu, 21 Apr 2016 08:47:55 +0200 Subject: [PATCH 11/14] Adding session_rel_user.duration validation see BT#8205 --- app/Migrations/Schema/V110/Version110.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Migrations/Schema/V110/Version110.php b/app/Migrations/Schema/V110/Version110.php index 03328fde95..989e27ebb9 100644 --- a/app/Migrations/Schema/V110/Version110.php +++ b/app/Migrations/Schema/V110/Version110.php @@ -77,7 +77,12 @@ class Version110 extends AbstractMigrationChamilo } $this->addSql("ALTER TABLE session ADD COLUMN duration int"); - $this->addSql("ALTER TABLE session_rel_user ADD COLUMN duration int"); + + $sessionRelUser = $schema->getTable('session_rel_user'); + if (!$sessionRelUser->hasColumn('duration')) { + $this->addSql("ALTER TABLE session_rel_user ADD COLUMN duration int"); + } + $this->addSql("ALTER TABLE skill ADD COLUMN criteria text"); $this->addSql("ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0"); $this->addSql("ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL"); From 77f9c3e46ef8da29aae396ec7dae4f96812a941b Mon Sep 17 00:00:00 2001 From: Julio Date: Thu, 21 Apr 2016 13:04:46 +0200 Subject: [PATCH 12/14] Fix wrong session_rel_user.duration bug see #8205 --- app/Migrations/Schema/V110/Version110.php | 5 ++++- tests/scripts/fix_migrations_1.9.x_1.10.0.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Migrations/Schema/V110/Version110.php b/app/Migrations/Schema/V110/Version110.php index 989e27ebb9..dbcd95c80a 100644 --- a/app/Migrations/Schema/V110/Version110.php +++ b/app/Migrations/Schema/V110/Version110.php @@ -76,7 +76,10 @@ class Version110 extends AbstractMigrationChamilo ); } - $this->addSql("ALTER TABLE session ADD COLUMN duration int"); + $sessionTable = $schema->getTable('session'); + if (!$sessionTable->hasColumn('duration')) { + $this->addSql("ALTER TABLE session ADD COLUMN duration int"); + } $sessionRelUser = $schema->getTable('session_rel_user'); if (!$sessionRelUser->hasColumn('duration')) { diff --git a/tests/scripts/fix_migrations_1.9.x_1.10.0.php b/tests/scripts/fix_migrations_1.9.x_1.10.0.php index bb03acd226..cd25e7dba7 100755 --- a/tests/scripts/fix_migrations_1.9.x_1.10.0.php +++ b/tests/scripts/fix_migrations_1.9.x_1.10.0.php @@ -47,7 +47,7 @@ Database::query("UPDATE session SET id_coach = NULL WHERE id_coach = 0"); Database::query("UPDATE session SET session_category_id = NULL WHERE session_category_id = 0"); Database::query("ALTER TABLE session ADD CONSTRAINT FK_D044D5D4D1DC2CFC FOREIGN KEY (id_coach) REFERENCES user (id)"); Database::query("ALTER TABLE session ADD CONSTRAINT FK_D044D5D4EE1F8395 FOREIGN KEY (session_category_id) REFERENCES session_category (id)"); -Database::query("ALTER TABLE session_rel_user ADD moved_status INT DEFAULT NULL, ADD moved_at DATETIME DEFAULT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL, CHANGE relation_type relation_type INT NOT NULL, CHANGE duration moved_to INT DEFAULT NULL"); +Database::query("ALTER TABLE session_rel_user ADD moved_status INT DEFAULT NULL, ADD moved_at DATETIME DEFAULT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL, CHANGE relation_type relation_type INT NOT NULL"); Database::query("ALTER TABLE session_rel_user ENGINE=InnoDB"); Database::query("ALTER TABLE session_rel_user ADD CONSTRAINT FK_B0D7D4C0613FECDF FOREIGN KEY (session_id) REFERENCES session (id)"); Database::query("ALTER TABLE session_rel_user ADD CONSTRAINT FK_B0D7D4C0A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)"); From c36a9c308818ea77e7d89846e1305c8392576244 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 21 Apr 2016 12:49:59 -0500 Subject: [PATCH 13/14] Add info to README about upgrading Chamilo to Git-based from a package-based installation --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index b7a8252f49..d746b95697 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,17 @@ Typically: DELETE FROM access_url_rel_course WHERE access_url_id NOT IN (SELECT id FROM access_url); +### Upgrading from non-Git Chamilo 1.10 ### + +In the *very unlikely* case of upgrading a "normal" Chamilo 1.10 installation (done with the downloadable zip package) to a Git-based installation, make sure you delete the contents of a few folders first. These folders are re-generated later by the ```composer update``` command. This is likely to increase the downtime of your Chamilo portal of a few additional minutes (plan for 10 minutes on a reasonnable internet connection). + +``` +rm composer.lock +rm -rf web/* +rm -rf vendor/* +``` + + # For developers and testers only This section is for developers only (or for people who have a good reason to use @@ -155,6 +166,11 @@ version and type the following (assuming you want to execute Version201505271207 php bin/doctrine.php migrations:execute 20150527120703 --up --configuration=app/config/migrations.yml ``` +You can also print the differences between your database and what it should be by issuing the following command from the Chamilo base folder: +``` +php bin/doctrine.php orm:schema:update --dump-sql +``` + ## Contributing If you want to submit new features or patches to Chamilo, please follow the From 81e1d972386985d050caadb9c6ed405bc3bd5cf3 Mon Sep 17 00:00:00 2001 From: Alex Aragon Date: Thu, 21 Apr 2016 18:30:52 -0500 Subject: [PATCH 14/14] fix link unsubscribe social BT#7683 --- main/inc/lib/social.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index dabfd84a90..3d9e3a9c80 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -976,7 +976,8 @@ class SocialManager extends UserManager } if ($show_delete_account_button) { - $html .= ''; } $html .= '';