Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

1.9.x
Yannick Warnier 11 years ago
commit eaff3649e9
  1. 10
      index.php
  2. 74
      main/admin/configure_homepage.php
  3. 8
      main/admin/sub_language.class.php
  4. 1
      main/course_home/activity.php
  5. 18
      main/course_home/course_home.php
  6. 5
      main/exercice/question_admin.inc.php
  7. 5
      main/exercice/question_create.php
  8. 9
      main/exercice/question_list_admin.inc.php
  9. 9
      main/exercice/testheaderpage.php
  10. 1
      main/exercice/unique_answer.class.php
  11. 1
      main/exercice/upload_exercise.php
  12. 3
      main/gradebook/gradebook_display_certificate.php
  13. 2
      main/gradebook/gradebook_flatview.php
  14. 6
      main/gradebook/index.php
  15. 1
      main/gradebook/lib/be/abstractlink.class.php
  16. 3
      main/gradebook/lib/be/attendancelink.class.php
  17. 41
      main/gradebook/lib/be/category.class.php
  18. 4
      main/gradebook/lib/be/evallink.class.php
  19. 13
      main/gradebook/lib/be/exerciselink.class.php
  20. 5
      main/gradebook/lib/be/studentpublicationlink.class.php
  21. 35
      main/gradebook/lib/be/surveylink.class.php
  22. 4
      main/gradebook/lib/fe/displaygradebook.php
  23. 21
      main/gradebook/lib/flatview_data_generator.class.php
  24. 15
      main/gradebook/lib/gradebook_functions.inc.php
  25. 60
      main/gradebook/lib/gradebook_functions_users.inc.php
  26. 33
      main/inc/introductionSection.inc.php
  27. 8
      main/inc/lib/display.lib.php
  28. 16
      main/inc/lib/internationalization.lib.php
  29. 8
      main/inc/lib/internationalization_database/name_order_conventions.php
  30. 30
      main/inc/lib/internationalization_internal.lib.php
  31. 14
      main/inc/lib/main_api.lib.php
  32. 2
      main/inc/lib/sessionmanager.lib.php
  33. 39
      main/inc/lib/userportal.lib.php
  34. 4
      main/install/configuration.dist.php
  35. 21
      main/mySpace/myStudents.php
  36. 2
      main/webservices/rest.php

