Adding clear prerequisites/set previous step as prerequisite see BT#4848

skala
Julio Montoya 13 years ago
parent 8c270acf6c
commit e07a0cd1e0
  1. 8
      main/css/base.css
  2. 256
      main/inc/lib/display.lib.php
  3. 61
      main/newscorm/learnpath.class.php
  4. 11
      main/newscorm/lp_controller.php

@ -419,10 +419,16 @@ footer .container .row {
vertical-align:middle; vertical-align:middle;
} }
.actions a { .actions a {
display:inline-block; display: block;
float: left;
margin-right: 10px; margin-right: 10px;
vertical-align:middle; vertical-align:middle;
} }
.actions .btn-toolbar {
margin : 0px;
}
.actions span { .actions span {
margin-right: 10px; margin-right: 10px;
vertical-align:middle; vertical-align:middle;

@ -27,7 +27,7 @@ define('ICON_SIZE_HUGE', 128);
define('SHOW_TEXT_NEAR_ICONS', false); define('SHOW_TEXT_NEAR_ICONS', false);
/** /**
* Display class * Display class
* contains several public functions dealing with the display of * contains several public functions dealing with the display of
@ -37,27 +37,27 @@ define('SHOW_TEXT_NEAR_ICONS', false);
*/ */
class Display { class Display {
/* The main template*/ /* The main template*/
static $global_template; static $global_template;
static $preview_style = null; static $preview_style = null;
private function __construct() { private function __construct() {
} }
/** /**
* Displays the page header * Displays the page header
* @param string The name of the page (will be showed in the page title) * @param string The name of the page (will be showed in the page title)
* @param string Optional help file name * @param string Optional help file name
*/ */
public static function display_header($tool_name ='', $help = null, $page_header = null) { public static function display_header($tool_name ='', $help = null, $page_header = null) {
self::$global_template = new Template($tool_name); self::$global_template = new Template($tool_name);
self::$global_template->set_help($help); self::$global_template->set_help($help);
if (!empty(self::$preview_style)) { if (!empty(self::$preview_style)) {
self::$global_template->preview_theme = self::$preview_style; self::$global_template->preview_theme = self::$preview_style;
self::$global_template->set_css_files(); self::$global_template->set_css_files();
self::$global_template->set_js_files(); self::$global_template->set_js_files();
} }
if (!empty($page_header)) { if (!empty($page_header)) {
self::$global_template->assign('header', $page_header); self::$global_template->assign('header', $page_header);
@ -68,34 +68,34 @@ class Display {
/** /**
* Displays the reduced page header (without banner) * Displays the reduced page header (without banner)
*/ */
public static function display_reduced_header() { public static function display_reduced_header() {
global $show_learnpath, $tool_name; global $show_learnpath, $tool_name;
self::$global_template = new Template($tool_name, false, false, $show_learnpath); self::$global_template = new Template($tool_name, false, false, $show_learnpath);
echo self::$global_template ->show_header_template(); echo self::$global_template ->show_header_template();
} }
public static function display_no_header() { public static function display_no_header() {
global $tool_name; global $tool_name;
$disable_js_and_css_files = true; $disable_js_and_css_files = true;
self::$global_template = new Template($tool_name, false, false, $show_learnpath); self::$global_template = new Template($tool_name, false, false, $show_learnpath);
//echo self::$global_template->show_header_template(); //echo self::$global_template->show_header_template();
} }
/** /**
* Displays the reduced page header (without banner) * Displays the reduced page header (without banner)
*/ */
public static function set_header() { public static function set_header() {
global $show_learnpath; global $show_learnpath;
self::$global_template = new Template($tool_name, false, false, $show_learnpath); self::$global_template = new Template($tool_name, false, false, $show_learnpath);
} }
/** /**
* Display the page footer * Display the page footer
*/ */
public static function display_footer() { public static function display_footer() {
echo self::$global_template ->show_footer_template(); echo self::$global_template ->show_footer_template();
} }
public static function page() public static function page()
{ {
return new Page(); return new Page();
@ -113,7 +113,7 @@ class Display {
public static function display_introduction_section($tool, $editor_config = null) { public static function display_introduction_section($tool, $editor_config = null) {
echo self::return_introduction_section($tool, $editor_config); echo self::return_introduction_section($tool, $editor_config);
} }
public static function return_introduction_section($tool, $editor_config = null) { public static function return_introduction_section($tool, $editor_config = null) {
$is_allowed_to_edit = api_is_allowed_to_edit(); $is_allowed_to_edit = api_is_allowed_to_edit();
$moduleId = $tool; $moduleId = $tool;
@ -231,7 +231,7 @@ class Display {
global $origin; global $origin;
$column = 0; $column = 0;
$default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20; $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
$table = new SortableTableFromArray($content, $column, $default_items_per_page, $name); $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
if (is_array($query_vars)) { if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars); $table->set_additional_parameters($query_vars);
} }
@ -304,7 +304,7 @@ class Display {
/** /**
* Displays an warning message. Use this if you want to draw attention to something * Displays an warning message. Use this if you want to draw attention to something
* This can also be used for instance with the hint in the exercises * This can also be used for instance with the hint in the exercises
* *
*/ */
public static function display_warning_message($message, $filter = true) { public static function display_warning_message($message, $filter = true) {
echo self::return_message($message, 'warning', $filter); echo self::return_message($message, 'warning', $filter);
@ -329,11 +329,11 @@ class Display {
public static function display_error_message ($message, $filter = true) { public static function display_error_message ($message, $filter = true) {
echo self::return_message($message, 'error', $filter); echo self::return_message($message, 'error', $filter);
} }
public static function return_message_and_translate($message, $type='normal', $filter = true) { public static function return_message_and_translate($message, $type='normal', $filter = true) {
$message = get_lang($message); $message = get_lang($message);
echo self::return_message($message, $type, $filter); echo self::return_message($message, $type, $filter);
} }
/** /**
* Returns a div html string with * Returns a div html string with
@ -344,7 +344,7 @@ class Display {
*/ */
public static function return_message($message, $type='normal', $filter = true) { public static function return_message($message, $type='normal', $filter = true) {
if ($filter) { if ($filter) {
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding()); $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
//$message = Security::remove_XSS($message); //$message = Security::remove_XSS($message);
} }
$class = ""; $class = "";
@ -406,7 +406,7 @@ class Display {
// Return encrypted mailto hyperlink // Return encrypted mailto hyperlink
return '<a href="'.$hmail.'"'.$style_class.' class="clickable_email_link">'.$hclickable_text.'</a>'; return '<a href="'.$hmail.'"'.$style_class.' class="clickable_email_link">'.$hclickable_text.'</a>';
} }
/** /**
* Returns an mailto icon hyperlink * Returns an mailto icon hyperlink
* *
@ -449,7 +449,7 @@ class Display {
return '<a href="'.api_get_path(WEB_PATH).'index.php">'.$name.'</a>'; return '<a href="'.api_get_path(WEB_PATH).'index.php">'.$name.'</a>';
} }
/** /**
* Prints an <option>-list with all letters (A-Z). * Prints an <option>-list with all letters (A-Z).
@ -560,22 +560,22 @@ class Display {
* @version Feb 2011 * @version Feb 2011
*/ */
public static function return_icon($image, $alt_text = '', $additional_attributes = array(), $size = ICON_SIZE_SMALL, $show_text = true, $return_only_path = false) { public static function return_icon($image, $alt_text = '', $additional_attributes = array(), $size = ICON_SIZE_SMALL, $show_text = true, $return_only_path = false) {
$code_path = api_get_path(SYS_CODE_PATH); $code_path = api_get_path(SYS_CODE_PATH);
$w_code_path = api_get_path(WEB_CODE_PATH); $w_code_path = api_get_path(WEB_CODE_PATH);
$image = trim($image); $image = trim($image);
$theme = 'css/'.api_get_visual_theme().'/icons/'; $theme = 'css/'.api_get_visual_theme().'/icons/';
$icon = ''; $icon = '';
$size_extra = ''; $size_extra = '';
if (isset($size)) { if (isset($size)) {
$size = intval($size); $size = intval($size);
$size_extra = $size.'/'; $size_extra = $size.'/';
} else { } else {
$size = ICON_SIZE_SMALL; $size = ICON_SIZE_SMALL;
} }
//Checking the theme icons folder example: main/css/chamilo/icons/XXX //Checking the theme icons folder example: main/css/chamilo/icons/XXX
if (is_file($code_path.$theme.$size_extra.$image)) { if (is_file($code_path.$theme.$size_extra.$image)) {
$icon = $w_code_path.$theme.$size_extra.$image; $icon = $w_code_path.$theme.$size_extra.$image;
@ -584,13 +584,13 @@ class Display {
$icon = $w_code_path.'img/icons/'.$size_extra.$image; $icon = $w_code_path.'img/icons/'.$size_extra.$image;
} else { } else {
//Checking the img/ folder //Checking the img/ folder
$icon = $w_code_path.'img/'.$image; $icon = $w_code_path.'img/'.$image;
} }
$icon = api_get_cdn_path($icon); $icon = api_get_cdn_path($icon);
if ($return_only_path) { if ($return_only_path) {
return $icon; return $icon;
} }
$img = self::img($icon, $alt_text, $additional_attributes); $img = self::img($icon, $alt_text, $additional_attributes);
if (SHOW_TEXT_NEAR_ICONS == true and !empty($alt_text)) { if (SHOW_TEXT_NEAR_ICONS == true and !empty($alt_text)) {
if ($show_text) { if ($show_text) {
@ -696,7 +696,7 @@ class Display {
} }
return self::tag('input', '', $extra_attributes); return self::tag('input', '', $extra_attributes);
} }
public static function button($name, $value, $extra_attributes = array()) { public static function button($name, $value, $extra_attributes = array()) {
if (!empty($name)) { if (!empty($name)) {
$extra_attributes['name']= $name; $extra_attributes['name']= $name;
@ -720,21 +720,21 @@ class Display {
} }
$html .= '<select name="'.$name.'" '.$default_id.' '.$extra.'>'; $html .= '<select name="'.$name.'" '.$default_id.' '.$extra.'>';
if ($show_blank_item) { if ($show_blank_item) {
if (empty($blank_item_text)) { if (empty($blank_item_text)) {
$blank_item_text = get_lang('Select'); $blank_item_text = get_lang('Select');
} else { } else {
$blank_item_text = Security::remove_XSS($blank_item_text); $blank_item_text = Security::remove_XSS($blank_item_text);
} }
$html .= self::tag('option', '-- '.$blank_item_text.' --', array('value'=>'-1')); $html .= self::tag('option', '-- '.$blank_item_text.' --', array('value'=>'-1'));
} }
if ($values) { if ($values) {
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
if(is_array($value) && isset($value['name'])) { if(is_array($value) && isset($value['name'])) {
$value = $value['name']; $value = $value['name'];
} }
$html .= '<option value="'.$key.'"'; $html .= '<option value="'.$key.'"';
if (is_array($default)) { if (is_array($default)) {
foreach($default as $item) { foreach($default as $item) {
if ($item == $key) { if ($item == $key) {
@ -747,7 +747,7 @@ class Display {
$html .= 'selected="selected"'; $html .= 'selected="selected"';
} }
} }
$html .= '>'.$value.'</option>'; $html .= '>'.$value.'</option>';
} }
} }
@ -797,7 +797,7 @@ class Display {
$main_div = self::tag('div',$ul.$divs, $attributes); $main_div = self::tag('div',$ul.$divs, $attributes);
return $main_div ; return $main_div ;
} }
public static function tabs_only_link($header_list, $selected = null) { public static function tabs_only_link($header_list, $selected = null) {
$id = uniqid(); $id = uniqid();
$i = 1; $i = 1;
@ -806,12 +806,12 @@ class Display {
$class = null; $class = null;
if ($i == $selected) { if ($i == $selected) {
$class = 'active'; $class = 'active';
} }
$item =self::tag('a', $item['content'], array('id'=>$id.'-'.$i, 'href' => $item['url'])); $item =self::tag('a', $item['content'], array('id'=>$id.'-'.$i, 'href' => $item['url']));
$lis .=self::tag('li', $item, array('class' => $class)); $lis .=self::tag('li', $item, array('class' => $class));
$i++; $i++;
} }
return self::tag('ul',$lis, array('class' => 'nav nav-tabs')); return self::tag('ul',$lis, array('class' => 'nav nav-tabs'));
} }
/** /**
@ -834,7 +834,7 @@ class Display {
$table .= self::tag('div','',array('id'=>$div_id.'_pager')); $table .= self::tag('div','',array('id'=>$div_id.'_pager'));
return $table; return $table;
} }
public static function form_row($label, $form_item) { public static function form_row($label, $form_item) {
$label = self::span($label, array('class' =>'control-label')); $label = self::span($label, array('class' =>'control-label'));
$form_item = self::div($form_item, array('class' =>'controls')); $form_item = self::div($form_item, array('class' =>'controls'));
@ -869,13 +869,13 @@ class Display {
$obj->pager = '#'.$div_id.'_pager'; $obj->pager = '#'.$div_id.'_pager';
$obj->datatype = 'json'; $obj->datatype = 'json';
//Default row quantity //Default row quantity
if (!isset($extra_params['rowList'])) { if (!isset($extra_params['rowList'])) {
$extra_params['rowList'] = array(20, 50, 100, 500, 1000); $extra_params['rowList'] = array(20, 50, 100, 500, 1000);
//$extra_params['rowList'] = array(20, 50, 100, 500, 1000, 2000, 5000, 10000); //$extra_params['rowList'] = array(20, 50, 100, 500, 1000, 2000, 5000, 10000);
} }
$json = ''; $json = '';
if (!empty($extra_params['datatype'])) { if (!empty($extra_params['datatype'])) {
$obj->datatype = $extra_params['datatype']; $obj->datatype = $extra_params['datatype'];
@ -929,7 +929,7 @@ class Display {
} }
$json_encode = json_encode($obj); $json_encode = json_encode($obj);
if (!empty($data)) { if (!empty($data)) {
//Converts the "data":"js_variable" to "data":js_variable othersiwe it will not work //Converts the "data":"js_variable" to "data":js_variable othersiwe it will not work
$json_encode = str_replace('"data":"'.$data_var.'"','"data":'.$data_var.'',$json_encode); $json_encode = str_replace('"data":"'.$data_var.'"','"data":'.$data_var.'',$json_encode);
@ -994,7 +994,7 @@ class Display {
} }
public static function table($headers, $rows, $attributes = array()) { public static function table($headers, $rows, $attributes = array()) {
if (empty($attributes)) { if (empty($attributes)) {
$attributes['class'] = 'data_table'; $attributes['class'] = 'data_table';
} }
@ -1012,7 +1012,7 @@ class Display {
$row = 1; $row = 1;
$column = 0; $column = 0;
} }
if (!empty($rows)) { if (!empty($rows)) {
foreach($rows as $content) { foreach($rows as $content) {
$table->setCellContents($row, $column, $content); $table->setCellContents($row, $column, $content);
@ -1035,21 +1035,21 @@ class Display {
* @param array Course information array, containing at least elements 'db' and 'k' * @param array Course information array, containing at least elements 'db' and 'k'
* @return string The HTML link to be shown next to the course * @return string The HTML link to be shown next to the course
*/ */
public static function show_notification($course_info) { public static function show_notification($course_info) {
$t_track_e_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); $t_track_e_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY); $tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_code = Database::escape_string($course_info['code']); $course_code = Database::escape_string($course_info['code']);
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
$course_info['id_session'] = intval($course_info['id_session']); $course_info['id_session'] = intval($course_info['id_session']);
// Get the user's last access dates to all tools of this course // Get the user's last access dates to all tools of this course
$sqlLastTrackInCourse = "SELECT * FROM $t_track_e_access USE INDEX (access_cours_code, access_user_id) $sqlLastTrackInCourse = "SELECT * FROM $t_track_e_access USE INDEX (access_cours_code, access_user_id)
WHERE access_cours_code = '".$course_code."' AND WHERE access_cours_code = '".$course_code."' AND
access_user_id = '$user_id' AND access_user_id = '$user_id' AND
access_session_id ='".$course_info['id_session']."'"; access_session_id ='".$course_info['id_session']."'";
$resLastTrackInCourse = Database::query($sqlLastTrackInCourse); $resLastTrackInCourse = Database::query($sqlLastTrackInCourse);
@ -1080,7 +1080,7 @@ class Display {
" ctt.image image, ctt.link link ". " ctt.image image, ctt.link link ".
" FROM $tool_edit_table tet, $course_tool_table ctt ". " FROM $tool_edit_table tet, $course_tool_table ctt ".
" WHERE tet.c_id = $course_id AND " WHERE tet.c_id = $course_id AND
ctt.c_id = $course_id AND ctt.c_id = $course_id AND
tet.lastedit_date > '$oldestTrackDate' ". tet.lastedit_date > '$oldestTrackDate' ".
" AND ctt.name = tet.tool ". " AND ctt.name = tet.tool ".
" AND ctt.visibility = '1' ". " AND ctt.visibility = '1' ".
@ -1140,7 +1140,7 @@ class Display {
$retvalue = '&nbsp;'; $retvalue = '&nbsp;';
while (list($key, $notification) = each($notifications)) { while (list($key, $notification) = each($notifications)) {
$lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date'])); $lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date']));
$type = $notification['lastedit_type']; $type = $notification['lastedit_type'];
if (empty($course_info['id_session'])) { if (empty($course_info['id_session'])) {
$my_course['id_session'] = 0; $my_course['id_session'] = 0;
} else { } else {
@ -1244,7 +1244,7 @@ class Display {
$output = array(); $output = array();
if (!$nosession) { if (!$nosession) {
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$active = false; $active = false;
// Request for the name of the general coach // Request for the name of the general coach
$sql ='SELECT tu.lastname, tu.firstname, ts.name, ts.date_start, ts.date_end, ts.session_category_id $sql ='SELECT tu.lastname, tu.firstname, ts.name, ts.date_start, ts.date_end, ts.session_category_id
@ -1257,7 +1257,7 @@ class Display {
$session['title'] = $session_info[2]; $session['title'] = $session_info[2];
$session['coach'] = ''; $session['coach'] = '';
$session['dates'] = ''; $session['dates'] = '';
if ($session_info['date_end'] == '0000-00-00' && $session_info['date_start'] == '0000-00-00') { if ($session_info['date_end'] == '0000-00-00' && $session_info['date_start'] == '0000-00-00') {
if (api_get_setting('show_session_coach') === 'true') { if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($session_info[1], $session_info[0]); $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($session_info[1], $session_info[0]);
@ -1300,8 +1300,8 @@ class Display {
/** /**
* Return the five star HTML * Return the five star HTML
* *
* @param string id of the rating ul element * @param string id of the rating ul element
* @param string url that will be added (for jquery see hot_courses.tpl) * @param string url that will be added (for jquery see hot_courses.tpl)
* @param string point info array see function CourseManager::get_course_ranking() * @param string point info array see function CourseManager::get_course_ranking()
* @param bool add a div wrapper * @param bool add a div wrapper
@ -1309,16 +1309,16 @@ class Display {
**/ **/
public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true) { public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true) {
$number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null; $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null;
$percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0; $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0;
if (!empty($percentage)) { if (!empty($percentage)) {
$percentage = $percentage*125/100; $percentage = $percentage*125/100;
} }
$accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0; $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0;
$star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']); $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']);
$html = '<ul id="'.$id.'" class="star-rating"> $html = '<ul id="'.$id.'" class="star-rating">
<li class="current-rating" style="width:'.$percentage.'px;"></li> <li class="current-rating" style="width:'.$percentage.'px;"></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=1" title="'.$star_label.'" class="one-star">1</a></li> <li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=1" title="'.$star_label.'" class="one-star">1</a></li>
@ -1327,34 +1327,34 @@ class Display {
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=4" title="'.$star_label.'" class="four-stars">4</a></li> <li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=4" title="'.$star_label.'" class="four-stars">4</a></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=5" title="'.$star_label.'" class="five-stars">5</a></li> <li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=5" title="'.$star_label.'" class="five-stars">5</a></li>
</ul>'; </ul>';
$labels = array(); $labels = array();
$labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); $labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
$labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits'); $labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits');
if (!empty($number_of_users_who_voted)) { if (!empty($number_of_users_who_voted)) {
$labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5'; $labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5';
} }
$labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] '; $labels[]= $point_info['user_vote'] ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] ';
if (!$add_div_wrapper && api_is_anonymous()) { if (!$add_div_wrapper && api_is_anonymous()) {
$labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error')); $labels[]= Display::tag('span', get_lang('LoginToVote'), array('class' => 'error'));
} }
$html .= Display::span(implode(' | ', $labels) , array('id' => 'vote_label_'.$id, 'class' => 'vote_label_info')); $html .= Display::span(implode(' | ', $labels) , array('id' => 'vote_label_'.$id, 'class' => 'vote_label_info'));
$html .= ' '.Display::span(' ', array('id' => 'vote_label2_'.$id)); $html .= ' '.Display::span(' ', array('id' => 'vote_label2_'.$id));
if ($add_div_wrapper) { if ($add_div_wrapper) {
$html = Display::div($html, array('id' => 'rating_wrapper_'.$id)); $html = Display::div($html, array('id' => 'rating_wrapper_'.$id));
} }
return $html; return $html;
} }
public static function return_default_table_class() { public static function return_default_table_class() {
return 'data_table'; return 'data_table';
} }
public static function page_header($title, $second_title = null, $size = 'h1') { public static function page_header($title, $second_title = null, $size = 'h1') {
$title = Security::remove_XSS($title); $title = Security::remove_XSS($title);
if (!empty($second_title)) { if (!empty($second_title)) {
@ -1363,17 +1363,17 @@ class Display {
} }
return '<div class="page-header"><'.$size.'>'.$title.'</'.$size.'></div>'; return '<div class="page-header"><'.$size.'>'.$title.'</'.$size.'></div>';
} }
public static function page_header_and_translate($title, $second_title = null) { public static function page_header_and_translate($title, $second_title = null) {
$title = get_lang($title); $title = get_lang($title);
return self::page_header($title, $second_title); return self::page_header($title, $second_title);
} }
public static function page_subheader_and_translate($title, $second_title = null) { public static function page_subheader_and_translate($title, $second_title = null) {
$title = get_lang($title); $title = get_lang($title);
return self::page_subheader($title, $second_title); return self::page_subheader($title, $second_title);
} }
public static function page_subheader($title, $second_title = null) { public static function page_subheader($title, $second_title = null) {
if (!empty($second_title)) { if (!empty($second_title)) {
$second_title = Security::remove_XSS($second_title); $second_title = Security::remove_XSS($second_title);
@ -1381,15 +1381,15 @@ class Display {
} }
return '<div class="page-header"><h2>'.Security::remove_XSS($title).'</h2></div>'; return '<div class="page-header"><h2>'.Security::remove_XSS($title).'</h2></div>';
} }
public static function page_subheader2($title, $second_title = null) { public static function page_subheader2($title, $second_title = null) {
return self::page_header($title, $second_title, 'h3'); return self::page_header($title, $second_title, 'h3');
} }
public static function page_subheader3($title, $second_title = null) { public static function page_subheader3($title, $second_title = null) {
return self::page_header($title, $second_title, 'h4'); return self::page_header($title, $second_title, 'h4');
} }
public static function description($list) { public static function description($list) {
$html = null; $html = null;
if (!empty($list)) { if (!empty($list)) {
@ -1402,25 +1402,25 @@ class Display {
} }
return $html; return $html;
} }
public static function bar_progress($percentage, $show_percentage = true, $extra_info = null) { public static function bar_progress($percentage, $show_percentage = true, $extra_info = null) {
$percentage = intval($percentage); $percentage = intval($percentage);
$div = '<div class="progress progress-striped"> $div = '<div class="progress progress-striped">
<div class="bar" style="width: '.$percentage.'%;"></div> <div class="bar" style="width: '.$percentage.'%;"></div>
</div>'; </div>';
if ($show_percentage) { if ($show_percentage) {
$div .= '<div class="progresstext">'.$percentage.'%</div>'; $div .= '<div class="progresstext">'.$percentage.'%</div>';
} else { } else {
if (!empty($extra_info)) { if (!empty($extra_info)) {
$div .= '<div class="progresstext">'.$extra_info.'</div>'; $div .= '<div class="progresstext">'.$extra_info.'</div>';
} }
} }
return $div; return $div;
} }
public static function badge($count, $type ="warning") { public static function badge($count, $type ="warning") {
$class = ''; $class = '';
switch ($type) { switch ($type) {
case 'success': case 'success':
$class = 'badge-success'; $class = 'badge-success';
@ -1436,15 +1436,15 @@ class Display {
break; break;
case 'inverse': case 'inverse':
$class = 'badge-inverse'; $class = 'badge-inverse';
break; break;
} }
if (!empty($count)) { if (!empty($count)) {
return ' <span class="badge '.$class.'">'.$count.'</span>'; return ' <span class="badge '.$class.'">'.$count.'</span>';
} }
return null; return null;
} }
public static function badge_group($badge_list) { public static function badge_group($badge_list) {
$html = '<div class="badge-group">'; $html = '<div class="badge-group">';
foreach ($badge_list as $badge) { foreach ($badge_list as $badge) {
@ -1453,8 +1453,8 @@ class Display {
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
} }
public static function label($content, $type = null) { public static function label($content, $type = null) {
$class = ''; $class = '';
switch ($type) { switch ($type) {
case 'success': case 'success':
@ -1471,36 +1471,36 @@ class Display {
break; break;
case 'inverse': case 'inverse':
$class = 'label-inverse'; $class = 'label-inverse';
break; break;
} }
$html = ''; $html = '';
if (!empty($content)) { if (!empty($content)) {
$html = '<span class="label '.$class.'">'; $html = '<span class="label '.$class.'">';
$html .= $content; $html .= $content;
$html .='</span>'; $html .='</span>';
} }
return $html; return $html;
} }
public static function actions($items) { public static function actions($items) {
$html = null; $html = null;
if (!empty($items)) { if (!empty($items)) {
$html = '<div class="new_actions"><ul class="nav nav-pills">'; $html = '<div class="new_actions"><ul class="nav nav-pills">';
foreach ($items as $value) { foreach ($items as $value) {
$class = null; $class = null;
if (isset($value['active']) && $value['active']) { if (isset($value['active']) && $value['active']) {
$class = 'class ="active"'; $class = 'class ="active"';
} }
$html .= "<li $class >"; $html .= "<li $class >";
$html .= self::url($value['content'], $value['url']); $html .= self::url($value['content'], $value['url']);
$html .= '</li>'; $html .= '</li>';
} }
$html .= '</ul></div>'; $html .= '</ul></div>';
} }
return $html; return $html;
} }
/** /**
* Prints a tooltip * Prints a tooltip
*/ */
@ -1510,18 +1510,18 @@ class Display {
} }
return self::span($text, array('class' => 'boot-tooltip', 'title' => strip_tags($tip))); return self::span($text, array('class' => 'boot-tooltip', 'title' => strip_tags($tip)));
} }
public static function generate_accordion($items) { public static function generate_accordion($items) {
$html = null; $html = null;
if (!empty($items)) { if (!empty($items)) {
$id = api_get_unique_id(); $id = api_get_unique_id();
//$html = '<div class="accordion" id="'.$id.'">'; //using bootstrap //$html = '<div class="accordion" id="'.$id.'">'; //using bootstrap
$html = '<div class="accordion_jquery" id="'.$id.'">'; //using jquery $html = '<div class="accordion_jquery" id="'.$id.'">'; //using jquery
$count = 1; $count = 1;
foreach ($items as $item) { foreach ($items as $item) {
$html .= '<div class="accordion-my-group">'; $html .= '<div class="accordion-my-group">';
$html .= '<div class="accordion-heading"> $html .= '<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#'.$id.'" href="#collapse'.$count.'"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#'.$id.'" href="#collapse'.$count.'">
'.$item['title'].' '.$item['title'].'
@ -1529,7 +1529,7 @@ class Display {
</div>'; </div>';
//$html .= '<div id="collapse'.$count.'" class="accordion-body collapse in"> //$html .= '<div id="collapse'.$count.'" class="accordion-body collapse in">
$html .= '<div id="collapse'.$count.'" class="accordion-body">'; $html .= '<div id="collapse'.$count.'" class="accordion-body">';
//$html .= '<div class="accordion-inner"> //$html .= '<div class="accordion-inner">
$html .= '<div class="accordion-my-inner"> $html .= '<div class="accordion-my-inner">
'.$item['content'].' '.$item['content'].'
@ -1540,4 +1540,20 @@ class Display {
} }
return $html; return $html;
} }
/**
* @todo use twig
*/
static function group_button($title, $elements) {
$html = '<div class="btn-toolbar">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">'.$title.' <span class="caret"></span></button>
<ul class="dropdown-menu">';
foreach ($elements as $item) {
$html .= Display::tag('li', Display::url($item['title'], $item['href']));
}
$html .= '</ul>
</div> </div>';
return $html;
}
} //end class Display } //end class Display

@ -113,6 +113,8 @@ class learnpath {
} }
} }
$this->set_course_int_id($course_id);
// Check learnpath ID. // Check learnpath ID.
if (empty($lp_id)) { if (empty($lp_id)) {
$this->error = 'Learnpath ID is empty'; $this->error = 'Learnpath ID is empty';
@ -3606,7 +3608,6 @@ class learnpath {
$prereq_string = $this->items[$item]->get_prereq_string(); $prereq_string = $this->items[$item]->get_prereq_string();
} }
if (empty($prereq_string)) { if (empty($prereq_string)) {
return true; return true;
} }
@ -4232,7 +4233,7 @@ class learnpath {
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - lp updated with new preview requisite : ' . $this->requisite, 0); error_log('New LP - lp updated with new preview requisite : ' . $this->requisite, 0);
} }
$res = Database::query($sql); Database::query($sql);
return true; return true;
} }
@ -5306,6 +5307,18 @@ class learnpath {
$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '&amp;updateaudio=true">' . Display :: return_icon('upload_audio.png', get_lang('UpdateAllAudioFragments'),'',ICON_SIZE_MEDIUM).'</a>'; $return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '&amp;updateaudio=true">' . Display :: return_icon('upload_audio.png', get_lang('UpdateAllAudioFragments'),'',ICON_SIZE_MEDIUM).'</a>';
$return .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=edit&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display :: return_icon('settings.png', get_lang('CourseSettings'),'',ICON_SIZE_MEDIUM).'</a>'; $return .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=edit&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display :: return_icon('settings.png', get_lang('CourseSettings'),'',ICON_SIZE_MEDIUM).'</a>';
$buttons = array(
array(
'title' => get_lang('SetPrerequisiteFoEachItem'),
'href' => 'lp_controller.php?'.api_get_cidreq().'&amp;action=set_previous_step_as_prerequisite&amp;lp_id=' . $_SESSION['oLP']->lp_id,
),
array(
'title' => get_lang('Clear all prerequisites'),
'href' => 'lp_controller.php?'.api_get_cidreq().'&amp;action=clear_prerequisites&amp;lp_id=' . $_SESSION['oLP']->lp_id,
),
);
$return .= Display::group_button(get_lang('PrerequisitesOptions'), $buttons);
$return .= '</div>'; $return .= '</div>';
echo $return; echo $return;
} }
@ -9219,6 +9232,50 @@ EOD;
return false; return false;
} }
} }
function clear_prerequisites() {
$course_id = $this->get_course_int_id();
if ($this->debug > 0) {
error_log('New LP - In learnpath::clear_prerequisites()', 0);
}
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$lp_id = $this->get_id();
//Cleaning prerequisites
$sql = "UPDATE $tbl_lp_item SET prerequisite = ''
WHERE c_id = ".$course_id." AND lp_id = '$lp_id'";
Database::query($sql);
//Cleaning mastery score for exercises
$sql = "UPDATE $tbl_lp_item SET mastery_score = ''
WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND item_type = 'quiz'";
Database::query($sql);
}
function set_previous_step_as_prerequisite_for_all_items() {
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$course_id = $this->get_course_int_id();
$lp_id = $this->get_id();
if (!empty($this->items)) {
$old_id = null;
$old_max = 0;
$old_type = null;
foreach ($this->items as $item) {
if (!empty($old_id)) {
$current_item_id = $item->get_id();
if ($old_type == 'quiz') {
$sql = "UPDATE $tbl_lp_item SET mastery_score = '$old_max' WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$old_id'";
Database::query($sql);
}
$sql = "UPDATE $tbl_lp_item SET prerequisite = '$old_id' WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$current_item_id'";
Database::query($sql);
}
$old_id = $item->get_id();
$old_max = $item->get_max();
$old_type = $item->get_type();
}
}
}
} }
if (!function_exists('trim_value')) { if (!function_exists('trim_value')) {

@ -135,7 +135,6 @@ if (isset($_SESSION['lpobject'])) {
} }
} }
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if ($debug>0) error_log('New LP - Passed data remains check', 0); if ($debug>0) error_log('New LP - Passed data remains check', 0);
@ -972,6 +971,16 @@ switch ($action) {
require 'lp_impress.php'; require 'lp_impress.php';
} }
break; break;
case 'set_previous_step_as_prerequisite':
$_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
break;
case 'clear_prerequisites':
$_SESSION['oLP']->clear_prerequisites();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
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);
//$_SESSION['refresh'] = 1; //$_SESSION['refresh'] = 1;

Loading…
Cancel
Save