Fixing queries due recent changes in the DB see BT#5638

skala
Julio Montoya 13 years ago
parent 01c79247da
commit aaa286944a
  1. 2
      main/admin/career_dashboard.php
  2. 2
      main/admin/session_course_list.php
  3. 188
      main/course_progress/thematic.php
  4. 20
      main/dropbox/dropbox_init.inc.php
  5. 1
      main/exercice/answer.class.php
  6. 3
      main/exercice/exercise.class.php
  7. 4
      main/exercice/exercise.lib.php
  8. 5
      main/exercice/testcategory.class.php
  9. 6
      main/inc/ajax/course_home.ajax.php
  10. 2
      main/inc/lib/course.lib.php
  11. 38
      main/inc/lib/sessionmanager.lib.php
  12. 3
      main/install/1.10.0/migrate-db-1.9.0-1.10.0-pre.sql
  13. 2
      main/newscorm/lp_controller.php
  14. 62
      main/session/add_courses_to_session.php
  15. 6
      main/session/resume_session.php
  16. 2
      src/ChamiloLMS/Controller/UserPortalController.php

@ -134,7 +134,7 @@ foreach($career_array as $career_id => $data) {
echo '<table>';
foreach($course_list as $course) {
echo '<tr>';
$url = Display::url($course['title'], api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session='.$session['data']['id']);
$url = Display::url($course['title'], api_get_path(WEB_COURSE_PATH).$course['directory'].'/index.php?id_session='.$session['data']['id']);
echo Display::tag('td',$url);
echo '</tr>';
}

@ -87,7 +87,7 @@ foreach ($Courses as $key=>$enreg) {
$course[] = '<input type="checkbox" name="idChecked[]" value="'.$enreg['c_id'].'">';
$course[] = api_htmlentities($enreg['title'],ENT_QUOTES,$charset);
$course[] = '<a href="session_course_user_list.php?id_session='.$id_session.'&course_code='.$enreg['c_id'].'">'.$enreg['nbr_users'].' '.get_lang('Users').'</a>';
$course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$enreg['c_id'].'/?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('Course')).'</a>
$course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$enreg['c_id'].'/index.php?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('Course')).'</a>
<a href="session_course_edit.php?id_session='.$id_session.'&page=session_course_list.php&course_code='.$enreg['c_id'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>
<a href="'.api_get_self().'?id_session='.$id_session.'&sort='.$sort.'&action=delete&idChecked[]='.$enreg['c_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
$tableCourses[] = $course;

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for thematic control
* View (MVC patter) for thematic control
* @author Christian Fasanando <christian1827@gmail.com>
* @author Julio Montoya <gugli100@gmail.com> Bug fixing
* @package chamilo.course_progress
@ -14,18 +14,18 @@ api_protect_course_script(true);
$token = Security::get_token();
$url_token = "&sec_token=".$token;
if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">';
switch ($action) {
case 'thematic_add' :
if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">';
switch ($action) {
case 'thematic_add' :
case 'thematic_import_select' :
echo '<a href="index.php?'.api_get_cidreq().'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ThematicDetails'),'',ICON_SIZE_MEDIUM).'</a>';
break;
case 'thematic_list' :
break;
case 'thematic_list' :
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
break;
case 'thematic_details' :
case 'thematic_details' :
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'.Display::return_icon('import_csv.png',get_lang('ImportThematic'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export'.$url_token.'">'.Display::return_icon('export_csv.png',get_lang('ExportThematic'),'', ICON_SIZE_MEDIUM).'</a>';
@ -33,28 +33,28 @@ if (api_is_allowed_to_edit(null, true)) {
break;
default :
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
echo '</div>';
}
if ($action == 'thematic_list') {
$table = new SortableTable('thematic_list', array('Thematic', 'get_number_of_thematics'), array('Thematic', 'get_thematic_data'));
$parameters['action'] = $action;
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, array('style'=>'width:20px;'));
$table->set_header(1, get_lang('Title'), false );
$table->set_header(1, get_lang('Title'), false );
if (api_is_allowed_to_edit(null, true)) {
$table->set_header(2, get_lang('Actions'), false,array('style'=>'text-align:center;width:40%;'));
$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));
$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));
}
$table->display();
} elseif ($action == 'thematic_details') {
if ($last_id) {
if (isset($last_id) && $last_id) {
$link_to_thematic_plan = '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$last_id.'">'.Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).'</a>';
$link_to_thematic_advance = '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$last_id.'">'.Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).'</a>';
Display::display_confirmation_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull').'<br />'.sprintf(get_lang('NowYouShouldAddThematicPlanXAndThematicAdvanceX'),$link_to_thematic_plan, $link_to_thematic_advance), false);
@ -62,47 +62,47 @@ if ($action == 'thematic_list') {
// display title
if (!empty($thematic_id)) {
} else {
} else {
// display information
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= get_lang('ThematicDetailsDescription');
$message .= get_lang('ThematicDetailsDescription');
Display::display_normal_message($message, false);
echo '<br />';
echo '<br />';
}
// display thematic data
// display thematic data
if (!empty($thematic_data)) {
// display progress
echo '<div style="text-align:right;"><h3>'.get_lang('Progress').': <span id="div_result">'.$total_average_of_advances.'</span> %</h3></div>';
echo '<table width="100%" class="data_table">';
echo '<table width="100%" class="data_table">';
echo '<tr><th width="33%">'.get_lang('Thematic').'</th><th>'.get_lang('ThematicPlan').'</th><th width="33%">'.get_lang('ThematicAdvance').'</th></tr>';
foreach ($thematic_data as $thematic) {
$my_thematic_id = $thematic['id'];
$session_star = '';
if (api_is_allowed_to_edit(null, true)) {
if (api_get_session_id() == $thematic['session_id']) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
}
}
//@todo add a validation in order to load or not course thematics in the session thematic
/*
if (api_get_session_id() == $thematic['session_id']) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
} else {
} else {
continue;
} */
} */
echo '<tr>';
$actions_first_col = '';
if (api_is_allowed_to_edit(null, true)) {
// Thematic title
// Thematic title
$actions_first_col = Display::url(Display::return_icon('cd.gif', get_lang('Copy')), 'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$param_gradebook.$url_token);
if (api_get_session_id() == 0 ) {
if ($thematic['display_order'] > 1) {
$actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$param_gradebook.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>';
} else {
@ -113,156 +113,156 @@ if ($action == 'thematic_list') {
} else {
$actions_first_col .= ' '.Display::return_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
}
}
if (api_get_session_id() == $thematic['session_id']) {
$actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$param_gradebook.$url_token.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
if (api_get_session_id() == $thematic['session_id']) {
$actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$param_gradebook.$url_token.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
$actions_first_col .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$my_thematic_id.$param_gradebook.$url_token.'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
}
$actions_first_col = Display::div($actions_first_col, array('id'=>'thematic_id_content_'.$thematic['id'], 'class'=>'thematic_tools'));
$actions_first_col = Display::div($actions_first_col, array('style'=>'height:20px'));
}
echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content'));
// Display 2nd column - thematic plan data
echo '<td>';
echo '<td>';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'&width=700&height=500">'.
Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'),ICON_SIZE_MEDIUM).'</a></div><br />';
}
}
if (empty($thematic_plan_div[$thematic['id']])) {
echo Display::div('', array('id' => "thematic_plan_".$thematic['id']));
} else {
echo $thematic_plan_div[$thematic['id']];
}
}
echo '</td>';
// Display 3rd column - thematic advance data
// Display 3rd column - thematic advance data
echo '<td style="vertical-align:top">';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&action=thematic_advance_add&thematic_id='.$thematic['id'].'">'.Display::return_icon('add.png',get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a></div>';
}
}
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (!empty($thematic_advance_data[$thematic['id']])) {
echo '<table width="100%">';
echo '<table width="100%">';
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
$thematic_advance['start_date'] = api_get_local_time($thematic_advance['start_date']);
$thematic_advance['start_date'] = api_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG);
echo '<tr>';
$thematic_advance['start_date'] = api_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG);
echo '<tr>';
echo '<td width="90%" class="thematic_advance_content" id="thematic_advance_content_id_'.$thematic_advance['id'].'">';
$edit_link = '';
if (api_is_allowed_to_edit(null, true)) {
$edit_link = '<a class="thickbox" href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'" >'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array(),ICON_SIZE_SMALL).'</a>';
$edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
//Links
$edit_link = Display::div(Display::div($edit_link , array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')), array('style'=>'height:20px;'));
}
$thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
echo $edit_link;
echo $edit_link;
echo '</td>';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
if (api_is_allowed_to_edit(null, true)) {
if (empty($thematic_id)) {
$checked = '';
$checked = '';
if ($last_done_thematic_advance == $thematic_advance['id']) {
$checked = 'checked';
}
$style = '';
if ($thematic_advance['done_advance'] == 1) {
if ($thematic_advance['done_advance'] == 1) {
$style = ' style="background-color:#E5EDF9" ';
} else {
$style = ' style="background-color:#fff" ';
}
}
echo '<td id="td_done_thematic_'.$thematic_advance['id'].'" '.$style.'><center>';
echo '<input type="radio" class="done_thematic" id="done_thematic_'.$thematic_advance['id'].'" name="done_thematic" value="'.$thematic_advance['id'].'" '.$checked.' onclick="update_done_thematic_advance(this.value)">';
echo '</center></td>';
} else {
echo '</center></td>';
} else {
if ($thematic_advance['done_advance'] == 1) {
echo '<td><center>'.get_lang('Done').'</center></td>';
echo '<td><center>'.get_lang('Done').'</center></td>';
} else {
echo '<td><center>-</center></td>';
}
}
}
}
echo '</tr>';
}
echo '</tr>';
}
echo '</table>';
} else {
echo '<div><em>'.get_lang('ThereIsNoAThematicAdvance').'</em></div>';
}
echo '</td>';
}
echo '</td>';
echo '</tr>';
} //End for
echo '</table>';
} else {
echo '<div><em>'.get_lang('ThereIsNoAThematicSection').'</em></div>';
}
echo '<div><em>'.get_lang('ThereIsNoAThematicSection').'</em></div>';
}
} else if ($action == 'thematic_add' || $action == 'thematic_edit') {
// Display form
$form = new FormValidator('thematic_add','POST','index.php?action=thematic_add&'.api_get_cidreq());
if ($action == 'thematic_edit') {
$form->addElement('header', '', get_lang('EditThematicSection'));
$form->addElement('header', '', get_lang('EditThematicSection'));
}
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'action', $action);
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id',$thematic_id);
}
$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$show_form = true;
if (!empty($thematic_data)) {
if (!empty($thematic_data)) {
if (api_get_session_id()) {
if ($thematic_data['session_id'] != api_get_session_id()) {
$show_form = false;
Display::display_error_message(get_lang('NotAllowedClickBack'),false);
Display::display_error_message(get_lang('NotAllowedClickBack'),false);
}
}
// set default values
$default['title'] = $thematic_data['title'];
$default['content'] = $thematic_data['content'];
$default['content'] = $thematic_data['content'];
$form->setDefaults($default);
}
// error messages
if ($error) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
if ($error) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
}
if ($show_form)
$form->display();
$form->display();
} else if ($action == 'thematic_import_select') {
// Create form to upload csv file.
$form = new FormValidator('thematic_import','POST','index.php?action=thematic_import&'.api_get_cidreq().$url_token);
$form->addElement('header', get_lang('ImportThematic'));
$form->addElement('file', 'file');
$form->addElement('checkbox', 'replace', null, get_lang('DeleteAllThematic'));
$form->addElement('checkbox', 'replace', null, get_lang('DeleteAllThematic'));
$form->addElement('style_submit_button', 'SubmitImport', get_lang('Import'), 'class="save"');
$form->display();
}

