Browse Source

Merge branch 'jloguercio-tempTademi' into 1.10.x

Yannick Warnier 9 years ago
parent
commit
c6d0a9e30c

+ 9 - 0
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;

+ 11 - 0
main/badge/issued.php

@@ -59,6 +59,17 @@ $skillInfo = [
     'courses' => []
 ];
 
+
+
+// Open Graph Markup
+$htmlHeadXtra[] = "
+    <meta property='og:type' content='article' />
+    <meta property='og:title' content='".sprintf(get_lang('IHaveObtainedSkillXOnY'), $skillInfo['name'], api_get_setting('siteName'))."' />
+    <meta property='og:url' content='".api_get_path(WEB_PATH)."badge/".$skillId."/user/".$userId."' />
+    <meta property='og:description' content='".$skillInfo['description']."' />
+    <meta property='og:image' content='".$skillInfo['badge_image']."' />
+";
+
 $badgeAssertions = [];
 
 foreach ($userSkills as $userSkill) {

+ 1 - 1
main/gradebook/lib/be/category.class.php

@@ -1952,7 +1952,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,

+ 1 - 0
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');

+ 23 - 11
main/inc/lib/template.lib.php

@@ -976,12 +976,6 @@ class Template
         $metaTitle = api_get_setting('meta_title');
         if (!empty($metaTitle)) {
             $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n";
-            $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n";
-            $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n";
-            $metaDescription = api_get_setting('meta_description');
-            if (!empty($metaDescription)) {
-                $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n";
-            }
             $metaSite = api_get_setting('meta_twitter_site');
             if (!empty($metaSite)) {
                 $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n";
@@ -990,11 +984,29 @@ class Template
                     $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\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 .= '<meta property="og:image" content="' . $path . '" />' . "\n";
+
+            // 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 .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n";
+                $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n";
+
+                $metaDescription = api_get_setting('meta_description');
+                if (!empty($metaDescription)) {
+                    $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\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 .= '<meta property="og:image" content="' . $path . '" />' . "\n";
+                    }
                 }
             }
         }

+ 5 - 0
main/newscorm/final_item_template/template.html

@@ -0,0 +1,5 @@
+<div>
+    Congratulations! You have finished this learning path
+</div>
+((certificate)) <br />
+((skill))

+ 170 - 21
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];
         }
@@ -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">&nbsp;{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')) {

+ 5 - 5
main/newscorm/lp_add_item.php

@@ -275,7 +275,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 {
@@ -285,20 +285,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;

+ 29 - 0
main/newscorm/lp_controller.php

@@ -364,8 +364,11 @@ if (isset($_POST['title'])) {
     }
 }
 
+$redirectTo = null;
+
 switch ($action) {
     case 'add_item':
+
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
@@ -1385,6 +1388,28 @@ switch ($action) {
             'lp_id' => $_SESSION['oLP']->lp_id
         ]));
         break;
+    case 'add_final_item':
+        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");
+}

+ 4 - 1
main/newscorm/lp_edit_item.php

@@ -161,7 +161,6 @@ echo $_SESSION['oLP']->build_action_menu();
 
 echo '<div class="row">';
 echo '<div class="col-md-3">';
-
 $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);
@@ -191,6 +190,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 '<script>$("#frmModel").remove()</script>';
+    }
+    unset($_SESSION['finalItem']);
 }
 
 echo '</div>';

+ 127 - 0
main/newscorm/lp_final_item.php

@@ -0,0 +1,127 @@
+<?php
+
+$_in_course = true;
+require_once '../inc/global.inc.php';
+$current_course_tool  = TOOL_GRADEBOOK;
+
+api_protect_course_script(true);
+
+$courseCode = api_get_course_id();
+$userId = api_get_user_id();
+$sessionId = api_get_session_id();
+$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'));
+    exit;
+}
+
+$catLoad = Category::load(null, null, $courseCode, null, null, $sessionId, 'ORDER By id');
+
+if (!$catLoad) {
+    Display::display_warning_message(get_lang('FileNotFound'));
+    exit;
+}
+
+$categoryId = $catLoad[0]->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 = "
+                    <div class='panel panel-default'>
+                        <div class='panel-body'>
+                            <h3 class='text-center'>".get_lang('NowDownloadYourCertificateClickHere')."</h3>
+                            <div class='text-center'>$downloadCertificateLink $viewCertificateLink</div>
+                        </div>
+                    </div>
+                ";
+            }
+
+            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 .= "
+                            <div class='row'>
+                                <div class='col-md-2 col-xs-6'>
+                                    <div class='thumbnail'>
+                                      <img class='skill-badge-img' src='".$oneSkill['web_icon_path']."' >
+                                    </div>
+                                </div>
+                                <div class='col-md-8 col-xs-6'>
+                                    <h5><b>".$oneSkill['name']."</b></h5>
+                                    ".$oneSkill['description']."
+                                </div>
+                                <div class='col-md-2 col-xs-12'>
+                                    <h5><b>".get_lang('ShareWithYourFriends')."</b></h5>
+                                    <a href='http://www.facebook.com/sharer.php?u=".api_get_path(WEB_PATH)."badge/".$oneSkill['id']."/user/".$userId."' target='_new'>
+                                        <em class='fa fa-facebook-square fa-3x text-info' aria-hidden='true'></em>
+                                    </a>
+                                    <a href='https://twitter.com/home?status=".api_get_path(WEB_PATH)."badge/".$oneSkill['id']."/user/".$userId."' target='_new'>
+                                        <em class='fa fa-twitter-square fa-3x text-light' aria-hidden='true'></em>
+                                    </a>
+                                </div>
+                            </div>
+                        ";
+                    }
+                    $badgeLink .= "
+                        <div class='panel panel-default'>
+                            <div class='panel-body'>
+                                <h3 class='text-center'>".get_lang('AdditionallyYouHaveObtainedTheFollowingSkills')."</h3>
+                                $skillList
+                            </div>
+                        </div>
+                    ";
+                }
+            }
+
+            $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();
+

+ 1 - 1
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[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
             $preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id);
+
             if ($preReqCheck === true) {
                 $src = $_SESSION['oLP']->get_link(
                     'http',

+ 3 - 0
main/newscorm/resourcelinker.inc.php

@@ -1724,6 +1724,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;

+ 9 - 0
main/template/default/skill/issued.tpl

@@ -36,6 +36,15 @@
                 </a>
             </p>
         {% endif %}
+        <div class='col-md-12 text-center'>
+            <h5><b> {{ 'ShareWithYourFriends' | get_lang }} </b></h5>
+            <a href='http://www.facebook.com/sharer.php?u={{ _p.web }}badge/{{ skill_info.id }}/user/{{ user_info.id }}' target='_new'>
+            <em class='fa fa-facebook-square fa-3x text-info' aria-hidden='true'></em>
+            </a>
+            <a href='https://twitter.com/home?status={{ 'IHaveObtainedSkillXOnY' | get_lang |format(skill_info.name, _s.site_name)}} - {{ _p.web }}badge/{{ skill_info.id }}/user/{{ user_info.id }}' target='_new'>
+            <em class='fa fa-twitter-square fa-3x text-light' aria-hidden='true'></em>
+            </a>
+        </div>
     </div>
     <div class="col-md-8">
         <div class="panel panel-default">