Merge pull request #1242 from ywarnier/lpchapters

Remove _chapters and _modules references from learning paths
pull/2487/head
Yannick Warnier 9 years ago committed by GitHub
commit 5ae36ede5c
  1. 47
      app/Migrations/Schema/V111/Version20160628220000.php
  2. 2
      main/inc/lib/document.lib.php
  3. 2
      main/inc/lib/tracking.lib.php
  4. 255
      main/lp/learnpath.class.php
  5. 10
      main/lp/learnpathItem.class.php
  6. 33
      main/lp/learnpath_functions.inc.php
  7. 2
      main/lp/lp_add_audio.php
  8. 13
      main/lp/lp_add_item.php
  9. 2
      main/lp/lp_ajax_initialize.php
  10. 2
      main/lp/lp_ajax_save_item.php
  11. 2
      main/lp/lp_ajax_switch_item.php
  12. 2
      main/lp/lp_ajax_switch_item_toc.php
  13. 10
      main/lp/lp_content.php
  14. 4
      main/lp/lp_controller.php
  15. 2
      main/lp/lp_final_item.php
  16. 2
      main/lp/lp_impress.php
  17. 8
      main/lp/openoffice_text.class.php
  18. 10
      main/lp/openoffice_text_document.class.php
  19. 16
      main/lp/resourcelinker.inc.php
  20. 36
      main/lp/resourcelinker.php
  21. 10
      main/resourcelinker/resourcelinker.php
  22. 14
      main/webservices/cm_webservice_course.php
  23. 14
      main/webservices/webservice_course.php
  24. 10
      tests/main/newscorm/learnpath.class.test.php
  25. 4
      tests/main/resourcelinker/resourcelinker.inc.test.php

@ -0,0 +1,47 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160628220000
* Integrate the Skype plugin and create new settings current to enable it
* @package Application\Migrations\Schema\V111
*/
class Version20160628220000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'dokeos_chapter'");
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'dokeos_module'");
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'chapter'");
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'module'");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
}
}

@ -3434,7 +3434,7 @@ class DocumentManager
/*$return .= '<div class="lp_resource_element">';
$return .= Display::return_icon('new_doc.gif', '', array(), ICON_SIZE_SMALL);
$return .= Display::url(
get_lang('NewDocument'),
get_lang('CreateTheDocument'),
api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id
);
$return .= '</div>';*/