@ -79,8 +79,10 @@ if (empty($session_id)) {
// off all the documents that have already been sent.
// @todo consider moving the javascripts in a function that displays the javascripts
// only when it is needed.
if ($_GET['action'] == 'add') {
if (isset($_GET['action']) && $_GET['action'] == 'add') {
$dropbox_person = new Dropbox_Person($_user['user_id'], api_is_course_admin(), $is_courseTutor);
} else {
$dropbox_person = null;
}
/* Create javascript and htmlHeaders */
@ -125,13 +127,15 @@ if (dropbox_cnf('allowOverwrite')) {
var sentArray = new Array("; //sentArray keeps list of all files still available in the sent files list
//of the user.
//This is used to show or hide the overwrite file-radio button of the upload form
for ($i = 0; $i < count($dropbox_person->sentWork); $i++) {
if ($i > 0) {
$javascript .= ", ";
}
$javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
//echo '***'.$dropbox_person->sentWork[$i]->title;
}
if ($dropbox_person) {
for ($i = 0; $i < count($dropbox_person->sentWork); $i++) {
if ($i > 0) {
$javascript .= ", ";
}
$javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
//echo '***'.$dropbox_person->sentWork[$i]->title;
}
}
$javascript .= ");
function checkfile(str)

@ -50,7 +50,6 @@ class Answer
*/
function Answer($questionId, $course_id = null)
{
$this->questionId = intval($questionId);
$this->answer = array();
$this->correct = array();

@ -457,8 +457,7 @@ class Exercise
public function getQuestionList($start, $limit, $sidx, $sord, $where_condition = array())
{
if (!empty($this->id)) {
$category_list = Testcategory::getCategoryListName();
$category_list = Testcategory::getListOfCategoriesNameForTest($this->id, false);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);

@ -1034,8 +1034,6 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
}
$course_id = api_get_course_int_id();
$course_code = api_get_course_id();
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh();
$TBL_USER = Database :: get_main_table(TABLE_MAIN_USER);
@ -1163,7 +1161,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
$sql = " $sql_select
FROM $TBL_EXERCICES AS ce
INNER JOIN $sql_inner_join_tbl_track_exercices AS te ON (te.exe_exo_id = ce.id)
INNER JOIN $sql_inner_join_tbl_track_exercices AS te ON (te.exe_exo_id = ce.iid)
INNER JOIN $sql_inner_join_tbl_user AS user ON (user.user_id = exe_user_id)
WHERE $extra_where_conditions AND
te.status != 'incomplete'

@ -232,7 +232,8 @@ class Testcategory
* jmontoya
*/
//function getCategoryQuestionsNumber($in_id) {
function getCategoryQuestionsNumber() {
function getCategoryQuestionsNumber()
{
$t_reltable = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$in_id = Database::escape_string($this->id);
$sql = "SELECT count(*) AS nb FROM $t_reltable WHERE category_id = $in_id";
@ -247,8 +248,6 @@ class Testcategory
echo "</textarea>";
}
/** return an array of all Category objects in the database
If in_field=="" Return an array of all category objects in the database
Otherwise, return an array of all in_field value in the database (in_field = id or name or description)

@ -143,7 +143,7 @@ switch ($action) {
$list = new LearnpathList(api_get_user_id(), $item['code'], $session_id);
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$course_url = api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id;
$course_url = api_get_path(WEB_COURSE_PATH).$item['directory'].'/index.php?id_session='.$session_id;
$item['title'] = Display::url($item['title'], $course_url, array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) {
@ -265,7 +265,7 @@ switch ($action) {
$list = new LearnpathList(api_get_user_id(),$item['code'], $session_id, 'publicated_on DESC');
$flat_list = $list->get_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'].'/index.php?id_session='.$session_id,array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) {
$temp[$count]['id']= $lp_id;
@ -392,7 +392,7 @@ switch ($action) {
$list = new LearnpathList(api_get_user_id(),$item['code'],$session_id);
$flat_list = $list->get_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'].'/index.php?id_session='.$session_id, array('target'=>SESSION_LINK_TARGET));
foreach($flat_list as $lp_id => $lp_item) {
$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';

@ -2042,7 +2042,7 @@ class CourseManager
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$coachs_emails = array();
$course_code = Database::escape_string($course_code);
$courseId = Database::escape_string($courseId);
$session_id = intval($session_id);
$sql = "SELECT id_user FROM $tbl_session_course_user WHERE id_session='$session_id' AND c_id ='$courseId' AND status =2";

@ -1097,7 +1097,7 @@ class SessionManager
* @param bool Whether to unsubscribe existing users (true, default) or not (false)
* @return void Nothing, or false on error
**/
public static function add_courses_to_session ($id_session, $course_list, $empty_courses=true) {
public static function add_courses_to_session($id_session, $course_list, $empty_courses = true) {
// security checks
if ($id_session!= strval(intval($id_session))) { return false; }
@ -1111,19 +1111,21 @@ class SessionManager
$id_coach = Database::query("SELECT id_coach FROM $tbl_session WHERE id=$id_session");
$id_coach = Database::fetch_array($id_coach);
$id_coach = $id_coach[0];
// get list of courses subscribed to this session
$rs = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE id_session=$id_session");
$existingCourses = Database::store_result($rs);
$existingCourses = Database::store_result($rs, 'ASSOC');
$nbr_courses=count($existingCourses);
// get list of users subscribed to this session
$sql="SELECT id_user
FROM $tbl_session_rel_user
WHERE id_session = $id_session AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
$result=Database::query($sql);
$user_list=Database::store_result($result);
$user_list=Database::store_result($result, 'ASSOC');
// Remove existing courses from the session
if ($empty_courses===true) {
if ($empty_courses === true) {
foreach ($existingCourses as $existingCourse) {
if (!in_array($existingCourse['c_id'], $course_list)){
Database::query("DELETE FROM $tbl_session_rel_course WHERE c_id='".$existingCourse['c_id']."' AND id_session=$id_session");
@ -1134,35 +1136,39 @@ class SessionManager
}
// Pass through the courses list we want to add to the session
foreach ($course_list as $enreg_course) {
$enreg_course = Database::escape_string($enreg_course);
foreach ($course_list as $courseId) {
$courseId = Database::escape_string($courseId);
$exists = false;
// check if the course we want to add is already subscribed
foreach ($existingCourses as $existingCourse) {
if ($enreg_course == $existingCourse['c_id']) {
if ($courseId == $existingCourse['c_id']) {
$exists=true;
}
}
if (!$exists) {
if ($exists == false) {
CourseManager::update_course_ranking($courseId, $id_session);
//if the course isn't subscribed yet
$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course (id_session, c_id, course_id) VALUES ('$id_session','$enreg_course', $courseId)";
$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course (id_session, c_id) VALUES ('$id_session','$courseId')";
Database::query($sql_insert_rel_course);
//We add the current course in the existing courses array, to avoid adding another time the current course
$existingCourses[]=array('course_code'=>$enreg_course);
$existingCourses[]=array('c_id' => $courseId);
$nbr_courses++;
// subscribe all the users from the session to this course inside the session
$nbr_users=0;
foreach ($user_list as $enreg_user) {
$enreg_user_id = Database::escape_string($enreg_user['id_user']);
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session, c_id, id_user) VALUES ('$id_session','$enreg_course','$enreg_user_id')";
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (id_session, c_id, id_user) VALUES ('$id_session','$courseId','$enreg_user_id')";
Database::query($sql_insert);
if (Database::affected_rows()) {
$nbr_users++;
}
}
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND c_id = '$enreg_course'");
SessionManager::subscribe_users_to_session_course($user_list, $id_session, $courseId);
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND c_id = '$courseId'");
}
}
Database::query("UPDATE $tbl_session SET nbr_courses=$nbr_courses WHERE id='$id_session'");
@ -1824,7 +1830,13 @@ class SessionManager
WHERE 1 = 1
";
}*/
$sql = "SELECT u.user_id, lastname, firstname, username, moved_to, moved_status, moved_at
$sql = "SELECT u.user_id,
lastname,
firstname,
username,
moved_to,
moved_status,
moved_at
FROM $tbl_user u INNER JOIN $tbl_session_rel_user su
ON u.user_id = su.id_user AND
su.id_session = $id

@ -53,8 +53,9 @@ ALTER TABLE session MODIFY COLUMN id INT unsigned NOT NULL;
ALTER TABLE session_rel_course MODIFY COLUMN id_session INT unsigned NOT NULL;
ALTER TABLE session_rel_course ADD COLUMN c_id INT NOT NULL DEFAULT '0';
ALTER TABLE session_rel_course ADD COLUMN id INT NOT NULL;
ALTER TABLE session_rel_course DROP PRIMARY KEY;
ALTER TABLE session_rel_course ADD COLUMN id INT NOT NULL;
ALTER TABLE session_rel_course MODIFY COLUMN id int unsigned AUTO_INCREMENT;
ALTER TABLE session_rel_course ADD INDEX idx_session_rel_course_course_id (c_id);
ALTER TABLE session_rel_course ADD PRIMARY KEY (id);

@ -993,7 +993,7 @@ switch ($action) {
else {
$_SESSION['oLP']->save_current();
$_SESSION['oLP']->save_last();
header('location: '.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/?id_session='.api_get_session_id());
header('location: '.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id());
exit;
}
break;

@ -88,54 +88,8 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$firstLetterCourse = $_POST['firstLetterCourse'];
$firstLetterSession = $_POST['firstLetterSession'];
$CourseList = $_POST['SessionCoursesList'];
if (!is_array($CourseList)) {
$CourseList=array();
}
$nbr_courses=0;
$id_coach = Database::query("SELECT id_coach FROM $tbl_session WHERE id = $id_session");
$id_coach = Database::fetch_array($id_coach);
$id_coach = $id_coach[0];
$rs = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE id_session = $id_session");
$existingCourses = Database::store_result($rs);
$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session ";
$result = Database::query($sql);
$UserList = Database::store_result($result);
foreach ($CourseList as $courseId) {
$courseId = Database::escape_string($courseId);
$exists = false;
foreach ($existingCourses as $existingCourse) {
if ($enreg_course == $existingCourse['c_id']) {
$exists=true;
}
}
if (!$exists) {
SessionManager::add_courses_to_session($id_session, array($courseId));
CourseManager::update_course_ranking($courseId, $id_session);
//We add in the existing courses table the current course, to not try to add another time the current course
$existingCourses[]=array('c_id'=>$courseId);
$newUserList = array();
foreach ($UserList as $enreg_user) {
$newUserList[] = $enreg_user['id_user'];
}
SessionManager::subscribe_users_to_session_course($newUserList, $id_session, $courseId);
}
}
foreach ($existingCourses as $existingCourse) {
if(!in_array($existingCourse['c_id'], $CourseList)) {
CourseManager::remove_course_ranking($existingCourse['c_id'], $id_session);
Database::query("DELETE FROM $tbl_session_rel_course WHERE c_id ='".$existingCourse['c_id']."' AND id_session = $id_session");
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE c_id ='".$existingCourse['c_id']."' AND id_session = $id_session");
}
}
$nbr_courses = count($CourseList);
Database::query("UPDATE $tbl_session SET nbr_courses = $nbr_courses WHERE id='$id_session'");
SessionManager::add_courses_to_session($id_session, $CourseList);
if (isset($_GET['add'])) {
header('Location: add_users_to_session.php?id_session='.$id_session.'&add=true');
exit;
@ -174,9 +128,9 @@ if ($ajax_search) {
$sql="SELECT code, title, visual_code, id_session
FROM $tbl_course course
INNER JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code
ON course.id = session_rel_course.c_id
AND session_rel_course.id_session = ".intval($id_session)."
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
ORDER BY ".(sizeof($courses)?"(course.code IN(".implode(',',$courses).")) DESC,":"")." title";
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -189,7 +143,7 @@ if ($ajax_search) {
AND session_rel_course.id_session = ".intval($id_session)."
INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.c_id = course.id)
WHERE access_url_id = $access_url_id
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
ORDER BY ".(sizeof($courses)?"(course.code IN(".implode(',',$courses).")) DESC,":"")." title";
}
}
@ -203,9 +157,9 @@ if ($ajax_search) {
$sql="SELECT code, title, visual_code, id_session
FROM $tbl_course course
LEFT JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code
ON course.id = session_rel_course.c_id
AND session_rel_course.id_session = ".intval($id_session)."
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
ORDER BY ".(sizeof($courses)?"(course.code IN(".implode(',',$courses).")) DESC,":"")." title";
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -214,11 +168,11 @@ if ($ajax_search) {
$sql="SELECT code, title, visual_code, id_session, course.id as real_id
FROM $tbl_course course
LEFT JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code
ON course.id = session_rel_course.c_id
AND session_rel_course.id_session = ".intval($id_session)."
INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.c_id = course.id)
WHERE access_url_id = $access_url_id
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
ORDER BY ".(sizeof($courses)?"(course.code IN(".implode(',',$courses).")) DESC,":"")." title";
}
}
$result = Database::query($sql);

@ -197,11 +197,11 @@ if ($session['nbr_courses'] == 0){
//hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
echo '
<tr>
<td>'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session),'</td>
<td>'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/index.php?id_session='.$id_session),'</td>
<td>'.$coaches.'</td>
<td>'.$count_users.'</td>
<td>
<a href="'.api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('Course')).'</a>
<a href="'.api_get_path(WEB_COURSE_PATH).$course['code'].'/index.php?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('Course')).'</a>
<a href="session_course_user_list.php?id_session='.$id_session.'&course_code='.$course['code'].'">'.Display::return_icon('user.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>
<a href="'.api_get_path(WEB_CODE_PATH).'/user/user_import.php?action=import&cidReq='.$course['code'].'&id_session='.$id_session.'">'.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), null, ICON_SIZE_SMALL).'</a>
<a href="../tracking/courseLog.php?id_session='.$id_session.'&cidReq='.$course['code'].$orig_param.'&hide_course_breadcrumb=1">'.Display::return_icon('statistics.gif', get_lang('Tracking')).'</a>&nbsp;
@ -343,7 +343,7 @@ if ($session['nbr_users'] == 0) {
$link_to_add_user_in_url = '';
if ($multiple_url_is_on) {
if ($user['access_url_id'] != $url_id) {
if (isset($user['access_url_id']) && $user['access_url_id'] != $url_id) {
$user_link .= ' '.Display::return_icon('warning.png', get_lang('UserNotAddedInURL'), array(), ICON_SIZE_SMALL);
$add = Display::return_icon('add.png', get_lang('AddUsersToURL'), array(), ICON_SIZE_SMALL);
$link_to_add_user_in_url = '<a href="resume_session.php?action=add_user_to_url&id_session='.$id_session.'&user_id='.$user['user_id'].'">'.$add.'</a>';

@ -140,7 +140,7 @@ class UserPortalController extends CommonController
$course_directory = $course_info['course_info']['path'];
$id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
$url = api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session;
$url = api_get_path(WEB_COURSE_PATH).$course_directory.'/index.php?id_session='.$id_session;
header('location:'.$url);
exit;
}

Loading…
Cancel
Save