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

pull/3312/head
Angel Fernando Quiroz Campos 5 years ago
commit 8f5aa4df5e
  1. 5
      documentation/optimization.html
  2. 21
      main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  3. 29
      main/exercise/global_multiple_answer.class.php
  4. 10
      main/exercise/multiple_answer_true_false.class.php
  5. 28
      main/gradebook/gradebook_display_certificate.php
  6. 59
      main/lp/lp_report.php
  7. 1
      main/lp/lp_view.php
  8. 129
      main/lp/scorm_api.php
  9. 20
      main/template/default/chat/chat.tpl
  10. 3
      main/template/default/learnpath/report.tpl
  11. 8
      main/work/work.lib.php
  12. 146
      plugin/customcertificate/src/print_certificate.php
  13. 4
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php
  14. 2
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php

@ -247,6 +247,11 @@ ALTER TABLE c_lp_item_view ADD INDEX idx_clpiv_c_i_v (c_id, id, view_count);
ALTER TABLE c_item_property ADD INDEX idx_item_property_visibility (visibility); ALTER TABLE c_item_property ADD INDEX idx_item_property_visibility (visibility);
ALTER TABLE c_dropbox_person ADD INDEX idx_file(file_id); ALTER TABLE c_dropbox_person ADD INDEX idx_file(file_id);
ALTER TABLE c_chat_connected ADD INDEX idx_user_course_session(user_id, c_id, session_id);
ALTER TABLE c_chat_connected ADD INDEX idx_user_course_group(user_id, c_id, to_group_id);
ALTER TABLE c_chat_connected ADD INDEX idx_course_session(c_id, session_id);
ALTER TABLE c_chat_connected ADD INDEX idx_course_group(c_id, to_group_id);
</pre> </pre>
<hr /> <hr />
<h2><a name="3.Indexes-caching"></a>3. Indexes caching</h2> <h2><a name="3.Indexes-caching"></a>3. Indexes caching</h2>

