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

pull/2729/head
Alex Aragón 7 years ago
commit dd1a76e753
  1. 6
      app/Resources/public/css/base.css
  2. 5
      main/auth/inscription.php
  3. 1
      main/course_progress/index.php
  4. 11
      main/gradebook/index.php
  5. 32
      main/gradebook/lib/fe/gradebooktable.class.php
  6. BIN
      main/img/icons/64/plugins.png
  7. 32
      main/inc/ajax/statistics.ajax.php
  8. 46
      main/inc/ajax/survey.ajax.php
  9. 2
      main/inc/lib/api.lib.php
  10. 7
      main/inc/lib/certificate.lib.php
  11. 2
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  12. 2
      main/inc/lib/usermanager.lib.php
  13. 157
      main/survey/create_meeting.php
  14. 8
      main/survey/fillsurvey.php
  15. 164
      main/survey/meeting.php
  16. 4
      main/survey/survey.lib.php
  17. 65
      main/survey/survey.php
  18. 94
      main/survey/surveyUtil.class.php
  19. 4
      main/survey/survey_list.php
  20. 4
      main/template/default/learnpath/view.tpl
  21. 29
      main/tracking/courseLog.php
  22. 3
      plugin/card_game/resources/ajax.card.php
  23. 1
      plugin/customcertificate/config.php
  24. 1
      plugin/customcertificate/src/CustomCertificatePlugin.php
  25. 16
      plugin/customcertificate/src/index.php
  26. 92
      plugin/customcertificate/src/print_certificate.php
  27. 19
      plugin/ims_lti/Entity/ImsLtiTool.php
  28. 6
      plugin/ims_lti/configure.php
  29. 2
      plugin/ims_lti/form.php
  30. 1
      plugin/ims_lti/lang/english.php
  31. 6
      plugin/ims_lti/lang/french.php
  32. 6
      plugin/ims_lti/lang/spanish.php
  33. 6
      plugin/ims_lti/src/Form/FrmAdd.php
  34. 6
      plugin/ims_lti/src/Form/FrmEdit.php
  35. 66
      plugin/ims_lti/view/add.tpl
  36. 12
      src/Chamilo/CoreBundle/Component/Utils/ChamiloApi.php

