Merge 1.10.x

1.10.x
Julio Montoya 11 years ago
commit 810d17fa90
  1. 20
      main/cron/create_course_sessions.php
  2. 65
      main/css/base.css
  3. 140
      main/css/chamilo/default.css
  4. BIN
      main/css/chamilo/images/border-line.png
  5. BIN
      main/css/chamilo/images/header-logo.png
  6. BIN
      main/css/chamilo/images/nav-border.png
  7. 4
      main/gradebook/gradebook.php
  8. 14
      main/gradebook/gradebook_display_certificate.php
  9. 64
      main/gradebook/index.php
  10. 55
      main/gradebook/lib/be/category.class.php
  11. 6
      main/gradebook/lib/be/evaluation.class.php
  12. 63
      main/gradebook/lib/fe/displaygradebook.php
  13. 10
      main/gradebook/lib/fe/gradebooktable.class.php
  14. 51
      main/inc/ajax/model.ajax.php
  15. 7
      main/inc/lib/banner.lib.php
  16. 9
      main/inc/lib/certificate.lib.php
  17. 172
      main/inc/lib/course.lib.php
  18. 1
      main/inc/lib/hook/HookCreateUser.php
  19. 5
      main/inc/lib/usermanager.lib.php
  20. 4
      main/install/database.sql
  21. 7
      main/install/index.php
  22. 4
      main/install/install.lib.php
  23. 18
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  24. 29
      main/install/update-db-1.9.0-1.10.0.inc.php
  25. 15
      main/link/index.php
  26. 3
      main/mySpace/company_reports.php
  27. 9
      main/mySpace/company_reports_resumed.php
  28. 2
      main/newscorm/learnpathItem.class.php
  29. 90
      main/newscorm/lp_view.php
  30. 2
      main/social/groups.php
  31. 2
      main/social/invitations.php
  32. 14
      main/upload/form.scorm.php
  33. 5
      plugin/createdrupaluser/src/HookCreateDrupalUser.php
  34. 41
      tests/scripts/course2session.php