@ -118,8 +118,7 @@ if (!empty($_POST['submitAuth'])) {
}
}
// End login -- if ($_POST['submitAuth'])
}
else {
} else {
// Only if login form was not sent because if the form is sent the user was already on the page.
event_open();
}
@ -142,8 +141,7 @@ if (!api_is_anonymous()) {
if (api_is_platform_admin()) {
$controller->tpl->assign('course_block', $controller->return_course_block());
}
else {
} else {
$controller->tpl->assign('teacher_block', $controller->return_teacher_link());
}
}
@ -163,9 +161,7 @@ if (!isset($_REQUEST['include'])) {
$controller->tpl->assign('hot_courses', $hot_courses);
$controller->tpl->assign('announcements_block', $announcements_block);
$controller->tpl->assign('home_page_block', $controller->return_home_page());
$controller->tpl->assign('navigation_course_links', $controller->return_navigation_links());
$controller->tpl->assign('notice_block', $controller->return_notice());
$controller->tpl->assign('main_navigation_block', $controller->return_navigation_links());
$controller->tpl->assign('help_block', $controller->return_help());
@ -183,7 +179,7 @@ if (isset($_GET['firstpage'])) {
api_set_firstpage_parameter($_GET['firstpage']);
// if we are already logged, go directly to course
if (api_user_is_login()) {
echo "<script type='text/javascript'>self.location.href='index.php?firstpage=".$_GET['firstpage']."'</script>";
echo "<script type='text/javascript'>self.location.href='index.php?firstpage=".Security::remove_XSS($_GET['firstpage'])."'</script>";
}
} else {
api_delete_firstpage_parameter();

@ -1,9 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Configure the portal homepage (manages multi-urls and languages)
* @package chamilo.admin
*/
/**
* Creates menu tabs for logged and anonymous users
*
@ -78,10 +80,17 @@ $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tool_name = get_lang('ConfigureHomePage');
$_languages = api_get_languages();
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array(
'url' => 'index.php',
'name' => get_lang('PlatformAdmin')
);
if (!empty($action)) {
$interbreadcrumb[] = array('url' => 'configure_homepage.php', 'name' => get_lang('ConfigureHomePage'));
$interbreadcrumb[] = array(
'url' => 'configure_homepage.php',
'name' => get_lang('ConfigureHomePage')
);
switch ($action) {
case 'edit_top':
$tool_name = get_lang('EditHomePage');
@ -134,6 +143,8 @@ if (!empty($_SESSION['user_language_choice'])) {
$lang = api_get_setting('platformLanguage');
}
$languageGet = isset($_GET['language']) ? Security::remove_XSS($_GET['language']) : $lang;
// Ensuring availability of main files in the corresponding language
if (api_is_multiple_url_enabled()) {
@ -186,6 +197,7 @@ foreach ($homef as $my_file) {
}
}
}
if (api_is_multiple_url_enabled()) {
$homep = $homep_new;
}
@ -224,25 +236,22 @@ if (!empty($action)) {
}
// Write
if (file_exists($homep.$topf.'_'.$lang.$ext)) {
if (is_writable($homep)) {
// Default
if (is_writable($homep.$topf.'_'.$lang.$ext)) {
$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
fputs($fp, $home_top);
fclose($fp);
// Language
foreach ($_languages['name'] as $key => $value) {
$lang_name = $_languages['folder'][$key];
if (isset($_POST[$lang_name])) {
if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
if (is_writable($homep.$topf.'_'.$lang_name.$ext)) {
$fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
fputs($fp, $home_top);
fclose($fp);
}
}
}
}
} else {
$errorMsg = get_lang('HomePageFilesNotWritable');
}
@ -267,7 +276,13 @@ if (!empty($action)) {
if (EventsMail::check_if_using_class('portal_homepage_edited')) {
EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
}
event_system(LOG_HOMEPAGE_CHANGED, 'edit_top', cut(strip_tags($home_top), 254), api_get_utc_datetime(), api_get_user_id());
event_system(
LOG_HOMEPAGE_CHANGED,
'edit_top',
cut(strip_tags($home_top), 254),
api_get_utc_datetime(),
api_get_user_id()
);
break;
case 'edit_notice':
// Filter
@ -530,12 +545,18 @@ if (!empty($action)) {
}
}
}
event_system(LOG_HOMEPAGE_CHANGED, $action, cut($link_name.':'.$link_url, 254), api_get_utc_datetime(), api_get_user_id());
event_system(
LOG_HOMEPAGE_CHANGED,
$action,
cut($link_name . ':' . $link_url, 254),
api_get_utc_datetime(),
api_get_user_id()
);
break;
} //end of switch($action)
if (empty($errorMsg)) {
header('Location: '.api_get_self());
header('Location: '.api_get_self().'?language='.$languageGet);
exit();
}
} else {
@ -920,7 +941,13 @@ switch ($action) {
}
$default = array();
$form = new FormValidator('configure_homepage_'.$action, 'post', api_get_self().'?action='.$action, '', array('style' => 'margin: 0px;'));
$form = new FormValidator(
'configure_homepage_'.$action,
'post',
api_get_self().'?action='.$action,
'',
array('style' => 'margin: 0px;')
);
$renderer =& $form->defaultRenderer();
$renderer->setHeaderTemplate('');
$renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
@ -944,6 +971,7 @@ switch ($action) {
$html .= '</select></td></tr>';
$form->addElement('html', $html);
}
if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
//TODO: review these lines
// Print WCAG-specific HTML editor
@ -957,19 +985,24 @@ switch ($action) {
}
$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
$form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
$currentLanguage = api_get_interface_language();
$i = 0;
foreach ($_languages['name'] as $key => $value) {
$i++;
$lang_name = $_languages['folder'][$key];
//if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
$i++;
$checked = null;
if ($languageGet == $lang_name) {
$checked = "checked";
}
$html_langs = '<td width="300">';
$html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
$html_langs .= '<label><input type="checkbox" '.$checked.' id="lang" name="'.$lang_name.'" />&nbsp;'.$value.'<label/>';
$html_langs .= '</td>';
if ($i % 5 == 0) {
$html_langs .= '</tr><tr>';
}
$form->addElement('html', $html_langs);
//}
}
$form->addElement('html','</tr></table><br/>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
@ -983,8 +1016,12 @@ switch ($action) {
<tr>
<td width="70%" valign="top">
<div class="actions">
<a href="<?php echo api_get_self(); ?>?action=edit_top"><?php Display::display_icon('edit.gif', get_lang('EditHomePage')); ?></a>
<a href="<?php echo api_get_self(); ?>?action=edit_top"><?php echo get_lang('EditHomePage'); ?></a>
<a href="<?php echo api_get_self(); ?>?action=edit_top&language=<?php echo $languageGet; ?>">
<?php Display::display_icon('edit.gif', get_lang('EditHomePage')); ?>
</a>
<a href="<?php echo api_get_self(); ?>?action=edit_top&language=<?php echo $languageGet; ?>">
<?php echo get_lang('EditHomePage'); ?>
</a>
</div>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
@ -1110,7 +1147,6 @@ switch ($action) {
</td>
<td width="10%" valign="top"></td>
<td width="20%" rowspan="3" valign="top">
<div id="login_block" class="well sidebar-nav">
<?php echo api_display_language_form(); ?>
<form id="formLogin">

@ -412,8 +412,9 @@ class SubLanguageManager
// select language - if case several languages match, get the last (more recent) one
$sql = "SELECT english_name
FROM " . $adminLanguagesTable . "
WHERE isocode ='$isocode'
AND available = 1
WHERE
isocode ='$isocode' AND
available = 1
ORDER BY id
DESC LIMIT 1";
$res = Database::query($sql);
@ -434,7 +435,9 @@ class SubLanguageManager
if (empty($preferences)) {
return false;
}
$preferencesArray = explode(',', $preferences);
if (count($preferencesArray) > 0) {
foreach ($preferencesArray as $pref) {
$s = strpos($pref, ';');
@ -444,6 +447,7 @@ class SubLanguageManager
$code = $pref;
}
$name = self::getLanguageFromIsocode($code);
if ($name !== false) {
return $name;
}

@ -65,7 +65,6 @@ if ($enabled == 'true') {
// COURSE ADMIN ONLY VIEW
// Start of tools for CourseAdmins (teachers/tutors)
if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
<div class="normal-message" id="id_normal_message" style="display:none">';

@ -28,9 +28,6 @@
* @package chamilo.course_home
*/
/* INIT SECTION */
use \ChamiloSession as Session;
// Name of the language file that needs to be included.
@ -48,9 +45,7 @@ require_once dirname(__FILE__).'/../inc/global.inc.php';
//unset($_SESSION['lpobject']);
$htmlHeadXtra[] ='<script>
/* option show/hide thematic-block */
$(document).ready(function(){
$("#thematic-show").click(function(){
$(".btn-hide-thematic").hide();
@ -64,7 +59,6 @@ $(document).ready(function(){
});
});
$(document).ready(function() {
$(".make_visible_and_invisible").attr("href", "javascript:void(0);");
$(".make_visible_and_invisible > img").click(function () {
@ -119,7 +113,6 @@ $(document).ready(function() {
});
});
</script>';
// The section for the tabs
@ -255,12 +248,15 @@ $content = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, array(
the setting homepage_view is adjustable through
the platform administration section */
//require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
if ($show_autolunch_lp_warning) {
$show_message .= Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'),'warning');
$show_message .= Display::return_message(
get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'),
'warning'
);
}
if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') {
if (api_get_setting('homepage_view') == 'activity' ||
api_get_setting('homepage_view') == 'activity_big'
) {
require 'activity.php';
} elseif (api_get_setting('homepage_view') == '2column') {
require '2column.php';

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Statement (?) administration
* This script allows to manage the statements of questions.
@ -8,9 +9,6 @@
* @author Olivier Brouckaert
* @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $
*/
/**
* Code
*/
// INIT QUESTION
if (isset($_GET['editQuestion'])) {
@ -44,7 +42,6 @@ if (is_object($objQuestion)) {
$objQuestion->createForm($form);
// answer form elements
$objQuestion->createAnswersForm($form);
// this variable $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications

@ -1,12 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Exercise
* @package chamilo.exercise
*/
/**
* Code
*/
// name of the language file that needs to be included
$language_file='exercice';

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Code library for HotPotatoes integration.
* @package chamilo.exercise
@ -87,7 +88,6 @@ $(function() {
headerSelected: "ui-icon-circle-arrow-s"
};
/* We can add links in the accordion header */
$("div > div > div > .edition > div > a").click(function() {
//Avoid the redirecto when selecting the delete button
@ -105,7 +105,6 @@ $(function() {
collapsible: true,
header: ".header_operations"
})
.sortable({
cursor: "move", // works?
update: function(event, ui) {
@ -205,7 +204,11 @@ if (!$inATest) {
$move = Display::return_icon('all_directions.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
// Question name
$questionName = Display::tag('div', '<a href="#" title = "'.htmlentities($title).'">'.$move.' '.cut($title, 42).'</a>', array('style'=>$styleQuestion));
$questionName = Display::tag(
'div',
'<a href="#" title = "'.Security::remove_XSS($title).'">'.$move.' '.cut($title, 42).'</a>',
array('style'=>$styleQuestion)
);
// Question type
list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();

@ -1,13 +1,12 @@
<?php //$id: $
<?php
/* For licensing terms, see /license.txt */
/**
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak
*/
/**
* Code
*/
// name of the language file that needs to be included
$language_file='exercice';
@ -16,9 +15,7 @@ require '../inc/global.inc.php';
require_once(api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php');
$documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$my_file = Security::remove_XSS($_GET['file']);
$my_file=str_replace(array('../','\\..','\\0','..\\'),array('','','',''),urldecode($my_file));
$title = GetQuizName($my_file,$documentPath);
if ($title =='') {
$title = basename($my_file);

@ -12,7 +12,6 @@
* @author Julio Montoya
* @package chamilo.exercise
**/
class UniqueAnswer extends Question
{
static $typePicture = 'mcua.png';

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Upload quiz: This script shows the upload quiz feature
* Initial work by Isaac flores on Nov 4 of 2010

@ -13,6 +13,9 @@ $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
set_time_limit(0);
ini_set('max_execution_time', 0);
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_data_generator.class.php';

@ -99,7 +99,6 @@ if ($simple_search_form->validate() && (empty($keyword))) {
if (!empty($keyword)) {
$users = find_students($keyword);
} else {
if (isset($alleval) && isset($alllinks)) {
$users = get_all_users($alleval, $alllinks);
@ -107,7 +106,6 @@ if (!empty($keyword)) {
$users = null;
}
}
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
// Main course category

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Gradebook controller
* @package chamilo.gradebook
@ -126,7 +127,9 @@ if (isset($_GET['isStudentView'])) {
}
}
if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) && (isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview')) {
if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) &&
(isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview')
) {
Display :: display_header();
//Introduction tool: student view
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction'));
@ -735,6 +738,7 @@ $no_qualification = false;
// Show certificate link.
$certificate = array();
if ($category != '0') {
$cat = new Category();
$category_id = intval($_GET['selectcat']);

@ -228,6 +228,7 @@ abstract class AbstractLink implements GradebookItem
$result = Database::query($sql);
$links = AbstractLink::create_objects_from_sql_result($result);
return $links;
}

@ -196,7 +196,8 @@ class AttendanceLink extends AbstractLink
return false;
}
public function get_name() {
public function get_name()
{
$this->get_attendance_data();
$attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : '';
$attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : '';

@ -786,14 +786,14 @@ class Category implements GradebookItem
foreach ($links as $link) {
$linkres = $link->calc_score($stud_id);
if (isset($linkres) && $link->get_weight() != 0) {
if (!empty($linkres) && $link->get_weight() != 0) {
$linkweight = $link->get_weight();
$link_res_denom = ($linkres[1] == 0) ? 1 : $linkres[1];
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
$rescount++;
$weightsum += $linkweight;
$ressum += (($linkres[0] / $link_res_denom) * $linkweight);
$ressum += ($linkres[0] / $link_res_denom) * $linkweight;
} else {
// Ddding if result does not exists
// Adding if result does not exists
if ($link->get_weight() != 0) {
$linkweight = $link->get_weight();
$weightsum += $linkweight;
@ -1439,8 +1439,14 @@ class Category implements GradebookItem
$sessionId
);
if (!empty($subcats)) {
/** @var Category $subcat */
foreach ($subcats as $subcat) {
$sublinks = $subcat->get_links($stud_id, false, $course_code, $sessionId);
$sublinks = $subcat->get_links(
$stud_id,
false,
$course_code,
$sessionId
);
$links = array_merge($links, $sublinks);
}
}
@ -1567,10 +1573,19 @@ class Category implements GradebookItem
public static function register_user_certificate($category_id, $user_id)
{
// Generating the total score for a course
$cats_course = Category::load($category_id, null, null, null, null, api_get_session_id(), false);
$alleval_course = $cats_course[0]->get_evaluations($user_id, true);
$alllink_course = $cats_course[0]->get_links($user_id, true);
$cats_course = Category::load(
$category_id,
null,
null,
null,
null,
api_get_session_id(),
false
);
/** @var Category $category */
$category = $cats_course[0];
$alleval_course = $category->get_evaluations($user_id, true);
$alllink_course = $category->get_links($user_id, true);
$evals_links = array_merge($alleval_course, $alllink_course);
//@todo move these in a function
@ -1589,13 +1604,15 @@ class Category implements GradebookItem
$main_weight = $cats_course[0]->get_weight();
$item_total_value = 0;
$item_value = 0;
for ($count=0; $count < count($evals_links); $count++) {
/** @var AbstractLink $item */
$item = $evals_links[$count];
$score = $item->calc_score($user_id);
$divide = ( ($score[1])==0 ) ? 1 : $score[1];
$item_value = 0;
if (!empty($score)) {
$divide = $score[1] == 0 ? 1 : $score[1];
$item_value = $score[0] / $divide * $item->get_weight();
}
$item_total_value += $item_value;
}

@ -157,7 +157,8 @@ abstract class EvalLink extends AbstractLink
/**
* Lazy load function to get the linked evaluation
*/
protected function get_evaluation () {
protected function get_evaluation ()
{
if (!isset($this->evaluation)) {
if (isset($this->ref_id)) {
$evalarray = Evaluation::load($this->get_ref_id());
@ -175,6 +176,7 @@ abstract class EvalLink extends AbstractLink
$this->set_ref_id($eval->get_id());
}
}
return $this->evaluation;
}
}

@ -260,6 +260,7 @@ class ExerciseLink extends AbstractLink
if ($title == '') {
$title = basename($data['path']);
}
return $title;
}
}
@ -334,20 +335,22 @@ class ExerciseLink extends AbstractLink
private function get_exercise_data()
{
$TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if ($this->is_hp == 1) {
$tbl_exercise = Database :: get_course_table(TABLE_DOCUMENT);
} else {
$tbl_exercise = $this->get_exercise_table();
}
$ref_id = intval($this->get_ref_id());
if ($tbl_exercise == '') {
return false;
} elseif (!isset($this->exercise_data)) {
if ($this->is_hp == 1) {
$ref_id = intval($this->get_ref_id());
$sql = "SELECT * FROM $tbl_exercise ex, $TBL_ITEM_PROPERTY ip
$sql = "SELECT * FROM $tbl_exercise ex
INNER JOIN $TBL_ITEM_PROPERTY ip
ON (ip.ref = ex.id AND ip.c_id = ex.c_id)
WHERE
ip.ref = ex.id AND
ip.c_id = $this->course_id AND
ex.c_id = $this->course_id AND
ip.ref = $ref_id AND
@ -359,7 +362,7 @@ class ExerciseLink extends AbstractLink
$sql = 'SELECT * FROM '.$tbl_exercise.'
WHERE
c_id = '.$this->course_id.' AND
id = '.(int)$this->get_ref_id().' ';
id = '.$ref_id.' ';
}
$result = Database::query($sql);
$this->exercise_data = Database::fetch_array($result);

@ -202,7 +202,10 @@ class StudentPublicationLink extends AbstractLink
// for 1 student
if (!empty($stud_id)) {
if ($data = Database::fetch_array($scores)) {
return array($data['qualification'], $assignment['qualification']);
return array(
$data['qualification'],
$assignment['qualification']
);
} else {
return '';
}

@ -69,8 +69,15 @@ class SurveyLink extends AbstractLink
WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id).'';
$result = Database::query($sql);
while ($data = Database::fetch_array($result)) {
$links[] = array($data['survey_id'], api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80));
};
$links[] = array(
$data['survey_id'],
api_trunc_str(
$data['code'] . ': ' . self::html_to_text($data['title']),
80
)
);
}
return isset($links) ? $links : null;
}
@ -112,7 +119,6 @@ class SurveyLink extends AbstractLink
$session_id = api_get_session_id();
$tbl_survey = Database::get_course_table(TABLE_SURVEY);
$tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
$get_individual_score = !is_null($stud_id);
$sql = "SELECT
COUNT(i.answered)
FROM $tbl_survey AS s
@ -153,7 +159,9 @@ class SurveyLink extends AbstractLink
WHERE
s.c_id = {$this->course_id} AND
i.c_id = {$this->course_id} AND
s.survey_id = $ref_id AND i.session_id = $session_id";
s.survey_id = $ref_id AND
i.session_id = $session_id
";
if ($get_individual_score) {
$sql .= ' AND i.user = '.intval($stud_id);
@ -199,7 +207,10 @@ class SurveyLink extends AbstractLink
{
$session_id = api_get_session_id();
$sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().'
WHERE c_id = '.$this->course_id.' AND survey_id = '.intval($this->get_ref_id()).' AND session_id='.intval($session_id).'';
WHERE
c_id = '.$this->course_id.' AND
survey_id = '.intval($this->get_ref_id()).' AND
session_id='.intval($session_id).'';
$result = Database::query($sql);
$number = Database::fetch_row($result);
return ($number[0] != 0);
@ -217,7 +228,10 @@ class SurveyLink extends AbstractLink
$session_id = api_get_session_id();
if ($tbl_name != '') {
$sql = 'SELECT survey_id FROM '.$this->get_survey_table().'
WHERE c_id = '.$this->course_id.' AND survey_id = '.intval($this->get_ref_id()).' AND session_id = '.intval($session_id).' ';
WHERE
c_id = '.$this->course_id.' AND
survey_id = '.intval($this->get_ref_id()).' AND
session_id = '.intval($session_id).' ';
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
$survey_id = $row['survey_id'];
@ -234,7 +248,11 @@ class SurveyLink extends AbstractLink
if ($tbl_name == '') {
return false;
} elseif (!isset($this->survey_data)) {
$sql = 'SELECT * FROM '.$tbl_name.' WHERE c_id = '.$this->course_id.' AND survey_id = '.intval($this->get_ref_id()).' AND session_id='.intval($session_id).'';
$sql = 'SELECT * FROM '.$tbl_name.'
WHERE
c_id = '.$this->course_id.' AND
survey_id = '.intval($this->get_ref_id()).' AND
session_id='.intval($session_id).'';
$query = Database::query($sql);
$this->survey_data = Database::fetch_array($query);
}
@ -248,6 +266,7 @@ class SurveyLink extends AbstractLink
private static function html_to_text($string)
{
return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES));
return strip_tags($string);
//return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES));
}
}

@ -439,13 +439,15 @@ class DisplayGradebook
for ($count = 0; $count < count($allEvalsLinks); $count++) {
$item = $allEvalsLinks[$count];
$score = $item->calc_score($user_id);
$divide = ( ($score[1]) == 0 ) ? 1 : $score[1];
if (!empty($score)) {
$divide = $score[1] == 0 ? 1 : $score[1];
//$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
//$item_value = $score[0] / $divide * $item->get_weight() / $sub_cat_percentage * $sub_cat_percentage / $main_weight * $main_weight;
$item_value = $score[0] / $divide * $item->get_weight();
//var_dump($score[0], $divide, $item->get_weight(), $sub_cat_percentage, $main_weight, $item_value);
$item_value_total += $item_value;
}
}
$item_total = $main_weight;
$total_score = array($item_value_total, $item_total);

@ -57,6 +57,7 @@ class FlatViewDataGenerator
/**
* Get total number of users (rows)
* @return int
*/
public function get_total_users_count()
{
@ -65,6 +66,7 @@ class FlatViewDataGenerator
/**
* Get total number of evaluations/links (columns) (the 2 users columns not included)
* @return int
*/
public function get_total_items_count()
{
@ -161,9 +163,6 @@ class FlatViewDataGenerator
foreach ($allcat as $sub_cat) {
$sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1);
$add_weight = " $sub_cat_weight %";
/*if (isset($this->params['export_pdf']) && $this->params['export_pdf']) {
$add_weight = null;
}*/
$headers[] = Display::url(
$sub_cat->get_name(),
api_get_self().'?selectcat='.$sub_cat->get_id()
@ -188,7 +187,9 @@ class FlatViewDataGenerator
for ($count = 0; ($count < $items_count) && ($items_start + $count < count($this->evals_links)); $count++) {
/** @var AbstractLink $item */
$item = $this->evals_links[$count + $items_start];
if ($mainCategoryId == $item->get_category_id() && !in_array($item->get_id(), $evaluationsAdded)) {
if ($mainCategoryId == $item->get_category_id() &&
!in_array($item->get_id(), $evaluationsAdded)
) {
$weight = round(100 * $item->get_weight() / $main_weight, 1);
$headers[] = $item->get_name() . ' ' . $weight . ' % ';
}
@ -220,6 +221,7 @@ class FlatViewDataGenerator
/**
* Get array containing evaluation items
* @return array
*/
public function get_evaluation_items($items_start = 0, $items_count = null)
{
@ -273,6 +275,7 @@ class FlatViewDataGenerator
// sort users array
if ($users_sorting & self :: FVDG_SORT_LASTNAME) {
usort($userTable, array('FlatViewDataGenerator','sort_by_last_name'));
} elseif ($users_sorting & self :: FVDG_SORT_FIRSTNAME) {
usort($userTable, array('FlatViewDataGenerator','sort_by_first_name'));
}
@ -796,11 +799,21 @@ class FlatViewDataGenerator
return $data;
}
/**
* @param $item1
* @param $item2
* @return int
*/
public function sort_by_last_name($item1, $item2)
{
return api_strcmp($item1[2], $item2[2]);
}
/**
* @param $item1
* @param $item2
* @return int
*/
public function sort_by_first_name($item1, $item2)
{
return api_strcmp($item1[3], $item2[3]);

@ -5,6 +5,7 @@
* Script
* @package chamilo.gradebook
*/
/**
* These are functions used in gradebook
*
@ -110,6 +111,7 @@ function remove_resource_from_course_gradebook($link_id)
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = "DELETE FROM $l WHERE id = ".(int)$link_id;
Database::query($sql);
return true;
}
@ -127,7 +129,9 @@ function block_students()
function get_course_name_from_code($code)
{
$tbl_main_categories = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql = 'SELECT title, code FROM ' . $tbl_main_categories . 'WHERE code = "' . Database::escape_string($code) . '"';
$sql = 'SELECT title, code
FROM ' . $tbl_main_categories . '
WHERE code = "' . Database::escape_string($code) . '"';
$result = Database::query($sql);
if ($col = Database::fetch_array($result)) {
return $col['title'];
@ -194,6 +198,7 @@ function get_icon_file_name($type)
$icon = 'link.gif';
break;
}
return $icon;
}
@ -400,7 +405,10 @@ function is_resource_in_course_gradebook($course_code, $resource_type, $resource
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$course_code = Database::escape_string($course_code);
$sql = "SELECT * FROM $l l
WHERE course_code = '$course_code' AND type = ".(int)$resource_type . " AND ref_id = " . (int)$resource_id;
WHERE
course_code = '$course_code' AND
type = ".(int)$resource_type . " AND
ref_id = " . (int)$resource_id;
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
@ -649,7 +657,8 @@ function get_list_users_certificates($cat_id = null, $userList = array())
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username
FROM ' . $table_user . ' u
INNER JOIN ' . $table_certificate . ' gc ON u.user_id=gc.user_id ';
INNER JOIN ' . $table_certificate . ' gc
ON u.user_id=gc.user_id ';
if (!is_null($cat_id) && $cat_id > 0) {
$sql.=' WHERE cat_id=' . intval($cat_id);
}

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Various user related functions
* @author Julio Montoya <gugli100@gmail.com> adding security functions
@ -23,17 +24,25 @@ function get_users_in_course($course_id)
if (!empty($current_session)) {
$sql = "SELECT user.user_id, user.username, lastname, firstname, official_code
FROM $tbl_session_course_user as scru, $tbl_user as user
WHERE scru.id_user=user.user_id
AND scru.status=0
AND scru.course_code='$course_id' AND id_session ='$current_session' $order_clause ";
WHERE
scru.id_user=user.user_id AND
scru.status=0 AND
scru.course_code='$course_id' AND
id_session ='$current_session'
$order_clause
";
} else {
$sql = 'SELECT user.user_id, user.username, lastname, firstname, official_code
FROM '.$tbl_course_user.' as course_rel_user, '.$tbl_user.' as user
WHERE course_rel_user.user_id=user.user_id AND
WHERE
course_rel_user.user_id=user.user_id AND
course_rel_user.status='.STUDENT.' AND
course_rel_user.course_code = "'.$course_id.'" '.$order_clause;
course_rel_user.course_code = "'.$course_id.'" '.
$order_clause;
}
$result = Database::query($sql);
return get_user_array_from_sql_result($result);
}
@ -68,14 +77,22 @@ function get_all_users ($evals = array(), $links = array())
$coursecodes[$coursecode] = '1';
$users = array_merge($users, get_users_in_course($coursecode));
}
} else {// course independent evaluation
} else {
// course independent evaluation
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_res = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'SELECT user.user_id, lastname, firstname, user.official_code
FROM '.$tbl_res.' as res, '.$tbl_user.' as user
WHERE res.evaluation_id = '.intval($eval->get_id())
.' AND res.user_id = user.user_id';
WHERE
res.evaluation_id = '.intval($eval->get_id()).' AND
res.user_id = user.user_id
';
$sql .= ' ORDER BY lastname, firstname';
if (api_is_western_name_order()) {
$sql .= ' ORDER BY firstname, lastname';
}
$result = Database::query($sql);
$users = array_merge($users, get_user_array_from_sql_result($result));
}
@ -89,7 +106,7 @@ function get_all_users ($evals = array(), $links = array())
$users = array_merge($users, get_users_in_course($coursecode));
}
}
unset ($coursecodes);
return $users;
}
@ -107,7 +124,8 @@ function find_students($mask= '')
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_cru = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql= 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code ' . ' FROM ' . $tbl_user . ' user';
$sql = 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code
FROM ' . $tbl_user . ' user';
if (!api_is_platform_admin()) {
$sql .= ', ' . $tbl_cru . ' cru';
}
@ -117,12 +135,26 @@ function find_students($mask= '')
$sql .= ' OR user.firstname LIKE '."'%" . $mask . "%')";
if (!api_is_platform_admin()) {
$sql .= ' AND user.user_id = cru.user_id AND cru.relation_type<>'.COURSE_RELATION_TYPE_RRHH.' ' . ' AND cru.course_code in' . ' (SELECT course_code' . ' FROM ' . $tbl_cru . ' WHERE user_id = ' . api_get_user_id() . ' AND status = ' . COURSEMANAGER . ')';
$sql .= ' AND user.user_id = cru.user_id AND
cru.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' AND
cru.course_code in (
SELECT course_code FROM '.$tbl_cru . '
WHERE
user_id = ' . api_get_user_id() . ' AND
status = ' . COURSEMANAGER . '
)
';
}
$sql .= ' ORDER BY lastname, firstname';
if (api_is_western_name_order()) {
$sql .= ' ORDER BY firstname, lastname';
}
$sql .= ' ORDER BY lastname';
$result = Database::query($sql);
$db_users= Database::store_result($result);
return $db_users;
$users = Database::store_result($result);
return $users;
}
/**

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* The INTRODUCTION MICRO MODULE is used to insert and edit
* an introduction section on a Chamilo module or on the course homepage.
@ -18,7 +19,7 @@
*
* usage :
*
* $moduleId = XX // specifying the module Id
* $moduleId = 'XX'; // specifying the module tool (string value)
* include(introductionSection.inc.php);
*
* This script is also used since Chamilo 1.9 to show course progress (from the
@ -91,19 +92,27 @@ $form->addElement('style_submit_button', 'intro_cmdUpdate', get_lang('SaveIntroT
$course_id = api_get_course_int_id();
if ($intro_editAllowed) {
$moduleId = intval($moduleId);
/* Replace command */
if ($intro_cmdUpdate) {
if ($form->validate()) {
$form_values = $form->exportValues();
$intro_content = Security::remove_XSS(stripslashes(api_html_entity_decode($form_values['intro_content'])), COURSEMANAGERLOWSECURITY);
if (!empty($intro_content)) {
$sql = "REPLACE $TBL_INTRODUCTION SET c_id = $course_id, id='$moduleId',intro_text='".Database::escape_string($intro_content)."', session_id='".intval($session_id)."'";
$sql = "REPLACE $TBL_INTRODUCTION
SET
c_id = $course_id, id='".Database::escape_string($moduleId)."',
intro_text='".Database::escape_string($intro_content)."',
session_id='".intval($session_id)."'
";
Database::query($sql);
$introduction_section .= Display::return_message(get_lang('IntroductionTextUpdated'),'confirmation', false);
$introduction_section .= Display::return_message(
get_lang('IntroductionTextUpdated'),
'confirmation',
false
);
} else {
$intro_cmdDel = true; // got to the delete command
// got to the delete command
$intro_cmdDel = true;
}
} else {
$intro_cmdEdit = true;
@ -112,12 +121,16 @@ if ($intro_editAllowed) {
/* Delete Command */
if ($intro_cmdDel) {
Database::query("DELETE FROM $TBL_INTRODUCTION WHERE c_id = $course_id AND id='".$moduleId."' AND session_id='".intval($session_id)."'");
$sql = "DELETE FROM $TBL_INTRODUCTION
WHERE
c_id = $course_id AND
id='".Database::escape_string($moduleId)."' AND
session_id='".intval($session_id)."'";
Database::query($sql);
$introduction_section .= Display::return_message(get_lang('IntroductionTextDeleted'), 'confirmation');
}
}
/* INTRODUCTION MICRO MODULE - DISPLAY SECTION */
/* Retrieves the module introduction text, if exist */
@ -126,6 +139,7 @@ if ($intro_editAllowed) {
$intro_content = null;
$sql = "SELECT intro_text FROM $TBL_INTRODUCTION
WHERE c_id = $course_id AND id='".Database::escape_string($moduleId)."' AND session_id = 0";
$intro_dbQuery = Database::query($sql);
if (Database::num_rows($intro_dbQuery) > 0) {
$intro_dbResult = Database::fetch_array($intro_dbQuery);
@ -337,9 +351,6 @@ $introduction_section .= '</div>';
$introduction_section .= '<div class="home-course-intro span12"><div class="page-course">';
if ($intro_dispDefault) {
$intro_content = $intro_content;
if (!empty($intro_content)) {
$introduction_section.='<div class="page-course-intro">';
$introduction_section .= $intro_content;

@ -142,7 +142,13 @@ class Display
echo self::return_introduction_section($tool, $editor_config);
}
public static function return_introduction_section($tool, $editor_config = null) {
/**
* @param string $tool
* @param array $editor_config
* @return null
*/
public static function return_introduction_section($tool, $editor_config = null)
{
$is_allowed_to_edit = api_is_allowed_to_edit();
$moduleId = $tool;
if (api_get_setting('enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {

@ -1011,7 +1011,15 @@ function api_get_months_long($language = null) {
* @author Carlos Vargas <carlos.vargas@dokeos.com> - initial implementation.
* @author Ivan Tcholakov
*/
function api_get_person_name($first_name, $last_name, $title = null, $format = null, $language = null, $encoding = null, $username = null) {
function api_get_person_name(
$first_name,
$last_name,
$title = null,
$format = null,
$language = null,
$encoding = null,
$username = null
) {
static $valid = array();
if (empty($format)) {
$format = PERSON_NAME_COMMON_CONVENTION;
@ -1025,6 +1033,7 @@ function api_get_person_name($first_name, $last_name, $title = null, $format = n
if (empty($encoding)) {
$encoding = _api_mb_internal_encoding();
}
if (!isset($valid[$format][$language])) {
if (is_int($format)) {
switch ($format) {
@ -1078,7 +1087,7 @@ function api_get_person_name($first_name, $last_name, $title = null, $format = n
/**
* Checks whether a given format represents person name in Western order (for which first name is first).
* @param int/string $format (optional) The person name format. It may be a pattern-string (for example '%t. %l, %f') or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER.
* @param string $language (optional) The language indentificator. If it is omited, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only.
* @param string $language (optional) The language identificator. If it is omited, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only.
* @return bool The result TRUE means that the order is first_name last_name, FALSE means last_name first_name.
* Note: You may use this function for determing the order of the fields or columns "First name" and "Last name" in forms, tables and reports.
* @author Ivan Tcholakov
@ -2499,7 +2508,8 @@ function api_strcasecmp($string1, $string2, $language = null, $encoding = null)
* @link http://php.net/manual/en/function.strcmp.php
* @link http://php.net/manual/en/collator.compare.php
*/
function api_strcmp($string1, $string2, $language = null, $encoding = null) {
function api_strcmp($string1, $string2, $language = null, $encoding = null)
{
if (INTL_INSTALLED) {
$collator = _api_get_collator($language);
if (is_object($collator)) {

@ -84,15 +84,7 @@ return array(
'simpl_chinese' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name' ), // Eastern order
'slovak' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name'),
'slovenian' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name'),
//'spanish' => array( 'format' => 'title first_name last_name', 'sort_by' => 'last_name'),
//'spanish' => array( 'format' => 'title last_name first_name', 'sort_by' => 'last_name'),
// Some experimental settings for Spanish language:
//'spanish' => array( 'format' => 'title first_name LAST_NAME', 'sort_by' => 'first_name'), // Western order, last name is uppercase when a full name is assembled
//'spanish' => array( 'format' => 'title first_name LAST_NAME', 'sort_by' => 'last_name'), // Western order, last name is uppercase when a full name is assembled
'spanish' => array('format' => 'title last_name, first_name', 'sort_by' => 'last_name'), // Library order
//'spanish' => array( 'format' => 'title LAST_NAME, first_name', 'sort_by' => 'last_name'), // Library order, last name is uppercase when a full name is assembled
'swahili' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name'),
'swedish' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name'),
'tagalog' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name'),

@ -196,18 +196,16 @@ function &_api_get_day_month_names($language = null) {
return $date_parts[$language];
}
/**
* Appendix to "Name order conventions"
*/
/**
* Returns returns person name convention for a given language.
* @param string $language The input language.
* @param string $type The type of the requested convention. It may be 'format' for name order convention or 'sort_by' for name sorting convention.
* @return mixed Depending of the requested type, the returned result may be string or boolean; null is returned on error;
* @param string $type The type of the requested convention.
* It may be 'format' for name order convention or 'sort_by' for name sorting convention.
* @return mixed Depending of the requested type,
* the returned result may be string or boolean; null is returned on error;
*/
function _api_get_person_name_convention($language, $type) {
function _api_get_person_name_convention($language, $type)
{
static $conventions;
$language = api_purify_language_id($language);
if (!isset($conventions)) {
@ -215,8 +213,22 @@ function _api_get_person_name_convention($language, $type) {
if (file_exists($file)) {
$conventions = include ($file);
} else {
$conventions = array('english' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name'));
$conventions = array(
'english' => array(
'format' => 'title first_name last_name',
'sort_by' => 'first_name'
)
);
}
// Overwrite classic conventions
$customConventions = api_get_configuration_value('name_order_conventions');
if (!empty($customConventions)) {
foreach ($customConventions as $key => $data) {
$conventions[$key] = $data;
}
}
$search1 = array('FIRST_NAME', 'LAST_NAME', 'TITLE');
$replacement1 = array('%F', '%L', '%T');
$search2 = array('first_name', 'last_name', 'title');

@ -3776,8 +3776,8 @@ function api_get_languages_combo($name = 'language', $chozen=true) {
* @param boolean Hide form if only one language available (defaults to false = show the box anyway)
* @return void Display the box directly
*/
function api_display_language_form($hide_if_no_choice = false) {
function api_display_language_form($hide_if_no_choice = false)
{
// Retrieve a complete list of all the languages.
$language_list = api_get_languages();
if (count($language_list['name']) <= 1 && $hide_if_no_choice) {
@ -3788,7 +3788,6 @@ function api_display_language_form($hide_if_no_choice = false) {
if (isset($_SESSION['user_language_choice'])) {
$user_selected_language = $_SESSION['user_language_choice'];
}
if (empty($user_selected_language)) {
$user_selected_language = api_get_setting('platformLanguage');
}
@ -3808,7 +3807,6 @@ function api_display_language_form($hide_if_no_choice = false) {
$html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
$html .= '<select id="language_list" class="chzn-select" name="language_list" onchange="javascript: jumpMenu(\'parent\',this,0);">';
foreach ($original_languages as $key => $value) {
if ($folder[$key] == $user_selected_language) {
$option_end = ' selected="selected" >';
@ -6416,12 +6414,15 @@ function api_is_multiple_url_enabled() {
* Returns a md5 unique id
* @todo add more parameters
*/
function api_get_unique_id() {
$id = md5(time().uniqid().api_get_user_id().api_get_course_id().api_get_session_id());
return $id;
}
/**
* Get home path
* @return string
*/
function api_get_home_path() {
$home = 'home/';
if (api_get_multiple_access_url()) {
@ -6432,8 +6433,9 @@ function api_get_home_path() {
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
// if $clean_url == "localhost/" means that the multiple URL was not well configured we don't rename the $home variable
if ($clean_url != 'localhost/')
//if ($clean_url != 'localhost/') {
$home = 'home/' . $clean_url;
//}
}
return $home;
}

@ -2741,9 +2741,9 @@ class SessionManager
}
}
}
// Inserting new sessions list.
if (!empty($sessions_list) && is_array($sessions_list)) {
foreach ($sessions_list as $session_id) {
$session_id = intval($session_id);
$sql = "INSERT IGNORE INTO $tbl_session_rel_user (id_session, id_user, relation_type)

@ -14,6 +14,10 @@ class IndexManager
public $home = '';
public $default_home = 'home/';
/**
* Construct
* @param string $title
*/
public function __construct($title)
{
$this->tpl = new Template($title);
@ -39,9 +43,7 @@ class IndexManager
// Only display if the user isn't logged in.
$this->tpl->assign('login_language_form', api_display_language_form(true));
if ($setLoginForm) {
$this->tpl->assign('login_form', self::display_login_form());
if ($loginFailed) {
@ -213,11 +215,15 @@ class IndexManager
if (!empty($html)) {
$html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block');
}
return $html;
}
/* Includes a created page */
function return_home_page()
/**
* Includes a created page
* @return string
*/
public function return_home_page()
{
$userId = api_get_user_id();
global $_configuration;
@ -229,7 +235,9 @@ class IndexManager
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
} else {
// Hiding home top when user not connected.
if (isset($_configuration['hide_home_top_when_connected']) && $_configuration['hide_home_top_when_connected'] && !empty($userId)) {
if (isset($_configuration['hide_home_top_when_connected']) &&
$_configuration['hide_home_top_when_connected'] && !empty($userId)
) {
return $html;
}
@ -241,20 +249,22 @@ class IndexManager
$user_selected_language = api_get_setting('platformLanguage');
}
if (!file_exists($this->home.'home_news_'.$user_selected_language.'.html')) {
if (file_exists($this->home.'home_top.html')) {
$home_top_temp = file($this->home.'home_top.html');
} else {
$home_top_temp = file($this->default_home.'home_top.html');
}
$home_top_temp = implode('', $home_top_temp);
} else {
// Try language specific home
if (file_exists($this->home.'home_top_'.$user_selected_language.'.html')) {
$home_top_temp = file_get_contents($this->home.'home_top_'.$user_selected_language.'.html');
} else {
}
// Try default language home
if (empty($home_top_temp)) {
if (file_exists($this->home.'home_top.html')) {
$home_top_temp = file_get_contents($this->home.'home_top.html');
} else {
if (file_exists($this->default_home.'home_top.html')) {
$home_top_temp = file_get_contents($this->default_home . 'home_top.html');
}
}
}
if (trim($home_top_temp) == '' && api_is_platform_admin()) {
$home_top_temp = '<div class="welcome-mascot">' . get_lang('PortalHomepageDefaultIntroduction') . '</div>';
} else {
@ -263,6 +273,7 @@ class IndexManager
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
}
return $html;
}

@ -278,3 +278,7 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['exercise_max_fckeditors_in_page'] = 0;
// Default upload option
//$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite
// Custom name_order_conventions
//$_configuration['name_order_conventions'] = array(
// 'french' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name')
//);

@ -33,7 +33,6 @@ require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php';
api_block_anonymous_users();
if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) {
// Check if the user is tutor of the course
$user_course_status = CourseManager::get_tutor_in_course_status(
@ -304,8 +303,6 @@ $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_course_info()
);
if (api_is_drh() && !api_is_platform_admin()) {
if (!empty($student_id)) {
if (api_drh_can_access_all_session_content()) {
@ -352,8 +349,7 @@ if (!empty($student_id)) {
}
echo $send_mail;
if (!empty($student_id) && !empty($_GET['course'])) {
//only show link to connection details if course and student were defined in the URL
// Only show link to connection details if course and student were defined in the URL
echo '<a href="access_details.php?student=' . $student_id . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq='.Security::remove_XSS($_GET['course']).'&amp;id_session='.$session_id.'">'.
Display :: return_icon('statistics.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>';
}
@ -418,7 +414,7 @@ if (!empty($student_id)) {
$last_connection_date = get_lang('NoConnexion');
}
// cvs informations
// cvs information
$csv_content[] = array(
get_lang('Informations', '')
);
@ -614,7 +610,6 @@ if (!empty($student_id)) {
</td>
</tr>
</table>
<?php
$table_title = '';
@ -827,7 +822,10 @@ if (!empty($student_id)) {
array($lp_id),
$session_id
);
if (!empty($total_time)) $any_result = true;
if (!empty($total_time)) {
$any_result = true;
}
// Get last connection time in lp
$start_time = Tracking::get_last_connection_time_in_lp(
@ -913,14 +911,17 @@ if (!empty($student_id)) {
if ($from_myspace) {
$from ='&from=myspace';
}
$link = Display::url('<img src="../img/2rightarrow.gif" border="0" />','lp_tracking.php?course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id);
$link = Display::url(
'<img src="../img/2rightarrow.gif" border="0" />',
'lp_tracking.php?cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id
);
echo Display::tag('td', $link);
}
if (api_is_allowed_to_edit()) {
echo '<td>';
if ($any_result === true) {
echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
echo '</a>';
}

@ -3,7 +3,7 @@
/**
* Controller for REST request
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.tour
* @package chamilo.webservices
*/
/* Require libs and classes */
require_once '../main/inc/global.inc.php';
Loading…
Cancel
Save