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

pull/3032/head
Sébastien Ducoulombier 7 years ago
commit e0b083eefd
  1. 10
      app/Resources/public/css/themes/chamilo/print.css
  2. 2
      main/auth/external_login/newUser.ldap.php
  3. 46
      main/auth/inscription.php
  4. 2
      main/document/showinframes.php
  5. 4
      main/exercise/fill_blanks.class.php
  6. 13
      main/gradebook/gradebook_display_certificate.php
  7. 2
      main/gradebook/gradebook_display_summary.php
  8. 13
      main/gradebook/lib/be/category.class.php
  9. 1
      main/gradebook/lib/fe/gradebooktable.class.php
  10. 73
      main/gradebook/lib/gradebook_data_generator.class.php
  11. 21
      main/inc/lib/MailTemplateManager.php
  12. 1
      main/inc/lib/document.lib.php
  13. 28
      main/inc/lib/events.lib.php
  14. 84
      main/inc/lib/message.lib.php
  15. 2
      main/lp/learnpath.class.php
  16. 5
      main/lp/learnpathList.class.php
  17. 2
      main/mySpace/myStudents.php
  18. 14
      main/template/default/mail/new_user_mail_to_admin_approval.tpl
  19. 1
      main/work/work.lib.php

@ -534,7 +534,7 @@ dl.upload_option {
height: 0;
}
p, blockquote, ol, ul {
font-size: 12px;
/*font-size: 12px;*/
}
h1 {
font-size: 21px;
@ -768,19 +768,19 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;}
text-align: left;
}
.data_table tr.row_odd {
background-color: #fafafa;
background-color: #fafafa;
}
.data_table tr.row_odd:hover, .data_table tr.row_even:hover {
background-color: #f0f0f0;
}
.data_table tr.row_even {
background-color: #fff;
background-color: #fff;
}
.data_table td .highlight {
font-weight: bold;
}
.data_table td {
padding: 5px;
padding: 5px;
border-bottom: 1px solid #b0b0b0;
border-right: 1px dotted #e1e1e1;
border-left: 1px dotted #e1e1e1;
@ -795,7 +795,7 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;}
margin-bottom: 15px;
margin-top: 8px;
text-align: left;
width: 100%;
width: 100%;
}
.data_table_no_border td {

@ -63,7 +63,7 @@ if ($ldap_user !== false) {
}
Event::eventLogin($chamiloUser->getId());
MessageManager::sendNotificationByRegisteredUser($chamiloUser);
MessageManager::sendNotificationOfNewRegisteredUser($chamiloUser);
}
} else {
$loginFailed = true;

@ -834,50 +834,8 @@ if ($form->validate()) {
sent a mail to the platform admin and exit the page.*/
if (api_get_setting('allow_registration') === 'approval') {
// 1. Send mail to all platform admin
$emailsubject = get_lang('ApprovalForNewAccount').': '.$values['username'];
$emailbody = get_lang('ApprovalForNewAccount')."\n";
$emailbody .= get_lang('UserName').': '.$values['username']."\n";
if (api_is_western_name_order()) {
$emailbody .= get_lang('FirstName').': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName').': '.$values['lastname']."\n";
} else {
$emailbody .= get_lang('LastName').': '.$values['lastname']."\n";
$emailbody .= get_lang('FirstName').': '.$values['firstname']."\n";
}
$emailbody .= get_lang('Email').': '.$values['email']."\n";
$emailbody .= get_lang('Status').': '.$values['status']."\n\n";
$url_edit = Display::url(
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id,
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id
);
$emailbody .= get_lang('ManageUser').": $url_edit";
if (api_get_configuration_value('send_inscription_notification_to_general_admin_only')) {
$email = api_get_setting('emailAdministrator');
$firtname = api_get_setting('administratorSurname');
$lastname = api_get_setting('administratorName');
api_mail_html("$firtname $lastname", $email, $emailsubject, $emailbody);
} else {
$admins = UserManager::get_all_administrators();
foreach ($admins as $admin_info) {
MessageManager::send_message(
$admin_info['user_id'],
$emailsubject,
$emailbody,
[],
[],
null,
null,
null,
null,
$user_id
);
}
}
$chamiloUser = api_get_user_entity($user_id);
MessageManager::sendNotificationOfNewRegisteredUserApproval($chamiloUser);
// 2. set account inactive
UserManager::disable($user_id);

@ -103,7 +103,7 @@ if (!$is_allowed_to_edit && !$is_visible) {
}
$pathinfo = pathinfo($header_file);
$playerSupportedFiles = ['mp3', 'mp4', 'ogv', 'flv', 'm4v', 'webm'];
$playerSupportedFiles = ['mp3', 'mp4', 'ogv', 'ogg', 'flv', 'm4v', 'webm'];
$playerSupported = false;
if (in_array(strtolower($pathinfo['extension']), $playerSupportedFiles)) {
$playerSupported = true;

@ -1133,7 +1133,7 @@ class FillBlanks extends Question
$result = '';
$listStudentAnswerInfo = self::getAnswerInfo($answer, true);
if (in_array($resultsDisabled, [
/*if (in_array($resultsDisabled, [
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
]
@ -1143,7 +1143,7 @@ class FillBlanks extends Question
if ($showTotalScoreAndUserChoices) {
$resultsDisabled = false;
}
}
}*/
// rebuild the answer with good HTML style
// this is the student answer, right or wrong

@ -317,12 +317,21 @@ if (count($certificate_list) == 0) {
echo '<td width="30%">'.get_lang('Date').' : '.api_convert_and_format_date($valueCertificate['created_at']).'</td>';
echo '<td width="20%">';
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$valueCertificate['id'].'&user_id='.$value['user_id'];
$certificates = Display::url(
$certificateUrl = Display::url(
get_lang('Certificate'),
$url,
['target' => '_blank', 'class' => 'btn btn-default']
);
echo $certificates;
echo $certificateUrl;
$url .= '&action=export';
$pdf = Display::url(
Display::return_icon('pdf.png', get_lang('Download')),
$url,
['target' => '_blank']
);
echo $pdf;
echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token='.$token.'&'.api_get_cidreq().'&action=delete&cat_id='.$categoryId.'&certificate_id='.$valueCertificate['id'].'">
'.Display::return_icon('delete.png', get_lang('Delete')).'
</a>';

@ -145,7 +145,7 @@ switch ($action) {
case 'download':
$userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
$cats = Category::load($cat_id, null, null, null, null, null, false);
GradebookUtils::generateTable($courseInfo, $userId, $cats);
GradebookUtils::generateTable($courseInfo, $userId, $cats, false, false, $userList);
break;
}

@ -937,7 +937,6 @@ class Category implements GradebookItem
}
}
$students = [];
if (!empty($evals)) {
/** @var Evaluation $eval */
foreach ($evals as $eval) {
@ -1128,18 +1127,6 @@ class Category implements GradebookItem
$maxScore = current($totalScorePerStudent);
return [$maxScore, $this->get_weight()];
if (empty($bestResult)) {
if ($cacheAvailable) {
$cacheDriver->save($key, null);
}
return null;
}
if ($cacheAvailable) {
$cacheDriver->save($key, [$bestResult, $weightsum]);
}
return [$bestResult, $weightsum];
break;
case 'average':
if (empty($ressum)) {

@ -268,7 +268,6 @@ class GradebookTable extends SortableTable
$defaultData[$item->get_id()]['ranking'] = $rankingStudentList;
$defaultData[$item->get_id()]['ranking_invalidate'] = $invalidateRanking;
}
//exit;
}
break;
}

@ -240,10 +240,71 @@ class GradebookDataGenerator
}
$score = AbstractLink::getCurrentUserRanking($userId, $rankingStudentList);
}
//$score = AbstractLink::getCurrentUserRanking($userId, $item->entity->getUserScoreList());
} else {
if (!empty($studentList)) {
$session_id = api_get_session_id();
//$cats = $item->get_subcategories(null);
$evals = $item->get_evaluations(null);
$links = $item->get_links(null);
foreach ($studentList as $user) {
$score = $this->build_result_column(
$ressum = 0;
$weightsum = 0;
$bestResult = 0;
if (!empty($evals)) {
foreach ($evals as $eval) {
$evalres = $eval->calc_score($user['user_id'], null);
$eval->setStudentList($studentList);
if (isset($evalres) && $eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$weightsum += $evalweight;
if (!empty($evalres[1])) {
$ressum += $evalres[0] / $evalres[1] * $evalweight;
}
if ($ressum > $bestResult) {
$bestResult = $ressum;
}
} else {
if ($eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$weightsum += $evalweight;
}
}
}
}
if (!empty($links)) {
foreach ($links as $link) {
$link->setStudentList($studentList);
if ($session_id) {
$link->set_session_id($session_id);
}
$linkres = $link->calc_score($user['user_id'], null);
if (!empty($linkres) && $link->get_weight() != 0) {
$linkweight = $link->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
$weightsum += $linkweight;
$ressum += $linkres[0] / $link_res_denom * $linkweight;
if ($ressum > $bestResult) {
$bestResult = $ressum;
}
} else {
// Adding if result does not exists
if ($link->get_weight() != 0) {
$linkweight = $link->get_weight();
$weightsum += $linkweight;
}
}
}
}
/*$score = $this->build_result_column(
$user['user_id'],
$item,
$ignore_score_color,
@ -251,11 +312,18 @@ class GradebookDataGenerator
);
if (!empty($score['score'][0])) {
$invalidateResults = false;
}*/
if (!empty($ressum)) {
$invalidateResults = false;
}
$rankingStudentList[$user['user_id']] = $score['score'][0];
$rankingStudentList[$user['user_id']] = $ressum;
}
}
//error_log($item->get_id());
$score = AbstractLink::getCurrentUserRanking($userId, $rankingStudentList);
//error_log(print_r($score, 1));
}
$row['ranking'] = $scoreDisplay->display_score(
@ -314,6 +382,7 @@ class GradebookDataGenerator
} else {
if (!empty($studentList)) {
foreach ($studentList as $user) {
$score = $this->build_result_column(
$user['user_id'],
$item,

@ -209,4 +209,25 @@ class MailTemplateManager extends Model
return false;
}
/**
* Gets a custom mail template by the name of the template it replaces
* @param string $templateType Name of the template file it replaces
* @return string
*/
public function getTemplateByType($templateType)
{
if (empty($templateType)) {
return '';
}
$result = Database::select(
'template',
$this->table,
['where' => ['type = ? ' => $templateType, ' AND url_id = ? ' => api_get_current_access_url_id()]],
'first'
);
if (empty($result)) {
return '';
}
return $result['template'];
}
}

@ -3256,6 +3256,7 @@ class DocumentManager
{
$id = api_get_unique_id();
switch ($extension) {
case 'ogg':
case 'mp3':
$document_data['file_extension'] = $extension;
$html = '<div style="margin: 0; position: absolute; top: 50%; left: 35%;">';

@ -2260,6 +2260,17 @@ class Event
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
Database::insert($courseTrackingTable, $params);
// Time should also be added to the track_e_login table so as to
// affect total time on the platform
$params = [
'login_user_id' => $userId,
'login_date' => $loginDate,
'user_ip' => api_get_real_ip(),
'logout_date' => $logoutDate
];
$platformTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
Database::insert($platformTrackingTable, $params);
return true;
}
@ -2292,6 +2303,7 @@ class Event
return false;
}
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$platformTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$courseId = (int) $courseId;
$userId = (int) $userId;
$sessionId = (int) $sessionId;
@ -2326,8 +2338,22 @@ class Event
$courseAccessId = $row[0];
$sql = "DELETE FROM $courseTrackingTable
WHERE course_access_id = $courseAccessId";
Database::query($sql);
}
$sql = "SELECT login_id
FROM $platformTrackingTable
WHERE
login_user_id = $userId AND
(UNIX_TIMESTAMP(logout_date) - UNIX_TIMESTAMP(login_date)) = '$virtualTime'
ORDER BY login_date DESC LIMIT 0,1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
// Found the latest connection
$row = Database::fetch_row($result);
$loginAccessId = $row[0];
$sql = "DELETE FROM $platformTrackingTable
WHERE login_id = $loginAccessId";
$result = Database::query($sql);
return $result;
}

@ -2655,7 +2655,7 @@ class MessageManager
*
* @param User $user
*/
public static function sendNotificationByRegisteredUser(User $user)
public static function sendNotificationOfNewRegisteredUser(User $user)
{
$tplMailBody = new Template(
null,
@ -2696,6 +2696,88 @@ class MessageManager
}
}
/**
* Send a notification to all admins when a new user is registered
* while the approval method is used for users registration
*
* @param User $user
*/
public static function sendNotificationOfNewRegisteredUserApproval(User $user)
{
$tplMailBody = new Template(
null,
false,
false,
false,
false,
false,
false
);
$tplMailBody->assign('user', $user);
$tplMailBody->assign('is_western_name_order', api_is_western_name_order());
$userId = $user->getId();
$url_edit = Display::url(
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$userId,
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$userId
);
$tplMailBody->assign(
'manageUrl',
$url_edit
);
// Get extra field values for this user and reformat the array
$extraFieldValues = new ExtraFieldValue('user');
$userExtraFields = $extraFieldValues->getAllValuesByItem($userId);
$values = [];
foreach($userExtraFields as $field => $value) {
$values[$value['variable']] = $value['value'];
}
$tplMailBody->assign(
'extra',
$values
);
$layoutContent = '';
$emailbody = '';
if (api_get_configuration_value('mail_template_system') == true) {
$mailTemplateManager = new MailTemplateManager();
$templateText = $mailTemplateManager->getTemplateByType('new_user_mail_to_admin_approval.tpl');
if (empty($templateText)) {
} else {
// custom procedure to load a template as a string (doesn't use cache so may slow down)
$template = $tplMailBody->twig->createTemplate($templateText);
$emailbody = $template->render($tplMailBody->params);
}
}
if (empty($emailbody)) {
$layoutContent = $tplMailBody->get_template('mail/new_user_mail_to_admin_approval.tpl');
$emailbody = $tplMailBody->fetch($layoutContent);
}
$emailsubject = '['.get_lang('ApprovalForNewAccount').'] '.$user->getUsername();
if (api_get_configuration_value('send_inscription_notification_to_general_admin_only')) {
$email = api_get_setting('emailAdministrator');
$firstname = api_get_setting('administratorSurname');
$lastname = api_get_setting('administratorName');
api_mail_html("$firstname $lastname", $email, $emailsubject, $emailbody);
} else {
$admins = UserManager::get_all_administrators();
foreach ($admins as $admin_info) {
self::send_message(
$admin_info['user_id'],
$emailsubject,
$emailbody,
[],
[],
null,
null,
null,
null,
$userId
);
}
}
}
/**
* Get the error log from failed mailing
* This assumes a complex setup where you have a cron script regularly copying the mail queue log

@ -12944,7 +12944,7 @@ EOD;
}
$documentPathInfo = pathinfo($document->getPath());
$mediaSupportedFiles = ['mp3', 'mp4', 'ogv', 'flv', 'm4v'];
$mediaSupportedFiles = ['mp3', 'mp4', 'ogv', 'ogg', 'flv', 'm4v'];
$extension = isset($documentPathInfo['extension']) ? $documentPathInfo['extension'] : '';
$showDirectUrl = !in_array($extension, $mediaSupportedFiles);

@ -106,10 +106,7 @@ class LearnpathList
$isAllowToEdit = api_is_allowed_to_edit();
/** @var CLp $row */
foreach ($learningPaths as $row) {
// Use domesticate here instead of Database::escape_string because
// it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
// is done using domesticate()
$name = domesticate($row->getName());
$name = Database::escape_string($row->getName());
$link = 'lp/lp_controller.php?action=view&lp_id='.$row->getId().'&id_session='.$session_id;
$oldLink = 'newscorm/lp_controller.php?action=view&lp_id='.$row->getId().'&id_session='.$session_id;

@ -1855,7 +1855,7 @@ if (empty($details)) {
echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>';
$qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
echo '<td class="text-center">'.$qualification.'</td>';
echo '<td class="text-center">'.$results['formatted_date'].'</td>';
echo '<td class="text-center">'.api_convert_and_format_date($results['sent_date_from_db']).' '.$results['expiry_note'].'</td>';
$assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']);
echo '<td class="text-center">';

@ -0,0 +1,14 @@
<h4>{{ 'ApprovalForNewAccount'|get_lang }}</h4>
<ul>
<li>{{ 'Username'|get_lang }}: {{ user.getUsername() }}</li>
{% if is_western_name_order %}
<li>{{ 'FirstName'|get_lang }}: {{ user.getFirstName() }}</li>
<li>{{ 'LastName' }}: {{ user.getLastName() }}</li>
{% else %}
<li>{{ 'LastName' }}: {{ user.getLastName() }}</li>
<li>{{ 'FirstName' }}: {{ user.getFirstName() }}</li>
{% endif %}
<li>{{ 'Email'|get_lang }}: {{ user.getEmail() }}</li>
<li>{{ 'Status'|get_lang }}: {{ user.getStatus() }}</li>
</ul>
<p>{{ 'ManageUser'|get_lang }}: <a href="{{ manageUrl }}">{{ manageUrl }}</a></p>

@ -2069,6 +2069,7 @@ function get_work_user_list(
$work_date = api_get_local_time($work['sent_date']);
$date = date_to_str_ago($work['sent_date']).' '.$work_date;
$work['formatted_date'] = $work_date.' '.$add_string;
$work['expiry_note'] = $add_string;
$work['sent_date_from_db'] = $work['sent_date'];
$work['sent_date'] = '<div class="work-date" title="'.$date.'">'.
$add_string.' '.Display::dateToStringAgoAndLongDate($work['sent_date']).'</div>';

Loading…
Cancel
Save