Minor - Format code

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

@ -3853,22 +3853,23 @@ class learnpath
}
/**
* Move a learnpath up (display_order)
* Move a LP up (display_order)
* @param integer $lp_id Learnpath ID
* @return bool
*/
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);
$sql = "SELECT * FROM $lp_table
WHERE c_id = $course_id
WHERE c_id = $courseId
ORDER BY display_order";
$res = Database::query($sql);
if ($res === false) {
return false;
}
$lps = array ();
$lp_order = array();
$lps = [];
$lp_order = [];
$num = Database::num_rows($res);
// First check the order is correct, globally (might be wrong because
// of versions < 1.8.4)
@ -3876,10 +3877,9 @@ class learnpath
$i = 1;
while ($row = Database::fetch_array($res)) {
if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it.
$need_fix = true;
$sql_u = "UPDATE $lp_table SET display_order = $i
WHERE c_id = ".$course_id." AND id = " . $row['id'];
Database::query($sql_u);
$sql = "UPDATE $lp_table SET display_order = $i
WHERE c_id = $courseId AND id = ".$row['id'];
Database::query($sql);
}
$row['display_order'] = $i;
$lps[$row['id']] = $row;
@ -3890,19 +3890,22 @@ class learnpath
if ($num > 1) { // If there's only one element, no need to sort.
$order = $lps[$lp_id]['display_order'];
if ($order > 1) { // If it's the first element, no need to move up.
$sql_u1 = "UPDATE $lp_table SET display_order = $order
WHERE c_id = ".$course_id." AND id = " . $lp_order[$order - 1];
Database::query($sql_u1);
$sql_u2 = "UPDATE $lp_table SET display_order = " . ($order - 1) . "
WHERE c_id = ".$course_id." 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);
}
}
return true;
}
/**
* Move a learnpath down (display_order)
* @param integer $lp_id Learnpath ID
* @return bool
*/
public static function move_down($lp_id)
{
@ -3915,8 +3918,8 @@ class learnpath
if ($res === false) {
return false;
}
$lps = array();
$lp_order = array();
$lps = [];
$lp_order = [];
$num = Database::num_rows($res);
$max = 0;
// 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.
$need_fix = true;
$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);
}
$row['display_order'] = $i;
@ -3941,13 +3944,15 @@ class learnpath
$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 = ".$course_id." AND id = " . $lp_order[$order + 1];
WHERE c_id = ".$course_id." AND id = ".$lp_order[$order + 1];
Database::query($sql_u1);
$sql_u2 = "UPDATE $lp_table SET display_order = " . ($order + 1) . "
WHERE c_id = ".$course_id." AND id = " . $lp_id;
$sql_u2 = "UPDATE $lp_table SET display_order = ".($order + 1)."
WHERE c_id = ".$course_id." AND id = ".$lp_id;
Database::query($sql_u2);
}
}
return true;
}
/**

@ -52,7 +52,6 @@ if (api_get_setting('search_enabled') === 'true') {
$current_session = api_get_session_id();
/* Introduction section (editable by course admins) */
$introductionSection = Display::return_introduction_section(
TOOL_LEARNPATH,
array(
@ -126,7 +125,6 @@ if (!empty($categoriesTempList)) {
$userId = api_get_user_id();
$userInfo = api_get_user_info();
$lpIsShown = false;
$test_mode = api_get_setting('server_type');
@ -228,7 +226,6 @@ foreach ($categories as $item) {
);
$now = time();
$is_actived_time = false;
if ($now > $start_time && $end_time > $now) {
$is_actived_time = true;
}
@ -397,7 +394,6 @@ foreach ($categories as $item) {
}
/* VISIBILITY COMMAND */
/* Session test not necessary if we want to show base course learning
paths inside the session.
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?'
. api_get_cidreq().'&'
. http_build_query([
@ -425,7 +421,12 @@ foreach ($categories as $item) {
]);
$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
);
@ -469,14 +470,14 @@ foreach ($categories as $item) {
}
/* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE
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
* 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
*/
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(
Display::return_icon(
'reload.png',
@ -487,7 +488,8 @@ foreach ($categories as $item) {
"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(
Display::return_icon(
'reload_na.png',
@ -498,7 +500,8 @@ foreach ($categories as $item) {
"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(
Display::return_icon(
'reload.png',
@ -657,7 +660,6 @@ foreach ($categories as $item) {
// Subscribe users
$subscribeUsers = null;
if ($details['subscribe_users'] == 1) {
$subscribeUsers = Display::url(
Display::return_icon('user.png', get_lang('SubscribeUsersToLp')),

Loading…
Cancel
Save