Merge remote-tracking branch 'origin/1.10.x' into 1.11.x

ofaj
Julio 10 years ago
commit 79f1e141ee
  1. 16
      README.md
  2. 12
      app/Migrations/Schema/V110/Version110.php
  3. 9
      app/Resources/public/css/base.css
  4. 11
      main/badge/issued.php
  5. 2
      main/gradebook/lib/be/category.class.php
  6. 1
      main/inc/lib/api.lib.php
  7. 6
      main/inc/lib/social.lib.php
  8. 34
      main/inc/lib/template.lib.php
  9. 5
      main/newscorm/final_item_template/template.html
  10. 191
      main/newscorm/learnpath.class.php
  11. 10
      main/newscorm/lp_add_item.php
  12. 29
      main/newscorm/lp_controller.php
  13. 5
      main/newscorm/lp_edit_item.php
  14. 128
      main/newscorm/lp_final_item.php
  15. 2
      main/newscorm/lp_view.php
  16. 3
      main/newscorm/resourcelinker.inc.php
  17. 9
      main/template/default/skill/issued.tpl
  18. 2
      tests/scripts/fix_migrations_1.9.x_1.10.0.php

@ -111,6 +111,17 @@ Typically:
DELETE FROM access_url_rel_course WHERE access_url_id NOT IN (SELECT id FROM access_url); DELETE FROM access_url_rel_course WHERE access_url_id NOT IN (SELECT id FROM access_url);
</pre> </pre>
### 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 # For developers and testers only
This section is for developers only (or for people who have a good reason to use This section is for developers only (or for people who have a good reason to use
@ -151,6 +162,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 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 ## Contributing
If you want to submit new features or patches to Chamilo, please follow the If you want to submit new features or patches to Chamilo, please follow the

@ -76,8 +76,16 @@ class Version110 extends AbstractMigrationChamilo
); );
} }
$this->addSql("ALTER TABLE session ADD COLUMN duration int"); $sessionTable = $schema->getTable('session');
$this->addSql("ALTER TABLE session_rel_user ADD COLUMN duration int"); if (!$sessionTable->hasColumn('duration')) {
$this->addSql("ALTER TABLE session 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 skill ADD COLUMN criteria text");
$this->addSql("ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0"); $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"); $this->addSql("ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL");

@ -5873,6 +5873,15 @@ a.sessionView {
color: black !important; color: black !important;
} }
.skill-badge-img{
width: 150px;
overflow: hidden;
}
.text-light{
color: #00CCFF;
}
#dropzone { #dropzone {
position: relative; position: relative;

