Remove $_SESSION + format code

pull/2487/head
jmontoyaa 7 years ago
parent 7af047969f
commit d384f674d3
  1. 2
      main/inc/ajax/exercise.ajax.php
  2. 119
      main/inc/lib/events.lib.php
  3. 2
      main/inc/lib/exercise.lib.php
  4. 16
      main/lp/download.php
  5. 47
      main/lp/lp_add_audio.php
  6. 3
      main/lp/lp_admin_view.php
  7. 7
      main/lp/lp_edit_item_prereq.php
  8. 18
      main/lp/lp_impress.php
  9. 6
      main/lp/lp_save.php
  10. 6
      main/lp/scorm_api.php
  11. 5
      main/mySpace/index.php

@ -489,7 +489,7 @@ switch ($action) {
$_SESSION['duration_time'][$key] = time();
Event::update_event_exercise(
Event::updateEventExercise(
$exe_id,
$objExercise->selectId(),
$total_score,

@ -286,10 +286,10 @@ class Event
*/
public static function event_link($link_id)
{
$TABLETRACK_LINKS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
$reallyNow = api_get_utc_datetime();
$user_id = api_get_user_id();
$sql = "INSERT INTO ".$TABLETRACK_LINKS."
$sql = "INSERT INTO ".$table."
( links_user_id,
c_id,
links_link_id,
@ -317,12 +317,13 @@ class Event
* @param int session_id
* @param int learnpath_id (id of the learnpath)
* @param int learnpath_item_id (id of the learnpath_item)
* @return bool
*
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
* @desc Record result of user when an exercise was done
*/
public static function update_event_exercise(
public static function updateEventExercise(
$exeid,
$exo_id,
$score,
@ -337,10 +338,6 @@ class Event
$remind_list = array(),
$end_date = null
) {
global $debug;
if ($debug) error_log('Called to update_event_exercice');
if ($debug) error_log('duration:'.$duration);
if ($exeid != '') {
/*
* Code commented due BT#8423 do not change the score to 0.
@ -356,7 +353,7 @@ class Event
$status = Database::escape_string($status);
}
$TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
if (!empty($question_list)) {
$question_list = array_map('intval', $question_list);
@ -374,13 +371,13 @@ class Event
$end_date = api_get_utc_datetime();
}
$sql = "UPDATE $TABLETRACK_EXERCICES SET
exe_exo_id = '".Database::escape_string($exo_id)."',
exe_result = '".Database::escape_string($score)."',
exe_weighting = '".Database::escape_string($weighting)."',
session_id = '".Database::escape_string($session_id)."',
orig_lp_id = '".Database::escape_string($learnpath_id)."',
orig_lp_item_id = '".Database::escape_string($learnpath_item_id)."',
$sql = "UPDATE $table SET
exe_exo_id = '".Database::escape_string($exo_id)."',
exe_result = '".Database::escape_string($score)."',
exe_weighting = '".Database::escape_string($weighting)."',
session_id = '".Database::escape_string($session_id)."',
orig_lp_id = '".Database::escape_string($learnpath_id)."',
orig_lp_item_id = '".Database::escape_string($learnpath_item_id)."',
orig_lp_item_view_id = '".Database::escape_string($learnpath_item_view_id)."',
exe_duration = '".Database::escape_string($duration)."',
exe_date = '".$end_date."',
@ -389,14 +386,11 @@ class Event
data_tracking = '".implode(',', $question_list)."',
user_ip = '" . Database::escape_string(api_get_real_ip())."'
WHERE exe_id = '".Database::escape_string($exeid)."'";
$res = Database::query($sql);
if ($debug) error_log('update_event_exercice called');
if ($debug) error_log("$sql");
Database::query($sql);
//Deleting control time session track
//ExerciseLib::exercise_time_control_delete($exo_id);
return $res;
return true;
} else {
return false;
}
@ -558,7 +552,13 @@ class Event
Database::update(
$TBL_TRACK_ATTEMPT,
$attempt,
array('exe_id = ? AND question_id = ? AND user_id = ? ' => array($exe_id, $question_id, $user_id))
array(
'exe_id = ? AND question_id = ? AND user_id = ? ' => array(
$exe_id,
$question_id,
$user_id
)
)
);
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')) {
@ -574,7 +574,13 @@ class Event
Database::update(
$recording_table,
$attempt_recording,
array('exe_id = ? AND question_id = ? AND session_id = ? ' => array($exe_id, $question_id, $session_id))
array(
'exe_id = ? AND question_id = ? AND session_id = ? ' => array(
$exe_id,
$question_id,
$session_id
)
)
);
}
$attempt_id = $exe_id;
@ -899,9 +905,9 @@ class Event
WHERE exe_id='.$exe_id;
$rs_last_attempt = Database::query($sql);
$row_last_attempt = Database::fetch_array($rs_last_attempt);
$last_attempt_date = $row_last_attempt['last_attempt_date']; //Get the date of last attempt
$date = $row_last_attempt['last_attempt_date']; //Get the date of last attempt
return $last_attempt_date;
return $date;
}
/**
@ -1121,8 +1127,12 @@ class Event
* @param int $course_id
* @param int session id
*/
public static function delete_all_incomplete_attempts($user_id, $exercise_id, $course_id, $session_id = 0)
{
public static function delete_all_incomplete_attempts(
$user_id,
$exercise_id,
$course_id,
$session_id = 0
) {
$track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$user_id = intval($user_id);
$exercise_id = intval($exercise_id);
@ -1214,7 +1224,6 @@ class Event
$get_count = true
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$courseId = intval($courseId);
$session_id = intval($session_id);
@ -1448,8 +1457,11 @@ class Event
* @return array with the results
* @todo rename this function
*/
public static function get_best_exercise_results_by_user($exercise_id, $courseId, $session_id = 0)
{
public static function get_best_exercise_results_by_user(
$exercise_id,
$courseId,
$session_id = 0
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$courseId = intval($courseId);
@ -1504,8 +1516,12 @@ class Event
* @param int $session_id
* @return array
*/
public static function get_best_attempt_exercise_results_per_user($user_id, $exercise_id, $courseId, $session_id = 0)
{
public static function get_best_attempt_exercise_results_per_user(
$user_id,
$exercise_id,
$courseId,
$session_id = 0
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$courseId = intval($courseId);
$exercise_id = intval($exercise_id);
@ -1550,8 +1566,11 @@ class Event
* @param int $session_id
* @return mixed
*/
public static function count_exercise_result_not_validated($exercise_id, $courseId, $session_id = 0)
{
public static function count_exercise_result_not_validated(
$exercise_id,
$courseId,
$session_id = 0
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$courseId = intval($courseId);
@ -1578,15 +1597,18 @@ class Event
}
/**
* Gets all exercise BEST results attempts (NO Exercises in LPs) from a given exercise id, course, session per user
* Gets all exercise BEST results attempts (NO Exercises in LPs)
* from a given exercise id, course, session per user
* @param int exercise id
* @param int course id
* @param int session id
* @return array with the results
*
*/
public static function get_count_exercises_attempted_by_course($courseId, $session_id = 0)
{
public static function get_count_exercises_attempted_by_course(
$courseId,
$session_id = 0
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$courseId = intval($courseId);
$session_id = intval($session_id);
@ -1615,8 +1637,11 @@ class Event
* @param int $session_id
* @return array
*/
public static function get_all_exercise_event_from_lp($exercise_id, $courseId, $session_id = 0)
{
public static function get_all_exercise_event_from_lp(
$exercise_id,
$courseId,
$session_id = 0
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$courseId = intval($courseId);
@ -1728,8 +1753,13 @@ class Event
* @param int $session_id
* @param int $question_id
*/
public static function delete_attempt($exe_id, $user_id, $courseId, $session_id, $question_id)
{
public static function delete_attempt(
$exe_id,
$user_id,
$courseId,
$session_id,
$question_id
) {
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$exe_id = intval($exe_id);
@ -2151,8 +2181,11 @@ class Event
* @param int $user_to
* @return boolean
*/
public static function check_if_mail_already_sent($event_name, $user_from, $user_to = null)
{
public static function check_if_mail_already_sent(
$event_name,
$user_from,
$user_to = null
) {
if ($user_to == null) {
$sql = 'SELECT COUNT(*) as total
FROM '.Database::get_main_table(TABLE_EVENT_SENT).'
@ -2173,9 +2206,7 @@ class Event
}
/**
*
* Filter EventEmailTemplate Filters see the main/inc/conf/events.conf.dist.php
*
*/
/**

@ -4159,7 +4159,7 @@ EOT;
$learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
if (api_is_allowed_to_session_edit()) {
Event::update_event_exercise(
Event::updateEventExercise(
$exercise_stat_info['exe_id'],
$objExercise->selectId(),
$total_score,

@ -1,8 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file is responsible for passing requested documents to the browser.
* @package chamilo.document
* This file is responsible for passing requested documents to the browser.
* @package chamilo.document
*/
session_cache_limiter('none');
@ -29,10 +32,11 @@ if (strpos($doc_url, '../') || strpos($doc_url, '/..')) {
}
$sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/scorm';
$user_id = api_get_user_id();
if ($_SESSION['oLP']) {
$lp_id = $_SESSION['oLP']->get_id();
$lp_item_id = $_SESSION['oLP']->current;
/** @var learnpath $lp */
$lp = Session::read('oLP');
if ($lp) {
$lp_id = $lp->get_id();
$lp_item_id = $lp->current;
$lp_item_info = new learnpathItem($lp_item_id);
if (!empty($lp_item_info)) {
$visible = learnpath::is_lp_visible_for_student($lp_id, $user_id);

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This is a learning path creation and player tool in Chamilo - previously
* @author Julio Montoya - Improving the list of templates
@ -8,24 +10,23 @@
*/
$this_section = SECTION_COURSES;
api_protect_course_script();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
$isStudentView = api_is_student_view_active();
$learnpath_id = (int) $_REQUEST['lp_id'];
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
$type = isset($_GET['type']) ? $_GET['type'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
if ((!$is_allowed_to_edit) || ($isStudentView)) {
if ((!$is_allowed_to_edit) || $isStudentView) {
error_log('New LP - User not authorized in lp_add_audio.php');
header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
exit;
}
/** @var learnpath $lp */
$lp = Session::read('oLP');
if (api_is_in_gradebook()) {
$interbreadcrumb[] = array(
'url' => Category::getUrl(),
@ -33,20 +34,26 @@ if (api_is_in_gradebook()) {
);
}
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $_SESSION['oLP']->get_name());
$interbreadcrumb[] = array(
'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
'name' => get_lang('LearningPaths')
);
$interbreadcrumb[] = array(
'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
'name' => $lp->get_name()
);
switch ($type) {
case 'dir':
$interbreadcrumb[] = array(
'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id().'&'.api_get_cidreq(),
'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$lp->get_id().'&'.api_get_cidreq(),
'name' => get_lang('NewStep'),
);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('NewChapter'));
break;
case 'document':
$interbreadcrumb[] = array(
'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id().'&'.api_get_cidreq(),
'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$lp->get_id().'&'.api_get_cidreq(),
'name' => get_lang('NewStep'),
);
break;
@ -78,7 +85,7 @@ $form = new FormValidator(
);
$suredel = trim(get_lang('AreYouSureToDeleteJS'));
$lpPathInfo = $_SESSION['oLP']->generate_lp_folder(api_get_course_info());
$lpPathInfo = $lp->generate_lp_folder(api_get_course_info());
$file = null;
if (isset($lp_item->audio) && !empty($lp_item->audio)) {
@ -91,10 +98,10 @@ if (isset($lp_item->audio) && !empty($lp_item->audio)) {
}
}
$page = $_SESSION['oLP']->build_action_menu(true);
$page = $lp->build_action_menu(true);
$page .= '<div class="row" style="overflow:hidden">';
$page .= '<div id="lp_sidebar" class="col-md-4">';
$page .= $_SESSION['oLP']->return_new_tree(null, true);
$page .= $lp->return_new_tree(null, true);
// Show the template list.
$page .= '</div>';
@ -128,8 +135,16 @@ if (!empty($file)) {
Display::getMediaPlayer($file, array('url' => $urlFile)).
"</div>";
$form->addElement('label', get_lang('Listen'), $audioPlayer);
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?lp_id='.$_SESSION['oLP']->get_id().'&action=add_audio&id='.$lp_item_id.'&delete_file=1&'.api_get_cidreq();
$form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger')));
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?lp_id='.$lp->get_id().'&action=add_audio&id='.$lp_item_id.'&delete_file=1&'.api_get_cidreq();
$form->addElement(
'label',
null,
Display::url(
get_lang('RemoveAudio'),
$url,
array('class' => 'btn btn-danger')
)
);
} else {
$form->addElement('file', 'file');
$form->addElement('hidden', 'id', $lp_item_id);
@ -145,7 +160,7 @@ $documentTree = DocumentManager::get_document_preview(
api_get_session_id(),
false,
'',
urlencode('lp_controller.php?action=add_audio&lp_id='.$_SESSION['oLP']->get_id().'&id='.$lp_item_id),
urlencode('lp_controller.php?action=add_audio&lp_id='.$lp->get_id().'&id='.$lp_item_id),
false,
true
//$folderId = false

@ -33,7 +33,8 @@ if ((!$is_allowed_to_edit) || ($isStudentView)) {
$course_id = api_get_course_int_id();
$sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
$sql_query = "SELECT * FROM $tbl_lp
WHERE c_id = $course_id AND id = $learnpath_id";
$result = Database::query($sql_query);
$therow = Database::fetch_array($result);

@ -1,5 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php
*
@ -34,7 +37,7 @@ if ((!$is_allowed_to_edit) || ($isStudentView)) {
// Theme calls.
$show_learn_path = true;
/** @var learnpath $lp */
$lp = $_SESSION['oLP'];
$lp = Session::read('oLP');
$lp_theme_css = $lp->get_theme();
if (api_is_in_gradebook()) {
@ -91,7 +94,7 @@ echo '<div class="prerequisites">';
$lpItem = new learnpathItem($_GET['id']);
if (isset($is_success) && $is_success == true) {
echo $lp->display_manipulate($_GET['id'], $lpItem->get_type());
echo Display::return_message(get_lang("PrerequisitesAdded"));
echo Display::return_message(get_lang('PrerequisitesAdded'));
} else {
echo $lp->display_manipulate($_GET['id'], $lpItem->get_type());
echo $lp->display_item_prerequisites_form($_GET['id']);

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
*
* @package chamilo.learnpath
@ -37,19 +39,17 @@ $visibility = api_get_item_visibility(
if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0) {
api_not_allowed();
}
if (empty($_SESSION['oLP'])) {
/** @var learnpath $lp */
$lp = Session::read('oLP');
if ($lp) {
api_not_allowed(true);
}
$debug = 0;
if ($debug) { error_log('------ Entering lp_impress.php -------'); }
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/impress/impress-demo.css');
$list = $_SESSION['oLP']->get_toc();
$list = $lp->get_toc();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
if ($is_allowed_to_edit) {
@ -60,8 +60,8 @@ if ($is_allowed_to_edit) {
'name' => get_lang('LearningPaths'),
);
$interbreadcrumb[] = array(
'url' => api_get_self()."?action=add_item&type=step&lp_id=".$_SESSION['oLP']->lp_id."&isStudentView=false&".api_get_cidreq(),
'name' => $_SESSION['oLP']->get_name(),
'url' => api_get_self()."?action=add_item&type=step&lp_id=".$lp->lp_id."&isStudentView=false&".api_get_cidreq(),
'name' => $lp->get_name(),
);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Preview'));
echo return_breadcrumb($interbreadcrumb, null, null);
@ -74,7 +74,7 @@ foreach ($list as $toc) {
$x = 1000 * $step;
$html .= '<div id="step-'.$step.'" class="step slide" data-x="'.$x.'" data-y="-1500" >';
$html .= '<div class="impress-content">';
$src = $_SESSION['oLP']->get_link('http', $toc['id']);
$src = $lp->get_link('http', $toc['id']);
if ($toc['type'] !== 'dir') {
//just showing the src in a iframe ...
$html .= '<h2>'.$toc['title'].'</h2>';

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Script that handles the saving of item status
* @package chamilo.learnpath
@ -22,7 +24,9 @@ error_log('New LP - Loaded lp_save : '.$_SERVER['REQUEST_URI'].' from '.$_SERVER
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
<script language='javascript'>
<?php
if ($_SESSION['oLP']->mode != 'fullscreen') {
/** @var learnpath $lp */
$lp = Session::read('oLP');
if ($lp->mode != 'fullscreen') {
}
?>
</script>

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* API event handler functions for Scorm 1.1 and 1.2 and 1.3 (latter not fully supported)
* This script is divided into three sections.
@ -25,9 +27,9 @@ $use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
$file = (empty($_SESSION['file']) ? '' : $_SESSION['file']);
$file = Session::read('file');
/** @var learnpath $oLP */
$oLP = unserialize($_SESSION['lpobject']);
$oLP = unserialize(Session::read('lpobject'));
/** @var learnpathItem $oItem */
$oItem = isset($oLP->items[$oLP->current]) ? $oLP->items[$oLP->current] : null;

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Homepage for the MySpace directory
* @package chamilo.reporting
@ -15,10 +17,9 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
// the section (for the tabs)
$this_section = SECTION_TRACKING;
//for HTML editor repository
unset($_SESSION['this_section']);
Session::erase('this_section');
ob_start();
$nameTools = get_lang('MySpace');
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;

Loading…
Cancel
Save