Fixing session special page see BT#8700

1.9.x
Julio Montoya 10 years ago
parent e66dbbc716
commit f168c7253a
  1. 39
      main/inc/ajax/course_home.ajax.php
  2. 2
      main/inc/lib/main_api.lib.php
  3. 4
      main/inc/lib/tracking.lib.php

@ -5,7 +5,6 @@
* Responses to AJAX calls * Responses to AJAX calls
*/ */
$action = $_GET['a']; $action = $_GET['a'];
$now = time();
switch ($action) { switch ($action) {
case 'set_visibility': case 'set_visibility':
@ -108,10 +107,11 @@ switch ($action) {
require_once '../global.inc.php'; require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$now = time();
$page = intval($_REQUEST['page']); //page $page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows $limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter //index to filter
$sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id';
$sord = $_REQUEST['sord']; //asc or desc $sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) { if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc'; $sord = 'desc';
@ -133,9 +133,6 @@ switch ($action) {
} }
} }
if (!$sidx) {
$sidx = 1;
}
$start = $limit*$page - $limit; $start = $limit*$page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id); $course_list = SessionManager::get_course_list_by_session_id($session_id);
$count = 0; $count = 0;
@ -232,16 +229,16 @@ switch ($action) {
$response->records = $count; $response->records = $count;
echo json_encode($response); echo json_encode($response);
break; break;
case 'session_courses_lp_by_week': case 'session_courses_lp_by_week':
require_once '../global.inc.php'; require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$now = time();
$page = intval($_REQUEST['page']); //page $page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows $limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'course';
if (empty($sidx)) $sidx = 'course'; $sidx = str_replace(array('week desc,', ' '), '', $sidx);
$sord = $_REQUEST['sord']; //asc or desc $sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) { if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc'; $sord = 'desc';
@ -280,7 +277,7 @@ switch ($action) {
$lps[$item['code']] = $flat_list; $lps[$item['code']] = $flat_list;
$item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>SESSION_LINK_TARGET)); $item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) { foreach ($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id; $temp[$count]['id']= $lp_id;
$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view'; $lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view';
@ -327,8 +324,9 @@ switch ($action) {
$count++; $count++;
} }
} }
if (!empty($sidx)) {
$temp = msort($temp, $sidx, $sord); $temp = msort($temp, $sidx, $sord);
}
$response = new stdClass(); $response = new stdClass();
$i =0; $i =0;
@ -360,10 +358,12 @@ switch ($action) {
case 'session_courses_lp_by_course': case 'session_courses_lp_by_course':
require_once '../global.inc.php'; require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$now = time();
$page = intval($_REQUEST['page']); //page $page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); // quantity of rows $limit = intval($_REQUEST['rows']); // quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id';
$sidx = str_replace(array('course asc,', ' '), '', $sidx);
$sord = $_REQUEST['sord']; //asc or desc $sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) { if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc'; $sord = 'desc';
@ -384,13 +384,8 @@ switch ($action) {
} }
} }
if (!$sidx) {
$sidx = 1;
}
$start = $limit*$page - $limit; $start = $limit*$page - $limit;
$course_list = SessionManager::get_course_list_by_session_id($session_id); $course_list = SessionManager::get_course_list_by_session_id($session_id);
$count = 0; $count = 0;
foreach ($course_list as $item) { foreach ($course_list as $item) {
@ -457,12 +452,12 @@ switch ($action) {
$response = new stdClass(); $response = new stdClass();
$i =0; $i =0;
foreach($temp as $key=>$row) { foreach ($temp as $key=>$row) {
$row = $row['cell']; $row = $row['cell'];
if (!empty($row)) { if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) { if ($key >= $start && $key < ($start + $limit)) {
$response->rows[$i]['id']= $key; $response->rows[$i]['id']= $key;
$response->rows[$i]['cell']=array($row[0], $row[1], $row[2],$row[3]); $response->rows[$i]['cell']=array($row[0], $row[1], $row[2]);
$i++; $i++;
} }
} }

@ -69,6 +69,8 @@ define('SESSION_VISIBLE', 2);
define('SESSION_INVISIBLE', 3); // not available define('SESSION_INVISIBLE', 3); // not available
define('SESSION_AVAILABLE', 4); define('SESSION_AVAILABLE', 4);
define('SESSION_LINK_TARGET','_self');
define('SUBSCRIBE_ALLOWED', 1); define('SUBSCRIBE_ALLOWED', 1);
define('SUBSCRIBE_NOT_ALLOWED', 0); define('SUBSCRIBE_NOT_ALLOWED', 0);
define('UNSUBSCRIBE_ALLOWED', 1); define('UNSUBSCRIBE_ALLOWED', 1);

@ -7,10 +7,6 @@
* @package chamilo.library * @package chamilo.library
* @author Julio Montoya <gugli100@gmail.com> (Score average fixes) * @author Julio Montoya <gugli100@gmail.com> (Score average fixes)
*/ */
/**
* Code
*/
define('SESSION_LINK_TARGET','_self');
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';

Loading…
Cancel
Save