@ -59,6 +59,17 @@ $skillInfo = [
'courses' => [] '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 = []; $badgeAssertions = [];
foreach ($userSkills as $userSkill) { foreach ($userSkills as $userSkill) {

@ -1952,7 +1952,7 @@ class Category implements GradebookItem
$userHasSkills = false; $userHasSkills = false;
if ($skillToolEnabled) { if ($skillToolEnabled) {
if (!$category->getGenerateCertificates()) { if ($category->getGenerateCertificates()) {
$skill = new Skill(); $skill = new Skill();
$skill->add_skill_to_user( $skill->add_skill_to_user(
$user_id, $user_id,

@ -96,6 +96,7 @@ define('SURVEY_VISIBLE_PUBLIC', 2);
// CONSTANTS defining all tools, using the english version // 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 */ /* When you add a new tool you must add it into function api_get_tools_lists() too */
define('TOOL_DOCUMENT', 'document'); define('TOOL_DOCUMENT', 'document');
define('TOOL_LP_FINAL_ITEM', 'final_item');
define('TOOL_THUMBNAIL', 'thumbnail'); define('TOOL_THUMBNAIL', 'thumbnail');
define('TOOL_HOTPOTATOES', 'hotpotatoes'); define('TOOL_HOTPOTATOES', 'hotpotatoes');
define('TOOL_CALENDAR_EVENT', 'calendar_event'); define('TOOL_CALENDAR_EVENT', 'calendar_event');

@ -976,7 +976,8 @@ class SocialManager extends UserManager
} }
if ($show_delete_account_button) { if ($show_delete_account_button) {
$html .= '<div class="sidebar-nav"><ul><li>'; $html .= '<div class="panel panel-default"><div class="panel-body">';
$html .= '<ul class="nav nav-pills nav-stacked"><li>';
$url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php'; $url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php';
$html .= Display::url( $html .= Display::url(
Display::return_icon( Display::return_icon(
@ -987,7 +988,8 @@ class SocialManager extends UserManager
).get_lang('Unsubscribe'), ).get_lang('Unsubscribe'),
$url $url
); );
$html .= '</li></ul></div>'; $html .= '</li></ul>';
$html .= '</div></div>';
} }
$html .= ''; $html .= '';

@ -1004,12 +1004,6 @@ class Template
$metaTitle = api_get_setting('meta_title'); $metaTitle = api_get_setting('meta_title');
if (!empty($metaTitle)) { if (!empty($metaTitle)) {
$socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; $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'); $metaSite = api_get_setting('meta_twitter_site');
if (!empty($metaSite)) { if (!empty($metaSite)) {
$socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n";
@ -1018,11 +1012,29 @@ class Template
$socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n";
} }
} }
$metaImage = api_get_setting('meta_image_path');
if (!empty($metaImage)) { // The user badge page emits its own meta tags, so if this is
if (is_file(api_get_path(SYS_PATH) . $metaImage)) { // enabled, ignore the global ones
$path = api_get_path(WEB_PATH) . $metaImage; $userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
$socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; $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";
}
} }
} }
} }

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

@ -1947,7 +1947,7 @@ class learnpath
error_log('New LP - In learnpath::get_last()', 0); 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" //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; $this->index = count($this->ordered_items) - 1;
return $this->ordered_items[$this->index]; return $this->ordered_items[$this->index];
} }
@ -3401,7 +3401,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. // 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; $lp_type = 1;
} }
@ -5605,6 +5605,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) { if (($i % 2) == 0) {
$oddClass = 'row_odd'; $oddClass = 'row_odd';
} else { } else {
@ -5620,7 +5625,11 @@ class learnpath
if (file_exists('../img/lp_' . $icon_name . '.gif')) { if (file_exists('../img/lp_' . $icon_name . '.gif')) {
$icon = Display::return_icon('lp_' . $icon_name . '.gif'); $icon = Display::return_icon('lp_' . $icon_name . '.gif');
} else { } 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');
}
} }
} }
@ -5656,13 +5665,15 @@ class learnpath
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {
if (!$update_audio || $update_audio <> 'true') { if (!$update_audio || $update_audio <> 'true') {
$move_icon .= '<a class="moved" href="#">'; if ($arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
$move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $move_icon .= '<a class="moved" href="#">';
$move_icon .= '</a>'; $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$move_icon .= '</a>';
}
} }
// No edit for this item types // 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'))) { 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 .= '<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); $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
@ -6215,7 +6226,6 @@ class learnpath
if (!is_dir($filepath)) { if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/'; $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
$dir = '/';
} }
$table_doc = Database :: get_course_table(TABLE_DOCUMENT); $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
@ -6337,7 +6347,6 @@ class learnpath
WHERE c_id = ".$course_id." AND id = " . intval($item_id); WHERE c_id = ".$course_id." AND id = " . intval($item_id);
$res = Database::query($sql); $res = Database::query($sql);
$row = Database::fetch_array($res); $row = Database::fetch_array($res);
switch ($row['item_type']) { switch ($row['item_type']) {
case 'dokeos_chapter' : case 'dokeos_chapter' :
case 'dir' : case 'dir' :
@ -6361,7 +6370,7 @@ class learnpath
doc.c_id = $course_id AND doc.c_id = $course_id AND
lp.id = " . intval($item_id); lp.id = " . intval($item_id);
$res_step = Database::query($sql); $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_manipulate($item_id, $row['item_type']);
$return .= $this->display_document_form('edit', $item_id, $row_step); $return .= $this->display_document_form('edit', $item_id, $row_step);
break; break;
@ -6380,6 +6389,22 @@ class learnpath
$return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_link_form('edit', $item_id, $row); $return .= $this->display_link_form('edit', $item_id, $row);
break; 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' : case 'dokeos_module' :
if (isset ($_GET['view']) && $_GET['view'] == 'build') { if (isset ($_GET['view']) && $_GET['view'] == 'build') {
$return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_manipulate($item_id, $row['item_type']);
@ -6432,26 +6457,30 @@ class learnpath
// Get all the links. // Get all the links.
$links = $this->get_links(); $links = $this->get_links();
// Get al the student publications. // Get all the student publications.
$works = $this->get_student_publications(); $works = $this->get_student_publications();
// Get al the forums. // Get all the forums.
$forums = $this->get_forums(null, $course_code); $forums = $this->get_forums(null, $course_code);
// Get the final item form (see BT#11048) .
$finish = $this->getFinalItemForm();
$headers = array( $headers = array(
Display::return_icon('folder_document.png', get_lang('Documents'), array(), ICON_SIZE_BIG), 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('quiz.png', get_lang('Quiz'), array(), ICON_SIZE_BIG),
Display::return_icon('links.png', get_lang('Links'), 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('works.png', get_lang('Works'), array(), ICON_SIZE_BIG),
Display::return_icon('forum.png', get_lang('Forums'), 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')); echo Display::display_normal_message(get_lang('ClickOnTheLearnerViewToSeeYourLearningPath'));
$chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item'); $chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item');
echo Display::tabs( echo Display::tabs(
$headers, $headers,
array($documents, $exercises, $links, $works, $forums, $chapter), 'resource_tab' array($documents, $exercises, $links, $works, $forums, $chapter, $finish), 'resource_tab'
); );
return true; return true;
@ -7748,10 +7777,10 @@ class learnpath
//POSITION //POSITION
for ($i = 0; $i < count($arrLP); $i++) { for ($i = 0; $i < count($arrLP); $i++) {
if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $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']) if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'] || $action == 'add') {
$s_selected_position = $arrLP[$i]['id']; $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'] . '"'; $arrHide[$arrLP[$i]['id']]['value'] = get_lang('After') . ' "' . $arrLP[$i]['title'] . '"';
} }
} }
@ -7763,6 +7792,7 @@ class learnpath
$padding = isset($value['padding']) ? $value['padding']: 20; $padding = isset($value['padding']) ? $value['padding']: 20;
$position->addOption($value['value'], $key, 'style="padding-left:' . $padding . 'px;"'); $position->addOption($value['value'], $key, 'style="padding-left:' . $padding . 'px;"');
} }
$position->setSelected($s_selected_position); $position->setSelected($s_selected_position);
if (is_array($arrLP)) { if (is_array($arrLP)) {
@ -7782,7 +7812,7 @@ class learnpath
$arrHide = array(); $arrHide = array();
for ($i = 0; $i < count($arrLP); $i++) { 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']) if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
$s_selected_position = $arrLP[$i]['id']; $s_selected_position = $arrLP[$i]['id'];
elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id']; elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
@ -7795,7 +7825,7 @@ class learnpath
if (!$no_display_add) { if (!$no_display_add) {
$item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null; $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
$edit = isset($_GET['edit']) ? $_GET['edit'] : 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'])) if (isset ($_POST['content']))
$content = stripslashes($_POST['content']); $content = stripslashes($_POST['content']);
elseif (is_array($extra_info)) { elseif (is_array($extra_info)) {
@ -8343,7 +8373,7 @@ class learnpath
// Commented the message cause should not show it. // Commented the message cause should not show it.
//$lang = get_lang('TitleManipulateModule'); //$lang = get_lang('TitleManipulateModule');
break; break;
case TOOL_LP_FINAL_ITEM :
case TOOL_DOCUMENT : case TOOL_DOCUMENT :
// Commented the message cause should not show it. // Commented the message cause should not show it.
//$lang = get_lang('TitleManipulateDocument'); //$lang = get_lang('TitleManipulateDocument');
@ -8417,7 +8447,7 @@ class learnpath
$return .= get_lang('File').': '.$document_data['absolute_path_from_document']; $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); $document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);
$return .= get_lang('File').': '.$document_data['absolute_path_from_document']; $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
} }
@ -10951,6 +10981,125 @@ EOD;
return $forumId; 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')) { if (!function_exists('trim_value')) {

@ -288,7 +288,7 @@ if (isset($new_item_id) && is_numeric($new_item_id)) {
case 'module': case 'module':
echo $learnPath->display_item_form($type, get_lang('EnterDataNewModule')); echo $learnPath->display_item_form($type, get_lang('EnterDataNewModule'));
break; break;
case 'document': case TOOL_DOCUMENT:
if (isset($_GET['file']) && is_numeric($_GET['file'])) { if (isset($_GET['file']) && is_numeric($_GET['file'])) {
echo $learnPath->display_document_form('add', 0, $_GET['file']); echo $learnPath->display_document_form('add', 0, $_GET['file']);
} else { } else {
@ -298,20 +298,20 @@ if (isset($new_item_id) && is_numeric($new_item_id)) {
case 'hotpotatoes': case 'hotpotatoes':
echo $learnPath->display_hotpotatoes_form('add', 0, $_GET['file']); echo $learnPath->display_hotpotatoes_form('add', 0, $_GET['file']);
break; break;
case 'quiz': case TOOL_QUIZ:
echo Display::display_warning_message(get_lang('ExerciseCantBeEditedAfterAddingToTheLP')); echo Display::display_warning_message(get_lang('ExerciseCantBeEditedAfterAddingToTheLP'));
echo $learnPath->display_quiz_form('add', 0, $_GET['file']); echo $learnPath->display_quiz_form('add', 0, $_GET['file']);
break; break;
case 'forum': case TOOL_FORUM:
echo $learnPath->display_forum_form('add', 0, $_GET['forum_id']); echo $learnPath->display_forum_form('add', 0, $_GET['forum_id']);
break; break;
case 'thread': case 'thread':
echo $learnPath->display_thread_form('add', 0, $_GET['thread_id']); echo $learnPath->display_thread_form('add', 0, $_GET['thread_id']);
break; break;
case 'link': case TOOL_LINK:
echo $learnPath->display_link_form('add', 0, $_GET['file']); echo $learnPath->display_link_form('add', 0, $_GET['file']);
break; break;
case 'student_publication': case TOOL_STUDENTPUBLICATION:
$extra = isset($_GET['file']) ? $_GET['file'] : null; $extra = isset($_GET['file']) ? $_GET['file'] : null;
echo $learnPath->display_student_publication_form('add', 0, $extra); echo $learnPath->display_student_publication_form('add', 0, $extra);
break; break;

@ -364,8 +364,11 @@ if (isset($_POST['title'])) {
} }
} }
$redirectTo = null;
switch ($action) { switch ($action) {
case 'add_item': case 'add_item':
if (!$is_allowed_to_edit) { if (!$is_allowed_to_edit) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -1400,6 +1403,28 @@ switch ($action) {
'lp_id' => $_SESSION['oLP']->lp_id 'lp_id' => $_SESSION['oLP']->lp_id
])); ]));
break; 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: default:
if ($debug > 0) error_log('New LP - default action triggered', 0); if ($debug > 0) error_log('New LP - default action triggered', 0);
require 'lp_list.php'; require 'lp_list.php';
@ -1410,3 +1435,7 @@ if (!empty($_SESSION['oLP'])) {
$_SESSION['lpobject'] = serialize($_SESSION['oLP']); $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0); if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
} }
if (!empty($redirectTo)) {
header("Location: $redirectTo");
}

@ -161,7 +161,6 @@ echo $_SESSION['oLP']->build_action_menu();
echo '<div class="row">'; echo '<div class="row">';
echo '<div class="col-md-3">'; echo '<div class="col-md-3">';
$path_item = isset($_GET['path_item']) ? $_GET['path_item'] : 0; $path_item = isset($_GET['path_item']) ? $_GET['path_item'] : 0;
$path_item = Database::escape_string($path_item); $path_item = Database::escape_string($path_item);
$tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); $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); echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
} else { } else {
echo $_SESSION['oLP']->display_edit_item($_GET['id']); echo $_SESSION['oLP']->display_edit_item($_GET['id']);
if (isset($_SESSION['finalItem'])) {
echo '<script>$("#frmModel").remove()</script>';
}
unset($_SESSION['finalItem']);
} }
echo '</div>'; echo '</div>';