@ -65,22 +65,21 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$renderer = &$form->defaultRenderer(); $renderer = &$form->defaultRenderer();
$defaults = []; $defaults = [];
$html = '<table class="data_table"><tr style="text-align: center;"><th>' $form->addHeader(get_lang('Answers'));
.get_lang('Number') $html = '<table class="table table-striped table-hover">
.'</th><th>' <tr>
.get_lang('True') <th width="10px">'.get_lang('Number').'</th>
.'</th><th>' <th width="10px">'.get_lang('True').'</th>
.get_lang('False') <th width="10px">'.get_lang('False').'</th>
.'</th><th>' <th width="50%">'.get_lang('Answer').'</th>';
.get_lang('Answer')
.'</th>';
// show column comment when feedback is enable // show column comment when feedback is enable
if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$html .= '<th>'.get_lang('Comment').'</th>'; $html .= '<th width="50%">'.get_lang('Comment').'</th>';
} }
$html .= '</tr>'; $html .= '</tr>';
$form->addElement('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
$form->addHtml($html);
$correct = 0; $correct = 0;
$answer = null; $answer = null;

@ -32,27 +32,18 @@ class GlobalMultipleAnswer extends Question
$obj_ex = Session::read('objExercise'); $obj_ex = Session::read('objExercise');
$form->addHeader(get_lang('Answers'));
/* Mise en variable de Affichage "Reponses" et son icone, "N<EFBFBD>", "Vrai", "Reponse" */ /* Mise en variable de Affichage "Reponses" et son icone, "N<EFBFBD>", "Vrai", "Reponse" */
$html = '<table class="data_table"> $html = '<table class="table table-striped table-hover">
<tr> <tr>
<th width="10px"> <th width="10px">'.get_lang('Number').'</th>
'.get_lang('Number').' <th width="10px">'.get_lang('True').'</th>
</th> <th width="50%">'.get_lang('Answer').'</th>
<th width="10px"> <th width="50%">'.get_lang('Comment').'</th>
'.get_lang('True').' </tr>
</th> ';
<th width="50%"> $form->addHtml($html);
'.get_lang('Answer').'
</th>';
$html .= '<th>'.get_lang('Comment').'</th>';
$html .= '</tr>';
$form->addElement(
'label',
get_lang('Answers').
'<br /> '.Display::return_icon('fill_field.png'),
$html
);
$defaults = []; $defaults = [];
$correct = 0; $correct = 0;
$answer = false; $answer = false;

@ -45,14 +45,14 @@ class MultipleAnswerTrueFalse extends Question
$html = '<table class="table table-striped table-hover">'; $html = '<table class="table table-striped table-hover">';
$html .= '<thead>'; $html .= '<thead>';
$html .= '<tr>'; $html .= '<tr>';
$html .= '<th>'.get_lang('Number').'</th>'; $html .= '<th width="10px">'.get_lang('Number').'</th>';
$html .= '<th>'.get_lang('True').'</th>'; $html .= '<th width="10px">'.get_lang('True').'</th>';
$html .= '<th>'.get_lang('False').'</th>'; $html .= '<th width="10px">'.get_lang('False').'</th>';
$html .= '<th>'.get_lang('Answer').'</th>'; $html .= '<th width="50%">'.get_lang('Answer').'</th>';
// show column comment when feedback is enable // show column comment when feedback is enable
if ($obj_ex->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { if ($obj_ex->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$html .= '<th>'.get_lang('Comment').'</th>'; $html .= '<th width="50%">'.get_lang('Comment').'</th>';
} }
$html .= '</tr>'; $html .= '</tr>';

@ -74,7 +74,7 @@ if ($filter === 'true') {
$content = ''; $content = '';
$courseCode = api_get_course_id(); $courseCode = api_get_course_id();
$allowExportToZip = api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true' && $allowCustomCertificate = api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true' &&
api_get_course_setting('customcertificate_course_enable', $courseInfo) == 1; api_get_course_setting('customcertificate_course_enable', $courseInfo) == 1;
$tags = Certificate::notificationTags(); $tags = Certificate::notificationTags();
@ -126,23 +126,29 @@ switch ($action) {
$content = $form->returnForm(); $content = $form->returnForm();
break; break;
case 'export_all_certificates': case 'export_all_certificates':
if (api_is_student_boss()) { if ($allowCustomCertificate) {
$userGroup = new UserGroup(); $params = 'course_code='.api_get_course_id().'&session_id='.api_get_session_id().'&'.api_get_cidreq();
$userList = $userGroup->getGroupUsersByUser(api_get_user_id()); $url = api_get_path(WEB_PLUGIN_PATH).
'customcertificate/src/print_certificate.php?export_all_in_one=1&'.$params;
} else { } else {
$userList = []; if (api_is_student_boss()) {
if (!empty($filterOfficialCodeGet)) { $userGroup = new UserGroup();
$userList = UserManager::getUsersByOfficialCode($filterOfficialCodeGet); $userList = $userGroup->getGroupUsersByUser(api_get_user_id());
} else {
$userList = [];
if (!empty($filterOfficialCodeGet)) {
$userList = UserManager::getUsersByOfficialCode($filterOfficialCodeGet);
}
} }
}
Category::exportAllCertificates($categoryId, $userList); Category::exportAllCertificates($categoryId, $userList);
}
header('Location: '.$url); header('Location: '.$url);
exit; exit;
break; break;
case 'export_all_certificates_zip': case 'export_all_certificates_zip':
if ($allowExportToZip) { if ($allowCustomCertificate) {
$params = 'course_code='.api_get_course_id().'&session_id='.api_get_session_id().'&'.api_get_cidreq(); $params = 'course_code='.api_get_course_id().'&session_id='.api_get_session_id().'&'.api_get_cidreq();
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php?export_all=1&'.$params; $url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php?export_all=1&'.$params;
@ -273,7 +279,7 @@ if (count($certificate_list) > 0 && $hideCertificateExport !== 'true') {
$url.'&action=export_all_certificates' $url.'&action=export_all_certificates'
); );
if ($allowExportToZip) { if ($allowCustomCertificate) {
$actions .= Display::url( $actions .= Display::url(
Display::return_icon('file_zip.png', get_lang('ExportAllCertificatesToZIP'), [], ICON_SIZE_MEDIUM), Display::return_icon('file_zip.png', get_lang('ExportAllCertificatesToZIP'), [], ICON_SIZE_MEDIUM),
$url.'&action=export_all_certificates_zip' $url.'&action=export_all_certificates_zip'

@ -20,18 +20,21 @@ if (!$isAllowedToEdit) {
$lpTable = Database::get_course_table(TABLE_LP_MAIN); $lpTable = Database::get_course_table(TABLE_LP_MAIN);
$lpId = isset($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0; $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0;
$export = isset($_GET['export']); $export = isset($_REQUEST['export']);
$lp = new learnpath(api_get_course_id(), $lpId, api_get_user_id()); $lp = new learnpath(api_get_course_id(), $lpId, api_get_user_id());
if (empty($lp)) { if (empty($lp)) {
api_not_allowed(true); api_not_allowed(true);
} }
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=report&lp_id='.$lpId;
$em = Database::getManager(); $em = Database::getManager();
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$courseCode = api_get_course_id(); $courseCode = api_get_course_id();
// Check LP subscribers // Check LP subscribers
if ('1' === $lp->getSubscribeUsers()) { if ('1' === $lp->getSubscribeUsers()) {
/** @var ItemPropertyRepository $itemRepo */ /** @var ItemPropertyRepository $itemRepo */
@ -93,35 +96,57 @@ $lpInfo = Database::select(
'first' 'first'
); );
$groups = GroupManager::get_group_list(null, api_get_course_info(), null, api_get_session_id());
$groupFilter = '';
if (!empty($groups)) {
$form = new FormValidator('group', 'post', $url);
$form->addSelect(
'group_id',
get_lang('Groups'),
array_column($groups, 'name', 'iid'),
['placeholder' => get_lang('SelectAnOption')]
);
$form->addButtonSearch(get_lang('Search'));
if ($form->validate()) {
$groupId = $form->getSubmitValue('group_id');
if (!empty($groupId)) {
$users = GroupManager::getStudents($groupId, true);
}
}
$groupFilter = $form->returnForm();
}
$userList = []; $userList = [];
$showEmail = api_get_setting('show_email_addresses'); $showEmail = api_get_setting('show_email_addresses');
if (!empty($users)) { if (!empty($users)) {
foreach ($users as $user) { foreach ($users as $user) {
$userInfo = api_get_user_info($user['user_id']); $userId = $user['user_id'];
$userInfo = api_get_user_info($userId);
$lpTime = Tracking::get_time_spent_in_lp( $lpTime = Tracking::get_time_spent_in_lp(
$user['user_id'], $userId,
$courseCode, $courseCode,
[$lpId], [$lpId],
$sessionId $sessionId
); );
$lpScore = Tracking::get_avg_student_score( $lpScore = Tracking::get_avg_student_score(
$user['user_id'], $userId,
$courseCode, $courseCode,
[$lpId], [$lpId],
$sessionId $sessionId
); );
$lpProgress = Tracking::get_avg_student_progress( $lpProgress = Tracking::get_avg_student_progress(
$user['user_id'], $userId,
$courseCode, $courseCode,
[$lpId], [$lpId],
$sessionId $sessionId
); );
$lpLastConnection = Tracking::get_last_connection_time_in_lp( $lpLastConnection = Tracking::get_last_connection_time_in_lp(
$user['user_id'], $userId,
$courseCode, $courseCode,
$lpId, $lpId,
$sessionId $sessionId
@ -132,11 +157,20 @@ if (!empty($users)) {
DATE_TIME_FORMAT_LONG DATE_TIME_FORMAT_LONG
); );
$userGroupList = '';
if (!empty($groups)) {
$groupsByUser = GroupManager::getAllGroupPerUserSubscription($userId, $courseId, $sessionId);
if (!empty($groupsByUser)) {
$userGroupList = implode(', ', array_column($groupsByUser, 'name'));
}
}
$userList[] = [ $userList[] = [
'id' => $user['user_id'], 'id' => $userId,
'first_name' => $userInfo['firstname'], 'first_name' => $userInfo['firstname'],
'last_name' => $userInfo['lastname'], 'last_name' => $userInfo['lastname'],
'email' => 'true' === $showEmail ? $userInfo['email'] : '', 'email' => 'true' === $showEmail ? $userInfo['email'] : '',
'groups' => $userGroupList,
'lp_time' => api_time_to_hms($lpTime), 'lp_time' => api_time_to_hms($lpTime),
'lp_score' => is_numeric($lpScore) ? "$lpScore%" : $lpScore, 'lp_score' => is_numeric($lpScore) ? "$lpScore%" : $lpScore,
'lp_progress' => "$lpProgress%", 'lp_progress' => "$lpProgress%",
@ -171,7 +205,7 @@ if (!empty($users)) {
[], [],
ICON_SIZE_MEDIUM ICON_SIZE_MEDIUM
), ),
api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=report&export=pdf&lp_id='.$lpId $url.'&export=pdf'
); );
} }
@ -182,13 +216,12 @@ $template->assign('course_code', api_get_course_id());
$template->assign('lp_id', $lpId); $template->assign('lp_id', $lpId);
$template->assign('show_email', 'true' === $showEmail); $template->assign('show_email', 'true' === $showEmail);
$template->assign('export', (int) $export); $template->assign('export', (int) $export);
$template->assign('groups', $groupFilter);
$layout = $template->get_template('learnpath/report.tpl'); $layout = $template->get_template('learnpath/report.tpl');
$template->assign('header', $lpInfo['name']); $template->assign('header', $lpInfo['name']);
$template->assign( $template->assign('actions', Display::toolbarAction('lp_actions', [$actions]));
'actions',
Display::toolbarAction('lp_actions', [$actions])
);
$result = $template->fetch($layout); $result = $template->fetch($layout);
$template->assign('content', $result); $template->assign('content', $result);

@ -576,6 +576,7 @@ $template->assign(
); );
$frameReady = Display::getFrameReadyBlock('#content_id, #content_id_blank'); $frameReady = Display::getFrameReadyBlock('#content_id, #content_id_blank');
$template->assign('frame_ready', $frameReady); $template->assign('frame_ready', $frameReady);
$view = $template->get_template('learnpath/view.tpl'); $view = $template->get_template('learnpath/view.tpl');
$content = $template->fetch($view); $content = $template->fetch($view);

@ -893,10 +893,6 @@ function savedata(item_id) {
item_to_save = old_item_id; item_to_save = old_item_id;
} }
// Original behaviour
// xajax_save_item_scorm(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, old_item_id);
// Modified version
xajax_save_item_scorm( xajax_save_item_scorm(
olms.lms_lp_id, olms.lms_lp_id,
olms.lms_user_id, olms.lms_user_id,
@ -1555,7 +1551,8 @@ function switch_item(current_item, next_item)
} else { } else {
logit_lms('Case 2 - current != sco but next == sco'); logit_lms('Case 2 - current != sco but next == sco');
} }
xajax_save_item(
var saveAjax = xajax_save_item(
olms.lms_lp_id, olms.lms_lp_id,
olms.lms_user_id, olms.lms_user_id,
olms.lms_view_id, olms.lms_view_id,
@ -1576,21 +1573,27 @@ function switch_item(current_item, next_item)
1, 1,
olms.statusSignalReceived olms.statusSignalReceived
); );
xajax_switch_item_details(
olms.lms_lp_id, if (saveAjax) {
olms.lms_user_id, $.when(saveAjax).done(function(results) {
olms.lms_view_id, xajax_switch_item_details(
olms.lms_item_id, olms.lms_lp_id,
next_item olms.lms_user_id,
); olms.lms_view_id,
olms.lms_item_id,
next_item
);
});
}
} else { } else {
if (next_item_type != 'sco') { if (next_item_type != 'sco') {
logit_lms('Case 3 - current == sco but next != sco'); logit_lms('Case 3 - current == sco but next != sco');
} else { } else {
logit_lms('Case 4 - current == sco and next == sco'); logit_lms('Case 4 - current == sco and next == sco');
} }
// Setting userNavigatesAway = 1 // Setting userNavigatesAway = 1
xajax_save_item_scorm( var saveAjax = xajax_save_item_scorm(
olms.lms_lp_id, olms.lms_lp_id,
olms.lms_user_id, olms.lms_user_id,
olms.lms_view_id, olms.lms_view_id,
@ -1602,24 +1605,27 @@ function switch_item(current_item, next_item)
olms.statusSignalReceived olms.statusSignalReceived
); );
reinit_updatable_vars_list(); if (saveAjax) {
$.when(saveAjax).done(function(result) {
xajax_switch_item_toc( reinit_updatable_vars_list();
olms.lms_lp_id, xajax_switch_item_toc(
olms.lms_user_id, olms.lms_lp_id,
olms.lms_view_id, olms.lms_user_id,
olms.lms_item_id, olms.lms_view_id,
next_item olms.lms_item_id,
); next_item
);
if (olms.item_objectives.length>0) {
xajax_save_objectives( if (olms.item_objectives.length>0) {
olms.lms_lp_id, xajax_save_objectives(
olms.lms_user_id, olms.lms_lp_id,
olms.lms_view_id, olms.lms_user_id,
olms.lms_item_id, olms.lms_view_id,
olms.item_objectives olms.lms_item_id,
); olms.item_objectives
);
}
});
} }
} }
@ -1641,42 +1647,6 @@ function switch_item(current_item, next_item)
* anymore) * anymore)
*/ */
/*
if (olms.lms_item_type == 'sco' &&
olms.lesson_status != 'completed' &&
olms.lesson_status != 'passed' &&
olms.lesson_status != 'browsed' &&
olms.lesson_status != 'incomplete' &&
olms.lesson_status != 'failed'
) {
// savedata() with olms.finishSignalReceived == 1 treats the special
// condition and saves the new status to the database, so
// switch_item_details() enjoys the new status
savedata(olms.lms_item_id);
}
xajax_save_item(
olms.lms_lp_id,
olms.lms_user_id,
olms.lms_view_id,
olms.lms_item_id,
olms.score,
olms.max,
olms.min,
olms.lesson_status,
olms.session_time,
olms.suspend_data,
olms.lesson_location,
olms.interactions,
olms.lms_item_core_exit,
orig_item_type,
olms.session_id,
olms.course_id,
olms.finishSignalReceived,
1,
olms.statusSignalReceived
);
*/
olms.execute_stats = false; olms.execute_stats = false;
// Considering info_lms_item[0] is initially the oldest and info_lms_item[1] // Considering info_lms_item[0] is initially the oldest and info_lms_item[1]
@ -1926,7 +1896,7 @@ function xajax_save_item(
if (olms.lms_lp_type == 1 || item_type == 'document' || item_type == 'asset') { if (olms.lms_lp_type == 1 || item_type == 'document' || item_type == 'asset') {
logit_lms('xajax_save_item with params:' + params, 3); logit_lms('xajax_save_item with params:' + params, 3);
$.ajax({ return $.ajax({
type:"POST", type:"POST",
data: params, data: params,
url: "lp_ajax_save_item.php" + courseUrl, url: "lp_ajax_save_item.php" + courseUrl,
@ -1934,6 +1904,8 @@ function xajax_save_item(
async: false async: false
}); });
} }
return false;
} }
/** /**
@ -2054,17 +2026,26 @@ function xajax_save_item_scorm(
result = navigator.sendBeacon(saveUrl, formData); result = navigator.sendBeacon(saveUrl, formData);
console.log(result); console.log(result);
params = '';
my_scorm_values = null;
return false;
} else { } else {
$.ajax({ logit_lms('Ajax call');
var ajax = $.ajax({
type:"POST", type:"POST",
data: params, data: params,
url: saveUrl, url: saveUrl,
dataType: "script", dataType: "script",
async: false async: true
}); });
params = '';
my_scorm_values = null;
return ajax;
} }
params = '';
my_scorm_values = null;
} }
/** /**
@ -2147,12 +2128,12 @@ function xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id
logit_lms('xajax_switch_item_details with params:' + params, 3); logit_lms('xajax_switch_item_details with params:' + params, 3);
$.ajax({ return $.ajax({
type: "POST", type: "POST",
data: params, data: params,
url: "lp_ajax_switch_item.php" + courseUrl, url: "lp_ajax_switch_item.php" + courseUrl,
dataType: "script", dataType: "script",
async: false async: true
}); });
} }

@ -81,14 +81,18 @@ $(function () {
friend: ChChat.currentFriend friend: ChChat.currentFriend
}) })
.done(function (response) { .done(function (response) {
if (response.data.history) { try {
ChChat._historySize = response.data.oldFileSize; if (response.data.history) {
ChChat.setHistory(response.data.history); ChChat._historySize = response.data.oldFileSize;
} ChChat.setHistory(response.data.history);
}
if (response.data.userList) {
ChChat.usersOnline = response.data.usersOnline; if (response.data.userList) {
ChChat.setConnectedUsers(response.data.userList); ChChat.usersOnline = response.data.usersOnline;
ChChat.setConnectedUsers(response.data.userList);
}
} catch (error) {
console.error(error);
} }
}); });
}, },

@ -1,3 +1,4 @@
{{ groups }}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover table-striped table-bordered"> <table class="table table-hover table-striped table-bordered">
<thead> <thead>
@ -7,6 +8,7 @@
{% if show_email %} {% if show_email %}
<th>{{ 'Email'|get_lang }}</th> <th>{{ 'Email'|get_lang }}</th>
{% endif %} {% endif %}
<th class="text-center">{{ 'Group'|get_lang }}</th>
<th class="text-center">{{ 'ScormTime'|get_lang }}</th> <th class="text-center">{{ 'ScormTime'|get_lang }}</th>
<th class="text-right">{{ 'Progress'|get_lang }}</th> <th class="text-right">{{ 'Progress'|get_lang }}</th>
<th class="text-right">{{ 'ScormScore'|get_lang }}</th> <th class="text-right">{{ 'ScormScore'|get_lang }}</th>
@ -24,6 +26,7 @@
{% if show_email %} {% if show_email %}
<td>{{ user.email }}</td> <td>{{ user.email }}</td>
{% endif %} {% endif %}
<td>{{ user.groups }}</td>
<td class="text-center">{{ user.lp_time }}</td> <td class="text-center">{{ user.lp_time }}</td>
<td class="text-right">{{ user.lp_progress }}</td> <td class="text-right">{{ user.lp_progress }}</td>
<td class="text-right">{{ user.lp_score }}</td> <td class="text-right">{{ user.lp_score }}</td>

@ -3821,6 +3821,9 @@ function sendAlertToUsers($workInfo, $workId, $courseInfo, $sessionId = 0)
} }
if ($send) { if ($send) {
$folderUrl = api_get_path(WEB_CODE_PATH)."work/work_list_all.php?cidReq=".$courseInfo['code']."&id_session=".$sessionId."&id=".$workInfo['id'];
$fileUrl = api_get_path(WEB_CODE_PATH)."work/view.php?cidReq=".$courseInfo['code']."&id_session=".$sessionId."&id=".$workData['id'];
foreach ($userList as $userData) { foreach ($userList as $userData) {
$userId = $userData['user_id']; $userId = $userData['user_id'];
$userInfo = api_get_user_info($userId); $userInfo = api_get_user_info($userId);
@ -3837,10 +3840,9 @@ function sendAlertToUsers($workInfo, $workId, $courseInfo, $sessionId = 0)
$subject = "[".api_get_setting('siteName')."] ".$userPostedADocument; $subject = "[".api_get_setting('siteName')."] ".$userPostedADocument;
$message = $userPostedADocument."<br />"; $message = $userPostedADocument."<br />";
$message .= get_lang('DateSent')." : ".api_format_date(api_get_local_time())."<br />"; $message .= get_lang('DateSent')." : ".api_format_date(api_get_local_time())."<br />";
$message .= get_lang('AssignmentName')." : ".$workInfo['title']."<br />"; $message .= get_lang('AssignmentName')." : ".Display::url($workInfo['title'], $folderUrl)."<br />";
$message .= get_lang('Filename')." : ".$workData['title']."<br />"; $message .= get_lang('Filename')." : ".$workData['title']."<br />";
$url = api_get_path(WEB_CODE_PATH)."work/view.php?cidReq=".$courseInfo['code']."&id_session=".$sessionId."&id=".$workData['id']; $message .= '<a href="'.$fileUrl.'">'.get_lang('DownloadLink')."</a><br />";
$message .= '<a href="'.$url.'">'.get_lang('DownloadLink')."</a><br />";
MessageManager::send_message_simple( MessageManager::send_message_simple(
$userId, $userId,

@ -16,6 +16,7 @@ api_block_anonymous_users();
$plugin = CustomCertificatePlugin::create(); $plugin = CustomCertificatePlugin::create();
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; $enable = $plugin->get('enable_plugin_customcertificate') == 'true';
$tblProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); $tblProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
$categoryId = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : 0;
if (!$enable) { if (!$enable) {
api_not_allowed(true, $plugin->get_lang('ToolDisabled')); api_not_allowed(true, $plugin->get_lang('ToolDisabled'));
@ -52,7 +53,9 @@ if (empty($sessionId)) {
$accessUrlId = api_get_current_access_url_id(); $accessUrlId = api_get_current_access_url_id();
$userList = []; $userList = [];
if (empty($_GET['export_all'])) { $exportZip = false;
$exportAllInOne = false;
if (empty($_GET['export_all']) && empty($_GET['export_all_in_one'])) {
if (!isset($_GET['student_id'])) { if (!isset($_GET['student_id'])) {
$studentId = api_get_user_id(); $studentId = api_get_user_id();
} else { } else {
@ -60,16 +63,15 @@ if (empty($_GET['export_all'])) {
} }
$userList[] = api_get_user_info($studentId); $userList[] = api_get_user_info($studentId);
} else { } else {
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); if (!empty($_GET['export_all'])) {
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $exportZip = true;
$sql = "SELECT cer.user_id AS user_id }
FROM $certificateTable cer if (!empty($_GET['export_all_in_one'])) {
INNER JOIN $categoryTable cat $exportAllInOne = true;
ON (cer.cat_id = cat.id) }
WHERE cat.course_code = '$courseCode' AND cat.session_id = $sessionId"; $certificate_list = GradebookUtils::get_list_users_certificates($categoryId);
$rs = Database::query($sql); foreach ($certificate_list as $index => $value) {
while ($row = Database::fetch_assoc($rs)) { $userList[] = api_get_user_info($value['user_id']);
$userList[] = api_get_user_info($row['user_id']);
} }
} }
@ -80,7 +82,7 @@ if ($sessionId > 0) {
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); $table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE);
$useDefault = false; $useDefault = false;
$path = api_get_path(SYS_UPLOAD_PATH).'certificates/'; $path = api_get_path(WEB_UPLOAD_PATH).'certificates/';
// Get info certificate // Get info certificate
$infoCertificate = CustomCertificatePlugin::getInfoCertificate($courseId, $sessionId, $accessUrlId); $infoCertificate = CustomCertificatePlugin::getInfoCertificate($courseId, $sessionId, $accessUrlId);
@ -109,16 +111,19 @@ $htmlList = [];
$currentLocalTime = api_get_local_time(); $currentLocalTime = api_get_local_time();
foreach ($userList as $userInfo) { foreach ($userList as $userInfo) {
$htmlText = '<html>'; $htmlText = '';
$htmlText .= ' if (!$exportAllInOne) {
<link rel="stylesheet" $htmlText = '<html>';
type="text/css" $htmlText .= '
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">'; <link rel="stylesheet"
$htmlText .= ' type="text/css"
<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">';
type="text/css" $htmlText .= '
href="'.api_get_path(WEB_CSS_PATH).'document.css">'; <link rel="stylesheet"
$htmlText .= '<body>'; type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'document.css">';
$htmlText .= '<body>';
}
$studentId = $userInfo['user_id']; $studentId = $userInfo['user_id'];
if (empty($infoCertificate['background'])) { if (empty($infoCertificate['background'])) {
@ -126,8 +131,9 @@ foreach ($userList as $userInfo) {
} else { } else {
$urlBackground = $path.$infoCertificate['background']; $urlBackground = $path.$infoCertificate['background'];
$htmlText .= ' <div $htmlText .= ' <div
class = "caraA" class="caraA"
style = "background-image:url('.$urlBackground.') no-repeat; background-image-resize:6; margin:0px; padding:0px;">'; style="background-image:url('.$urlBackground.') no-repeat;
background-image-resize:6; margin:0px; padding:0px;">';
} }
if (!empty($infoCertificate['logo_left'])) { if (!empty($infoCertificate['logo_left'])) {
@ -164,7 +170,9 @@ foreach ($userList as $userInfo) {
border="0">'; border="0">';
$htmlText .= '<tr>'; $htmlText .= '<tr>';
$htmlText .= '<td style="width:'.intval($workSpace / 3).'mm" class="logo">'.$logoLeft.'</td>'; $htmlText .= '<td style="width:'.intval($workSpace / 3).'mm" class="logo">'.$logoLeft.'</td>';
$htmlText .= '<td style="width:'.intval($workSpace / 3).'mm; text-align:center;" class="logo">'.$logoCenter.'</td>'; $htmlText .= '<td style="width:'.intval($workSpace / 3).'mm; text-align:center;" class="logo">';
$htmlText .= $logoCenter;
$htmlText .= '</td>';
$htmlText .= '<td style="width:'.intval($workSpace / 3).'mm; text-align:right;" class="logo">'.$logoRight.'</td>'; $htmlText .= '<td style="width:'.intval($workSpace / 3).'mm; text-align:right;" class="logo">'.$logoRight.'</td>';
$htmlText .= '</tr>'; $htmlText .= '</tr>';
$htmlText .= '</table>'; $htmlText .= '</table>';
@ -461,7 +469,10 @@ foreach ($userList as $userInfo) {
} }
$htmlText .= '</div>'; $htmlText .= '</div>';
} }
$htmlText .= '</body></html>';
if (!$exportAllInOne) {
$htmlText .= '</body></html>';
}
$fileName = 'certificate_'.$courseInfo['code'].'_'.$userInfo['complete_name'].'_'.$currentLocalTime; $fileName = 'certificate_'.$courseInfo['code'].'_'.$userInfo['complete_name'].'_'.$currentLocalTime;
$htmlList[$fileName] = $htmlText; $htmlList[$fileName] = $htmlText;
} }
@ -472,10 +483,8 @@ if (!is_dir($archivePath)) {
mkdir($archivePath, api_get_permissions_for_new_directories()); mkdir($archivePath, api_get_permissions_for_new_directories());
} }
foreach ($htmlList as $fileName => $content) { if ($exportAllInOne) {
$fileName = api_replace_dangerous_char($fileName);
$params = [ $params = [
'filename' => $fileName,
'pdf_title' => 'Certificate', 'pdf_title' => 'Certificate',
'pdf_description' => '', 'pdf_description' => '',
'format' => 'A4-L', 'format' => 'A4-L',
@ -485,25 +494,72 @@ foreach ($htmlList as $fileName => $content) {
'bottom' => 0, 'bottom' => 0,
]; ];
$pdf = new PDF($params['format'], $params['orientation'], $params); $pdf = new PDF($params['format'], $params['orientation'], $params);
if (count($htmlList) == 1) {
$pdf->content_to_pdf($content, '', $fileName, null, 'D', false, null, false, false, false); $contentAllCertificate = '';
exit; foreach ($htmlList as $fileName => $content) {
} else { $contentAllCertificate .= $content;
$filePath = $archivePath.$fileName.'.pdf';
$pdf->content_to_pdf($content, '', $fileName, null, 'F', true, $filePath, false, false, false);
$fileList[] = $filePath;
} }
}
if (!empty($fileList)) { if (!empty($contentAllCertificate)) {
$zipFile = $archivePath.'certificates_'.api_get_unique_id().'.zip'; $certificateContent = '<html>';
$zipFolder = new PclZip($zipFile); $certificateContent .= '
foreach ($fileList as $file) { <link rel="stylesheet"
$zipFolder->add($file, PCLZIP_OPT_REMOVE_ALL_PATH); type="text/css"
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">';
$certificateContent .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'document.css">';
$certificateContent .= '<body>';
$certificateContent .= $contentAllCertificate;
$certificateContent .= '</body></html>';
$pdf->content_to_pdf(
$certificateContent,
'',
'certificate'.date("Y_m_d_His"),
null,
'D',
false,
null,
false,
false,
false
);
}
} else {
foreach ($htmlList as $fileName => $content) {
$fileName = api_replace_dangerous_char($fileName);
$params = [
'filename' => $fileName,
'pdf_title' => 'Certificate',
'pdf_description' => '',
'format' => 'A4-L',
'orientation' => 'L',
'left' => 15,
'top' => 15,
'bottom' => 0,
];
$pdf = new PDF($params['format'], $params['orientation'], $params);
if ($exportZip) {
$filePath = $archivePath.$fileName.'.pdf';
$pdf->content_to_pdf($content, '', $fileName, null, 'F', true, $filePath, false, false, false);
$fileList[] = $filePath;
} else {
$pdf->content_to_pdf($content, '', $fileName, null, 'D', false, null, false, false, false);
}
}
if (!empty($fileList)) {
$zipFile = $archivePath.'certificates_'.api_get_unique_id().'.zip';
$zipFolder = new PclZip($zipFile);
foreach ($fileList as $file) {
$zipFolder->add($file, PCLZIP_OPT_REMOVE_ALL_PATH);
}
$name = 'certificates_'.$courseInfo['code'].'_'.$currentLocalTime.'.zip';
DocumentManager::file_send_for_download($zipFile, true, $name);
exit;
} }
$name = 'certificates_'.$courseInfo['code'].'_'.$currentLocalTime.'.zip';
DocumentManager::file_send_for_download($zipFile, true, $name);
exit;
} }
function getIndexFiltered($index) function getIndexFiltered($index)

@ -1,12 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
/** /**
* Documents toolbar configuration. * Documents toolbar configuration.
*
* @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
*/ */
class Documents extends Basic class Documents extends Basic
{ {
@ -156,6 +155,7 @@ class Documents extends Basic
'Link', 'Link',
'Image', 'Image',
'Video', 'Video',
'Oembed',
'Flash', 'Flash',
'Youtube', 'Youtube',
'VimeoEmbed', 'VimeoEmbed',

@ -34,7 +34,7 @@ class TestQuestionDescription extends Basic
]; ];
$config['extraPlugins'] = $this->getPluginsToString(); $config['extraPlugins'] = $this->getPluginsToString();
if (api_get_setting('more_buttons_maximized_mode') != 'true') { if (api_get_setting('more_buttons_maximized_mode') !== 'true') {
$config['toolbar'] = $this->getNormalToolbar(); $config['toolbar'] = $this->getNormalToolbar();
} else { } else {
$config['toolbar_minToolbar'] = $this->getMinimizedToolbar(); $config['toolbar_minToolbar'] = $this->getMinimizedToolbar();

Loading…
Cancel
Save