|
|
|
|
@ -2061,7 +2061,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]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') && $index < $this->max_ordered_items) { |
|
|
|
|
while ( |
|
|
|
|
!empty($this->ordered_items[$index]) && ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') && |
|
|
|
|
$index < $this->max_ordered_items |
|
|
|
|
) { |
|
|
|
|
$index++; |
|
|
|
|
if ($index == $this->max_ordered_items) { |
|
|
|
|
if ($this->items[$this->ordered_items[$index]]->get_type() == 'dir') { |
|
|
|
|
@ -2203,7 +2206,9 @@ 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')) { |
|
|
|
|
while (isset($this->ordered_items[$index]) && |
|
|
|
|
($this->items[$this->ordered_items[$index]]->get_type() == 'dir') |
|
|
|
|
) { |
|
|
|
|
$index--; |
|
|
|
|
if ($index < 0) { |
|
|
|
|
return $this->index; |
|
|
|
|
@ -2538,10 +2543,12 @@ class learnpath |
|
|
|
|
{ |
|
|
|
|
$text = $percentage.$text_add; |
|
|
|
|
$output = '<div class="progress"> |
|
|
|
|
<div id="progress_bar_value" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' .$percentage.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$text.';"> |
|
|
|
|
'. $text.' |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
<div id="progress_bar_value" |
|
|
|
|
class="progress-bar progress-bar-success" role="progressbar" |
|
|
|
|
aria-valuenow="' .$percentage.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$text.';"> |
|
|
|
|
'. $text.' |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
|
|
|
|
|
return $output; |
|
|
|
|
} |
|
|
|
|
@ -2563,7 +2570,7 @@ class learnpath |
|
|
|
|
* @param string $mode Mode of display (can be '%' or 'abs').abs means |
|
|
|
|
* we display a number of completed elements per total elements |
|
|
|
|
* @param integer $add Additional steps to fake as completed |
|
|
|
|
* @return list array Percentage or number and symbol (% or /xx) |
|
|
|
|
* @return array Percentage or number and symbol (% or /xx) |
|
|
|
|
*/ |
|
|
|
|
public function get_progress_bar_text($mode = '', $add = 0) |
|
|
|
|
{ |
|
|
|
|
@ -3170,6 +3177,7 @@ class learnpath |
|
|
|
|
'dir' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Uses the table generated by get_toc() and returns an HTML-formatted string ready to display |
|
|
|
|
* @return string HTML TOC ready to display |
|
|
|
|
@ -3239,9 +3247,7 @@ class learnpath |
|
|
|
|
if (in_array($item['type'], $dirTypes)) { |
|
|
|
|
$list['css_level'] = 'level_'.$item['level']; |
|
|
|
|
} else { |
|
|
|
|
$list['css_level'] = 'level_'.$item['level'] |
|
|
|
|
.' scorm_type_' |
|
|
|
|
.learnpath::format_scorm_type_item($item['type']); |
|
|
|
|
$list['css_level'] = 'level_'.$item['level'].' scorm_type_'.learnpath::format_scorm_type_item($item['type']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (in_array($item['type'], $dirTypes)) { |
|
|
|
|
@ -3512,8 +3518,7 @@ class learnpath |
|
|
|
|
// some contents use this form: resource.htm?resource=http://blablabla |
|
|
|
|
// which means we have to find a protocol at the path's start, otherwise |
|
|
|
|
// it should not be considered as an external URL. |
|
|
|
|
|
|
|
|
|
//if ($this->prerequisites_match($item_id)) { |
|
|
|
|
// if ($this->prerequisites_match($item_id)) { |
|
|
|
|
if (preg_match('#^[a-zA-Z]{2,5}://#', $lp_item_path) != 0) { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('New LP - In learnpath::get_link() '.__LINE__.' - Found match for protocol in '.$lp_item_path, 0); |
|
|
|
|
@ -4023,9 +4028,9 @@ class learnpath |
|
|
|
|
$max = $i; |
|
|
|
|
if ($row['display_order'] != $i) { |
|
|
|
|
// If we find a gap in the order, we need to fix it. |
|
|
|
|
$sql_u = "UPDATE $lp_table SET display_order = $i |
|
|
|
|
$sql = "UPDATE $lp_table SET display_order = $i |
|
|
|
|
WHERE c_id = ".$courseId." AND id = ".$row['id']; |
|
|
|
|
Database::query($sql_u); |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
$row['display_order'] = $i; |
|
|
|
|
$lps[$row['id']] = $row; |
|
|
|
|
@ -4036,12 +4041,12 @@ class learnpath |
|
|
|
|
if ($num > 1) { // If there's only one element, no need to sort. |
|
|
|
|
$order = $lps[$lp_id]['display_order']; |
|
|
|
|
if ($order < $max) { // If it's the first element, no need to move up. |
|
|
|
|
$sql_u1 = "UPDATE $lp_table SET display_order = $order |
|
|
|
|
WHERE c_id = ".$courseId." AND id = ".$lp_order[$order + 1]; |
|
|
|
|
Database::query($sql_u1); |
|
|
|
|
$sql_u2 = "UPDATE $lp_table SET display_order = ".($order + 1)." |
|
|
|
|
WHERE c_id = ".$courseId." AND id = ".$lp_id; |
|
|
|
|
Database::query($sql_u2); |
|
|
|
|
$sql = "UPDATE $lp_table SET display_order = $order |
|
|
|
|
WHERE c_id = ".$courseId." AND id = ".$lp_order[$order + 1]; |
|
|
|
|
Database::query($sql); |
|
|
|
|
$sql = "UPDATE $lp_table SET display_order = ".($order + 1)." |
|
|
|
|
WHERE c_id = ".$courseId." AND id = ".$lp_id; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -4081,7 +4086,6 @@ class learnpath |
|
|
|
|
* Open a resource = initialise all local variables relative to this resource. Depending on the child |
|
|
|
|
* class, this might be redefined to allow several behaviours depending on the document type. |
|
|
|
|
* @param integer Resource ID |
|
|
|
|
* @return boolean True on success, false otherwise |
|
|
|
|
*/ |
|
|
|
|
public function open($id) |
|
|
|
|
{ |
|
|
|
|
@ -4386,8 +4390,7 @@ class learnpath |
|
|
|
|
$link = self::getCategoryLinkForTool($id); |
|
|
|
|
|
|
|
|
|
/** @var CTool $tool */ |
|
|
|
|
$tool = $em |
|
|
|
|
->createQuery(" |
|
|
|
|
$tool = $em->createQuery(" |
|
|
|
|
SELECT t FROM ChamiloCourseBundle:CTool t |
|
|
|
|
WHERE |
|
|
|
|
t.cId = :course AND |
|
|
|
|
@ -4556,7 +4559,7 @@ class learnpath |
|
|
|
|
* Make sure the results are saved with anoter method. This method should probably be |
|
|
|
|
* redefined in children classes. |
|
|
|
|
* To use a similar method statically, use the create_new_attempt() method |
|
|
|
|
* @return string URL to load in the viewer |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public function restart() |
|
|
|
|
{ |
|
|
|
|
@ -4633,9 +4636,9 @@ class learnpath |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Saves the given item |
|
|
|
|
* @param integer $item_id Optional (will take from $_REQUEST if null) |
|
|
|
|
* @param boolean $from_outside Save from url params (true) or from current attributes (false). Optional. Defaults to true |
|
|
|
|
* @return boolean |
|
|
|
|
* @param integer $item_id Optional (will take from $_REQUEST if null) |
|
|
|
|
* @param bool $from_outside Save from url params (true) or from current attributes (false). Default true |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public function save_item($item_id = null, $from_outside = true) |
|
|
|
|
{ |
|
|
|
|
@ -5138,7 +5141,7 @@ class learnpath |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets use_max_score |
|
|
|
|
* @param string $use_max_score Optional string giving the new location of this learnpath |
|
|
|
|
* @param int $use_max_score Optional string giving the new location of this learnpath |
|
|
|
|
* @return boolean True on success / False on error |
|
|
|
|
*/ |
|
|
|
|
public function set_use_max_score($use_max_score = 1) |
|
|
|
|
@ -5601,7 +5604,6 @@ class learnpath |
|
|
|
|
/** |
|
|
|
|
* Switch between multiple attempt, single attempt or serious_game mode (only for scorm) |
|
|
|
|
* |
|
|
|
|
* @return boolean |
|
|
|
|
* @author ndiechburg <noel@cblue.be> |
|
|
|
|
**/ |
|
|
|
|
public function switch_attempt_mode() |
|
|
|
|
@ -7022,7 +7024,7 @@ class learnpath |
|
|
|
|
/** |
|
|
|
|
* Function that displays a list with al the resources that |
|
|
|
|
* could be added to the learning path |
|
|
|
|
* @return string |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public function display_resources() |
|
|
|
|
{ |
|
|
|
|
@ -7455,11 +7457,13 @@ class learnpath |
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($arrLP); $i++) { |
|
|
|
|
if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { |
|
|
|
|
if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
|
|
|
if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
|
|
|
$selected = 'selected="selected" '; |
|
|
|
|
} elseif ($action == 'add') { |
|
|
|
|
$selected = 'selected="selected" '; |
|
|
|
|
elseif ($action == 'add') $selected = 'selected="selected" '; |
|
|
|
|
else |
|
|
|
|
} else { |
|
|
|
|
$selected = ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$return .= '<option '.$selected.'value="'.$arrLP[$i]['id'].'">'.get_lang('After').' "'.$arrLP[$i]['title'].'"</option>'; |
|
|
|
|
} |
|
|
|
|
@ -7615,7 +7619,6 @@ class learnpath |
|
|
|
|
['id' => 'idParent', 'onchange' => 'load_cbo(this.value);', 'class' => 'learnpath_item_form'] |
|
|
|
|
); |
|
|
|
|
$selectParent->addOption($this->name, 0); |
|
|
|
|
|
|
|
|
|
$arrHide = array( |
|
|
|
|
$id |
|
|
|
|
); |
|
|
|
|
@ -8192,7 +8195,7 @@ class learnpath |
|
|
|
|
$form->addElement('hidden', 'type', $item_type); |
|
|
|
|
$form->addElement('hidden', 'post_time', time()); |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
return $form->return_form(); |
|
|
|
|
return $form->returnForm(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -8546,7 +8549,6 @@ class learnpath |
|
|
|
|
// A new document, it is in the root of the repository. |
|
|
|
|
$relative_path = ''; |
|
|
|
|
$relative_prefix = ''; |
|
|
|
|
|
|
|
|
|
if (is_array($extra_info) && $extra_info != 'new') { |
|
|
|
|
// The document already exists. Whe have to determine its relative path towards the repository root. |
|
|
|
|
$relative_path = explode('/', $extra_info['dir']); |
|
|
|
|
|