Fix fatal error + fix UI, + fix wrong course id (when copy a session)

1.10.x
Julio Montoya 10 years ago
parent 43021e9227
commit a678e2d8f5
  1. 59
      main/inc/lib/sessionmanager.lib.php
  2. 5
      main/session/resume_session.php
  3. 2
      main/session/session_list.php

@ -2073,6 +2073,12 @@ class SessionManager
// Pass through the courses list we want to add to the session
foreach ($courseList as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
// If course doesn't exists continue!
if (empty($courseInfo)) {
continue;
}
$exists = false;
// check if the course we want to add is already subscribed
@ -3018,7 +3024,8 @@ class SessionManager
}
// select the courses
$sql = "SELECT *, c.id as real_id FROM $tbl_course c
$sql = "SELECT *, c.id, c.id as real_id
FROM $tbl_course c
INNER JOIN $tbl_session_rel_course src
ON c.id = src.c_id
WHERE src.session_id = '$session_id' ";
@ -3051,7 +3058,7 @@ class SessionManager
}
while ($row = Database::fetch_array($result,'ASSOC')) {
$courses[$row['id']] = $row;
$courses[$row['real_id']] = $row;
}
}
@ -3520,8 +3527,29 @@ class SessionManager
$flat_list = $list->get_flat_list();
if (!empty($flat_list)) {
foreach ($flat_list as $lp_id => $data) {
api_item_property_update($course_info, TOOL_LEARNPATH, $lp_id, 'invisible', api_get_user_id(), 0, 0, 0, 0, $sid);
api_item_property_update($course_info, TOOL_LEARNPATH, $lp_id, 'invisible', api_get_user_id(), 0, 0, 0, 0);
api_item_property_update(
$course_info,
TOOL_LEARNPATH,
$lp_id,
'invisible',
api_get_user_id(),
0,
0,
0,
0,
$sid
);
api_item_property_update(
$course_info,
TOOL_LEARNPATH,
$lp_id,
'invisible',
api_get_user_id(),
0,
0,
0,
0
);
}
}
$quiz_table = Database::get_course_table(TABLE_QUIZ_TEST);
@ -6903,7 +6931,7 @@ class SessionManager
// Magic filter
if (isset($formatted_sessions[$session_id])) {
$formatted_sessions[$session_id] = self::compare_arrays_to_merge($formatted_sessions[$session_id], $session);
$formatted_sessions[$session_id] = self::compareArraysToMerge($formatted_sessions[$session_id], $session);
} else {
$formatted_sessions[$session_id] = $session;
}
@ -6912,4 +6940,25 @@ class SessionManager
return $formatted_sessions;
}
/**
* Compare two arrays
* @param array $array1
* @param array $array2
*/
static function compareArraysToMerge($array1, $array2)
{
if (empty($array2)) {
return $array1;
}
foreach ($array1 as $key => $item) {
if (!isset($array1[$key])) {
//My string is empty try the other one
if (isset($array2[$key]) && !empty($array2[$key])) {
$array1[$key] = $array2[$key];
}
}
}
return $array1;
}
}

@ -12,6 +12,9 @@ use Chamilo\CoreBundle\Entity\SequenceResource;
$cidReset = true;
require_once '../inc/global.inc.php';
// setting breadcrumbs
$interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('Sessions'));
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
@ -376,7 +379,7 @@ if (!empty($requirementAndDependencies['dependencies'])) {
$dependencies .= implode(',', array_column($requirementAndDependencies['dependencies'], 'name'));
}
$tpl = new Template();
$tpl = new Template(get_lang('Session'));
$tpl->assign('session_header', $sessionHeader);
$tpl->assign('title', $sessionTitle);
$tpl->assign('general_coach', $generalCoach);

@ -20,10 +20,12 @@ $list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple';
if ($action == 'delete') {
SessionManager::delete($idChecked);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: session_list.php');
exit();
} elseif ($action == 'copy') {
SessionManager::copy($idChecked);
Display::addFlash(Display::return_message(get_lang('ItemCopied')));
header('Location: session_list.php');
exit();
}

Loading…
Cancel
Save