Minor - Format code

pull/2487/head
jmontoyaa 9 years ago
parent eae736c491
commit e7fba9424a
  1. 65
      main/lp/learnpath.class.php
  2. 26
      main/lp/lp_list.php

@ -3141,11 +3141,11 @@ class learnpath
$list['id'] = $item['id']; $list['id'] = $item['id'];
$list['status'] = $item['status']; $list['status'] = $item['status'];
$cssStatus = null; $cssStatus = null;
if (isset($classStatus[$item['status']])) { if (isset($classStatus[$item['status']])) {
$cssStatus = $classStatus[$item['status']]; $cssStatus = $classStatus[$item['status']];
} }
$classStyle = ' '; $classStyle = ' ';
$dirTypes = self::getChapterTypes(); $dirTypes = self::getChapterTypes();
@ -3162,13 +3162,13 @@ class learnpath
$title = self::rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']); $title = self::rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
} }
$title = Security::remove_XSS($item['title']); $title = Security::remove_XSS($item['title']);
if (empty($item['description'])) { if (empty($item['description'])) {
$list['description'] = $title; $list['description'] = $title;
} else { } else {
$list['description'] = $item['description']; $list['description'] = $item['description'];
} }
$list['class'] = $classStyle.' '.$cssStatus; $list['class'] = $classStyle.' '.$cssStatus;
$list['level'] = $item['level']; $list['level'] = $item['level'];
$list['type'] = $item['type']; $list['type'] = $item['type'];
@ -3190,7 +3190,7 @@ class learnpath
} }
$arrayList[] = $list; $arrayList[] = $list;
} }
return $arrayList; return $arrayList;
} }
@ -3853,22 +3853,23 @@ class learnpath
} }
/** /**
* Move a learnpath up (display_order) * Move a LP up (display_order)
* @param integer $lp_id Learnpath ID * @param integer $lp_id Learnpath ID
* @return bool
*/ */
public static function move_up($lp_id) public static function move_up($lp_id)
{ {
$course_id = api_get_course_int_id(); $courseId = api_get_course_int_id();
$lp_table = Database::get_course_table(TABLE_LP_MAIN); $lp_table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT * FROM $lp_table $sql = "SELECT * FROM $lp_table
WHERE c_id = $course_id WHERE c_id = $courseId
ORDER BY display_order"; ORDER BY display_order";
$res = Database::query($sql); $res = Database::query($sql);
if ($res === false) { if ($res === false) {
return false; return false;
} }
$lps = array (); $lps = [];
$lp_order = array(); $lp_order = [];
$num = Database::num_rows($res); $num = Database::num_rows($res);
// First check the order is correct, globally (might be wrong because // First check the order is correct, globally (might be wrong because
// of versions < 1.8.4) // of versions < 1.8.4)
@ -3876,10 +3877,9 @@ class learnpath
$i = 1; $i = 1;
while ($row = Database::fetch_array($res)) { while ($row = Database::fetch_array($res)) {
if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it. if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it.
$need_fix = true; $sql = "UPDATE $lp_table SET display_order = $i
$sql_u = "UPDATE $lp_table SET display_order = $i WHERE c_id = $courseId AND id = ".$row['id'];
WHERE c_id = ".$course_id." AND id = " . $row['id']; Database::query($sql);
Database::query($sql_u);
} }
$row['display_order'] = $i; $row['display_order'] = $i;
$lps[$row['id']] = $row; $lps[$row['id']] = $row;
@ -3890,19 +3890,22 @@ class learnpath
if ($num > 1) { // If there's only one element, no need to sort. if ($num > 1) { // If there's only one element, no need to sort.
$order = $lps[$lp_id]['display_order']; $order = $lps[$lp_id]['display_order'];
if ($order > 1) { // If it's the first element, no need to move up. if ($order > 1) { // If it's the first element, no need to move up.
$sql_u1 = "UPDATE $lp_table SET display_order = $order $sql = "UPDATE $lp_table SET display_order = $order
WHERE c_id = ".$course_id." AND id = " . $lp_order[$order - 1]; WHERE c_id = $courseId AND id = ".$lp_order[$order - 1];
Database::query($sql_u1); Database::query($sql);
$sql_u2 = "UPDATE $lp_table SET display_order = " . ($order - 1) . " $sql = "UPDATE $lp_table SET display_order = ".($order - 1)."
WHERE c_id = ".$course_id." AND id = " . $lp_id; WHERE c_id = $courseId AND id = ".$lp_id;
Database::query($sql_u2); Database::query($sql);
} }
} }
return true;
} }
/** /**
* Move a learnpath down (display_order) * Move a learnpath down (display_order)
* @param integer $lp_id Learnpath ID * @param integer $lp_id Learnpath ID
* @return bool
*/ */
public static function move_down($lp_id) public static function move_down($lp_id)
{ {
@ -3915,8 +3918,8 @@ class learnpath
if ($res === false) { if ($res === false) {
return false; return false;
} }
$lps = array(); $lps = [];
$lp_order = array(); $lp_order = [];
$num = Database::num_rows($res); $num = Database::num_rows($res);
$max = 0; $max = 0;
// First check the order is correct, globally (might be wrong because // First check the order is correct, globally (might be wrong because
@ -3928,7 +3931,7 @@ class learnpath
if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it. if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it.
$need_fix = true; $need_fix = true;
$sql_u = "UPDATE $lp_table SET display_order = $i $sql_u = "UPDATE $lp_table SET display_order = $i
WHERE c_id = ".$course_id." AND id = " . $row['id']; WHERE c_id = ".$course_id." AND id = ".$row['id'];
Database::query($sql_u); Database::query($sql_u);
} }
$row['display_order'] = $i; $row['display_order'] = $i;
@ -3941,13 +3944,15 @@ class learnpath
$order = $lps[$lp_id]['display_order']; $order = $lps[$lp_id]['display_order'];
if ($order < $max) { // If it's the first element, no need to move up. if ($order < $max) { // If it's the first element, no need to move up.
$sql_u1 = "UPDATE $lp_table SET display_order = $order $sql_u1 = "UPDATE $lp_table SET display_order = $order
WHERE c_id = ".$course_id." AND id = " . $lp_order[$order + 1]; WHERE c_id = ".$course_id." AND id = ".$lp_order[$order + 1];
Database::query($sql_u1); Database::query($sql_u1);
$sql_u2 = "UPDATE $lp_table SET display_order = " . ($order + 1) . " $sql_u2 = "UPDATE $lp_table SET display_order = ".($order + 1)."
WHERE c_id = ".$course_id." AND id = " . $lp_id; WHERE c_id = ".$course_id." AND id = ".$lp_id;
Database::query($sql_u2); Database::query($sql_u2);
} }
} }
return true;
} }
/** /**
@ -8785,7 +8790,7 @@ class learnpath
$return .= '<div class="radio learnpath"><label for="idNone">'; $return .= '<div class="radio learnpath"><label for="idNone">';
$return .= '<input checked="checked" id="idNone" name="prerequisites" type="radio" />'; $return .= '<input checked="checked" id="idNone" name="prerequisites" type="radio" />';
$return .= get_lang('None') . '</label>'; $return .= get_lang('None') . '</label>';
$return .= '</div>'; $return .= '</div>';
$return .= '</tr>'; $return .= '</tr>';
$sql = "SELECT * FROM $tbl_lp_item $sql = "SELECT * FROM $tbl_lp_item
@ -8839,7 +8844,7 @@ class learnpath
$return .= '<div style="margin-left:' . $item['depth'] * 20 . 'px;" class="radio learnpath">'; $return .= '<div style="margin-left:' . $item['depth'] * 20 . 'px;" class="radio learnpath">';
$return .= '<label for="id' . $item['id'] . '">'; $return .= '<label for="id' . $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" 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" type="radio" value="' . $item['id'] . '" />';
$icon_name = str_replace(' ', '', $item['item_type']); $icon_name = str_replace(' ', '', $item['item_type']);
if (file_exists('../img/lp_' . $icon_name . '.png')) { if (file_exists('../img/lp_' . $icon_name . '.png')) {

@ -52,7 +52,6 @@ if (api_get_setting('search_enabled') === 'true') {
$current_session = api_get_session_id(); $current_session = api_get_session_id();
/* Introduction section (editable by course admins) */ /* Introduction section (editable by course admins) */
$introductionSection = Display::return_introduction_section( $introductionSection = Display::return_introduction_section(
TOOL_LEARNPATH, TOOL_LEARNPATH,
array( array(
@ -126,7 +125,6 @@ if (!empty($categoriesTempList)) {
$userId = api_get_user_id(); $userId = api_get_user_id();
$userInfo = api_get_user_info(); $userInfo = api_get_user_info();
$lpIsShown = false; $lpIsShown = false;
$test_mode = api_get_setting('server_type'); $test_mode = api_get_setting('server_type');
@ -228,7 +226,6 @@ foreach ($categories as $item) {
); );
$now = time(); $now = time();
$is_actived_time = false; $is_actived_time = false;
if ($now > $start_time && $end_time > $now) { if ($now > $start_time && $end_time > $now) {
$is_actived_time = true; $is_actived_time = true;
} }
@ -267,7 +264,7 @@ foreach ($categories as $item) {
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {
$url_start_lp .= '&isStudentView=true'; $url_start_lp .= '&isStudentView=true';
$dsp_desc = '<em>'.$details['lp_maker'].'</em> '.($lpVisibility ? '' : ' - ('.get_lang('LPNotVisibleToStudent').')'); $dsp_desc = '<em>'.$details['lp_maker'].'</em> '.($lpVisibility ? '' : ' - ('.get_lang('LPNotVisibleToStudent').')');
$extra = '<div class ="lp_content_type_label">'.$dsp_desc.'</div>'; $extra = '<div class ="lp_content_type_label">'.$dsp_desc.'</div>';
} }
@ -397,7 +394,6 @@ foreach ($categories as $item) {
} }
/* VISIBILITY COMMAND */ /* VISIBILITY COMMAND */
/* Session test not necessary if we want to show base course learning /* Session test not necessary if we want to show base course learning
paths inside the session. paths inside the session.
See http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions). See http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions).
@ -416,7 +412,7 @@ foreach ($categories as $item) {
} }
} }
//Tracking command // Tracking command
$trackingActionUrl = 'lp_controller.php?' $trackingActionUrl = 'lp_controller.php?'
. api_get_cidreq().'&' . api_get_cidreq().'&'
. http_build_query([ . http_build_query([
@ -425,7 +421,12 @@ foreach ($categories as $item) {
]); ]);
$trackingAction = Display::url( $trackingAction = Display::url(
Display::return_icon('test_results.png', get_lang('Results'), array(), ICON_SIZE_SMALL), Display::return_icon(
'test_results.png',
get_lang('Results'),
array(),
ICON_SIZE_SMALL
),
$trackingActionUrl $trackingActionUrl
); );
@ -469,14 +470,14 @@ foreach ($categories as $item) {
} }
/* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE /* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE
SERIOUSGAME MODE is a special mode where : SERIOUSGAME MODE is a special mode where :
* If a user exits the learning path before finishing it, he comes back where he left next time he tries * If a user exits the learning path before finishing it, he comes back where he left next time he tries
* When lp status is completed, user can still modify the attempt (adds/time change score, and browse it) * When lp status is completed, user can still modify the attempt (adds/time change score, and browse it)
* It is thus a mix betwenn multiple attempt and mono attempt * It is thus a mix betwenn multiple attempt and mono attempt
*/ */
if ($current_session == $details['lp_session']) { if ($current_session == $details['lp_session']) {
if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) {
// seriousgame mode | next = single
$dsp_reinit = Display::url( $dsp_reinit = Display::url(
Display::return_icon( Display::return_icon(
'reload.png', 'reload.png',
@ -487,7 +488,8 @@ foreach ($categories as $item) {
"lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id" "lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id"
); );
} }
if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) { //single mode | next = multiple if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) {
// single mode | next = multiple
$dsp_reinit = Display::url( $dsp_reinit = Display::url(
Display::return_icon( Display::return_icon(
'reload_na.png', 'reload_na.png',
@ -498,7 +500,8 @@ foreach ($categories as $item) {
"lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id" "lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id"
); );
} }
if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) {
// multiple mode | next = seriousgame
$dsp_reinit = Display::url( $dsp_reinit = Display::url(
Display::return_icon( Display::return_icon(
'reload.png', 'reload.png',
@ -657,7 +660,6 @@ foreach ($categories as $item) {
// Subscribe users // Subscribe users
$subscribeUsers = null; $subscribeUsers = null;
if ($details['subscribe_users'] == 1) { if ($details['subscribe_users'] == 1) {
$subscribeUsers = Display::url( $subscribeUsers = Display::url(
Display::return_icon('user.png', get_lang('SubscribeUsersToLp')), Display::return_icon('user.png', get_lang('SubscribeUsersToLp')),

Loading…
Cancel
Save