@ -418,7 +418,7 @@ class Tracking
// Remove "NaN" if any (@todo: locate the source of these NaN)
$time = str_replace('NaN', '00' . $h . '00\'00"', $time);
if ($row['item_type'] != 'dokeos_chapter') {
if ($row['item_type'] != 'dir') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
} else {

@ -494,7 +494,7 @@ class learnpath
public function add_item(
$parent,
$previous,
$type = 'dokeos_chapter',
$type = 'dir',
$id,
$title,
$description,
@ -622,7 +622,7 @@ class learnpath
$new_item_id = Database::insert($tbl_lp_item, $params);
if ($this->debug > 2) {
error_log('New LP - Inserting chapter: ' . $new_item_id, 0);
error_log('New LP - Inserting dir/chapter: ' . $new_item_id, 0);
}
if ($new_item_id) {
@ -1585,11 +1585,11 @@ class learnpath
* @param integer Item ID
* @return array A list of all the "brother items" (or an empty array on failure)
*/
public function get_brother_chapters($id)
public function getSiblingDirectories($id)
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) {
error_log('New LP - In learnpath::get_brother_chapters()', 0);
error_log('New LP - In learnpath::getSiblingDirectories()', 0);
}
if (empty($id) || $id != strval(intval($id))) {
@ -1599,7 +1599,7 @@ class learnpath
$lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$sql_parent = "SELECT * FROM $lp_item
WHERE c_id = ".$course_id." AND id = $id AND item_type='dokeos_chapter'";
WHERE c_id = ".$course_id." AND id = $id AND item_type='dir'";
$res_parent = Database::query($sql_parent);
if (Database :: num_rows($res_parent) > 0) {
$row_parent = Database :: fetch_array($res_parent);
@ -1609,7 +1609,7 @@ class learnpath
c_id = ".$course_id." AND
parent_item_id = $parent AND
id = $id AND
item_type='dokeos_chapter'
item_type='dir'
ORDER BY display_order";
$res_bros = Database::query($sql);
@ -1707,7 +1707,6 @@ class learnpath
foreach ($this->items as $id => $dummy) {
// Trying failed and browsed considered "progressed" as well.
if ($this->items[$id]->status_is($completedStatusList) &&
$this->items[$id]->get_type() != 'dokeos_chapter' &&
$this->items[$id]->get_type() != 'dir'
) {
$i++;
@ -1764,10 +1763,10 @@ class learnpath
* Gets the total number of items available for viewing in this SCORM but without chapters
* @return integer The total no-chapters number of items
*/
public function get_total_items_count_without_chapters()
public function getTotalItemsCountWithoutDirs()
{
if ($this->debug > 0) {
error_log('New LP - In learnpath::get_total_items_count_without_chapters()', 0);
error_log('New LP - In learnpath::getTotalItemsCountWithoutDirs()', 0);
}
$total = 0;
$typeListNotToCount = self::getChapterTypes();
@ -1804,8 +1803,7 @@ class learnpath
if (!empty($this->last_item_seen) &&
!empty($this->items[$this->last_item_seen]) &&
$this->items[$this->last_item_seen]->get_type() != 'dir' &&
$this->items[$this->last_item_seen]->get_type() != 'dokeos_chapter'
$this->items[$this->last_item_seen]->get_type() != 'dir'
//with this change (below) the LP will NOT go to the next item, it will take lp item we left
//&& !$this->items[$this->last_item_seen]->is_done()
) {
@ -1842,7 +1840,6 @@ class learnpath
is_a($this->items[$this->ordered_items[$index]], 'learnpathItem') AND
(
$this->items[$this->ordered_items[$index]]->get_type() == 'dir' OR
$this->items[$this->ordered_items[$index]]->get_type() == 'dokeos_chapter' OR
$this->items[$this->ordered_items[$index]]->is_done() === true
) AND $index < $this->max_ordered_items) {
$index++;
@ -2028,10 +2025,10 @@ class learnpath
if ($this->debug > 2) {
error_log('New LP - Now looking at ordered_items[' . ($index) . '] - type is ' . $this->items[$this->ordered_items[$index]]->type, 0);
}
while (!empty ($this->ordered_items[$index]) AND ($this->items[$this->ordered_items[$index]]->get_type() == 'dir' || $this->items[$this->ordered_items[$index]]->get_type() == 'dokeos_chapter') AND $index < $this->max_ordered_items) {
while (!empty ($this->ordered_items[$index]) AND ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') AND $index < $this->max_ordered_items) {
$index++;
if ($index == $this->max_ordered_items){
if ($this->items[$this->ordered_items[$index]]->get_type() == 'dir' || $this->items[$this->ordered_items[$index]]->get_type() == 'dokeos_chapter') {
if ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') {
return $this->index;
} else {
return $index;
@ -2170,7 +2167,7 @@ class learnpath
$index = $this->index;
if (isset ($this->ordered_items[$index -1])) {
$index--;
while (isset($this->ordered_items[$index]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir' || $this->items[$this->ordered_items[$index]]->get_type() == 'dokeos_chapter')) {
while (isset($this->ordered_items[$index]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir')) {
$index--;
if ($index < 0) {
return $this->index;
@ -2506,7 +2503,7 @@ class learnpath
if (empty($mode)) {
$mode = $this->progress_bar_mode;
}
$total_items = $this->get_total_items_count_without_chapters();
$total_items = $this->getTotalItemsCountWithoutDirs();
if ($this->debug > 2) {
error_log('New LP - Total items available in this learnpath: ' . $total_items, 0);
}
@ -3161,9 +3158,6 @@ class learnpath
public static function getChapterTypes()
{
return array(
'dokeos_chapter',
'dokeos_module',
'chapter',
'dir'
);
}
@ -3432,7 +3426,7 @@ class learnpath
}
switch ($lp_item_type) {
case 'dokeos_chapter':
case 'dir':
$file = 'lp_content.php?type=dir';
break;
case 'link':
@ -5687,7 +5681,7 @@ class learnpath
// No edit for this item types
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 ($arrLP[$i]['item_type'] != 'dir') {
$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 .= '</a>';
@ -5752,7 +5746,7 @@ class learnpath
);
}
if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) {
if ($arrLP[$i]['item_type'] != 'dir') {
$prerequisities_icon = Display::url(
Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY),
$url.'&action=edit_item_prereq', ['class' => 'btn btn-default']
@ -5876,7 +5870,7 @@ class learnpath
$item['type'] = $default_content[$item['load_data']]['item_type'];
}
$sub_list = '';
if (isset($item['type']) && $item['type'] == 'dokeos_chapter') {
if (isset($item['type']) && $item['type'] == 'dir') {
$sub_list = Display::tag('li', '', array('class'=>'sub_item empty')); // empty value
}
if (empty($item['children'])) {
@ -6286,10 +6280,10 @@ class learnpath
WHERE c_id = ".$course_id." AND lp.id = " . intval($item_id);
$result = Database::query($sql);
while ($row = Database :: fetch_array($result,'ASSOC')) {
$_SESSION['parent_item_id'] = ($row['item_type'] == 'dokeos_chapter' || $row['item_type'] == 'dokeos_module' || $row['item_type'] == 'dir') ? $item_id : 0;
$_SESSION['parent_item_id'] = $row['item_type'] == 'dir' ? $item_id : 0;
// Prevents wrong parent selection for document, see Bug#1251.
if ($row['item_type'] != 'dokeos_chapter' && $row['item_type'] != 'dokeos_module') {
if ($row['item_type'] != 'dir') {
$_SESSION['parent_item_id'] = $row['parent_item_id'];
}
@ -6361,7 +6355,6 @@ class learnpath
$res = Database::query($sql);
$row = Database::fetch_array($res);
switch ($row['item_type']) {
case 'dokeos_chapter':
case 'dir':
case 'asset':
case 'sco':
@ -6418,14 +6411,6 @@ class learnpath
$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']);
$return .= $this->display_item_form($row['item_type'], get_lang('EditCurrentModule') . ' :', 'edit', $item_id, $row);
} else {
$return .= $this->display_item_small_form($row['item_type'], get_lang('EditCurrentModule') . ' :', $row);
}
break;
case TOOL_QUIZ:
$return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_quiz_form('edit', $item_id, $row);
@ -6490,10 +6475,10 @@ class learnpath
);
echo Display::display_normal_message(get_lang('ClickOnTheLearnerViewToSeeYourLearningPath'));
$chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item');
$dir = $_SESSION['oLP']->display_item_form('dir', get_lang('EnterDataNewChapter'), 'add_item');
echo Display::tabs(
$headers,
array($documents, $exercises, $links, $works, $forums, $chapter, $finish), 'resource_tab'
array($documents, $exercises, $links, $works, $forums, $dir, $finish), 'resource_tab'
);
return true;
@ -6639,11 +6624,7 @@ class learnpath
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (
(
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) &&
($arrLP[$i]['item_type'] == 'dir') &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
@ -6660,11 +6641,7 @@ class learnpath
$arrHide[] = $arrLP[$i]['id'];
}
} else {
if (
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) {
if ($arrLP[$i]['item_type'] == 'dir') {
$selectParent->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'], ['style' => 'padding-left: ' . (20 + $arrLP[$i]['depth'] * 20) . 'px']
@ -6709,7 +6686,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'] != 'dir') {
if (is_array($extra_info)) {
if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
$s_selected_position = $arrLP[$i]['id'];
@ -6870,13 +6847,13 @@ class learnpath
if (count($arrLP) > 0) {
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
$return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
} else {
$arrHide[] = $arrLP[$i]['id'];
}
} else {
if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
if ($arrLP[$i]['item_type'] == 'dir')
$return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
}
}
@ -6925,7 +6902,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'] != 'dir') {
if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
$s_selected_position = $arrLP[$i]['id'];
elseif ($action == 'add') $s_selected_position = 0;
@ -7056,7 +7033,7 @@ class learnpath
//$parent_item_id = $_SESSION['parent_item_id'];
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
$selectParent->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'],
@ -7070,11 +7047,7 @@ class learnpath
$arrHide[] = $arrLP[$i]['id'];
}
} else {
if (
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) {
if ($arrLP[$i]['item_type'] == 'dir') {
$selectParent->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'],
@ -7124,7 +7097,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'] != 'dir') {
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 = 0;
@ -7250,11 +7223,7 @@ class learnpath
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (
(
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) &&
($arrLP[$i]['item_type'] == 'dir') &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
@ -7271,11 +7240,7 @@ class learnpath
$arrHide[] = $arrLP[$i]['id'];
}
} else {
if (
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) {
if ($arrLP[$i]['item_type'] == 'dir') {
$selectParent->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'],
@ -7329,7 +7294,7 @@ class learnpath
$s_selected_position = 0;
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'] != 'dir') {
if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
$s_selected_position = $arrLP[$i]['id'];
elseif ($action == 'add') $s_selected_position = 0;
@ -7379,8 +7344,8 @@ class learnpath
}
/**
* Return the HTML form to display an item (generally a section/module item)
* @param string Item type (module/dokeos_module)
* Return the HTML form to display an item (generally a dir item)
* @param string Item type (dir)
* @param string Title (optional, only when creating)
* @param string Action ('add'/'edit')
* @param integer lp_item ID
@ -7420,7 +7385,7 @@ class learnpath
lp_id = " . $this->lp_id . " AND
id != $id";
if ($item_type == 'module')
if ($item_type == 'dir')
$sql .= " AND parent_item_id = 0";
$result = Database::query($sql);
@ -7466,44 +7431,43 @@ class learnpath
$arrHide[0]['padding'] = 20;
$charset = api_get_system_encoding();
if ($item_type != 'module' && $item_type != 'dokeos_module') {
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
$s_selected_parent = $arrHide[$arrLP[$i]['id']];
}
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
$s_selected_parent = $arrHide[$arrLP[$i]['id']];
}
} else {
if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
$s_selected_parent = $arrHide[$arrLP[$i]['id']];
}
}
} else {
if ($arrLP[$i]['item_type'] == 'dir') {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
$s_selected_parent = $arrHide[$arrLP[$i]['id']];
}
}
}
}
if ($action != 'move') {
$form->addElement('text', 'title', get_lang('Title'));
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
} else {
$form->addElement('hidden', 'title');
}
if ($action != 'move') {
$form->addElement('text', 'title', get_lang('Title'));
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
} else {
$form->addElement('hidden', 'title');
}
$parent_select = $form->addElement('select', 'parent', get_lang('Parent'), '', array('id' => 'idParent', 'onchange' => "javascript: load_cbo(this.value);"));
$parent_select = $form->addElement('select', 'parent', get_lang('Parent'), '', array('id' => 'idParent', 'onchange' => "javascript: load_cbo(this.value);"));
foreach ($arrHide as $key => $value) {
$parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"');
}
if (!empty($s_selected_parent)) {
$parent_select->setSelected($s_selected_parent);
}
foreach ($arrHide as $key => $value) {
$parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"');
}
if (!empty($s_selected_parent)) {
$parent_select->setSelected($s_selected_parent);
}
if (is_array($arrLP)) {
reset($arrLP);
}
@ -7542,12 +7506,9 @@ class learnpath
$form->addButtonSave(get_lang('SaveSection'), 'submit_button');
if ($item_type == 'module' || $item_type == 'dokeos_module') {
$form->addElement('hidden', 'parent', '0');
}
//fix in order to use the tab
if ($item_type == 'chapter') {
$form->addElement('hidden', 'type', 'chapter');
if ($item_type == 'dir') {
$form->addElement('hidden', 'type', 'dir');
}
$extension = null;
@ -7583,7 +7544,7 @@ class learnpath
$defaults['content_lp'] = file_get_contents($content_path);
}
$form->addElement('hidden', 'type', 'dokeos_' . $item_type);
$form->addElement('hidden', 'type', $item_type);
$form->addElement('hidden', 'post_time', time());
$form->setDefaults($defaults);
return $form->return_form();
@ -7742,7 +7703,7 @@ class learnpath
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
@ -7750,7 +7711,7 @@ class learnpath
}
}
} else {
if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
if ($arrLP[$i]['item_type'] == 'dir') {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
@ -7825,7 +7786,7 @@ class learnpath
$arrHide = array();
for ($i = 0; $i < count($arrLP); $i++) {
if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir' && $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'];
@ -8035,11 +7996,7 @@ class learnpath
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (
(
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) &&
($arrLP[$i]['item_type'] == 'dir') &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
@ -8056,7 +8013,7 @@ class learnpath
$arrHide[] = $arrLP[$i]['id'];
}
} else {
if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
if ($arrLP[$i]['item_type'] == 'dir') {
$selectParent->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'],
@ -8116,7 +8073,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'] != 'dir') {
if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
$s_selected_position = $arrLP[$i]['id'];
elseif ($action == 'add') $s_selected_position = 0;
@ -8245,11 +8202,7 @@ class learnpath
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (
(
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' ||
$arrLP[$i]['item_type'] == 'dir'
) &&
($arrLP[$i]['item_type'] == 'dir') &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
@ -8266,10 +8219,7 @@ class learnpath
$arrHide[] = $arrLP[$i]['id'];
}
} else {
if (
$arrLP[$i]['item_type'] == 'dokeos_module' ||
$arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir'
) {
if ($arrLP[$i]['item_type'] == 'dir') {
$parentSelect->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'],
@ -8321,7 +8271,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'] != 'dir') {
if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
$s_selected_position = $arrLP[$i]['id'];
elseif ($action == 'add') $s_selected_position = 0;
@ -8375,17 +8325,11 @@ class learnpath
$return = '<div class="actions">';
switch ($item_type) {
case 'dokeos_chapter' :
case 'chapter' :
case 'dir' :
// Commented the message cause should not show it.
//$lang = get_lang('TitleManipulateChapter');
break;
case 'dokeos_module' :
case 'module' :
// 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.
@ -8444,7 +8388,7 @@ class learnpath
);
// Commented for now as prerequisites cannot be added to chapters.
if ($item_type != 'dokeos_chapter' && $item_type != 'chapter') {
if ($item_type != 'dir') {
$return .= Display::url(
Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_SMALL),
$url.'&action=edit_item_prereq'
@ -8548,16 +8492,11 @@ class learnpath
$row = Database :: fetch_array($res);
switch ($row['item_type']) {
case 'dokeos_chapter' :
case 'dir' :
case 'asset' :
$return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_item_form($row['item_type'], get_lang('MoveCurrentChapter'), 'move', $item_id, $row);
break;
case 'dokeos_module' :
$return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_item_form($row['item_type'], 'Move th current module:', 'move', $item_id, $row);
break;
case TOOL_DOCUMENT :
$return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_document_form('move', $item_id, $row);
@ -8698,7 +8637,7 @@ class learnpath
$return .= '<tr>';
$return .= '<td class="radio"' . (($item['item_type'] != TOOL_QUIZ && $item['item_type'] != TOOL_HOTPOTATOES) ? ' colspan="3"' : '') . '>';
$return .= '<label for="id' . $item['id'] . '">';
$return .= '<input' . (in_array($prerequisiteId, array($item['id'], $item['ref'])) ? ' checked="checked" ' : '') . (($item['item_type'] == 'dokeos_module' || $item['item_type'] == 'dokeos_chapter') ? ' disabled="disabled" ' : ' ') . 'id="id' . $item['id'] . '" name="prerequisites" style="margin-left:' . $item['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $item['id'] . '" />';
$return .= '<input' . (in_array($prerequisiteId, array($item['id'], $item['ref'])) ? ' checked="checked" ' : '') . ($item['item_type'] == 'dir' ? ' disabled="disabled" ' : ' ') . 'id="id' . $item['id'] . '" name="prerequisites" style="margin-left:' . $item['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $item['id'] . '" />';
$icon_name = str_replace(' ', '', $item['item_type']);
if (file_exists('../img/lp_' . $icon_name . '.png')) {
@ -8814,7 +8753,7 @@ class learnpath
$headers = array(
get_lang('Files'),
get_lang('NewDocument'),
get_lang('CreateTheDocument'),
get_lang('Upload')
);
@ -10084,9 +10023,7 @@ EOD;
$files_to_export[] = array('title'=>$item->get_title(), 'path' => $file_path);
}
break;
case 'dokeos_chapter':
case 'dir':
case 'chapter':
$files_to_export[] = array('title'=> $item->get_title(), 'path'=>null);
break;
}
@ -10336,36 +10273,36 @@ EOD;
$previous_item_id = null;
$previous_item_max = 0;
$previous_item_type = null;
$last_item_not_chapter = null;
$last_item_not_chapter_type = null;
$last_item_not_chapter_max = null;
$last_item_not_dir = null;
$last_item_not_dir_type = null;
$last_item_not_dir_max = null;
foreach ($this->items as $item) {
// if there was a previous item... (otherwise jump to set it)
if (!empty($previous_item_id)) {
$current_item_id = $item->get_id(); //save current id
if (!in_array($item->get_type(), array('dokeos_chapter', 'chapter'))) {
if ($item->get_type() != 'dir') {
// Current item is not a folder, so it qualifies to get a prerequisites
if ($last_item_not_chapter_type == 'quiz') {
if ($last_item_not_dir_type == 'quiz') {
// if previous is quiz, mark its max score as default score to be achieved
$sql = "UPDATE $tbl_lp_item SET mastery_score = '$last_item_not_chapter_max'
WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$last_item_not_chapter'";
$sql = "UPDATE $tbl_lp_item SET mastery_score = '$last_item_not_dir_max'
WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$last_item_not_dir'";
Database::query($sql);
}
// now simply update the prerequisite to set it to the last non-chapter item
$sql = "UPDATE $tbl_lp_item SET prerequisite = '$last_item_not_chapter'
$sql = "UPDATE $tbl_lp_item SET prerequisite = '$last_item_not_dir'
WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$current_item_id'";
Database::query($sql);
// record item as 'non-chapter' reference
$last_item_not_chapter = $item->get_id();
$last_item_not_chapter_type = $item->get_type();
$last_item_not_chapter_max = $item->get_max();
$last_item_not_dir = $item->get_id();
$last_item_not_dir_type = $item->get_type();
$last_item_not_dir_max = $item->get_max();
}
} else {
if (!in_array($item->get_type(), array('dokeos_chapter', 'chapter'))) {
if ($item->get_type() != 'dir') {
// Current item is not a folder (but it is the first item) so record as last "non-chapter" item
$last_item_not_chapter = $item->get_id();
$last_item_not_chapter_type = $item->get_type();
$last_item_not_chapter_max = $item->get_max();
$last_item_not_dir = $item->get_id();
$last_item_not_dir_type = $item->get_type();
$last_item_not_dir_max = $item->get_max();
}
}
// Saving the item as "previous item" for the next loop

@ -69,7 +69,7 @@ class learnpathItem
public $title;
/**
* Type attribute can contain one of
* chapter|link|student_publication|module|quiz|document|forum|thread
* link|student_publication|dir|quiz|document|forum|thread
*/
public $type;
public $view_id;
@ -517,7 +517,7 @@ class learnpathItem
$path = $this->get_path();
$type = $this->get_type();
if (empty($path)) {
if ($type == 'dokeos_chapter' || $type == 'chapter' || $type == 'dir') {
if ($type == 'dir') {
return '';
} else {
return '-1';
@ -525,9 +525,7 @@ class learnpathItem
} elseif ($path == strval(intval($path))) {
// The path is numeric, so it is a reference to a Chamilo object.
switch ($type) {
case 'dokeos_chapter':
case 'dir':
case 'chapter':
return '';
case TOOL_DOCUMENT:
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
@ -3790,6 +3788,8 @@ class learnpathItem
$course_id = api_get_course_int_id();
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$total_time = ' ';
$my_status = ' ';
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = 'SELECT status FROM ' . $item_view_table . '
@ -4004,7 +4004,7 @@ class learnpathItem
$my_status = " status = '" . $this->get_status(false) . "' ,";
} else {
if (($my_type_lp == 3 && $this->type == 'au') ||
($my_type_lp == 1 && $this->type != 'chapter')) {
($my_type_lp == 1 && $this->type != 'dir')) {
// Is AICC or Chamilo LP
$total_time = " total_time = total_time + " . $this->get_total_time() . ", ";
$my_status = " status = '" . $this->get_status(false) . "' ,";

@ -24,39 +24,6 @@
* @todo remove code duplication
*/
/**
* This function returns false if there is at least one item in the path
* @param Learnpath ID
* @return boolean True if nothing was found, false otherwise
*/
function is_empty($id) {
$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $tbl_learnpath_chapter WHERE c_id = $course_id AND lp_id=$id ORDER BY display_order ASC";
$result = Database::query($sql);
$num_modules = Database::num_rows($result);
$empty = true;
if ($num_modules != 0) {
while ($row = Database::fetch_array($result)) {
$num_items = 0;
$parent_item_id = $row['id'];
$sql2 = "SELECT * FROM $tbl_learnpath_item WHERE c_id = $course_id AND (parent_item_id=$parent_item_id) ORDER BY display_order ASC";
$result2 = Database::query($sql2);
$num_items = Database::num_rows($result2);
if ($num_items > 0) {
$empty = false;
}
}
}
return ($empty);
}
/**
* This function deletes an entire directory
* @param string The directory path

@ -51,7 +51,7 @@ $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => g
$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $_SESSION['oLP']->get_name());
switch ($type) {
case 'chapter':
case 'dir':
$interbreadcrumb[] = array(
'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id().'&'.api_get_cidreq(),
'name' => get_lang('NewStep'),

@ -112,7 +112,7 @@ $interbreadcrumb[] = array(
);
switch ($type) {
case 'chapter':
case 'dir':
$interbreadcrumb[] = array(
'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id().'&'.api_get_cidreq(),
'name' => get_lang('NewStep'),
@ -247,7 +247,7 @@ if (in_array($message, array('ItemUpdated'))) {
if (isset($new_item_id) && is_numeric($new_item_id)) {
switch ($type) {
case 'chapter':
case 'dir':
echo $learnPath->display_manipulate($new_item_id, $_POST['type']);
Display::display_confirmation_message(get_lang('NewChapterCreated'));
break;
@ -259,10 +259,6 @@ if (isset($new_item_id) && is_numeric($new_item_id)) {
echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewStudentPublicationCreated'));
break;
case 'module':
echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewModuleCreated'));
break;
case TOOL_QUIZ:
echo $learnPath->display_manipulate($new_item_id, $type);
Display::display_confirmation_message(get_lang('NewExerciseCreated'));
@ -282,12 +278,9 @@ if (isset($new_item_id) && is_numeric($new_item_id)) {
}
} else {
switch ($type) {
case 'chapter':
case 'dir':
echo $learnPath->display_item_form($type, get_lang('EnterDataNewChapter'));
break;
case 'module':
echo $learnPath->display_item_form($type, get_lang('EnterDataNewModule'));
break;
case TOOL_DOCUMENT:
if (isset($_GET['file']) && is_numeric($_GET['file'])) {
echo $learnPath->display_document_form('add', 0, $_GET['file']);

@ -132,7 +132,7 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item)
* -lms_view_id
* -lms_user_id
*/
$mytotal = $mylp->get_total_items_count_without_chapters();
$mytotal = $mylp->getTotalItemsCountWithoutDirs();
$mycomplete = $mylp->get_complete_items_count();
$myprogress_mode = $mylp->get_progress_bar_mode();
$myprogress_mode = ($myprogress_mode == '' ? '%' : $myprogress_mode);

@ -408,7 +408,7 @@ function save_item(
$myStatus = $myStatusInDB;
}
$myTotal = $myLP->get_total_items_count_without_chapters();
$myTotal = $myLP->getTotalItemsCountWithoutDirs();
$myComplete = $myLP->get_complete_items_count();
$myProgressMode = $myLP->get_progress_bar_mode();
$myProgressMode = $myProgressMode == '' ? '%' : $myProgressMode;

@ -172,7 +172,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
* -lms_view_id
* -lms_user_id
*/
$mytotal = $mylp->get_total_items_count_without_chapters();
$mytotal = $mylp->getTotalItemsCountWithoutDirs();
$mycomplete = $mylp->get_complete_items_count();
$myprogress_mode = $mylp->get_progress_bar_mode();
$myprogress_mode = ($myprogress_mode == '' ? '%' : $myprogress_mode);

@ -110,7 +110,7 @@ function switch_item_toc($lpId, $userId, $viewId, $currentItem, $nextItem)
$interactionsString = substr($interactionsString, 1);
}
*/
$totalItems = $myLP->get_total_items_count_without_chapters();
$totalItems = $myLP->getTotalItemsCountWithoutDirs();
$completedItems = $myLP->get_complete_items_count();
$progressMode = $myLP->get_progress_bar_mode();
$progressMode = ($progressMode == '' ? '%' : $progressMode);

@ -34,16 +34,14 @@ if ($debug > 0) {
$list = $_SESSION['oLP']->get_toc();
$dokeos_chapter = false;
$dir = false;
foreach ($list as $toc) {
if ($toc['id'] == $lp_item_id &&
($toc['type'] == 'dokeos_chapter' || $toc['type'] == 'dokeos_module' || $toc['type'] == 'dir')
) {
$dokeos_chapter = true;
if ($toc['id'] == $lp_item_id && $toc['type'] == 'dir') {
$dir = true;
}
}
if ($dokeos_chapter) {
if ($dir) {
$src = 'blank.php';
} else {
switch ($lp_type) {

@ -582,7 +582,7 @@ switch ($action) {
);
if (is_numeric($new_lp_id)) {
// TODO: Maybe create a first module directly to avoid bugging the user with useless queries
// TODO: Maybe create a first directory directly to avoid bugging the user with useless queries
$_SESSION['oLP'] = new learnpath(
api_get_course_id(),
$new_lp_id,
@ -1023,7 +1023,7 @@ switch ($action) {
exit;
}
break;
case 'add_sub_item': // Add an item inside a chapter.
case 'add_sub_item': // Add an item inside a dir/chapter.
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}

@ -36,7 +36,7 @@ $finalItemTemplate = '';
// Check prerequisites and total completion of the learning path
$lp = new Learnpath($courseCode, $lpId, $userId);
$count = $lp->get_total_items_count_without_chapters();
$count = $lp->getTotalItemsCountWithoutDirs();
$completed = $lp->get_complete_items_count(true);
$currentItemId = $lp->get_current_item_id();
$currentItem = $lp->items[$currentItemId];

@ -77,7 +77,7 @@ foreach ($list as $toc) {
$html .= '<div id="step-'.$step.'" class="step slide" data-x="'.$x.'" data-y="-1500" >';
$html .= '<div class="impress-content">';
$src = $_SESSION['oLP']->get_link('http', $toc['id']);
if ($toc['type'] !== 'dokeos_chapter') {
if ($toc['type'] !== 'dir') {
//just showing the src in a iframe ...
$html .= '<h2>'.$toc['title'].'</h2>';
$html .= '<iframe border="0" frameborder="0" style="width:100%;height:600px" src="' . $src . '"></iframe>';

@ -93,7 +93,7 @@ class OpenofficeText extends OpenofficeDocument {
}
/**
* Manages chapter splitting
* Manages dir/chapter splitting
* @param string Chapter header
* @param string Content
* @return void
@ -128,11 +128,11 @@ class OpenofficeText extends OpenofficeDocument {
$content = strstr($content,$matches[0][$i]);
if ($i + 1 !== count($matches[0])) {
$chapter_content = substr($content, 0, strpos($content, $matches[0][$i + 1]));
$dir_content = substr($content, 0, strpos($content, $matches[0][$i + 1]));
} else {
$chapter_content = $content;
$dir_content = $content;
}
$items_to_create[$matches[1][$i]] = $chapter_content;
$items_to_create[$matches[1][$i]] = $dir_content;
}

@ -89,7 +89,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
}
/**
* Manages chapter splitting
* Manages dir/chapter splitting
* @param string Chapter header
* @param string Content
* @return void
@ -103,7 +103,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
// Get all the h1.
preg_match_all("|<h1[^>]*>([^(h1)+]*)</h1>|is", $content, $matches_temp);
// Empty the fake chapters.
// Empty the fake dir/chapters.
$new_index = 0;
for ($i = 0; $i < count($matches_temp[0]); $i++) {
if (trim($matches_temp[1][$i]) !== '') {
@ -124,11 +124,11 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
$content = api_strstr($content, $matches[0][$i]);
if ($i + 1 !== count($matches[0])) {
$chapter_content = api_substr($content, 0, api_strpos($content, $matches[0][$i + 1]));
$dir_content = api_substr($content, 0, api_strpos($content, $matches[0][$i + 1]));
} else {
$chapter_content = $content;
$dir_content = $content;
}
$items_to_create[$matches[1][$i]] = $chapter_content;
$items_to_create[$matches[1][$i]] = $dir_content;
}
$i = 0;

@ -36,10 +36,11 @@ function unset_session_resources() {
/**
* Insert description here.
* @param int $chapter_id The ID of the dir/chapter
*/
function show_folder_up() {
function show_folder_up($chapter_id) {
global $folder;
global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
global $source_id, $action, $learnpath_id, $originalresource;
$learningPathId = $learnpath_id;
$level = get_levels($folder);
@ -59,10 +60,11 @@ function show_folder_up() {
/**
* Shows the documents of the document tool
* @param $folder
* @param int $folder
* @param int $chapter_id
*/
function show_documents($folder) {
global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
function show_documents($folder, $chapter_id) {
global $source_id, $action, $learnpath_id;
$learningPathId = $learnpath_id;
// Documents are a special case: The teacher can add an invisible document (it will be viewable by the user)
@ -1680,7 +1682,7 @@ function rl_get_resource_link_for_learnpath($course_id, $learningPathId, $id_in_
$main_course_path = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/';
$link = '';
switch ($type) {
case 'dokeos_chapter':
case 'dir':
$link .= $main_dir_path . 'lp/blank.php';
case TOOL_CALENDAR_EVENT:
$link .= $main_dir_path.'calendar/agenda.php?origin='.$origin.'&agenda_id='.$id;
@ -1878,7 +1880,7 @@ function rl_get_resource_name($course_code, $learningPathId, $id_in_path)
$post = Database::fetch_array($result);
$output = $post['post_title'];
break;
case 'dokeos_chapter':
case 'dir':
$title = $row_item['title'];
if (!empty($title)) {
$output = $title;

@ -56,8 +56,8 @@ $external_link = $_REQUEST['external_link'];
$from_learnpath = $_SESSION['from_learnpath'];
// This variable controls wether the link to add a chapter in a module or
// another chapter is shown. This allows to create multi-level learnpaths,
// This variable controls wether the link to add a dir/chapter in a module or
// another dir/chapter is shown. This allows to create multi-level learnpaths,
// but export features are not ready for this, yet, so use at your own risks
// default : false -> do not display link
// This setting should be moved to the platform configuration page in time...
@ -77,15 +77,15 @@ if ($from_learnpath == 'yes') {
$course_id = api_get_course_int_id();
// Process a new chapter?
if (!empty ($_POST['add_chapter']) && !empty ($_POST['title'])) {
// Process a new dir/chapter?
if (!empty ($_POST['add_dir']) && !empty ($_POST['title'])) {
$title = $_POST['title'];
$description = '';
/*if (!empty ($_POST['description'])) {
$description = $_POST['description'];
}*/
// Get max display_order so far in this parent chapter.
// Get max display_order so far in this parent dir/chapter.
$sql = "SELECT MAX(display_order) as maxi FROM $tbl_lp_item " .
"WHERE c_id = $course_id AND lp_id = $learnpath_id ".
" AND parent_item_id = $chapter_id";
@ -105,7 +105,7 @@ if (!empty ($_POST['add_chapter']) && !empty ($_POST['title'])) {
$order = $lastorder_item + 1;
$sql = "INSERT INTO $tbl_lp_item "."(c_id, lp_id,item_type,title,parent_item_id,previous_item_id, next_item_id, display_order) " .
"VALUES "."($course_id, $learnpath_id,'dokeos_chapter','$title', $chapter_id, $previous, 0, $order )";
"VALUES "."($course_id, $learnpath_id,'dir','$title', $chapter_id, $previous, 0, $order )";
//error_log('New LP - Inserting new resource: '.$sql, 0);
$res = Database::query($sql);
$my_id = Database::insert_id($res);
@ -168,11 +168,11 @@ if ($add) {
$_SESSION['addedresource'] = $addedresource;
$_SESSION['addedresourceid'] = $addedresourceid;
// We assign to chapters immediately!
// We assign to dirs/chapters immediately!
$resource_added = false;
if ($from_learnpath == 'yes') {
$i = 0;
// Calculating the last order of the items of this chapter.
// Calculating the last order of the items of this dir/chapter.
$sql = "SELECT MAX(display_order) as maxi FROM $tbl_lp_item " .
"WHERE c_id = $course_id AND lp_id = $learnpath_id AND parent_item_id=$chapter_id";
$result = Database::query($sql);
@ -191,11 +191,11 @@ if ($add) {
}
$lastorder = $lastorder_item + 1;
foreach ($addedresource as $addedresource_item) {
// In the case we added a chapter, add this into the chapters list with the correct parent_id.
// In the case we added a dir/chapter, add this into the dirs/chapters list with the correct parent_id.
if ($addedresource_item == 'Chap') {
$sql = "INSERT INTO $tbl_lp_item " .
"(c_id, lp_id,item_type,title,parent_item_id,previous_item_id,next_item_id,display_order) " .
"VALUES ($course_id, ".$learnpath_id.",'dokeos_chapter','".$learnpath_chapter_name."',".$chapter_id.",$previous,0,".$lastorder.")";
"VALUES ($course_id, ".$learnpath_id.",'dir','".$learnpath_chapter_name."',".$chapter_id.",$previous,0,".$lastorder.")";
//error_log('New LP - Inserting new resource: '.$sql, 0);
$res = Database::query($sql);
$my_id = Database::insert_id($res);
@ -403,9 +403,9 @@ if ($from_learnpath != 'yes') {
$sql_result = Database::query($learnpath_select_query);
$therow = Database::fetch_array($sql_result);
$learnpath_chapter_query = " SELECT * FROM $tbl_lp_item
$learnpath_dir_query = " SELECT * FROM $tbl_lp_item
WHERE (lp_id = '$learnpath_id' and id = '$chapter_id')";
$sql_result = Database::query($learnpath_chapter_query);
$sql_result = Database::query($learnpath_dir_query);
$therow2 = Database::fetch_array($sql_result);
$from_learnpath = 'yes';
@ -502,7 +502,7 @@ while ($row = Database::fetch_array($result_select_active)) {
</tr-->
<?php if ($multi_level_learnpath === true ) { ?>
<tr>
<td><?php echo "<a href=\"".api_get_self()."?content=chapter&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Chapter')."</a>"; ?></td>
<td><?php echo "<a href=\"".api_get_self()."?content=dir&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Chapter')."</a>"; ?></td>
</tr>
<?php } ?>
<tr>
@ -639,11 +639,11 @@ if ($content == 'Agenda') {
/* Chapter */
if ($content == 'chapter') {
echo '<table><form name="add_chapter" action="'.'" method="POST">'."\n";
if ($content == 'dir') {
echo '<table><form name="add_dir" action="'.'" method="POST">'."\n";
echo ' <tr><td>'.get_lang('Title').'</td><td><input type="text" name="title" value="'.$title.'"></input></td></tr>'."\n";
echo ' <tr><td>'.get_lang('Description').'</td><td><input type="text" name="description" value="'.$description.'"></input></td></tr>'."\n";
echo ' <tr><td></td><td><input type="submit" name="add_chapter" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
echo ' <tr><td></td><td><input type="submit" name="add_dir" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
echo '</form></table>'."\n";
//echo "<hr />";
}
@ -661,7 +661,7 @@ if ($content == 'Document' || (empty($content) && (api_is_allowed_to_edit() || i
$courseDir = $_course['path'].'/document';
$baseWorkDir = $baseServDir.$courseDir;
// showing the link to move one folder up (when not in the root folder)
show_folder_up();
show_folder_up($chapter_id);
// showing the blue bar with the path in it when we are not in the root
if (get_levels($folder)) {
echo "<table width=\"100%\"><tr><td bgcolor=\"#4171B5\">";
@ -670,7 +670,7 @@ if ($content == 'Document' || (empty($content) && (api_is_allowed_to_edit() || i
}
// Showing the documents and subfolders of the folder we are in.
show_documents($folder);
show_documents($folder, $chapter_id);
//echo "<hr />";
}

@ -89,7 +89,7 @@ if ($from_learnpath == 'yes')
}
// Process a new chapter?
if (!empty ($_POST['add_chapter']) && !empty ($_POST['title']))
if (!empty ($_POST['add_dir']) && !empty ($_POST['title']))
{
$title = $_POST['title'];
$description = '';
@ -620,10 +620,10 @@ if ($content == "Agenda")
*/
if ($content == "chapter")
{
echo '<table><form name="add_chapter" action="'.'" method="POST">'."\n";
echo '<table><form name="add_dir" action="'.'" method="POST">'."\n";
echo ' <tr><td>'.get_lang('Title').'</td><td><input type="text" name="title" value="'.$title.'"></input></td></tr>'."\n";
echo ' <tr><td>'.get_lang('Description').'</td><td><input type="text" name="description" value="'.$description.'"></input></td></tr>'."\n";
echo ' <tr><td></td><td><input type="submit" name="add_chapter" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
echo ' <tr><td></td><td><input type="submit" name="add_dir" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
echo '</form></table>'."\n";
//echo "<hr>";
}
@ -645,7 +645,7 @@ if ($content == "Document" OR (empty($content) AND (api_is_allowed_to_edit() OR
$courseDir = $_course['path']."/document";
$baseWorkDir = $baseServDir.$courseDir;
// showing the link to move one folder up (when not in the root folder)
show_folder_up();
show_folder_up($chapter_id);
// showing the blue bar with the path in it when we are not in the root
if (get_levels($folder))
{
@ -655,7 +655,7 @@ if ($content == "Document" OR (empty($content) AND (api_is_allowed_to_edit() OR
}
// showing the documents and subfolders of the folder we are in.
show_documents($folder);
show_documents($folder, $chapter_id);
//echo "<hr>";
}

@ -211,19 +211,19 @@ class WSCMCourse extends WSCM
return $course_id;
} else {
$attributes = array();
if(!is_empty($title)) {
if(!empty($title)) {
$attributes['title'] = $title;
}
if(!is_empty($category_code)) {
if(!empty($category_code)) {
$attributes['category_code'] = $category_code;
}
if(!is_empty($department_name)) {
if(!empty($department_name)) {
$attributes['department_name'] = $department_name;
}
if(!is_empty($department_url)) {
if(!empty($department_url)) {
$attributes['department_url'] = $department_url;
}
if(!is_empty($language)) {
if(!empty($language)) {
$attributes['course_language'] = $language;
}
if($visibility != '') {
@ -235,10 +235,10 @@ class WSCMCourse extends WSCM
if($unsubscribe != '') {
$attributes['unsubscribe'] = (int)$unsubscribe;
}
if(!is_empty($visual_code)) {
if(!empty($visual_code)) {
$attributes['visual_code'] = $visual_code;
}
if(!is_empty($attributes)) {
if(!empty($attributes)) {
CourseManager::update_attributes($course_id, $attributes);
}
if(!empty($extras)) {

@ -213,19 +213,19 @@ class WSCourse extends WS
return $course_id;
} else {
$attributes = array();
if(!is_empty($title)) {
if(!empty($title)) {
$attributes['title'] = $title;
}
if(!is_empty($category_code)) {
if(!empty($category_code)) {
$attributes['category_code'] = $category_code;
}
if(!is_empty($department_name)) {
if(!empty($department_name)) {
$attributes['department_name'] = $department_name;
}
if(!is_empty($department_url)) {
if(!empty($department_url)) {
$attributes['department_url'] = $department_url;
}
if(!is_empty($language)) {
if(!empty($language)) {
$attributes['course_language'] = $language;
}
if($visibility != '') {
@ -237,10 +237,10 @@ class WSCourse extends WS
if($unsubscribe != '') {
$attributes['unsubscribe'] = (int)$unsubscribe;
}
if(!is_empty($visual_code)) {
if(!empty($visual_code)) {
$attributes['visual_code'] = $visual_code;
}
if(!is_empty($attributes)) {
if(!empty($attributes)) {
CourseManager::update_attributes($course_id, $attributes);
}
if(!empty($extras)) {

@ -9,10 +9,10 @@ class TestLearnpath extends UnitTestCase {
//ob_start();
$parent = 2;
$previous = 1;
$type = 'dokeos_chapter';
$type = 'dir';
$id = 1;
$title = 'Titulo';
$description = 'Descripcion';
$title = 'Title';
$description = 'Description';
$prerequisites = 0;
$max_time_allowed = 0;
@ -402,7 +402,7 @@ class TestLearnpath extends UnitTestCase {
public function testGetBrotherChapters() {
//ob_start();
$id = '';
$res = learnpath::get_brother_chapters($id);
$res = learnpath::getSiblingDirectories($id);
$this->assertTrue(is_array($res));
//ob_end_clean();
//var_dump($res);
@ -891,7 +891,7 @@ class TestLearnpath extends UnitTestCase {
/*
public function testGetTotalItemsCountWithoutChapters() {
//ob_start();
$res = learnpath::get_total_items_count_without_chapters();
$res = learnpath::getTotalItemsCountWithoutDirs();
$this->assertTrue(is_numeric($res));
//ob_end_clean();
//var_dump($res);

@ -102,7 +102,7 @@ class TestResourcelinker extends UnitTestCase {
function testShowDocuments() {
ob_start();
$folder='';
$res = show_documents($folder);
$res = show_documents($folder, 1);
$this->assertTrue(is_null($res));
ob_end_clean();
//var_dump($res);
@ -110,7 +110,7 @@ class TestResourcelinker extends UnitTestCase {
function testShowFolderUp() {
//ob_start();
$res = show_folder_up();
$res = show_folder_up(1);
$this->assertTrue(is_null($res));
//ob_end_clean();
//var_dump($res);

Loading…
Cancel
Save