@ -0,0 +1,128 @@
<?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']) && isset($certificate['badge_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>
";
$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>
";
}
$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);
Category::registerCurrentScore($currentScore, $userId, $categoryId);
}
}
}
// 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();

@ -25,7 +25,6 @@ if ($lp_controller_touched != 1) {
} }
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
//To prevent the template class //To prevent the template class
$show_learnpath = true; $show_learnpath = true;
@ -174,6 +173,7 @@ if (!isset($src)) {
$_SESSION['oLP']->stop_previous_item(); $_SESSION['oLP']->stop_previous_item();
$htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>'; $htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
$preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id); $preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id);
if ($preReqCheck === true) { if ($preReqCheck === true) {
$src = $_SESSION['oLP']->get_link( $src = $_SESSION['oLP']->get_link(
'http', 'http',

@ -1724,6 +1724,9 @@ function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_pa
Session::write('openmethod',$openmethod); Session::write('openmethod',$openmethod);
Session::write('officedoc',$officedoc); Session::write('officedoc',$officedoc);
break; 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': case 'assignments':
$link .= $main_dir_path.'work/work.php?origin='.$origin; $link .= $main_dir_path.'work/work.php?origin='.$origin;
break; break;

@ -36,6 +36,15 @@
</a> </a>
</p> </p>
{% endif %} {% 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>
<div class="col-md-8"> <div class="col-md-8">
<div class="panel panel-default"> <div class="panel panel-default">

@ -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("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_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 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 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_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)"); Database::query("ALTER TABLE session_rel_user ADD CONSTRAINT FK_B0D7D4C0A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");

Loading…
Cancel
Save