@ -21,10 +21,11 @@ define("OFFSET", "15");
/**
* If no $initialDate is supplied, returns an array with the first and last days of the current
* month. Otherwise, returns an array with the first and last days of the $initialDate month .
* @param array First day of the month
* @param array $initialDate First day of the month
* @return array First and last days of the month
*/
function getMonthFirstAndLastDates($initialDate = null) {
function getMonthFirstAndLastDates($initialDate = null)
{
$startDate = $initialDate ? $initialDate : date("Y-m-01");
$nextMonthStartDate = date("Y-m-d", api_strtotime($startDate." + 1 month"));
$endDate = date("Y-m-d", api_strtotime($nextMonthStartDate." - 1 minute"));
@ -34,13 +35,14 @@ function getMonthFirstAndLastDates($initialDate = null) {
/**
* Creates one session per course with $administratorId as the creator and
* adds it to the session starting on $startDate and finishing on $endDate
* @param array Courses
* @param int Administrator id
* @param date First day of the month
* @param date Last day of the month
* @param array $courses Courses
* @param int $administratorId Administrator id
* @param date $startDate First day of the month
* @param date $endDate Last day of the month
* @return void
*/
function createCourseSessions($courses, $administratorId, $startDate, $endDate) {
function createCourseSessions($courses, $administratorId, $startDate, $endDate)
{
echo "\n";
echo $courses ?
"Creating sessions and adding courses for the period between ".$startDate." and ".$endDate :
@ -48,7 +50,7 @@ function createCourseSessions($courses, $administratorId, $startDate, $endDate)
echo "\n=====================================================================================\n\n";
// Loop through courses creating one session per each and adding them
foreach ($courses as $course) {
$sessionName = $course['title']." (".date("M Y", api_strtotime($startDate)).")";
$sessionName = $course['title']." (".date("m/Y", api_strtotime($startDate)).")";
$sessionId = SessionManager::create_session(
$sessionName,
$startDate,
@ -66,7 +68,7 @@ function createCourseSessions($courses, $administratorId, $startDate, $endDate)
}
// Starts the script
echo "Starting process..." . PHP_EOL;
// Get first active administrator
$administrators = array_reverse(UserManager::get_all_administrators());
$lastingAdministrators = count($administrators);

@ -24,12 +24,6 @@ html,body{
display: block;
clear: both;
}
footer {
width: 100%;
height: 100px;
margin: 0px auto 0;
background-color: #f5f5f5;
}
/* chzn-select fix */
select {
@ -62,7 +56,7 @@ select {
#announcements-slider .left, #announcements-slider .right{
position: absolute;
top: 50%;
background: #C52D2F;
background: #00829C;
color: #fff;
margin-top: -25px;
height: 40px;
@ -401,14 +395,15 @@ footer {
position: relative;
bottom: 0;
width: 100%;
height: 80px;
background-color: #f5f5f5;
height: 100px;
}
#footer_left, #footer_center, #footer_right {
margin: 20px 0 0 0;
}
#footer_right{
text-align: right;
}
/* Sticky footer*/
.push {
height: 9em; /* Very important */
@ -3382,7 +3377,7 @@ form .formw .freeze {
padding-bottom: 10px;
}
.scorm_item_normal{
padding:10px;
padding:0;
border-bottom: 1px solid #DCDCDC;
border-left: 1px solid #DCDCDC;
border-right: 1px solid #DCDCDC;
@ -3399,6 +3394,9 @@ form .formw .freeze {
.scorm_highlight a{
color: #ffffff !important;
}
#scorm-info .panel-heading{
padding: 5px;
}
/* .scorm_item_normal .scorm_item_level_1{
padding-left: 1.8em;
padding-right: 1.5em;
@ -5550,6 +5548,13 @@ ul.holder li.bit-box a.closebutton{
#learning_path_left_zone #ui-option{
width: 100%;
display: block;
text-align: center;
cursor: pointer;
}
#learning_path_left_zone #ui-option #icon-up,
#learning_path_left_zone #ui-option #icon-down{
width: 100%;
display: block;
}
.hidden{
visibility: hidden;
@ -5628,19 +5633,38 @@ ul.holder li.bit-box a.closebutton{
width: 25.66666667%;
}
.content-scorm{
width: 74.33333333%;
width: 76.33333333%;
}
.total{
width: 100%;
}
#learning_path_right_zone{
width: 68%;
display: block;
padding-left: 0;
padding-right: 0;
}
#learning_path_right_zone.total{
width: 100%;
visibility: visible;
padding-left: 15px;
padding-right: 15px;
}
}
/* Portrait tablet to landscape and desktop - Escritorio pequeño o Tablet */
@media (min-width: 768px) and (max-width: 979px) {
}
/* Landscape phone to portrait tablet - Tablet o Smartphone Horizontal */
@media (max-width: 767px) {
#learning_path_right_zone{
width: 58%;
display: block;
padding-left: 0;
padding-right: 0;
}
#learning_path_right_zone.total{
width: 100%;
padding-left: 15px;
padding-right: 15px;
visibility: visible;
}
}
/* Landscape phones and down - Solo Smartphone*/
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
@ -5679,8 +5703,15 @@ ul.holder li.bit-box a.closebutton{
.content-scorm{
visibility: hidden;
}
#control-bottom.well{
padding: 10px;
}
.total{
width: 100%;
visibility: visible;
}
#learning_path_left_zone{
width: 100%;
display: block;
}
}

@ -5,38 +5,150 @@
* Licensed GLP
* Based on Bootstrap
*/
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,700);
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
font-family: 'Open Sans', sans-serif;
line-height: 1.72222;
}
a {
color: #00829C;
text-decoration: none;
-webkit-transition: .25s;
transition: .25s;
}
a:hover,
a:focus {
color: #1abc9c;
text-decoration: none;
}
a:focus {
outline: none;
}
.navbar{
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
}
.navbar {
background-image: -webkit-linear-gradient(#54b4eb, #2fa4e7 60%, #1d9ce5);
background-image: -o-linear-gradient(#54b4eb, #2fa4e7 60%, #1d9ce5);
background-image: -webkit-gradient(linear, left top, left bottom, from(#54b4eb), color-stop(60%, #2fa4e7), to(#1d9ce5));
background-image: linear-gradient(#54b4eb, #2fa4e7 60%, #1d9ce5);
background-repeat: no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff54b4eb', endColorstr='#ff1d9ce5', GradientType=0);
border-bottom: 1px solid #178acc;
background: #00829C;
-webkit-filter: none;
filter: none;
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1);
}
.navbar:after{
background: url("images/nav-border.png") repeat-x;
height: 5px;
width: 100%;
display: block;
content: "";
}
.nav > li > a{
padding: 10px 15px;
}
.navbar-nav > li > a{
font-size: 14px;
font-weight: 600;
line-height: 21px;
padding-top: 19.5px;
padding-bottom: 19.5px;
background: url("images/border-line.png") no-repeat 100% 50%;
}
.navbar-default .navbar-nav > li > a:focus,
.navbar-default .navbar-nav > li > a:hover {
color: #A4DC2D;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus{
color: #fff;
background-color:#00677C;
}
.navbar-default .navbar-nav > li > a{
color: #ffffff;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus{
background: #00677C;
color: #ffffff;
}
.navbar-nav > li > .dropdown-menu{
min-width: 100%;
margin-top: 5px;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
}
.navbar-default .navbar-nav > .open > .dropdown-menu{
padding: 3px 4px;
background-color: #00677C;
}
.navbar-default .navbar-nav > .open > .dropdown-menu > li > a{
padding: 6px 9px;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
color: #ffffff !important;
}
.navbar-default .navbar-nav > .open > .dropdown-menu > li > a:hover,
.navbar-default .navbar-nav > .open > .dropdown-menu > li > a:focus{
background-color:#00829C;
}
.nav > li > a:hover, .nav > li > a:focus{
background-color: transparent;
}
.badge-warning{
background-color: #FD6600;
}
.breadcrumb{
padding: 8px 15px;
margin-bottom: 21px;
list-style: outside none none;
background-color: #ECF0F1;
}
.breadcrumb > .active{
color: #95a5a6;
}
.panel-default{
border-color: #ECF0F1;
}
.panel-default .panel-heading{
color: #2c3e50;
background-color:#ECF0F1;
border-color: #ECF0F1;
}
/* Jquery UI */
.ui-accordion .ui-accordion-icons{
padding-left: 0.2em;
}
.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default{
background: #ECF0F1;
border-color: #ECF0F1;
}
.ui-widget-content{
border-color: #ECF0F1;
}
.ui-widget-header{
border: none;
background: transparent;
}
/* End Jquery UI */
footer{
background-image: -webkit-linear-gradient(#54b4eb, #2fa4e7 60%, #1d9ce5);
background-image: -o-linear-gradient(#54b4eb, #2fa4e7 60%, #1d9ce5);
background-image: -webkit-gradient(linear, left top, left bottom, from(#54b4eb), color-stop(60%, #2fa4e7), to(#1d9ce5));
background-image: linear-gradient(#54b4eb, #2fa4e7 60%, #1d9ce5);
background-repeat: no-repeat;
background-color:#2C3E50;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff54b4eb', endColorstr='#ff1d9ce5', GradientType=0);
border-bottom: 1px solid #178acc;
border-bottom: 1px solid #2C3E50;
-webkit-filter: none;
filter: none;
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.1);

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

@ -576,7 +576,7 @@ if (((empty ($allcat)) && (empty ($alleval)) && (empty ($alllink)) && (!$is_plat
}
// Here we are in a sub category
if ($category != '0') {
DisplayGradebook:: display_header_gradebook(
DisplayGradebook:: header(
$cats[0],
1,
$_GET['selectcat'],
@ -586,7 +586,7 @@ if ($category != '0') {
);
} else {
// This is the root category
DisplayGradebook:: display_header_gradebook(
DisplayGradebook:: header(
$cats[0],
(((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1),
0,

@ -43,7 +43,11 @@ switch ($action) {
Category::exportAllCertificates($cat_id, $userList);
break;
case 'generate_all_certificates':
$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
$user_list = CourseManager::get_user_list_from_course_code(
api_get_course_id(),
api_get_session_id()
);
if (!empty($user_list)) {
foreach ($user_list as $user_info) {
if ($user_info['status'] == INVITEE) {
@ -171,14 +175,14 @@ if ($filter) {
echo '<div class="btn-group">';
$url = api_get_self().'?action=generate_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn'));
echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn btn-default'));
$url = api_get_self().'?action=delete_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn'));
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn btn-default'));
if (count($certificate_list) > 0) {
$url = api_get_self().'?action=export_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn'));
echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn btn-default'));
}
echo '</div>';
@ -204,7 +208,7 @@ if (count($certificate_list) == 0 ) {
echo '<td width="30%">'.get_lang('Date').' : '.api_convert_and_format_date($value_certificate['created_at']).'</td>';
echo '<td width="20%">';
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$value_certificate['id'];
$certificates = Display::url(get_lang('Certificate'), $url, array('target'=>'_blank', 'class' => 'btn'));
$certificates = Display::url(get_lang('Certificate'), $url, array('target'=>'_blank', 'class' => 'btn btn-default'));
echo $certificates;
echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token='.$token.'&cidReq='.$course_code.'&action=delete&cat_id='.$cat_id.'&certificate_id='.$value_certificate['id'].'">
'.Display::return_icon('delete.png',get_lang('Delete')).'

@ -96,6 +96,7 @@ $filter_confirm_msg = true;
$filter_warning_msg = true;
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
$first_time = null;
if (empty($cats)) {
@ -151,7 +152,7 @@ if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) &&
// ACTIONS
//this is called when there is no data for the course admin
if (isset ($_GET['createallcategories'])) {
if (isset($_GET['createallcategories'])) {
GradebookUtils::block_students();
$coursecat= Category :: get_not_created_course_categories($stud_id);
if (!count($coursecat) == 0) {
@ -173,13 +174,13 @@ if (isset ($_GET['createallcategories'])) {
}
//show logs evaluations
if (isset ($_GET['visiblelog'])) {
if (isset($_GET['visiblelog'])) {
header('Location: ' . api_get_self().'/gradebook_showlog_eval.php');
exit;
}
//move a category
if (isset ($_GET['movecat'])) {
if (isset($_GET['movecat'])) {
GradebookUtils::block_students();
$cats= Category :: load($_GET['movecat']);
if (!isset ($_GET['targetcat'])) {
@ -196,7 +197,7 @@ if (isset ($_GET['movecat'])) {
exit;
}
} else {
$targetcat= Category :: load($_GET['targetcat']);
$targetcat = Category :: load($_GET['targetcat']);
$course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
if (!($course_to_crsind && !isset($_GET['confirm']))) {
@ -210,7 +211,7 @@ if (isset ($_GET['movecat'])) {
}
//move an evaluation
if (isset ($_GET['moveeval'])) {
if (isset($_GET['moveeval'])) {
GradebookUtils::block_students();
$evals= Evaluation :: load($_GET['moveeval']);
if (!isset ($_GET['targetcat'])) {
@ -244,7 +245,7 @@ if (isset ($_GET['moveeval'])) {
}
//move a link
if (isset ($_GET['movelink'])) {
if (isset($_GET['movelink'])) {
GradebookUtils::block_students();
$link= LinkFactory :: load($_GET['movelink']);
$move_form = new LinkForm(
@ -266,7 +267,7 @@ if (isset ($_GET['movelink'])) {
}
//parameters for categories
if (isset ($_GET['visiblecat'])) {
if (isset($_GET['visiblecat'])) {
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
@ -274,7 +275,7 @@ if (isset ($_GET['visiblecat'])) {
} else {
$visibility_command= 0;
}
$cats= Category :: load($_GET['visiblecat']);
$cats = Category :: load($_GET['visiblecat']);
$cats[0]->set_visible($visibility_command);
$cats[0]->save();
$cats[0]->apply_visibility_to_children();
@ -302,8 +303,9 @@ if (isset($_GET['deletecat'])) {
$confirmation_message = get_lang('CategoryDeleted');
$filter_confirm_msg = false;
}
//parameters for evaluations
if (isset ($_GET['visibleeval'])) {
if (isset($_GET['visibleeval'])) {
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
@ -322,6 +324,7 @@ if (isset ($_GET['visibleeval'])) {
$filter_confirm_msg = false;
}
}
//parameters for evaluations
if (isset($_GET['lockedeval'])) {
GradebookUtils::block_students();
@ -339,9 +342,9 @@ if (isset($_GET['lockedeval'])) {
}
$filter_confirm_msg = false;
}
if (isset ($_GET['deleteeval'])) {
if (isset($_GET['deleteeval'])) {
GradebookUtils::block_students();
$eval= Evaluation :: load($_GET['deleteeval']);
if ($eval[0] != null) {
@ -350,8 +353,9 @@ if (isset ($_GET['deleteeval'])) {
$confirmation_message = get_lang('GradebookEvaluationDeleted');
$filter_confirm_msg = false;
}
//parameters for links
if (isset ($_GET['visiblelink'])) {
if (isset($_GET['visiblelink'])) {
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
@ -441,7 +445,7 @@ switch ($action) {
}
//actions on the sortabletable
if (isset ($_POST['action'])) {
if (isset($_POST['action'])) {
GradebookUtils::block_students();
$number_of_selected_items= count($_POST['id']);
@ -450,8 +454,7 @@ if (isset ($_POST['action'])) {
$filter_warning_msg = false;
} else {
switch ($_POST['action']) {
case 'deleted' :
case 'deleted':
$number_of_deleted_categories= 0;
$number_of_deleted_evaluations= 0;
$number_of_deleted_links= 0;
@ -486,10 +489,10 @@ if (isset ($_POST['action'])) {
$confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>';
$filter_confirm_msg = false;
break;
case 'setvisible' :
case 'setvisible':
foreach ($_POST['id'] as $indexstr) {
if (substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(substr($indexstr, 4));
$cats = Category :: load(substr($indexstr, 4));
$cats[0]->set_visible(1);
$cats[0]->save();
$cats[0]->apply_visibility_to_children();
@ -508,10 +511,10 @@ if (isset ($_POST['action'])) {
$confirmation_message = get_lang('ItemsVisible');
$filter_confirm_msg = false;
break;
case 'setinvisible' :
case 'setinvisible':
foreach ($_POST['id'] as $indexstr) {
if (substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(substr($indexstr, 4));
$cats = Category :: load(substr($indexstr, 4));
$cats[0]->set_visible(0);
$cats[0]->save();
$cats[0]->apply_visibility_to_children();
@ -609,15 +612,15 @@ $is_course_admin = api_is_allowed_to_edit(null, true);
//load data for category, evaluation and links
if (empty($_GET['selectcat'])) {
$category= 0;
$category = 0;
} else {
$category= $_GET['selectcat'];
$category = $_GET['selectcat'];
}
$simple_search_form='';
if (isset($_GET['studentoverview'])) {
//@todo this code also seems to be deprecated ...
$cats= Category :: load($category);
$cats = Category :: load($category);
$stud_id= (api_is_allowed_to_edit() ? null : $stud_id);
$allcat= array ();
$alleval= $cats[0]->get_evaluations($stud_id, true);
@ -656,6 +659,7 @@ if (isset($_GET['studentoverview'])) {
//if $category = 0 (which happens when GET['selectcat'] is undefined)
// then Category::load() will create a new 'root' category with empty
// course and session fields in memory (Category::create_root_category())
if ($_in_course === true) {
// When *inside* a course, we want to make sure there is one (and only
// one) category for this course or for this session.
@ -671,7 +675,7 @@ if (isset($_GET['studentoverview'])) {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
if (empty($cats)) {
// There is no category for this course+session, so create one
$cat= new Category();
$cat = new Category();
if (!empty($session_id)) {
$s_name = api_get_session_name($session_id);
$cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name);
@ -690,10 +694,11 @@ if (isset($_GET['studentoverview'])) {
if ($can_edit) {
$cat->add();
}
unset ($cat);
unset($cat);
}
unset($cats);
}
$cats = Category::load($category, null, null, null, null, null, false);
//with this fix the teacher only can view 1 gradebook
@ -706,19 +711,17 @@ if (isset($_GET['studentoverview'])) {
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cats[0]->get_evaluations($stud_id);
$alllink = $cats[0]->get_links($stud_id);
//whether we found a category or not, we now have a category object with
// empty or full subcats
}
// add params to the future links (in the table shown)
$addparams = array ('selectcat' => $cats[0]->get_id());
$addparams = array('selectcat' => $cats[0]->get_id());
if (isset ($_GET['studentoverview'])) {
if (isset($_GET['studentoverview'])) {
$addparams['studentoverview'] = '';
}
//$addparams['cidReq']='';
if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
$addparams['cidReq']=Security::remove_XSS($_GET['cidReq']);
$addparams['cidReq'] = Security::remove_XSS($_GET['cidReq']);
} else {
$addparams['cidReq']='';
}
@ -849,8 +852,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
} else {
// This is the father
// Create gradebook/add gradebook links.
DisplayGradebook::display_header_gradebook(
DisplayGradebook::header(
$cat,
0,
$cat->get_id(),

@ -807,7 +807,12 @@ class Category implements GradebookItem
*/
public function is_certificate_available($user_id)
{
$score = $this->calc_score($user_id, null, $this->course_code);
$score = $this->calc_score(
$user_id,
null,
$this->course_code,
$this->session_id
);
if (isset($score) && isset($score[0])) {
// Get a percentage score to compare to minimum certificate score
@ -1487,13 +1492,15 @@ class Category implements GradebookItem
* @param int $stud_id student id (default: all students)
* @param boolean $recursive process subcategories (default: no recursion)
* @param string $course_code
* @param int $sessionId
*
* @return array
*/
public function get_evaluations(
$stud_id = null,
$recursive = false,
$course_code = ''
$course_code = '',
$sessionId = 0
) {
$evals = array();
@ -1501,18 +1508,30 @@ class Category implements GradebookItem
$course_code = api_get_course_id();
}
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
// 1 student
if (isset($stud_id) && !empty($stud_id)) {
// Special case: this is the root
if ($this->id == 0) {
$evals = Evaluation::get_evaluations_with_result_for_student(0, $stud_id);
} else {
$evals = Evaluation::load(null,null, $course_code, $this->id, api_is_allowed_to_edit() ? null : 1);
$evals = Evaluation::load(
null,
null,
$course_code,
$this->id,
api_is_allowed_to_edit() ? null : 1
);
}
} else {
// All students
// course admin
if ((api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) && !api_is_platform_admin()) {
if ((api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) &&
!api_is_platform_admin()
) {
// root
if ($this->id == 0) {
$evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null);
@ -1529,11 +1548,11 @@ class Category implements GradebookItem
}
if ($recursive) {
$subcats = $this->get_subcategories($stud_id, $course_code);
$subcats = $this->get_subcategories($stud_id, $course_code, $sessionId);
if (!empty($subcats)) {
foreach ($subcats as $subcat) {
$subevals = $subcat->get_evaluations($stud_id, true, $course_code);
//$this->debugprint($subevals);
$evals = array_merge($evals, $subevals);
}
}
@ -1555,7 +1574,7 @@ class Category implements GradebookItem
$stud_id = null,
$recursive = false,
$course_code = '',
$sessionId = null
$sessionId = 0
) {
$links = array();
@ -1737,6 +1756,7 @@ class Category implements GradebookItem
*/
public static function register_user_certificate($category_id, $user_id)
{
$sessionId = api_get_session_id();
// Generating the total score for a course
$cats_course = Category::load(
$category_id,
@ -1744,19 +1764,21 @@ class Category implements GradebookItem
null,
null,
null,
api_get_session_id(),
$sessionId,
false
);
/** @var Category $category */
$category = $cats_course[0];
if (!$category->getGenerateCetificates()) {
$skill = new Skill();
$skill->add_skill_to_user(
$user_id,
$category_id,
api_get_course_int_id(),
api_get_session_id()
$sessionId
);
return false;
@ -1792,7 +1814,11 @@ class Category implements GradebookItem
return false;
}
$my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
$my_certificate = GradebookUtils::get_certificate_by_user_id(
$cats_course[0]->get_id(),
$user_id
);
if (empty($my_certificate)) {
GradebookUtils::register_user_info_about_certificate(
$category_id,
@ -1800,8 +1826,12 @@ class Category implements GradebookItem
$my_score_in_gradebook,
api_get_utc_datetime()
);
$my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
$my_certificate = GradebookUtils::get_certificate_by_user_id(
$cats_course[0]->get_id(),
$user_id
);
}
$html = array();
if (!empty($my_certificate)) {
$certificate_obj = new Certificate($my_certificate['id']);
@ -1809,6 +1839,7 @@ class Category implements GradebookItem
if (!empty($fileWasGenerated)) {
$url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
$certificates = Display::url(
'&nbsp;'.get_lang('DownloadCertificate'),
$url,
@ -1817,6 +1848,7 @@ class Category implements GradebookItem
'class' => 'btn'
)
);
$exportToPDF = Display::url(
Display::return_icon(
'pdf.png',
@ -1826,6 +1858,7 @@ class Category implements GradebookItem
),
"$url&action=export"
);
$html = array(
'certificate_link' => $certificates,
'pdf_link' => $exportToPDF

@ -218,34 +218,40 @@ class Evaluation implements GradebookItem
$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'SELECT * FROM '.$tbl_grade_evaluations;
$paramcount = 0;
if (isset ($id)) {
$sql.= ' WHERE id = '.intval($id);
$paramcount ++;
}
if (isset ($user_id)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
$sql .= ' user_id = '.intval($user_id);
$paramcount ++;
}
if (isset ($course_code) && $course_code <> '-1') {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
$sql .= " course_code = '".Database::escape_string($course_code)."'";
$paramcount ++;
}
if (isset ($category_id)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
$sql .= ' category_id = '.intval($category_id);
$paramcount ++;
}
if (isset ($visible)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
$sql .= ' visible = '.intval($visible);
$paramcount ++;
}
if (isset ($locked)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';

@ -341,8 +341,10 @@ class DisplayGradebook
$my_course_id = api_get_course_id();
$my_file = substr($_SESSION['gradebook_dest'], 0, 5);
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' . Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' .
Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';
$visibility_icon = ($catobj->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($catobj->is_visible() == 0) ? 'set_visible' : 'set_invisible';
@ -380,7 +382,7 @@ class DisplayGradebook
* where we have only one calification per course or session)
* @return void Everything is printed on screen upon closing
*/
static function display_header_gradebook(
static function header(
$catobj,
$showtree,
$selectcat,
@ -391,8 +393,22 @@ class DisplayGradebook
$show_add_link = true,
$certificateLinkInfo = null
) {
$userId = api_get_user_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
// Student.
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$status = CourseManager::get_user_in_course_status($userId, $courseCode);
if (!empty($sessionId)) {
$sessionStatus = SessionManager::get_user_status_in_course_session(
$userId,
$courseCode,
$sessionId
);
}
$objcat = new Category();
$course_id = CourseManager::get_course_by_category($selectcat);
$message_resource = $objcat->show_message_resource_delete($course_id);
@ -403,7 +419,15 @@ class DisplayGradebook
$sum_categories_weight_array = array();
if (isset($catobj) && !empty($catobj)) {
$categories = Category::load(null, null, null, $catobj->get_id());
$categories = Category::load(
null,
null,
null,
$catobj->get_id(),
null,
$sessionId
);
if (!empty($categories)) {
foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight();
@ -413,23 +437,15 @@ class DisplayGradebook
}
}
if (!$is_course_admin && $status <> 1 && $selectcat <> 0) {
$user_id = api_get_user_id();
if (!$is_course_admin && ($status <> 1 || $sessionStatus == 0) && $selectcat <> 0) {
$catcourse = Category::load($catobj->get_id());
$main_weight = $catcourse[0]->get_weight();
/** @var Category $category */
$category = $catcourse[0];
$main_weight = $category->get_weight();
$scoredisplay = ScoreDisplay :: instance();
//$categories = Category::getCategories($catcourse[0]->get_id());
// generating the total score for a course
/*if (count($categories) > 0) {
foreach ($categories as $category) {
$allevals = $category->get_evaluations($user_id, true);
$alllinks = $category->get_links($user_id, true);
$catEvalsLinks = array_merge($allevals, $alllinks);
}
}*/
$allevals = $catcourse[0]->get_evaluations($user_id, true);
$alllinks = $catcourse[0]->get_links($user_id, true);
$allevals = $category->get_evaluations($userId, true);
$alllinks = $category->get_links($userId, true);
$allEvalsLinks = array_merge($allevals, $alllinks);
@ -438,13 +454,10 @@ class DisplayGradebook
for ($count = 0; $count < count($allEvalsLinks); $count++) {
$item = $allEvalsLinks[$count];
$score = $item->calc_score($user_id);
$score = $item->calc_score($userId);
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;
}
}
@ -600,8 +613,6 @@ class DisplayGradebook
if ($isDrhOfCourse) {
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
/*$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' .
Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';*/
}
$header .= '</div>';
@ -609,7 +620,7 @@ class DisplayGradebook
echo $header;
if (api_is_allowed_to_edit(null, true)) {
$weight = ((intval($catobj->get_weight()) > 0) ? $catobj->get_weight() : 0);
$weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
$weight = get_lang('TotalWeight') . ' : ' . $weight;
$min_certification = (intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0);

@ -221,7 +221,7 @@ class GradebookTable extends SortableTable
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
// Weight.
$average = $scoredisplay->display_score(
$weight = $scoredisplay->display_score(
array(
$data['3'],
$this->currentcat->get_weight()
@ -231,11 +231,10 @@ class GradebookTable extends SortableTable
true
);
// Weight
if (api_is_allowed_to_edit(null, true)) {
$row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;
$row[] = $invisibility_span_open .Display::tag('h4', $weight).$invisibility_span_close;
} else {
$row[] = $invisibility_span_open .$average.$invisibility_span_close;
$row[] = $invisibility_span_open .$weight.$invisibility_span_close;
}
$category_weight = $item->get_weight();
@ -270,7 +269,8 @@ class GradebookTable extends SortableTable
}
// Students get the results and certificates columns
if (count($this->evals_links) > 0 && $status_user != 1) {
//if (count($this->evals_links) > 0 && $status_user != 1) {
if ($status_user != 1) {
$value_data = isset($data[4]) ? $data[4] : null;
$best = isset($data['best']) ? $data['best'] : null;
$average = isset($data['average']) ? $data['average'] : null;

@ -146,6 +146,9 @@ switch ($action) {
if (!(api_is_platform_admin(false, true))) {
//exit;
}
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
$courseCodeList = array();
$userIdList = array();
if (api_is_drh()) {
@ -186,12 +189,27 @@ switch ($action) {
}
} elseif (api_is_student_boss()) {
$users = UserManager::getUsersFollowedByStudentBoss($userId);
$userIdList = array_keys($users);
}
$groups = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_ADMIN);
$sessionIdList = [];
if ($sessionId == -1) {
$userIdList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
'admin',
null
);
$userIdList = array_column($userIdList, 'user_id');
$sessionList = SessionManager::get_sessions_list();
$sessionIdList = array_column($sessionList, 'id');
$courseCodeList = array();
foreach ($sessionList as $session) {
$courses = SessionManager::get_course_list_by_session_id($session['id']);
$courseCodeList = array_merge($courseCodeList, array_column($courses, 'code'));
}
}
$groups = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_ADMIN);
$groupsId = array_keys($groups);
if (is_array($groupsId)) {
@ -217,13 +235,20 @@ switch ($action) {
}
if ($action == 'get_user_course_report') {
$count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList);
$count = CourseManager::get_count_user_list_from_course_code(
false,
null,
$courseCodeList,
$userIdList,
$sessionIdList
);
} else {
$count = CourseManager::get_count_user_list_from_course_code(
true,
array('ruc'),
$courseCodeList,
$userIdList
$userIdList,
$sessionIdList
);
}
break;
@ -460,7 +485,14 @@ $columns = array();
switch ($action) {
case 'get_course_exercise_medias':
$columns = array('question');
$result = Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $whereCondition);
$result = Question::get_course_medias(
$course_id,
$start,
$limit,
$sidx,
$sord,
$whereCondition
);
break;
case 'get_user_course_report_resumed':
$columns = array(
@ -508,7 +540,9 @@ switch ($action) {
true,
array('ruc'),
$courseCodeList,
$userIdList
$userIdList,
null,
$sessionIdList
);
$new_result = array();
@ -542,6 +576,7 @@ switch ($action) {
if (!in_array($sidx, array('title'))) {
$sidx = 'title';
}
$result = CourseManager::get_user_list_from_course_code(
null,
null,
@ -553,7 +588,9 @@ switch ($action) {
false,
null,
$courseCodeList,
$userIdList
$userIdList,
null,
$sessionIdList
);
break;

@ -466,7 +466,7 @@ function return_menu() {
$current = '';
}
if (!empty($navigation_info['title'])) {
$pre_lis .= '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a></li>';
$pre_lis .= '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a></li>';
}
}
$lis = $pre_lis.$lis;
@ -609,7 +609,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
if ($navigation_info['url'] == '#') {
$final_navigation[$index] = $navigation_info['title'];
} else {
$final_navigation[$index] = '<a href="'.$navigation_info['url'].'" class="" target="_top">'.$navigation_info['title'].'</a>';
$final_navigation[$index] = '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
}
$counter++;
}
@ -628,7 +628,6 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
$lis = '';
$i = 0;
$final_navigation_count = count($final_navigation);
if (!empty($final_navigation)) {
// $home_link.= '<span class="divider">/</span>';
if (!empty($home_link)) {
@ -641,7 +640,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
if ($final_navigation_count-1 > $i) {
$bread .= '';
}
$lis.= Display::tag('li', $bread);
$lis.= Display::tag('li', $bread,array('class'=>'active'));
$i++;
}
}

@ -148,17 +148,22 @@ class Certificate extends Model
**/
public function generate($params = array())
{
//The user directory should be set
if (empty($this->certification_user_path) && $this->force_certificate_generation == false) {
// The user directory should be set
if (empty($this->certification_user_path) &&
$this->force_certificate_generation == false
) {
return false;
}
$params['hide_print_button'] = isset($params['hide_print_button']) ? true : false;
$my_category = Category :: load($this->certificate_data['cat_id']);
if (isset($my_category[0]) &&
$my_category[0]->is_certificate_available($this->user_id)
) {
$user = api_get_user_info($this->user_id);
$scoredisplay = ScoreDisplay :: instance();
$scorecourse = $my_category[0]->calc_score($this->user_id);
$scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable');

@ -1209,6 +1209,7 @@ class CourseManager
* @param array $courseCodeList
* @param array $userIdList
* @param string $filterByActive
* @param array $sessionIdList
* @return array|int
*/
public static function get_user_list_from_course_code(
@ -1223,16 +1224,21 @@ class CourseManager
$extra_field = array(),
$courseCodeList = array(),
$userIdList = array(),
$filterByActive = null
$filterByActive = null,
$sessionIdList = array()
) {
// variable initialisation
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sessionTable = Database::get_main_table(TABLE_MAIN_SESSION);
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$courseId = 0;
if (!empty($courseInfo)) {
$courseId = $courseInfo['real_id'];
}
$where = array();
if (empty($order_by)) {
$order_by = 'user.lastname, user.firstname';
if (api_is_western_name_order()) {
@ -1251,17 +1257,41 @@ class CourseManager
$filter_by_status_condition = null;
if (!empty($session_id)) {
$sql = 'SELECT DISTINCT user.user_id, session_course_user.status as status_session, user.* ';
if (!empty($session_id) || !empty($sessionIdList)) {
$sql = 'SELECT DISTINCT
user.user_id,
session_course_user.status as status_session,
id_session,
user.*,
course.*,
session.name as session_name
';
if ($return_count) {
$sql = " SELECT COUNT(user.user_id) as count";
}
$sessionCondition = " session_course_user.id_session = $session_id";
if (!empty($sessionIdList)) {
$sessionIdListTostring = implode("','", array_map('intval', $sessionIdList));
$sessionCondition = " session_course_user.id_session IN ('$sessionIdListTostring') ";
}
$courseCondition = " session_course_user.course_code = '".$course_code."' AND ";
if (!empty($courseCodeList)) {
$courseCodeListForSession = array_map(array('Database', 'escape_string'), $courseCodeList);
$courseCodeListForSession = implode('","', $courseCodeListForSession);
$courseCondition = ' session_course_user.course_code IN ("' . $courseCodeListForSession . '") AND ';
}
$sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user ';
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' as session_course_user
$sql .= " LEFT JOIN ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " as session_course_user
ON
user.user_id = session_course_user.id_user AND
session_course_user.course_code="' . $course_code . '" AND
session_course_user.id_session = ' . $session_id;
$courseCondition
$sessionCondition
INNER JOIN $course_table course ON session_course_user.course_code = course.code
INNER JOIN $sessionTable session ON session_course_user.id_session = session.id
";
$where[] = ' session_course_user.course_code IS NOT NULL ';
// 2 = coach
@ -1304,8 +1334,7 @@ class CourseManager
if (!empty($course_code)) {
$sql .= ' AND course_rel_user.course_code="' . $course_code . '"';
} else {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql .= " INNER JOIN $course_table course ON course_rel_user.course_code = course.code ";
$sql .= " INNER JOIN $course_table course ON course_rel_user.course_code = course.code ";
}
$where[] = ' course_rel_user.course_code IS NOT NULL ';
@ -1320,11 +1349,19 @@ class CourseManager
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au ON (au.user_id = user.user_id) ';
}
$extraFieldWasAdded = false;
if ($return_count && $resumed_report) {
foreach ($extra_field as $extraField) {
$extraFieldInfo = UserManager::get_extra_field_information_by_name($extraField);
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES) . ' as ufv
ON (user.user_id = ufv.user_id AND (field_id = ' . $extraFieldInfo['id'] . ' OR field_id IS NULL ) )';
if (!empty($extraFieldInfo)) {
$fieldValuesTable = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$sql .= ' LEFT JOIN '.$fieldValuesTable.' as ufv
ON (
user.user_id = ufv.user_id AND
(field_id = '.$extraFieldInfo['id'].' OR field_id IS NULL)
)';
$extraFieldWasAdded = true;
}
}
}
@ -1335,14 +1372,16 @@ class CourseManager
$sql .= " AND (access_url_id = $current_access_url_id ) ";
}
if ($return_count && $resumed_report) {
if ($return_count && $resumed_report && $extraFieldWasAdded) {
$sql .= ' AND field_id IS NOT NULL GROUP BY field_value ';
}
if (!empty($courseCodeList)) {
$courseCodeList = array_map(array('Database', 'escape_string'), $courseCodeList);
$courseCodeList = implode('","', $courseCodeList);
$sql .= ' AND course.code IN ("' . $courseCodeList . '")';
if (empty($sessionIdList)) {
$sql .= ' AND course.code IN ("'.$courseCodeList.'")';
}
}
if (!empty($userIdList)) {
@ -1392,34 +1431,51 @@ class CourseManager
$user_info['status_session'] = $user['status_session'];
}
$sessionId = isset($user['id_session']) ? $user['id_session'] : 0;
$course_code = isset($user['code']) ? $user['code'] : null;
if ($add_reports) {
$course_code = $user['code'];
if ($resumed_report) {
foreach ($extra_fields as $extra) {
if (in_array($extra['1'], $extra_field)) {
$user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']);
break;
$extra = array();
if (!empty($extra_fields)) {
foreach ($extra_fields as $extra) {
if (in_array($extra['1'], $extra_field)) {
$user_data = UserManager::get_extra_user_data_by_field(
$user['user_id'],
$extra['1']
);
break;
}
}
}
if (empty($user_data[$extra['1']])) {
$row_key = '-1';
$name = '-';
} else {
$row_key = $user_data[$extra['1']];
$name = $user_data[$extra['1']];
$row_key = '-1';
$name = '-';
if (!empty($extra)) {
if (!empty($user_data[$extra['1']])) {
$row_key = $user_data[$extra['1']];
$name = $user_data[$extra['1']];
$users[$row_key]['extra_'.$extra['1']] = $name;
}
}
$users[$row_key]['extra_' . $extra['1']] = $name;
$users[$row_key]['training_hours'] += Tracking::get_time_spent_on_the_course($user['user_id'],
$courseId, 0);
$users[$row_key]['training_hours'] += Tracking::get_time_spent_on_the_course(
$user['user_id'],
$courseId,
$sessionId
);
$users[$row_key]['count_users'] += $counter;
$registered_users_with_extra_field = 0;
if (!empty($name) && $name != '-') {
$name = Database::escape_string($name);
$sql = "SELECT count(user_id) as count FROM $table_user_field_value WHERE field_value = '$name'";
$sql = "SELECT count(user_id) as count
FROM $table_user_field_value
WHERE field_value = '$name'";
$result_count = Database::query($sql);
if (Database::num_rows($result_count)) {
$row_count = Database::fetch_array($result_count);
@ -1430,10 +1486,19 @@ class CourseManager
$users[$row_key]['count_users_registered'] = $registered_users_with_extra_field;
$users[$row_key]['average_hours_per_user'] = $users[$row_key]['training_hours'] / $users[$row_key]['count_users'];
$category = Category:: load(null, null, $course_code);
$category = Category:: load(
null,
null,
$course_code,
null,
null,
$sessionId
);
if (!isset($users[$row_key]['count_certificates'])) {
$users[$row_key]['count_certificates'] = 0;
}
if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) {
$users[$row_key]['count_certificates']++;
}
@ -1450,23 +1515,41 @@ class CourseManager
}
}
}
} else {
$report_info['course'] = $user['title'];
$sessionName = !empty($sessionId) ? ' - '.$user['session_name'] : '';
$report_info['course'] = $user['title'].$sessionName;
$report_info['user'] = api_get_person_name($user['firstname'], $user['lastname']);
$report_info['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'],
$courseId, 0));
$report_info['time'] = api_time_to_hms(
Tracking::get_time_spent_on_the_course(
$user['user_id'],
$courseId,
$sessionId
)
);
$category = Category:: load(
null,
null,
$course_code,
null,
null,
$sessionId
);
$category = Category:: load(null, null, $course_code);
$report_info['certificate'] = Display::label(get_lang('No'));
if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) {
$report_info['certificate'] = Display::label(get_lang('Yes'), 'success');
}
$progress = intval(Tracking::get_avg_student_progress($user['user_id'], $course_code, array(),
0));
$report_info['progress_100'] = $progress == 100 ? Display::label(get_lang('Yes'),
'success') : Display::label(get_lang('No'));
$progress = intval(
Tracking::get_avg_student_progress(
$user['user_id'],
$course_code,
array(),
$sessionId
)
);
$report_info['progress_100'] = $progress == 100 ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No'));
$report_info['progress'] = $progress . "%";
foreach ($extra_fields as $extra) {
@ -1480,6 +1563,7 @@ class CourseManager
}
}
}
return $users;
}
@ -1488,13 +1572,15 @@ class CourseManager
* @param array $extra_field
* @param array $courseCodeList
* @param array $userIdList
* @param array $sessionIdList
* @return array|int
*/
static function get_count_user_list_from_course_code(
$resumed_report = false,
$extra_field = array(),
$courseCodeList = array(),
$userIdList = array()
$userIdList = array(),
$sessionIdList = array()
) {
return self::get_user_list_from_course_code(
null,
@ -1507,7 +1593,9 @@ class CourseManager
$resumed_report,
$extra_field,
$courseCodeList,
$userIdList
$userIdList,
null,
$sessionIdList
);
}

@ -28,7 +28,6 @@ class HookCreateUser extends HookEvent implements HookCreateUserEventInterface
foreach ($this->observers as $observer) {
$observer->hookCreateUser($this);
}
return 1;
}
}

@ -2726,7 +2726,7 @@ class UserManager
}
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM $tbl_session_user, $tbl_session
FROM $tbl_session
WHERE (
id_coach = $user_id
)
@ -2751,7 +2751,8 @@ class UserManager
if ($session_visibility == SESSION_INVISIBLE) {
continue;
}
// This query is horribly slow when more than a few thousand
// users and just a few sessions to which they are subscribed
$id_session = $enreg['id'];
$personal_course_list_sql = "SELECT DISTINCT
course.code code,

@ -459,7 +459,7 @@ DROP TABLE IF EXISTS session;
CREATE TABLE IF NOT EXISTS session (
id smallint unsigned NOT NULL auto_increment,
id_coach int unsigned NOT NULL default '0',
name char(50) NOT NULL default '',
name char(100) NOT NULL default '',
nbr_courses smallint unsigned NOT NULL default '0',
nbr_users mediumint unsigned NOT NULL default '0',
nbr_classes mediumint unsigned NOT NULL default '0',
@ -4729,5 +4729,5 @@ CREATE TABLE c_attendance_calendar_rel_group (
-- Version
LOCK TABLES settings_current WRITE;
UPDATE settings_current SET selected_value = '1.10.0.27' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.30' WHERE variable = 'chamilo_database_version';
UNLOCK TABLES;

@ -71,16 +71,15 @@ if (!empty($_POST['language_list'])) {
// Language validation.
if (!array_key_exists($install_language, get_language_folder_list())) {
$install_language = 'english';
$install_language = 'english';
}
// Loading language files.
require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
require api_get_path(SYS_LANG_PATH).'english/install.inc.php';
if ($install_language != 'english') {
include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
include_once api_get_path(SYS_LANG_PATH).$install_language.'/install.inc.php';
include_once api_get_path(SYS_LANG_PATH).$install_language.'/admin.inc.php';
include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
include_once api_get_path(SYS_LANG_PATH).$install_language.'/install.inc.php';
}
// These global variables must be set for proper working of the function get_lang(...) during the installation.

@ -1586,7 +1586,9 @@ function display_license_agreement()
?>
<table>
<tr><td>
<pre style="overflow: auto; height: 150px; margin-top: 5px;" class="span7"><?php echo api_htmlentities(@file_get_contents(api_get_path(SYS_PATH).'documentation/license.txt')); ?></pre>
<pre style="overflow: auto; height: 150px; margin-top: 5px;" class="col-md-7">
<?php echo api_htmlentities(@file_get_contents(api_get_path(SYS_PATH).'documentation/license.txt')); ?>
</pre>
</td>
</tr>
<tr><td>

@ -39,17 +39,28 @@ ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL
RENAME TABLE track_e_exercices TO track_e_exercises;
ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL;
UPDATE track_e_access SET c_id = (SELECT id FROM course WHERE code = access_cours_code);
ALTER TABLE track_e_default ADD COLUMN c_id int NOT NULL;
UPDATE track_e_default SET c_id = (SELECT id FROM course WHERE code = default_cours_code);
ALTER TABLE track_e_lastaccess ADD COLUMN c_id int NOT NULL;
UPDATE track_e_lastaccess SET c_id = (SELECT id FROM course WHERE code = access_cours_code);
ALTER TABLE track_e_exercises ADD COLUMN c_id int NOT NULL;
UPDATE track_e_exercises SET c_id = (SELECT id FROM course WHERE code = exe_cours_id);
ALTER TABLE track_e_downloads ADD COLUMN c_id int NOT NULL;
UPDATE track_e_downloads SET c_id = (SELECT id FROM course WHERE code = down_cours_id);
ALTER TABLE track_e_hotpotatoes ADD COLUMN c_id int NOT NULL;
UPDATE track_e_hotpotatoes SET c_id = (SELECT id FROM course WHERE code = exe_cours_id);
ALTER TABLE track_e_links ADD COLUMN c_id int NOT NULL;
UPDATE track_e_links SET c_id = (SELECT id FROM course WHERE code = links_cours_id);
ALTER TABLE track_e_course_access ADD COLUMN c_id int NOT NULL;
UPDATE track_e_course_access SET c_id = (SELECT id FROM course WHERE code = course_code);
ALTER TABLE track_e_online ADD COLUMN c_id int NOT NULL;
UPDATE track_e_online SET c_id = (SELECT id FROM course WHERE code = course);
ALTER TABLE track_e_attempt ADD COLUMN c_id int NOT NULL;
UPDATE track_e_attempt SET c_id = (SELECT id FROM course WHERE code = course_code);
ALTER TABLE track_e_default ADD COLUMN session_id int NOT NULL;
DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages';
DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages';
DELETE FROM settings_current WHERE variable = 'advanced_filemanager';
@ -68,14 +79,14 @@ ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT null;
ALTER TABLE user DROP PRIMARY KEY;
ALTER TABLE user ADD COLUMN id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT AFTER user_id;
UPDATE user SET id = user_id;
UPDATE user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00';
UPDATE user SET expiration_date = NULL WHERE expiration_date = '0000-00-00 00:00:00';
ALTER TABLE user MODIFY COLUMN chatcall_date datetime default NULL;
ALTER TABLE user MODIFY COLUMN chatcall_text varchar(50) default NULL;
ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default '0';
ALTER TABLE user MODIFY COLUMN expiration_date datetime default NULL;
ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL;
UPDATE user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00';
UPDATE user SET expiration_date = NULL WHERE expiration_date = '0000-00-00 00:00:00';
ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0;
@ -94,6 +105,7 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value,
INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No');
ALTER TABLE session MODIFY COLUMN name char(100) NOT NULL DEFAULT '';
-- xxCOURSExx
@ -113,4 +125,4 @@ CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT
CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL);
-- Do not move this query
UPDATE settings_current SET selected_value = '1.10.0.27' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.30' WHERE variable = 'chamilo_database_version';

@ -94,33 +94,8 @@ if (defined('SYSTEM_INSTALLATION')) {
}
if (INSTALL_TYPE_UPDATE == 'update') {
// Updating track tables with c_id
$res = iDatabase::query("SELECT id, code FROM $dbNameForm.course");
$result = iDatabase::query($sql);
$courses = Database::store_result($result);
foreach ($courses as $course) {
$courseId = $course['id'];
$courseCode = $course['code'];
$fields = array(
'track_e_access' => 'access_cours_code',
'track_e_default' => 'default_cours_code',
'track_e_lastaccess' => 'access_cours_code',
'track_e_downloads' => 'down_cours_id',
'track_e_hotpotatoes' => 'exe_cours_id',
'track_e_links' => 'links_cours_id',
'track_e_course_access' => 'course_code',
'track_e_online' => 'course',
'track_e_attempt' => 'course_code',
'track_e_exercises' => 'exe_cours_id'
);
foreach ($fields as $table => $key) {
$sql = "UPDATE $dbNameForm.$table SET c_id = $courseId
WHERE $key = '$courseCode'";
iDatabase::query($sql);
}
}
// Updating track tables with c_id -> moved to migrate-db
}
}

@ -1,15 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Homepage for links tool
* @package chamilo.link
*/
/**
* Code
*/
namespace Link;
require_once '../inc/global.inc.php';
Controller::instance()->run();
return;

@ -22,9 +22,10 @@ $tool_name = get_lang('Report');
$this_section = SECTION_TRACKING;
$htmlHeadXtra[] = api_get_jqgrid_js();
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report&session_id='.$sessionId;
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);

@ -4,9 +4,7 @@
* Special report for corporate users
* @package chamilo.reporting
*/
/**
* Code
*/
$cidReset = true;
require_once '../inc/global.inc.php';
@ -22,9 +20,10 @@ $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('MySpace'));
$tool_name = get_lang('Report');
$this_section = SECTION_TRACKING;
$htmlHeadXtra[] = api_get_jqgrid_js();
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report_resumed';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report_resumed&session_id='.$sessionId;
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
@ -117,7 +116,7 @@ if (!api_is_student_boss()) {
'class' => 'btn btn-info'
)
);
$content .= '</div>';
$content .= '</div>';
}
$content .= '</div>';

@ -2605,7 +2605,7 @@ class learnpathItem
return $returnstatus;
} else {
$status = $items[$refs_list[$prereqs_string]]->get_status(false);
$returnstatus = $status == $this->possible_status[2] OR $status == $this->possible_status[3];
$returnstatus = $status == $this->possible_status[2] || $status == $this->possible_status[3];
if (!$returnstatus) {
if (self::debug > 1) {

@ -83,30 +83,13 @@ $(document).ready(function() {
$("div#log_content_cleaner").bind("click", function() {
$("div#log_content").empty();
});
//jQuery("video:not(.skip), audio:not(.skip)").mediaelementplayer();
});
var chamilo_xajax_handler = window.oxajax;
</script>';
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready(function(){
$("#icon-down").click(function(){
$("#icon-up").removeClass("hidden");
$(this).addClass("hidden");
});
$("#icon-up").click(function(){
$("#icon-down").removeClass("hidden");
$(this).addClass("hidden");
});
});
</script>';
if ($_SESSION['oLP']->mode == 'embedframe' || $_SESSION['oLP']->get_hide_toc_frame()==1 ) {
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
toggle_minipanel();
});
</script>';
$htmlHeadXtra[] = 'hello';
}
//Impress js
@ -378,10 +361,10 @@ if ($is_allowed_to_edit) {
/* Fin left zone */
echo '<div class="container-fluid"><div class="row">';
echo '<div id="learning_path_left_zone" class="sidebar-scorm"> ';
echo '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';
echo '<div class="panel panel-default">';
echo '<div class="panel-heading" role="tab" id="headingOne">
<a id="ui-option" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
echo '<div id="scorm-info" class="panel panel-default">';
echo '<div class="panel-heading">
<a id="ui-option">
<i id="icon-down"class="fa fa-chevron-down hidden"></i>
<i id="icon-up" class="fa fa-chevron-up"></i>
</a></div>';
@ -389,8 +372,7 @@ if ($is_allowed_to_edit) {
<!-- end header -->
<!-- Author image preview -->
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<div id="panel-scorm" class="panel-body">
<?php
// Return to course home.
if ($is_allowed_to_edit) {
@ -450,9 +432,9 @@ if ($is_allowed_to_edit) {
echo '</div>';
}
?>
</div>
</div>
</div>
</div>
<!-- TOC layout -->
@ -490,30 +472,31 @@ if ($is_allowed_to_edit) {
function updateContentHeight() {
document.body.style.overflow = 'hidden';
var IE = window.navigator.appName.match(/microsoft/i);
var heightHeader = ($('#header').height())? $('#header').height() : 0 ;
var heightAuthorImg = ($('#author_image').height())? $('#author_image').height() : 0 ;
var heightAuthorName = ($('#author_name').height())? $('#author_name').height() : 0 ;
/* Identified new height */
var heightControl = $('#control-bottom').height();
var heightBreadcrumb = ($('#learning_path_breadcrumb_zone').height())? $('#learning_path_breadcrumb_zone').height() : 0 ;
var heightControl = ($('#control').is(':visible'))? $('#control').height() : 0 ;
var heightMedia = ($('#lp_media_file').length != 0)? $('#lp_media_file').height() : 0 ;
//var heightTitle = ($('#scorm_title').height())? $('#scorm_title').height() : 0 ;
var heightAction = ($('#actions_lp').height())? $('#actions_lp').height() : 0 ;
//var heightTop = heightHeader + heightAuthorImg + heightAuthorName + heightMedia + heightTitle + heightAction + 100;
var heightTop = heightHeader + heightAuthorImg + heightAuthorName + heightMedia + heightAction + 100;
var heightScormInfo = $('#scorm-info').height();
heightTop = (heightTop < 300)? heightTop : 300;
var innerHeight = (IE) ? document.body.clientHeight : window.innerHeight ;
// -40 is a static adjustement for margin, spaces on the page
var heightTop = heightScormInfo + 100;
$('#inner_lp_toc').css('height', innerHeight - heightTop - heightBreadcrumb - heightControl + "px");
if ($('#content_id')) {
$('#content_id').css('height', innerHeight - heightBreadcrumb - heightControl + "px");
}
if ($('#hide_bar')) {
$('#hide_bar').css('height', innerHeight - heightBreadcrumb - heightControl + "px");
//heightTop = (heightTop > 300)? heightTop : 300;
var innerHeight = $(window).height();
if(innerHeight<=640){
$('#inner_lp_toc').css('height', innerHeight - heightTop + "px");
$('#content_id').css('height', innerHeight - heightControl + "px");
}else{
$('#inner_lp_toc').css('height', innerHeight - heightBreadcrumb - heightTop + "px");
$('#content_id').css('height', innerHeight - heightControl + "px");
}
//var innerHeight = (IE) ? document.body.clientHeight : window.innerHeight ;
// Loads the glossary library.
<?php
$glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
@ -558,6 +541,25 @@ if ($is_allowed_to_edit) {
});
window.onload = updateContentHeight();
window.onresize = updateContentHeight();
$(document).ready(function(){
$("#icon-down").click(function(){
$("#icon-up").removeClass("hidden");
$(this).addClass("hidden");
$('#panel-scorm').slideDown("slow",function(){
updateContentHeight();
});
});
$("#icon-up").click(function(){
$("#icon-down").removeClass("hidden");
$(this).addClass("hidden");
$('#panel-scorm').slideUp("slow",function(){
updateContentHeight();
});
});
});
</script>
<?php
// Restore a global setting.

@ -10,7 +10,7 @@ $cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
if (api_get_setting('allow_social_tool') != 'true' && !api_is_platform_admin()) {
api_not_allowed();
}

@ -200,7 +200,7 @@ if (count($pending_invitations) > 0) {
$socialInvitationsBlock .='</div>';
$socialInvitationsBlock .= '</div></div>';
}
$socialInvitationsBlock.='</div>';
$socialInvitationsBlock.='</div></div>';
}
$tpl = new Template(null);

@ -47,11 +47,16 @@ echo '<div class="actions">';
echo '<a href="../newscorm/lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('back.png', get_lang('ReturnToLearningPaths'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
$form = new FormValidator('', 'POST', 'upload.php', '', 'id="upload_form" enctype="multipart/form-data" style="background-image: url(\'../img/scorm.jpg\'); background-repeat: no-repeat; background-position: 620px;"');
$form = new FormValidator(
'',
'POST',
'upload.php',
'',
'id="upload_form" enctype="multipart/form-data" style="background-image: url(\'../img/scorm.jpg\'); background-repeat: no-repeat; background-position: 620px;"'
);
$form->addElement('header', '', $nameTools);
$form->addElement('hidden', 'curdirpath', $path);
$form->addElement('hidden', 'tool', $my_tool);
$form->addElement('file', 'user_file', get_lang('FileToUpload'));
$form->add_real_progress_bar('uploadScorm', 'user_file');
$form->addRule('user_file', get_lang('ThisFieldIsRequired'), 'required');
@ -71,11 +76,10 @@ if (api_is_platform_admin()) {
$form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
}
$form->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"');
$form->addElement('html', '<br /><br /><br />');
$form->addButtonUpload(get_lang('Upload'));
if (is_dir(api_get_path(PLUGIN_PATH)."/pens")) {
require_once(api_get_path(PLUGIN_PATH)."/pens/chamilo_pens.php");
require_once api_get_path(PLUGIN_PATH)."/pens/chamilo_pens.php";
$list = ChamiloPens::findAll();
if (count($list) > 0) {
$select_pens = $form->addElement('select', 'pens_package', get_lang('Or').' '.get_lang('select a PENS package'));

@ -54,7 +54,10 @@ class HookCreateDrupalUser extends HookObserver implements HookCreateUserObserve
);
$client = new SoapClient(null, $options);
$client->addUser($fields, $extraFields);
$drupalUserId = $client->addUser($fields, $extraFields);
if ($drupalUserId !== false) {
UserManager::update_extra_field_value($return, 'drupal_user_id', $drupalUserId);
}
}
}

@ -12,6 +12,8 @@ exit;
require __DIR__ . '/../../main/inc/global.inc.php';
$debug = 1;
// Who will be the general coach assigned to all sessions created?
$generalCoach = 'username';
// List of tables that will need an update
$tables = array(
@ -114,19 +116,27 @@ $end = api_strtotime($year.'-'.$month.'-01 00:00:00') - 1;
$start = $end - (2*365*86400);
// Prepare a list of admin users to avoid removing their relation to the base course
$sql = 'SELECT user_id FROM admin';
$sql = 'SELECT user_id FROM '.Database::get_main_table(TABLE_MAIN_ADMIN);
$resultAdmin = Database::query($sql);
$admins = array();
while ($row = Database::fetch_assoc($resultAdmin)) {
$admins[] = $row['user_id'];
}
$res = Database::select('id, title, code', TABLE_MAIN_COURSE);
$eol = PHP_EOL;
$eof = PHP_EOL;
if (php_sapi_name() != 'cli') {
echo '<pre>';
$eol = "<br />".PHP_EOL;
$eof = '</pre>';
}
$res = Database::select('id, title, code', Database::get_main_table(TABLE_MAIN_COURSE));
foreach ($res as $course) {
if ($debug) {
echo $course['title'] . PHP_EOL;
echo $course['title'] . $eol;
}
$sessionTitle = $course['title'] . ' ' . $month . '-' . $year . ' - a';
$sessionTitle = $course['title'] . ' (' . $month . '/' . $year . ' - a)';
$startDate = ($year-2) . '-' . $month . '-01';
$endDate = $year . '-' . $month . '-01';
$id = SessionManager::create_session(
@ -136,13 +146,13 @@ foreach ($res as $course) {
0,
0,
0,
'info@contidosdixitais.com',
$username,
0,
SESSION_VISIBLE_READ_ONLY
);
while ($id == 'SessionNameAlreadyExists') {
if ($debug) {
echo "Could not create session $sessionTitle" . PHP_EOL;
echo "Could not create session $sessionTitle" . $eol;
}
// Increase the last letter
$sessionTitle = substr($sessionTitle, 0, -1) . chr(ord(substr($sessionTitle, -1, 1))+1);
@ -153,13 +163,13 @@ foreach ($res as $course) {
0,
0,
0,
'info@contidosdixitais.com',
$username,
0,
SESSION_VISIBLE_READ_ONLY
);
}
if ($debug) {
echo "Session $sessionTitle created with ID $id" . PHP_EOL;
echo "Session $sessionTitle created with ID $id" . $eol;
}
SessionManager::add_courses_to_session($id, array($course['code']));
$resultUsers = Database::query("SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER). " WHERE course_code = '" . $course['code'] . "'");
@ -168,10 +178,11 @@ foreach ($res as $course) {
$users[] = $row['user_id'];
}
if ($debug) {
echo count($users) . " users in course " . $course['title'] . " will be moved to session $id (unless they're admins)" . PHP_EOL;
echo count($users) . " users in course " . $course['title'] . " will be moved to session $id (unless they're admins)" . $eol;
}
SessionManager::subscribe_users_to_session_course($users, $id, $course['code']);
foreach ($userTables as $table => $fields) {
$table = Database::get_main_database().'.'.$table;
//c_id + course_id = int, others = char
if ($fields['c'] == 'c_id' or $fields['c'] == 'course_id') {
$sql = "UPDATE $table SET " . $fields['s'] . " = $id WHERE " . $fields['c'] . " = " . $course['id'];
@ -179,7 +190,7 @@ foreach ($res as $course) {
$sql = "UPDATE $table SET " . $fields['s'] . " = $id WHERE " . $fields['c'] . " = '" . $course['code'] . "'";
}
if ($debug) {
echo $sql . PHP_EOL;
echo $sql . $eol;
}
$resultChange = Database::query($sql);
}
@ -190,13 +201,15 @@ foreach ($res as $course) {
// Skip un-subscribing of admin users
continue;
}
$sql = "DELETE FROM course_rel_user WHERE user_id = $user AND course_code = '" . $course['code'] . "'";
$table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$sql = "DELETE FROM $table WHERE user_id = $user AND course_code = '" . $course['code'] . "'";
if ($debug) {
echo $sql . PHP_EOL;
echo $sql . $eol;
}
$resultRemove = Database::query($sql);
}
}
if ($debug) {
echo "End of moving process" . PH_EOL;
}
echo "End of moving process" . $eol;
}
echo $eof;

Loading…
Cancel
Save