@ -7442,14 +7442,8 @@ a.sessionView {
display: block;
}
.data_table .title {
text-align: left;
padding-left: 10px;
}
#course-list.data_table .title {
width: 390px;
padding-left: 0;
}
.actions label {

@ -1006,7 +1006,7 @@ if ($form->validate()) {
if ($is_allowedCreateCourse) {
if ($usersCanCreateCourse) {
$form_data['message'] = '<p>'.get_lang('NowGoCreateYourCourse')."</p>";
$form_data['message'] = '<p>'.get_lang('NowGoCreateYourCourse').'</p>';
}
$form_data['action'] = api_get_path(WEB_CODE_PATH).'create_course/add_course.php';
@ -1044,9 +1044,9 @@ if ($form->validate()) {
}
if ($sessionPremiumChecker && $sessionId) {
header('Location:'.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process.php?i='.$sessionId.'&t=2');
Session::erase('SessionIsPremium');
Session::erase('sessionId');
header('Location:'.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process.php?i='.$sessionId.'&t=2');
exit;
}
@ -1059,7 +1059,6 @@ if ($form->validate()) {
}
$form_data = CourseManager::redirectToCourse($form_data);
$form_register = new FormValidator('form_register', 'post', $form_data['action']);
if (!empty($form_data['message'])) {
$form_register->addElement('html', $form_data['message'].'<br /><br />');

@ -181,7 +181,6 @@ function check_per_custom_date(obj) {
$thematicControl = Session::read('thematic_control');
if ($action == 'thematic_list') {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('ThematicControl')];
}

@ -919,7 +919,6 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)
$loadStats = [];
$teacher = api_is_allowed_to_edit(null, true);
if (!$teacher) {
if (api_get_setting('gradebook_detailed_admin_view') === 'true') {
$loadStats = [1, 2, 3];
@ -948,14 +947,16 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)
4 => 'class="text-center"',
];
} else {
if (empty($model)) {
/*if (empty($model)) {
$gradebookTable->td_attributes = [
3 => 'class="text-right"',
4 => 'class="text-center"',
];
for ($z = 5; $z < count($loadStats); $z++) {
$gradebookTable->td_attributes[$z] = 'class="text-center"';
if (!empty($loadStats)) {
for ($z = 5; $z < count($loadStats); $z++) {
$gradebookTable->td_attributes[$z] = 'class="text-center"';
}
}
} else {
$gradebookTable->td_attributes = [
@ -966,7 +967,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)
if ($action == 'export_table') {
unset($gradebookTable->td_attributes[7]);
}
}*/
}
$table = $gradebookTable->return_table();

@ -111,7 +111,10 @@ class GradebookTable extends SortableTable
'',
'width="100px"'
);
$this->set_header($column++, get_lang('Result'), false);
if (!$this->teacherView) {
$this->set_header($column++, get_lang('Result'), false);
}
if (empty($model)) {
if (in_array(1, $this->loadStats)) {
@ -464,7 +467,6 @@ class GradebookTable extends SortableTable
}
} else {
$row[] = $scoreToDisplay;
if (!empty($this->cats)) {
if ($this->exportToPdf == false) {
$row[] = $this->build_edit_column($item);
@ -574,6 +576,7 @@ class GradebookTable extends SortableTable
if (!is_null($value_data)) {
// Result
$row[] = $value_data;
$best = isset($data['best']) ? $data['best'] : null;
$average = isset($data['average']) ? $data['average'] : null;
$ranking = isset($data['ranking']) ? $data['ranking'] : null;
@ -702,7 +705,7 @@ class GradebookTable extends SortableTable
$row = [
null,
'<h3>'.get_lang('Total').'</h3>',
'<strong>'.get_lang('Total').'</strong>',
];
if (!$this->exportToPdf) {
@ -742,13 +745,12 @@ class GradebookTable extends SortableTable
if ($invalidateRanking) {
$totalRanking = null;
}
$row[] = $totalRanking;
}
if (in_array(2, $this->loadStats)) {
// Overwrite main weight
$totalBest[1] = $main_weight;
$totalBest = $scoredisplay->display_score(
$totalBest,
SCORE_DIV,
@ -762,15 +764,17 @@ class GradebookTable extends SortableTable
$totalAverage[0] = $average / count($this->studentList);
$totalAverage[1] = $main_weight;
$totalAverage = $scoredisplay->display_score(
$totalAverage,
SCORE_DIV,
SCORE_BOTH,
true
);
$totalAverage,
SCORE_DIV,
SCORE_BOTH,
true
);
$row[] = $totalAverage;
}
$sortable_data[] = $row;
if (!empty($row)) {
$sortable_data[] = $row;
}
}
}
@ -860,9 +864,9 @@ class GradebookTable extends SortableTable
}
if (!$this->teacherView) {
$rowTotal = [];
/*$rowTotal = [];
$rowTotal[] = ' ';
$rowTotal[] = get_lang('FinalScore');
$rowTotal[] = '<strong>'.get_lang('FinalScore').'</strong>';
if (!$this->exportToPdf) {
$rowTotal[] = ' ';
@ -877,7 +881,7 @@ class GradebookTable extends SortableTable
$rowTotal[] = ' ';
}
$sortable_data[] = $rowTotal;
$sortable_data[] = $rowTotal;*/
}
return $sortable_data;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

@ -1,13 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
* Responses to AJAX calls.
*/
require_once __DIR__.'/../global.inc.php';
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
api_protect_admin_script();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
@ -107,7 +107,6 @@ switch ($action) {
echo json_encode($list);
break;
case 'recent_logins':
// Give a JSON array to the stats page main/admin/statistics/index.php
// for global recent logins
@ -119,24 +118,24 @@ switch ($action) {
}
$list['datasets'][0]['label'] = get_lang('Logins');
$list['datasets'][0]['backgroundColor'] = "rgba(151,187,205,0.2)";
$list['datasets'][0]['borderColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointBackgroundColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointBorderColor'] = "#fff";
$list['datasets'][0]['pointHoverBackgroundColor'] = "#fff";
$list['datasets'][0]['pointHoverBorderColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['backgroundColor'] = 'rgba(151,187,205,0.2)';
$list['datasets'][0]['borderColor'] = 'rgba(151,187,205,1)';
$list['datasets'][0]['pointBackgroundColor'] = 'rgba(151,187,205,1)';
$list['datasets'][0]['pointBorderColor'] = '#fff';
$list['datasets'][0]['pointHoverBackgroundColor'] = '#fff';
$list['datasets'][0]['pointHoverBorderColor'] = 'rgba(151,187,205,1)';
foreach ($all as $tick => $tock) {
$list['datasets'][0]['data'][] = $tock;
}
$list['datasets'][1]['label'] = get_lang('DistinctUsersLogins');
$list['datasets'][1]['backgroundColor'] = "rgba(0,204,0,0.2)";
$list['datasets'][1]['borderColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointBackgroundColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointBorderColor'] = "#fff";
$list['datasets'][1]['pointHoverBackgroundColor'] = "#fff";
$list['datasets'][1]['pointHoverBorderColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['backgroundColor'] = 'rgba(0,204,0,0.2)';
$list['datasets'][1]['borderColor'] = 'rgba(0,204,0,1)';
$list['datasets'][1]['pointBackgroundColor'] = 'rgba(0,204,0,1)';
$list['datasets'][1]['pointBorderColor'] = '#fff';
$list['datasets'][1]['pointHoverBackgroundColor'] = '#fff';
$list['datasets'][1]['pointHoverBorderColor'] = 'rgba(0,204,0,1)';
$distinct = Statistics::getRecentLoginStats(true, $sessionDuration);
foreach ($distinct as $tick => $tock) {
@ -145,7 +144,6 @@ switch ($action) {
echo json_encode($list);
break;
case 'tools_usage':
// Give a JSON array to the stats page main/admin/statistics/index.php
// for global tools usage (number of clicks)
@ -159,7 +157,7 @@ switch ($action) {
$palette = ChamiloApi::getColorPalette(true, true);
$list['datasets'][0]['label'] = get_lang('Tools');
$list['datasets'][0]['borderColor'] = "rgba(255,255,255,1)";
$list['datasets'][0]['borderColor'] = 'rgba(255,255,255,1)';
$i = 0;
foreach ($all as $tick => $tock) {

@ -0,0 +1,46 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../global.inc.php';
$action = isset($_GET['a']) ? $_GET['a'] : null;
$current_user_id = api_get_user_id();
$courseId = api_get_course_int_id();
switch ($action) {
case 'save_question':
if (api_is_anonymous()) {
echo '';
break;
}
$surveyId = isset($_GET['survey_id']) ? $_GET['survey_id'] : null;
$questionId = isset($_GET['question_id']) ? $_GET['question_id'] : null;
$status = isset($_GET['status']) ? (int) $_GET['status'] : null;
$userId = api_get_user_id();
$surveyData = SurveyManager::get_survey($surveyId);
if (empty($surveyData)) {
exit;
}
SurveyUtil::remove_answer(
$userId,
$surveyId,
$questionId,
$courseId
);
SurveyUtil::store_answer(
$userId,
$surveyId,
$questionId,
1,
$status,
$surveyData
);
break;
}
exit;

@ -8720,7 +8720,7 @@ function api_mail_html(
$mail->Mailer = $platform_email['SMTP_MAILER'];
$mail->Host = $platform_email['SMTP_HOST'];
$mail->Port = $platform_email['SMTP_PORT'];
$mail->CharSet = $platform_email['SMTP_CHARSET'];
$mail->CharSet = isset($platform_email['SMTP_CHARSET']) ? $platform_email['SMTP_CHARSET'] : 'UTF-8';
// Stay far below SMTP protocol 980 chars limit.
$mail->WordWrap = 200;

@ -391,6 +391,7 @@ class Certificate extends Model
'((author_last_name))',
'((score))',
'((portal_name))',
'((certificate_link))',
];
return $tags;
@ -417,6 +418,9 @@ class Certificate extends Model
}
$currentUserInfo = api_get_user_info();
$url = api_get_path(WEB_PATH).
'certificates/index.php?id='.$certificateInfo['id'].'&user_id='.$certificateInfo['user_id'];
$link = Display::url($url, $url);
$replace = [
$courseInfo['title'],
@ -426,9 +430,10 @@ class Certificate extends Model
$currentUserInfo['lastname'],
$certificateInfo['score_certificate'],
api_get_setting('Institution'),
$link,
];
$message = str_replace(self::notificationTags(), $replace, $message);
$message = str_replace(self::notificationTags(), $replace, $message);
MessageManager::send_message(
$userInfo['id'],
$subject,

@ -45,7 +45,7 @@ class DateTimePicker extends HTML_QuickForm_text
$resetFieldX = sprintf(get_lang('ResetFieldX'), $label);
return '
<div class="input-group">
<div class="input-group" id="date_time_wrapper_'.$id.'">
<span class="input-group-addon cursor-pointer">
<input '.$this->_getAttrString($this->_attributes).'>
</span>

@ -1292,6 +1292,7 @@ class UserManager
$emailBody = $tplContent->fetch($layoutContent);
$mailTemplateManager = new MailTemplateManager();
if (!empty($emailTemplate) &&
isset($emailTemplate['user_edit_content.tpl']) &&
!empty($emailTemplate['user_edit_content.tpl'])
@ -1299,7 +1300,6 @@ class UserManager
$userInfo = api_get_user_info($user_id);
$emailBody = $mailTemplateManager->parseTemplate($emailTemplate['user_edit_content.tpl'], $userInfo);
}
api_mail_html(
$recipient_name,
$email,

@ -0,0 +1,157 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$tool_name = get_lang('CreateMeeting');
$form = new FormValidator(
'survey',
'post',
api_get_self().'?action=add&'.api_get_cidreq()
);
$form->addElement('header', $tool_name);
$form->addHidden('anonymous', 0);
$form->addHidden('survey_language', $courseInfo['language']);
$form->addHidden('survey_subtitle', '');
$form->addHidden('survey_thanks', '');
$form->addHidden('visible_results', '0');
$form->addHidden('survey_type', 3);
// Setting the form elements
/*if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) {
$form->addElement('hidden', 'survey_id');
}*/
$text = $form->addElement(
'text',
'survey_title',
get_lang('Title'),
null,
['ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '200']
);
$form->addDateTimePicker('start_date', get_lang('StartDate'));
$form->addDateTimePicker('end_date', get_lang('EndDate'));
$form->addRule('start_date', get_lang('InvalidDate'), 'datetime');
$form->addRule('end_date', get_lang('InvalidDate'), 'datetime');
$form->addRule(
['start_date', 'end_date'],
get_lang('StartDateShouldBeBeforeEndDate'),
'date_compare',
'lte'
);
$form->addHtmlEditor('survey_introduction', get_lang('Description'), false);
$form->setRequired($text);
$hideList = '';
$maxEvents = 20;
for ($i = 1; $i <= $maxEvents; $i++) {
$name = 'time_'.$i;
$form->addDateTimePicker($name, get_lang('Time'));
if ($i > 3) {
$hideList .= "$('#date_time_wrapper_$name').parent().parent().hide();";
}
}
$form->addHtml('<script>
$(function() {
'.$hideList.'
var number = 3;
$("#add_button").on("click", function() {
number++;
$("#date_time_wrapper_time_" + number).parent().parent().show();
});
$("#remove_button").on("click", function() {
if (number >= 1) {
number--;
$("#date_time_wrapper_time_" + number).parent().parent().hide();
}
});
});
</script>
');
$form->addLabel(
'',
Display::url(get_lang('Add'), 'javascript:void(0)', ['id' => 'add_button', 'class' => 'btn btn-default'])
.' '.
Display::url(
get_lang('Remove'),
'javascript:void(0)',
['id' => 'remove_button', 'class' => 'btn btn-danger']
)
);
$form->addButtonCreate(get_lang('CreateSurvey'), 'submit_survey');
$defaults = [];
$form->setDefaults($defaults);
// The validation or display
if ($form->validate()) {
// Exporting the values
$values = $form->getSubmitValues();
$values['survey_code'] = SurveyManager::generateSurveyCode($values['survey_title']);
// Storing the survey
$surveyData = SurveyManager::store_survey($values);
$dates = [];
for ($i = 1; $i <= $maxEvents; $i++) {
$name = 'time_'.$i;
if (isset($values[$name]) && !empty($values[$name])) {
$dates[] = $values[$name];
}
}
$questionTable = Database::get_course_table(TABLE_SURVEY_QUESTION);
$counter = 1;
if (!empty($surveyData['id'])) {
foreach ($dates as $date) {
//SurveyManager::save_question();
$params = [
'c_id' => api_get_course_int_id(),
'survey_id' => $surveyData['id'],
'survey_question' => $date,
'survey_question_comment' => '',
'type' => 'doodle',
'display' => 'horizontal',
'sort' => $counter,
'shared_question_id' => '0',
'max_value' => 0,
];
$questionId = Database::insert($questionTable, $params);
if ($questionId) {
$sql = "UPDATE $questionTable SET question_id = $questionId
WHERE iid = $questionId";
Database::query($sql);
}
$counter++;
}
}
// Redirecting to the survey page (whilst showing the return message)
header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq());
exit;
} else {
// Displaying the header
Display::display_header($tool_name);
$form->display();
}
Display::display_footer();

@ -204,6 +204,14 @@ if (empty($survey_data)) {
}
$survey_data['survey_id'] = $survey_invitation['survey_id'];
if ($survey_data['survey_type'] == '3') {
header('Location: '.
api_get_path(WEB_CODE_PATH).
'survey/meeting.php?cidReq='.$courseInfo['code'].'&id_session='.$sessionId.'&invitationcode='.Security::remove_XSS($invitationcode)
);
exit;
}
// Storing the answers
if (count($_POST) > 0) {
if ($survey_data['survey_type'] === '0') {

@ -0,0 +1,164 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$sessionId = api_get_session_id();
$courseId = api_get_course_int_id();
$userId = api_get_user_id();
$courseInfo = api_get_course_info();
$surveyId = isset($_REQUEST['survey_id']) ? (int) $_REQUEST['survey_id'] : 0;
$invitationcode = isset($_REQUEST['invitationcode']) ? Database::escape_string($_REQUEST['invitationcode']) : 0;
if (!api_is_allowed_to_edit() || !empty($invitationcode)) {
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
$table_survey = Database::get_course_table(TABLE_SURVEY);
$sql = "SELECT * FROM $table_survey_invitation
WHERE
c_id = $courseId AND
invitation_code = '".Database::escape_string($invitationcode)."'";
$result = Database::query($sql);
if (Database::num_rows($result) < 1) {
api_not_allowed(true, get_lang('WrongInvitationCode'));
}
$survey_invitation = Database::fetch_array($result, 'ASSOC');
$sql = "SELECT * FROM $table_survey
WHERE
c_id = $courseId AND
code = '".Database::escape_string($survey_invitation['survey_code'])."'";
$sql .= api_get_session_condition($sessionId);
$result = Database::query($sql);
$result = Database::fetch_array($result, 'ASSOC');
$surveyId = $result['iid'];
}
// getting all the students of the course
if (empty($sessionId)) {
// Registered students in a course outside session.
$students = CourseManager:: get_student_list_from_course_code(
api_get_course_id(),
false,
0,
null,
null,
true
);
} else {
// Registered students in session.
$students = CourseManager:: get_student_list_from_course_code(
api_get_course_id(),
true,
$sessionId
);
}
$surveyData = SurveyManager::get_survey($surveyId);
if (empty($surveyData)) {
api_not_allowed(true);
}
$content = Display::page_header($surveyData['title']);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?cidReq='.$courseInfo['code'].'&id_session='.$sessionId,
'name' => get_lang('SurveyList'),
];
$template = new Template();
$questions = SurveyManager::get_questions($surveyData['iid']);
$table = new HTML_Table(['class' => 'table']);
$row = 0;
$column = 1;
$answerList = [];
foreach ($questions as $item) {
$answers = SurveyUtil::get_answers_of_question_by_user($surveyId, $item['question_id']);
foreach ($answers as $tempUserId => &$value) {
$value = $value[0];
$value = explode('*', $value);
$value = isset($value[1]) ? $value[1] : 0;
}
$answerList[$item['question_id']] = $answers;
$table->setHeaderContents($row, $column, api_get_local_time($item['question']));
$column++;
}
$row = 1;
$column = 0;
foreach ($students as $student) {
$name = api_get_person_name($student['firstname'], $student['lastname']);
$studentId = $student['user_id'];
if ($userId == $studentId) {
$rowColumn = 1;
foreach ($questions as $item) {
$checked = '';
if (isset($answerList[$item['question_id']][$studentId])) {
$checked = 'checked';
}
$table->setHeaderContents(
$row,
$rowColumn,
'<input id="'.$item['question_id'].'" class="question" '.$checked.' type="checkbox"/>'
);
$rowColumn++;
}
} else {
$rowColumn = 1;
foreach ($questions as $item) {
$checked = '';
if (isset($answerList[$item['question_id']][$studentId])) {
$checked = Display::return_icon('check-circle.png');
}
$table->setHeaderContents(
$row,
$rowColumn,
$checked
);
$rowColumn++;
}
}
$column = 0;
$table->setCellContents($row, $column, $name);
$class = 'class="row_odd"';
if ($row % 2) {
$class = 'class="row_even"';
}
//$table->setRowAttributes($row, $class, true);
//$column++;
$row++;
}
$content .= $table->toHtml();
$ajaxUrl = api_get_path(WEB_AJAX_PATH).'survey.ajax.php?a=save_question&'.api_get_cidreq().'&survey_id='.$surveyId.'&question_id=';
$content .= '<script>
$(function() {
$(".question").on("change", function() {
var questionId = $(this).attr("id");
var status = 0;
if ($(this).prop("checked")) {
status = 1;
}
$.ajax({
url: "'.$ajaxUrl.'" + questionId + "&status=" + status,
success: function (data) {
return;
},
});
});
});
</script>';
$template->assign('content', $content);
$template->display_one_col_template();

@ -355,6 +355,10 @@ class SurveyManager
'visible_results' => $values['visible_results'],
];
if (isset($values['survey_type']) && !empty($values['survey_type'])) {
$params['survey_type'] = $values['survey_type'];
}
$params = array_merge($params, $extraParams);
$survey_id = Database::insert($table_survey, $params);
if ($survey_id > 0) {

@ -44,7 +44,7 @@ $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$survey_id = intval($_GET['survey_id']);
$survey_id = (int) $_GET['survey_id'];
$course_id = api_get_course_int_id();
$action = isset($_GET['action']) ? $_GET['action'] : null;
@ -89,7 +89,9 @@ if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) {
}
if ($action == 'deletegroup') {
Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id));
$sql = 'DELETE FROM '.$table_survey_question_group.'
WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id);
Database::query($sql);
$sendmsg = 'GroupDeletedSuccessfully';
}
header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg);
@ -97,7 +99,6 @@ if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) {
}
// Displaying the header
Display::display_header($tool_name, 'Survey');
// Action handling
@ -136,8 +137,12 @@ $survey_actions = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_sur
Display::return_icon('edit.png', get_lang('EditSurvey'), '', ICON_SIZE_MEDIUM).'</a>';
$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES)).'\')) return false;">'.
Display::return_icon('delete.png', get_lang('DeleteSurvey'), '', ICON_SIZE_MEDIUM).'</a>';
$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>';
if ($survey_data['survey_type'] != 3) {
$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>';
}
$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_MEDIUM).'</a>';
@ -150,8 +155,8 @@ if (!api_get_configuration_value('hide_survey_reporting_button')) {
echo '<div class="actions">'.$survey_actions.'</div>';
$urlQuestion = api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add';
if ($survey_data['survey_type'] == 0) {
$urlQuestion = api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add';
echo '<div class="well">';
echo Display::url(
Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG),
@ -191,12 +196,14 @@ if ($survey_data['survey_type'] == 0) {
);
echo '</div>';
} else {
echo '<div class="well">';
echo Display::url(
Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG),
$urlQuestion.'&type=personality&survey_id='.$survey_id
);
echo '</a></div>';
if ($survey_data['survey_type'] != 3) {
echo '<div class="well">';
echo Display::url(
Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG),
$urlQuestion.'&type=personality&survey_id='.$survey_id
);
echo '</a></div>';
}
}
// Displaying the table header with all the questions
@ -218,7 +225,7 @@ echo '</thead>';
// Displaying the table contents with all the questions
$question_counter = 1;
$sql = "SELECT * FROM $table_survey_question_group
WHERE c_id = '.$course_id.' AND survey_id = ".intval($survey_id)."
WHERE c_id = $course_id AND survey_id = $survey_id
ORDER BY id";
$result = Database::query($sql);
$groups = [];
@ -261,21 +268,27 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
echo '<td>'.$tool_name.'</td>';
echo '<td>'.$row['number_of_options'].'</td>';
echo '<td>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
if ($survey_data['survey_type'] != 3) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
}
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?', ENT_QUOTES, $charset)).'\')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
if ($question_counter > 1) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
if ($question_counter < $question_counter_max) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
if ($survey_data['survey_type'] != 3) {
if ($question_counter > 1) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq(
).'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
if ($question_counter < $question_counter_max) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq(
).'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
}
echo ' </td>';
$question_counter++;

@ -2878,6 +2878,8 @@ class SurveyUtil
return $hideReportingButton ? '-' : $reportingLink;
}
$type = $survey->getSurveyType();
// Coach can see that only if the survey is in his session
if (api_is_allowed_to_edit() ||
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
@ -2893,30 +2895,35 @@ class SurveyUtil
$codePath.'survey/generate_link.php?'.http_build_query($params + ['survey_id' => $survey_id])
);
}
$actions[] = Display::url(
Display::return_icon('backup.png', get_lang('CopySurvey')),
$codePath.'survey/copy_survey.php?'.http_build_query($params + ['survey_id' => $survey_id])
);
$actions[] = Display::url(
Display::return_icon('copy.png', get_lang('DuplicateSurvey')),
$codePath.'survey/survey_list.php?'
if ($type != 3) {
$actions[] = Display::url(
Display::return_icon('backup.png', get_lang('CopySurvey')),
$codePath.'survey/copy_survey.php?'.http_build_query($params + ['survey_id' => $survey_id])
);
$actions[] = Display::url(
Display::return_icon('copy.png', get_lang('DuplicateSurvey')),
$codePath.'survey/survey_list.php?'
.http_build_query($params + ['action' => 'copy_survey', 'survey_id' => $survey_id])
);
);
$warning = addslashes(api_htmlentities(get_lang('EmptySurvey').'?', ENT_QUOTES));
$actions[] = Display::url(
Display::return_icon('clean.png', get_lang('EmptySurvey')),
$codePath.'survey/survey_list.php?'
$warning = addslashes(api_htmlentities(get_lang('EmptySurvey').'?', ENT_QUOTES));
$actions[] = Display::url(
Display::return_icon('clean.png', get_lang('EmptySurvey')),
$codePath.'survey/survey_list.php?'
.http_build_query($params + ['action' => 'empty', 'survey_id' => $survey_id]),
[
'onclick' => "javascript: if (!confirm('".$warning."')) return false;",
]
[
'onclick' => "javascript: if (!confirm('".$warning."')) return false;",
]
);
}
}
if ($type != 3) {
$actions[] = Display::url(
Display::return_icon('preview_view.png', get_lang('Preview')),
$codePath.'survey/preview.php?'.http_build_query($params + ['survey_id' => $survey_id])
);
}
$actions[] = Display::url(
Display::return_icon('preview_view.png', get_lang('Preview')),
$codePath.'survey/preview.php?'.http_build_query($params + ['survey_id' => $survey_id])
);
$actions[] = Display::url(
Display::return_icon('mail_send.png', get_lang('Publish')),
$codePath.'survey/survey_invite.php?'.http_build_query($params + ['survey_id' => $survey_id])
@ -3093,9 +3100,9 @@ class SurveyUtil
if ($search_restriction) {
$search_restriction = ' AND '.$search_restriction;
}
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = intval($column);
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$column = (int) $column;
if (!in_array(strtolower($direction), ['asc', 'desc'])) {
$direction = 'asc';
}
@ -3122,7 +3129,8 @@ class SurveyUtil
survey.iid AS col9,
survey.session_id AS session_id,
survey.answered,
survey.invited
survey.invited,
survey.survey_type
FROM $table_survey survey
LEFT JOIN $table_survey_question survey_question
ON (survey.survey_id = survey_question.survey_id AND survey_question.c_id = $course_id)
@ -3135,22 +3143,27 @@ class SurveyUtil
ORDER BY col$column $direction
LIMIT $from,$number_of_items
";
$res = Database::query($sql);
$surveys = [];
$array = [];
$efv = new ExtraFieldValue('survey');
while ($survey = Database::fetch_array($res)) {
$array[0] = $survey[0];
if (self::checkHideEditionToolsByCode($survey['col2'])) {
$array[1] = $survey[1];
} else {
$array[1] = Display::url(
$survey[1],
api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey[0].'&'.api_get_cidreq()
);
// Doodle
if ($survey['survey_type'] == 3) {
$array[1] = Display::url(
$survey[1],
api_get_path(WEB_CODE_PATH).'survey/meeting.php?survey_id='.$survey[0].'&'.api_get_cidreq()
);
} else {
$array[1] = Display::url(
$survey[1],
api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey[0].'&'.api_get_cidreq()
);
}
}
// Validation when belonging to a session
@ -3307,7 +3320,7 @@ class SurveyUtil
{
$_course = api_get_course_info();
$course_id = $_course['real_id'];
$user_id = intval($user_id);
$user_id = (int) $user_id;
$sessionId = api_get_session_id();
$mandatoryAllowed = api_get_configuration_value('allow_mandatory_survey');
$allowSurveyAvailabilityDatetime = api_get_configuration_value('allow_survey_availability_datetime');
@ -3317,16 +3330,6 @@ class SurveyUtil
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
$table_survey = Database::get_course_table(TABLE_SURVEY);
$sql = "SELECT question_id
FROM $table_survey_question
WHERE c_id = $course_id";
$result = Database::query($sql);
$all_question_id = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$all_question_id[] = $row;
}
echo '<table id="list-survey" class="table ">';
echo '<thead>';
echo '<tr>';
@ -3349,8 +3352,8 @@ class SurveyUtil
$table_survey_invitation survey_invitation
ON (
survey.code = survey_invitation.survey_code AND
survey.c_id = survey_invitation.c_id
AND survey.session_id = survey_invitation.session_id
survey.c_id = survey_invitation.c_id AND
survey.session_id = survey_invitation.session_id
)
WHERE
survey_invitation.user = $user_id AND
@ -3374,8 +3377,9 @@ class SurveyUtil
[],
ICON_SIZE_TINY
);
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['sysCode']
.'&invitationcode='.$row['invitation_code'].'&cidReq='.$_course['sysCode'].'&id_session='.$row['session_id'].'">
$url = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['sysCode']
.'&invitationcode='.$row['invitation_code'].'&cidReq='.$_course['sysCode'].'&id_session='.$row['session_id'];
echo '<a href="'.$url.'">
'.$row['title']
.'</a></td>';
} else {

@ -17,7 +17,6 @@ if (!isset($_GET['cidReq'])) {
$cidReset = true;
}
// Including the global initialization file
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_SURVEY;
@ -166,11 +165,12 @@ if (!api_is_session_general_coach() || $extend_rights_for_coachs == 'true') {
// Action links
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.
Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'), '', ICON_SIZE_MEDIUM).'</a> ';
$url = api_get_path(WEB_CODE_PATH).'survey/create_meeting.php?'.api_get_cidreq();
echo Display::url(Display::return_icon('add.png', get_lang('CreateNewSurvey'), '', ICON_SIZE_MEDIUM), $url);
}
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.
Display::return_icon('search.png', get_lang('Search'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
// Load main content
if (api_is_session_general_coach() && $extend_rights_for_coachs == 'false') {
SurveyUtil::display_survey_list_for_coach();

@ -298,7 +298,9 @@
{% if disable_js_in_lp_view == 0 %}
$('iframe#content_id').on('load', function () {
if ('link' !== olms.lms_item_type) {
var arr = ['link', 'sco'];
if (!$.inArray(olms.lms_item_type, arr)) {
setFrameReady('content_name');
}
});

@ -1,8 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use ChamiloSession as Session;
/**
* @package chamilo.tracking
@ -171,7 +171,6 @@ if (empty($session_id)) {
$a_students = CourseManager::get_student_list_from_course_code(
$courseId
);
} else {
// Registered students in session.
$a_students = CourseManager::get_student_list_from_course_code(
@ -347,7 +346,7 @@ if ($nbStudents > 0) {
$numberStudentsCompletedLP = 0;
$averageStudentsTestScore = 0;
$scoresDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$userScoreList = [];
$listStudentIds = [];
$timeStudent = [];
@ -368,7 +367,7 @@ if ($nbStudents > 0) {
}
$averageStudentTestScore = substr($userTracking[7], 0, -1);
$averageStudentsTestScore += $averageStudentTestScore;
if ($averageStudentTestScore === '100') {
$reducedAverage = 9;
} else {
@ -380,30 +379,30 @@ if ($nbStudents > 0) {
$scoreStudent = substr($userTracking[5], 0, -1) + substr($userTracking[7], 0, -1);
list($hours, $minutes, $seconds) = preg_split('/:/', $userTracking[4]);
$minutes = round((3600 * $hours + 60 * $minutes + $seconds) / 60);
$certificate = false;
if (isset($category[0]) && $category[0]->is_certificate_available($userId)) {
$certificate = true;
$certificateCount++;
}
$listStudent = [
'id' => $userId,
'fullname' => $userTracking[2] . ', ' . $userTracking[1],
'fullname' => $userTracking[2].', '.$userTracking[1],
'score' => floor($scoreStudent / 2),
'total_time' => $minutes,
'avatar' => UserManager::getUserPicture($userId),
'certicate' => $certificate
'certicate' => $certificate,
];
$listStudentIds[] = $userId;
$userScoreList[] = $listStudent;
}
uasort($userScoreList, 'sort_by_order');
$averageStudentsTestScore = round($averageStudentsTestScore / $nbStudents);
$colors = ChamiloApi::getColorPalette(true, true, 10);
$tpl->assign('chart_colors', json_encode($colors));
$tpl->assign('certificate_count', $certificateCount);
$tpl->assign('score_distribution', json_encode($scoresDistribution));
@ -412,11 +411,10 @@ if ($nbStudents > 0) {
$tpl->assign('students_completed_lp', $numberStudentsCompletedLP);
$tpl->assign('number_students', $nbStudents);
$tpl->assign('top_students', $userScoreList);
$trackingSummaryLayout = $tpl->get_template("tracking/tracking_course_log.tpl");
$content = $tpl->fetch($trackingSummaryLayout);
echo $content;
}
@ -492,7 +490,6 @@ if (count($a_students) > 0) {
$table->set_additional_parameters($parameters);
$headers = [];
// tab of header texts
$table->set_header(0, get_lang('OfficialCode'), true);
@ -653,9 +650,7 @@ if ($export_csv) {
}
Display::display_footer();
function sort_by_order($a, $b)
{
return $a['score'] <= $b['score'];
}

@ -16,7 +16,6 @@ require_once __DIR__.'/../../../main/inc/global.inc.php';
$cardGameSession = Session::read('cardgame');
if (!empty($cardGameSession)) {
if ($cardGameSession == 'havedeck') {
$part = '1';
if (isset($_GET['part'])) {
@ -24,7 +23,6 @@ if (!empty($cardGameSession)) {
$userId = api_get_user_id();
if (isset($userId)) {
$sql = "UPDATE plugin_card_game
SET access_date = CURDATE(), parts = CONCAT(parts,'!!$part;!')
WHERE user_id = $userId";
@ -47,7 +45,6 @@ if (!empty($cardGameSession)) {
Database::query($sql);
Session::write('cardgame', 'done');
}
}
}
}

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin.
*

@ -259,7 +259,6 @@ class CustomCertificatePlugin extends Plugin
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true') {
$infoCertificate = self::getCertificateData($certId, $userId);
var_dump($infoCertificate);
if (!empty($infoCertificate)) {
if ($certificate->user_id == api_get_user_id() && !empty($certificate->certificate_data)) {
$certificateId = $certificate->certificate_data['id'];

@ -1,7 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
if (intval($_GET['default']) == 1) {
$isDefault = isset($_GET['default']) ? (int) $_GET['default'] : null;
if ($isDefault === 1) {
$cidReset = true;
}
@ -17,7 +19,7 @@ $enable = $plugin->get('enable_plugin_customcertificate') == 'true';
$accessUrlId = api_get_current_access_url_id();
$course_info = api_get_course_info();
if (intval($_GET['default']) == 1) {
if ($isDefault === 1) {
$courseId = 0;
$courseCode = '';
$sessionId = 0;
@ -106,13 +108,13 @@ if ($form->validate()) {
'c_id' => $formValues['c_id'],
'session_id' => $formValues['session_id'],
'content_course' => $formValues['content_course'],
'contents_type' => intval($formValues['contents_type']),
'contents_type' => (int) $formValues['contents_type'],
'contents' => $contents,
'date_change' => intval($formValues['date_change']),
'date_start' => date("Y-m-d", strtotime($date_start)),
'date_end' => date("Y-m-d", strtotime($date_end)),
'place' => $formValues['place'],
'type_date_expediction' => intval($formValues['type_date_expediction']),
'type_date_expediction' => (int) $formValues['type_date_expediction'],
'day' => $formValues['day'],
'month' => $formValues['month'],
'year' => $formValues['year'],
@ -120,8 +122,8 @@ if ($form->validate()) {
'signature_text2' => $formValues['signature_text2'],
'signature_text3' => $formValues['signature_text3'],
'signature_text4' => $formValues['signature_text4'],
'margin_left' => intval($formValues['margin_left']),
'margin_right' => intval($formValues['margin_right']),
'margin_left' => (int) $formValues['margin_left'],
'margin_right' => (int) $formValues['margin_right'],
'certificate_default' => 0,
];
@ -245,7 +247,7 @@ $dir = '/';
$courseInfo = api_get_course_info();
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
$editorConfig = [
'ToolbarSet' => ($isAllowedToEdit ? 'Documents' : 'DocumentsStudent'),
'ToolbarSet' => $isAllowedToEdit ? 'Documents' : 'DocumentsStudent',
'Width' => '100%',
'Height' => '300',
'cols-size' => [0, 12, 0],

@ -5,7 +5,7 @@ use Chamilo\CourseBundle\Entity\CLpCategory;
$default = isset($_GET['default']) ? (int) $_GET['default'] : null;
if ($default == 1) {
if ($default === 1) {
$cidReset = true;
}
@ -41,6 +41,8 @@ if (empty($courseCode)) {
if (!empty($courseInfo)) {
$courseId = $courseInfo['real_id'];
}
} else {
$courseInfo = api_get_course_info($courseCode);
}
if (empty($sessionId)) {
@ -116,17 +118,21 @@ if (empty($infoCertificate)) {
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']);
$widthCell = intval($workSpace / 6);
$htmlText = '<html>';
$htmlText .= '
$htmlList = [];
$currentLocalTime = api_get_local_time();
foreach ($userList as $userInfo) {
$htmlText = '<html>';
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">';
$htmlText .= '
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'document.css">';
$htmlText .= '<body>';
foreach ($userList as $userInfo) {
$htmlText .= '<body>';
$studentId = $userInfo['user_id'];
if (empty($infoCertificate['background'])) {
@ -248,8 +254,10 @@ foreach ($userList as $userInfo) {
);
}
} else {
$dateInfo = api_get_local_time($sessionInfo['access_end_date']);
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG);
if (!empty($sessionInfo)) {
$dateInfo = api_get_local_time($sessionInfo['access_end_date']);
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG);
}
}
}
@ -465,24 +473,50 @@ foreach ($userList as $userInfo) {
}
$htmlText .= '</div>';
}
$htmlText .= '</body></html>';
$fileName = 'certificate_'.$courseInfo['code'].'_'.$userInfo['complete_name'].'_'.$currentLocalTime;
$htmlList[$fileName] = $htmlText;
}
$fileList = [];
$archivePath = api_get_path(SYS_ARCHIVE_PATH).'certificates/';
if (!is_dir($archivePath)) {
mkdir($archivePath, api_get_permissions_for_new_directories());
}
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 (count($htmlList) == 1) {
$pdf->content_to_pdf($content, '', $fileName, null, 'D', false, null, false, false, false);
exit;
} else {
$filePath = $archivePath.$fileName.'.pdf';
$pdf->content_to_pdf($content, '', $fileName, null, 'F', true, $filePath, false, false, false);
$fileList[] = $filePath;
}
}
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;
}
$htmlText .= '</body></html>';
$fileName = 'certificate_'.date('Ymd_His');
$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);
$pdf->content_to_pdf($htmlText, '', $fileName, null, 'D', false, null, false, false, false);
exit;
function getIndexFiltered($index)
{
@ -491,12 +525,16 @@ function getIndexFiltered($index)
$lines = explode(chr(13).chr(10), $txt);
$text1 = '';
for ($x = 0; $x < 47; $x++) {
$text1 .= $lines[$x].chr(13).chr(10);
if (isset($lines[$x])) {
$text1 .= $lines[$x].chr(13).chr(10);
}
}
$text2 = '';
for ($x = 47; $x < 94; $x++) {
$text2 .= $lines[$x].chr(13).chr(10);
if (isset($lines[$x])) {
$text2 .= $lines[$x].chr(13).chr(10);
}
}
$showLeft = str_replace(chr(13).chr(10), "<br/>", $text1);

@ -254,13 +254,20 @@ class ImsLtiTool
*/
public function parseCustomParams()
{
$strings = explode($this->customParams, "\n");
$pairs = explode('=', $strings);
if (empty($this->customParams)) {
return [];
}
return [
'key' => 'custom_'.$pairs[0],
'value' => $pairs[1]
];
$params = [];
$strings = explode("\n", $this->customParams);
foreach ($strings as $string) {
$pairs = explode('=', $string);
$params['custom_'.$pairs[0]] = $pairs[1];
}
return $params;
}
/**

@ -62,7 +62,7 @@ switch ($action) {
empty($formValues['custom_params']) ? null : $formValues['custom_params']
)
->setCourse($course)
->setActiveDeepLinking(false)
->setActiveDeepLinking(!empty($formValues['deep_linking']))
->setPrivacy(
!empty($formValues['share_name']),
!empty($formValues['share_email']),
@ -85,7 +85,9 @@ switch ($action) {
$em->persist($tool);
$em->flush();
$plugin->addCourseTool($course, $tool);
if (!$tool->isActiveDeepLinking()) {
$plugin->addCourseTool($course, $tool);
}
Display::addFlash(
Display::return_message($plugin->get_lang('ToolAdded'), 'success')

@ -106,6 +106,8 @@ $params['tool_consumer_instance_name'] = api_get_setting('siteName');
$params['tool_consumer_instance_url'] = api_get_path(WEB_PATH);
$params['tool_consumer_instance_contact_email'] = api_get_setting('emailAdministrator');
$params += $tool->parseCustomParams();
$oauth = new OAuthSimple(
$tool->getConsumerKey(),
$tool->getSharedSecret()

@ -35,3 +35,4 @@ $strings['ShareLauncherEmail'] = 'Share launcher\'s email';
$strings['ShareLauncherPicture'] = 'Share launcher\'s picture';
$strings['NoTool'] = 'Tool not exists';
$strings['ToolAddedOnCourseX'] = 'Tool addeed on course <strong>%s</strong>.';
$strings['SupportDeppLinkingHelp'] = 'Contact your Tool Provider to verify if Deep Linking support is mandatory';

@ -30,3 +30,9 @@ $strings['ScoreNotSet'] = 'Score non défini';
$strings['ScoreForXUserIsYScore'] = 'Score pour %s est %s';
$strings['ToolsAdded'] = 'Outils ajoutés';
$strings['ToolEdited'] = 'Outil édité';
$strings['ShareLauncherName'] = 'Share launcher\'s name';
$strings['ShareLauncherEmail'] = 'Share launcher\'s email';
$strings['ShareLauncherPicture'] = 'Share launcher\'s picture';
$strings['NoTool'] = 'Tool not exists';
$strings['ToolAddedOnCourseX'] = 'Tool addeed on course <strong>%s</strong>.';
$strings['SupportDeppLinkingHelp'] = 'Contact your Tool Provider to verify if Deep Linking support is mandatory';

@ -30,3 +30,9 @@ $strings['ScoreNotSet'] = 'Puntuación no establecida';
$strings['ScoreForXUserIsYScore'] = 'Puntuación para %s es %s';
$strings['ToolsAdded'] = 'Herramientas agregadas';
$strings['ToolEdited'] = 'Herramienta editada';
$strings['ShareLauncherName'] = 'Enviar el nombre del usuario';
$strings['ShareLauncherEmail'] = 'Enviar el correo electrónico del usuario';
$strings['ShareLauncherPicture'] = 'Enviar la foto del usuario';
$strings['NoTool'] = 'La herramienta no existe';
$strings['ToolAddedOnCourseX'] = 'Herramienta agregada en el curso <strong>%s</strong>.';
$strings['SupportDeppLinkingHelp'] = 'Contacte a su Proveedor de Herramienta para verificar si el soporte a Deep Linking es obligatorio';

@ -58,7 +58,11 @@ class FrmAdd extends FormValidator
if (null === $this->baseTool ||
($this->baseTool && !$this->baseTool->isActiveDeepLinking())
) {
$this->addCheckBox('deep_linking', null, $plugin->get_lang('SupportDeepLinking'));
$this->addCheckBox(
'deep_linking',
[null, $plugin->get_lang('SupportDeppLinkingHelp'), null],
$plugin->get_lang('SupportDeepLinking')
);
}
$this->addHtml('</div>');

@ -75,7 +75,11 @@ class FrmEdit extends FormValidator
if (null === $parent ||
(null !== $parent && !$parent->isActiveDeepLinking())
) {
$this->addCheckBox('deep_linking', null, $plugin->get_lang('SupportDeepLinking'));
$this->addCheckBox(
'deep_linking',
[null, $plugin->get_lang('SupportDeppLinkingHelp'), null],
$plugin->get_lang('SupportDeepLinking')
);
}
$this->addHtml('</div>');

@ -2,31 +2,55 @@
{% if global_tools|length or added_tools|length %}
<div class="col-sm-3">
{% if added_tools|length %}
<h2>{{ 'ToolsAdded'|get_plugin_lang('ImsLtiPlugin') }}</h2>
<ul class="nav nav-pills nav-stacked">
{% for tool in added_tools %}
<li class="{{ type == tool.id ? 'active' : '' }}">
<a href="{{ _p.web_plugin }}ims_lti/configure.php?action=edit&id={{ tool.id }}&{{ _p.web_cid_query }}">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ 'ToolsAdded'|get_plugin_lang('ImsLtiPlugin') }}</h2>
</div>
<ul class="list-group">
{% for tool in added_tools %}
<li class="list-group-item {{ type == tool.id ? 'active' : '' }}">
<div class="pull-right">
{% if tool.isActiveDeepLinking %}
<a href="{{ _p.web_plugin }}ims_lti/start.php?id={{ tool.id }}&{{ _p.web_cid_query }}">
{{ 'settings.png'|img(22, 'Configure'|get_lang) }}
</a>
{% endif %}
<a href="{{ _p.web_plugin }}ims_lti/configure.php?action=edit&id={{ tool.id }}&{{ _p.web_cid_query }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
</a>
</div>
{{ tool.name }}
</a>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if global_tools|length %}
<h2>{{ 'AvailableTools'|get_plugin_lang('ImsLtiPlugin') }}</h2>
<ul class="nav nav-pills nav-stacked">
{% for tool in global_tools %}
<li class="{{ type == tool.id ? 'active' : '' }}">
{% if tool.isActiveDeepLinking %}
<a href="{{ _p.web_plugin }}ims_lti/start.php?id={{ tool.id }}&{{ _p.web_cid_query }}">{{ tool.name }}</a>
{% else %}
<a href="{{ _p.web_self }}?type={{ tool.id }}&{{ _p.web_cid_query }}">{{ tool.name }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ 'AvailableTools'|get_plugin_lang('ImsLtiPlugin') }}</h2>
</div>
<ul class="list-group">
{% for tool in global_tools %}
<li class="list-group-item {{ type == tool.id ? 'active' : '' }}">
<div class="pull-right">
{% if tool.isActiveDeepLinking %}
<a href="{{ _p.web_plugin }}ims_lti/start.php?id={{ tool.id }}&{{ _p.web_cid_query }}">
{{ 'settings.png'|img(22, 'Configure'|get_lang) }}
</a>
{% else %}
<a href="{{ _p.web_self }}?type={{ tool.id }}&{{ _p.web_cid_query }}">
{{ 'add.png'|img(22, 'Add'|get_lang) }}
</a>
{% endif %}
</div>
{{ tool.name }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% endif %}

@ -289,12 +289,15 @@ class ChamiloApi
return api_get_path(WEB_CSS_PATH).'editor_content.css';
}
/**
* Get a list of colors from the palette at main/palette/pchart/default.color
* and return it as an array of strings
* and return it as an array of strings.
*
* @param bool $decimalOpacity Whether to return the opacity as 0..100 or 0..1
* @param bool $wrapInRGBA Whether to return it as 1,1,1,100 or rgba(1,1,1,100)
* @param int $fillUpTo If the number of colors is smaller than this number, generate more colors
* @param bool $wrapInRGBA Whether to return it as 1,1,1,100 or rgba(1,1,1,100)
* @param int $fillUpTo If the number of colors is smaller than this number, generate more colors
*
* @return array An array of string colors
*/
public static function getColorPalette(
@ -324,9 +327,10 @@ class ChamiloApi
$count = count($palette);
if (isset($fillUpTo) && $fillUpTo > $count) {
for ($i = $count; $i < $fillUpTo; $i++) {
$palette[$i] = $palette[$i%$count];
$palette[$i] = $palette[$i % $count];
}
}
return $palette;
}
}

Loading…
Cancel
Save