Minor - merge from 1.x

pull/2744/head
Julio Montoya 6 years ago
parent 49c89f2d47
commit 65060bef05
  1. 40
      main/admin/statistics/index.php
  2. 22
      main/admin/user_add.php
  3. 12
      main/admin/user_edit.php
  4. 2
      main/admin/user_list.php
  5. 2
      main/calendar/agenda_list.php
  6. 17
      main/document/download.php
  7. 1
      main/exercise/overview.php
  8. 5
      main/gradebook/gradebook_display_certificate.php
  9. 2
      main/gradebook/lib/GradebookUtils.php
  10. 4
      main/gradebook/lib/be/exerciselink.class.php
  11. 23
      main/gradebook/lib/be/result.class.php
  12. 2
      main/gradebook/lib/fe/evalform.class.php
  13. 8
      main/gradebook/lib/fe/flatviewtable.class.php
  14. 46
      main/gradebook/lib/fe/gradebooktable.class.php
  15. 22
      main/gradebook/lib/gradebook_data_generator.class.php
  16. 27
      main/inc/ajax/model.ajax.php
  17. 56
      main/inc/ajax/statistics.ajax.php
  18. 8
      main/inc/ajax/work.ajax.php
  19. 376
      main/inc/lib/AnnouncementManager.php
  20. 6
      main/inc/lib/ScheduledAnnouncement.php
  21. 26
      main/inc/lib/api.lib.php
  22. 27
      main/inc/lib/course.lib.php
  23. 39
      main/inc/lib/exercise.lib.php
  24. 16659
      main/inc/lib/javascript/chartjs/Chart.js
  25. 9
      main/inc/lib/javascript/chartjs/Chart.min.js
  26. 7
      main/inc/lib/javascript/readout_text/js/start.js
  27. 7
      main/inc/lib/pdf.lib.php
  28. 8
      main/inc/lib/sessionmanager.lib.php
  29. 17
      main/inc/lib/statistics.lib.php
  30. 127
      main/inc/lib/usermanager.lib.php
  31. 13
      main/lp/learnpath.class.php
  32. 18
      main/lp/learnpathItem.class.php
  33. 7
      main/lp/lp_nav.php
  34. 4
      main/lp/readout_text.php
  35. 9
      main/palettes/pchart/default.color
  36. 14
      main/session/scheduled_announcement.php
  37. 115
      main/tracking/courseLog.php
  38. 5
      main/work/add_document.php
  39. 6
      main/work/edit.php
  40. 6
      main/work/edit_work.php
  41. 12
      main/work/upload.php
  42. 11
      main/work/view.php
  43. 38
      main/work/work.lib.php
  44. 12
      main/work/work_list.php
  45. 14
      main/work/work_list_all.php

@ -22,11 +22,44 @@ if ($report == 'recentlogins') {
<script>
$(document).ready(function() {
$.ajax({
url: "'.api_get_path(WEB_CODE_PATH).'inc/ajax/statistics.ajax.php?a=recentlogins&session_duration='.$sessionDuration.'",
url: "'.api_get_path(WEB_CODE_PATH).'inc/ajax/statistics.ajax.php?a=recent_logins&session_duration='.$sessionDuration.'",
type: "POST",
success: function(data) {
Chart.defaults.global.responsive = true;
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(data);
var ctx = document.getElementById("canvas").getContext("2d");
var myLoginChart = new Chart(ctx, {
type: "line",
data: data
});
}
});
});
</script>';
}
if ($report == 'tools') {
$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
$htmlHeadXtra[] = '
<script>
$(document).ready(function() {
$.ajax({
url: "'.api_get_path(WEB_CODE_PATH).'inc/ajax/statistics.ajax.php?a=tools_usage",
type: "POST",
success: function(data) {
Chart.defaults.global.responsive = true;
var ctx = document.getElementById("canvas").getContext("2d");
var myLoginChart = new Chart(ctx, {
type: "pie",
data: data,
options: {
legend: {
position: "left"
},
title: {
text: "'.get_lang('PlatformToolAccess').'",
display: true
}
}
});
}
});
});
@ -198,6 +231,7 @@ switch ($report) {
Statistics::printStats(get_lang('CountCours'), $courses);
break;
case 'tools':
echo '<canvas class="col-md-12" id="canvas" height="300px" style="margin-bottom: 20px"></canvas>';
Statistics::printToolStats();
break;
case 'coursebylanguage':
@ -236,7 +270,7 @@ switch ($report) {
$form->addHidden('report', 'recentlogins');
$form->display();
echo '<canvas class="col-md-12" id="canvas" height="100px" style="margin-bottom: 20px"></canvas>';
echo '<canvas class="col-md-12" id="canvas" height="200px" style="margin-bottom: 20px"></canvas>';
Statistics::printRecentLoginStats(false, $sessionDuration);
Statistics::printRecentLoginStats(true, $sessionDuration);
break;

@ -305,6 +305,19 @@ $returnParams = $extraField->addElements(
[],
true
);
$allowEmailTemplate = api_get_configuration_value('mail_template_system');
if ($allowEmailTemplate) {
$form->addEmailTemplate(
[
'subject_registration_platform.tpl',
'content_registration_platform.tpl',
'new_user_first_email_confirmation.tpl',
'new_user_second_email_confirmation.tpl',
]
);
}
$jquery_ready_content = $returnParams['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
@ -381,6 +394,8 @@ if ($form->validate()) {
}
}
$template = isset($user['email_template_option']) ? $user['email_template_option'] : [];
$user_id = UserManager::create_user(
$firstname,
$lastname,
@ -399,7 +414,12 @@ if ($form->validate()) {
$extra,
null,
$send_mail,
$platform_admin
$platform_admin,
'',
false,
null,
0,
$template
);
Security::clear_token();

@ -324,7 +324,12 @@ $returnParams = $extraField->addElements(
);
$jqueryReadyContent = $returnParams['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
$allowEmailTemplate = api_get_configuration_value('mail_template_system');
if ($allowEmailTemplate) {
$form->addEmailTemplate(['user_edit_content.tpl']);
}
// the $jqueryReadyContent variable collects all functions that will be load in the
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
'.$jqueryReadyContent.'
@ -425,6 +430,8 @@ if ($form->validate()) {
$username = $email;
}
$template = isset($user['email_template_option']) ? $user['email_template_option'] : [];
UserManager::update_user(
$user_id,
$firstname,
@ -446,7 +453,8 @@ if ($form->validate()) {
null,
$send_mail,
$reset_password,
$address
$address,
$template
);
if (isset($user['student_boss'])) {

@ -12,6 +12,8 @@ use ChamiloSession as Session;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_session_admin_list_users();
$urlId = api_get_current_access_url_id();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';

@ -79,7 +79,7 @@ $tpl = new Template(get_lang('Events'));
$tpl->assign('agenda_events', $events);
$tpl->assign('url', $url);
$tpl->assign('show_action', in_array($type, ['course', 'session']));
$tpl->assign('actions', $actions);
$tpl->assign('agenda_actions', $actions);
$tpl->assign('is_allowed_to_edit', api_is_allowed_to_edit());
if (api_is_allowed_to_edit()) {

@ -26,10 +26,21 @@ $doc_url = str_replace('///', '&', $doc_url);
// Still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace(['../', '\\..', '\\0', '..\\'], ['', '', '', ''], $doc_url); //echo $doc_url;
$docUrlParts = preg_split('/\/|\\\/', $doc_url);
$doc_url = '';
if (strpos($doc_url, '../') || strpos($doc_url, '/..')) {
$doc_url = '';
foreach ($docUrlParts as $docUrlPart) {
if (empty($docUrlPart) || in_array($docUrlPart, ['.', '..', '0'])) {
continue;
}
$doc_url .= '/'.$docUrlPart;
}
if (empty($doc_url)) {
api_not_allowed(
!empty($_GET['origin']) && $_GET['origin'] === 'learnpath'
);
}
// Dealing with image included into survey: when users receive a link towards a

@ -29,6 +29,7 @@ $exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId'])
$objExercise = new Exercise();
$result = $objExercise->read($exercise_id);
if (!$result) {
api_not_allowed(true);
}

@ -131,7 +131,8 @@ switch ($action) {
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1
) {
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php?export_all=1';
$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;
} else {
if (api_is_student_boss()) {
$userGroup = new UserGroup();
@ -307,7 +308,7 @@ if (count($certificate_list) == 0) {
echo '<td width="50%">'.get_lang('Score').' : '.$valueCertificate['score_certificate'].'</td>';
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'];
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$valueCertificate['id'].'&user_id='.$value['user_id'];
$certificates = Display::url(
get_lang('Certificate'),
$url,

@ -1608,7 +1608,6 @@ class GradebookUtils
$userInfo = api_get_user_info($userId);
$cat = $cats[0];
$allcat = $cats[0]->get_subcategories(
$userId,
api_get_course_id(),
@ -1625,7 +1624,6 @@ class GradebookUtils
$loadStats = [2];
}
}
$gradebooktable = new GradebookTable(
$cat,
$allcat,

@ -199,7 +199,7 @@ class ExerciseLink extends AbstractLink
if ($exercise->exercise_was_added_in_lp == false) {
$sql = "SELECT * FROM $tblStats
WHERE
exe_exo_id = ".$exerciseId." AND
exe_exo_id = $exerciseId AND
orig_lp_id = 0 AND
orig_lp_item_id = 0 AND
status <> 'incomplete' AND
@ -217,7 +217,7 @@ class ExerciseLink extends AbstractLink
$sql = "SELECT *
FROM $tblStats
WHERE
exe_exo_id = ".$exerciseId." AND
exe_exo_id = $exerciseId AND
orig_lp_id = $lpId AND
status <> 'incomplete' AND
session_id = $sessionId AND

@ -289,4 +289,27 @@ class Result
Database::query($sql);
}
}
/**
* Check if exists a result with its user and evaluation.
*
* @throws \Doctrine\ORM\Query\QueryException
*
* @return bool
*/
public function exists()
{
$em = Database::getManager();
$result = $em
->createQuery(
'SELECT COUNT(gr) FROM ChamiloCoreBundle:GradebookResult gr
WHERE gr.evaluationId = :eval_id AND gr.userId = :user_id'
)
->setParameters(['eval_id' => $this->evaluation, 'user_id' => $this->user_id])
->getSingleScalarResult();
$count = (int) $result;
return $count > 0;
}
}

@ -20,7 +20,7 @@ class EvalForm extends FormValidator
const TYPE_ALL_RESULTS_EDIT = 6;
const TYPE_ADD_USERS_TO_EVAL = 7;
private $evaluation_object;
protected $evaluation_object;
private $result_object;
private $extra;

@ -187,7 +187,11 @@ class FlatViewTable extends SortableTable
$dataSet = new pData();
$dataSet->addPoints($resource, 'Serie');
$dataSet->addPoints(array_keys($resource), 'Labels');
$dataSet->setSerieDescription('Labels', strip_tags($headerName[$i - 1]));
$header = $headerName[$i - 1];
if (is_array($header) && isset($header['header'])) {
$header = $header['header'];
}
$dataSet->setSerieDescription('Labels', strip_tags($header));
$dataSet->setAbscissa('Labels');
$dataSet->setAbscissaName(get_lang('GradebookSkillsRanking'));
$dataSet->setAxisName(0, get_lang('Students'));
@ -245,7 +249,7 @@ class FlatViewTable extends SortableTable
$myPicture->drawText(
250,
30,
strip_tags($headerName[$i - 1]),
strip_tags($header),
[
'FontSize' => 12,
'Align' => TEXT_ALIGN_BOTTOMMIDDLE,

@ -79,6 +79,7 @@ class GradebookTable extends SortableTable
$this->cats = $cats;
$this->loadStats = $loadStats;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
$this->datagen->hidePercentage = api_get_configuration_value('hide_gradebook_percentage_user_result');
if (!empty($userId)) {
$this->datagen->userId = $userId;
@ -285,7 +286,9 @@ class GradebookTable extends SortableTable
}
$model = ExerciseLib::getCourseScoreModel();
$userExerciseScoreInCategory = api_get_configuration_value(
'gradebook_use_exercise_score_settings_in_categories'
);
// Categories.
if (!empty($data_array)) {
foreach ($data_array as $data) {
@ -320,7 +323,6 @@ class GradebookTable extends SortableTable
}
$this->dataForGraph['categories'][] = $item->get_name();
$main_categories[$item->get_id()]['weight'] = $item->get_weight();
$total_categories_weight += $item->get_weight();
@ -411,17 +413,32 @@ class GradebookTable extends SortableTable
$data['result_score'][1]
);
}
$totalResultAverageValue = strip_tags(
$scoredisplay->display_score(
$totalResult,
SCORE_AVERAGE
)
$mode = SCORE_AVERAGE;
if ($userExerciseScoreInCategory) {
$mode = SCORE_SIMPLE;
$result = ExerciseLib::convertScoreToPlatformSetting($totalAverage[0], $totalAverage[1]);
$totalAverage[0] = $result['score'];
$totalAverage[1] = $result['weight'];
$result = ExerciseLib::convertScoreToPlatformSetting($totalResult[0], $totalResult[1]);
$totalResult[0] = $result['score'];
$totalResult[1] = $result['weight'];
$result = ExerciseLib::convertScoreToPlatformSetting(
$data['result_score'][0],
$data['result_score'][1]
);
$data['my_result_no_float'][0] = $result['score'];
}
$totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, $mode));
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, $mode));
$this->dataForGraph['my_result'][] = floatval($totalResultAverageValue);
$this->dataForGraph['my_result_no_float'][] = $data['result_score'][0];
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE));
$this->dataForGraph['average'][] = floatval($totalAverageValue);
$this->dataForGraph['my_result_no_float'][] = $data['result_score'][0];
if (empty($model)) {
// Ranking
@ -699,8 +716,14 @@ class GradebookTable extends SortableTable
$totalRanking = [];
$invalidateRanking = true;
$average = 0;
$main_cat[0]->setStudentList($this->studentList);
foreach ($this->studentList as $student) {
$score = $main_cat[0]->calc_score($student['user_id']);
$score = $main_cat[0]->calc_score(
$student['user_id'],
null,
api_get_course_id(),
api_get_session_id()
);
if (!empty($score[0])) {
$invalidateRanking = false;
}
@ -709,7 +732,6 @@ class GradebookTable extends SortableTable
}
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
$totalRanking = $scoredisplay->display_score(
$totalRanking,
SCORE_DIV,
@ -739,7 +761,6 @@ class GradebookTable extends SortableTable
// Overwrite main weight
$totalAverage[0] = $average / count($this->studentList);
$totalAverage[1] = $main_weight;
$totalAverage = $scoredisplay->display_score(
$totalAverage,
SCORE_DIV,
@ -749,7 +770,6 @@ class GradebookTable extends SortableTable
$row[] = $totalAverage;
}
$sortable_data[] = $row;
}
}

@ -22,6 +22,7 @@ class GradebookDataGenerator
const GDG_SORT_DESC = 64;
const GDG_SORT_ID = 128;
public $userId;
public $hidePercentage = false;
private $items;
private $evals_links;
@ -188,7 +189,6 @@ class GradebookDataGenerator
$ignore_score_color,
true
);
if (!empty($score['score'][0])) {
$invalidateResults = false;
}
@ -353,10 +353,15 @@ class GradebookDataGenerator
api_get_session_id()
);
$scoreMode = SCORE_DIV_PERCENT_WITH_CUSTOM;
if ($this->hidePercentage) {
$scoreMode = SCORE_DIV;
}
$scoreDisplay = ScoreDisplay::instance();
$display = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM,
$scoreMode,
SCORE_BOTH,
true
);
@ -380,15 +385,26 @@ class GradebookDataGenerator
{
$score = $item->calc_score(null, 'average');
$scoreDisplay = ScoreDisplay::instance();
$scoreMode = SCORE_DIV_PERCENT_WITH_CUSTOM;
if ($this->hidePercentage) {
$scoreMode = SCORE_DIV;
}
$display = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM,
$scoreMode,
SCORE_BOTH,
true
);
$type = $item->get_item_type();
if ($type === 'L' && get_class($item) === 'ExerciseLink') {
$display = ExerciseLib::show_score($score[0], $score[1], false);
$result = ExerciseLib::convertScoreToPlatformSetting($score[0], $score[1]);
$score[0] = $result['score'];
$score[1] = $result['weight'];
}
return [

@ -1910,6 +1910,32 @@ switch ($action) {
}
$result = $new_result;
break;
case 'get_mail_template':
$columns = ['name', 'type', 'default_template', 'actions'];
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
$result = Database::select(
'*',
$obj->table,
[
'where' => ['url_id = ? ' => api_get_current_access_url_id()],
'order' => "$sidx $sord",
'LIMIT' => "$start , $limit",
]
);
$new_result = [];
foreach ($result as $item) {
$new_result[] = $item;
}
$result = $new_result;
break;
case 'get_grade_models':
$columns = ['name', 'description', 'actions'];
if (!in_array($sidx, $columns)) {
@ -2159,6 +2185,7 @@ switch ($action) {
$allowed_actions = [
'get_careers',
'get_promotions',
'get_mail_template',
'get_usergroups',
'get_usergroups_teacher',
'get_gradebooks',

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
* Responses to AJAX calls.
*/
@ -105,8 +107,9 @@ switch ($action) {
echo json_encode($list);
break;
break;
case 'recentlogins':
case 'recent_logins':
// Give a JSON array to the stats page main/admin/statistics/index.php
// for global recent logins
header('Content-type: application/json');
$list = [];
$all = Statistics::getRecentLoginStats(false, $sessionDuration);
@ -115,30 +118,55 @@ switch ($action) {
}
$list['datasets'][0]['label'] = get_lang('Logins');
$list['datasets'][0]['fillColor'] = "rgba(151,187,205,0.2)";
$list['datasets'][0]['strokeColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointStrokeColor'] = "#fff";
$list['datasets'][0]['pointHighlightFill'] = "#fff";
$list['datasets'][0]['pointHighlightStroke'] = "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]['fillColor'] = "rgba(0,204,0,0.2)";
$list['datasets'][1]['strokeColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointStrokeColor'] = "#fff";
$list['datasets'][1]['pointHighlightFill'] = "#fff";
$list['datasets'][1]['pointHighlightStroke'] = "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) {
$list['datasets'][1]['data'][] = $tock;
}
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)
header('Content-type: application/json');
$list = [];
$all = Statistics::getToolsStats();
foreach ($all as $tick => $tock) {
$list['labels'][] = $tick;
}
$palette = ChamiloApi::getColorPalette(true, true);
$list['datasets'][0]['label'] = get_lang('Tools');
$list['datasets'][0]['borderColor'] = 'rgba(255,255,255,1)';
$i = 0;
foreach ($all as $tick => $tock) {
$j = $i % count($palette);
$list['datasets'][0]['data'][] = $tock;
$list['datasets'][0]['backgroundColor'][] = $palette[$j];
$i++;
}
echo json_encode($list);
break;
}

@ -20,6 +20,14 @@ switch ($action) {
$userId = api_get_user_id();
$groupId = api_get_group_id();
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
if ($onlyOnePublication) {
$count = get_work_count_by_student($userId, $workId);
if ($count >= 1) {
exit;
}
}
if (!empty($_FILES)) {
$files = $_FILES['files'];
$fileList = [];

@ -1336,7 +1336,7 @@ class AnnouncementManager
public static function get_attachment($announcementId)
{
$table = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
$announcementId = intval($announcementId);
$announcementId = (int) $announcementId;
$courseId = api_get_course_int_id();
$row = [];
$sql = 'SELECT id, path, filename, comment
@ -1560,6 +1560,9 @@ class AnnouncementManager
$courseId = 0,
$sessionId = 0
) {
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$user_id = $userId ?: api_get_user_id();
$group_id = api_get_group_id();
$session_id = $sessionId ?: api_get_session_id();
@ -1575,28 +1578,255 @@ class AnnouncementManager
return [];
}
$condition_session = api_get_session_condition(
$session_id,
true,
true,
'announcement.session_id'
);
$group_memberships = GroupManager::get_group_ids(
$courseId,
api_get_user_id()
);
$allowUserEditSetting = api_get_course_setting('allow_user_edit_announcement');
$select = ' DISTINCT
announcement.*,
ip.visibility,
ip.to_group_id,
ip.insert_user_id,
ip.insert_date,
ip.lastedit_date';
$groupBy = ' GROUP BY announcement.iid';
if ($getCount) {
$groupBy = '';
$select = ' COUNT(DISTINCT announcement.iid) count';
}
$searchCondition = '';
if (!empty($titleToSearch)) {
$titleToSearch = Database::escape_string($titleToSearch);
$searchCondition .= " AND (title LIKE '%$titleToSearch%')";
}
$result = Container::$container
->get('chamilo_course.entity.manager.announcement_manager')
->getAnnouncements(
api_get_user_entity($user_id),
api_get_course_entity($courseId),
api_get_group_entity($group_id),
api_get_session_entity($session_id),
api_get_course_setting('allow_user_edit_announcement') === 'true',
api_get_configuration_value('hide_base_course_announcements_in_group') === true,
$getCount,
$start,
$limit,
$titleToSearch,
$userIdToSearch ? api_get_user_entity($userIdToSearch) : null
);
if (!empty($userIdToSearch)) {
$userIdToSearch = (int) $userIdToSearch;
$searchCondition .= " AND (ip.insert_user_id = $userIdToSearch)";
}
$allowOnlyGroup = api_get_configuration_value('hide_base_course_announcements_in_group');
$extraGroupCondition = '';
if ($allowOnlyGroup) {
$extraGroupCondition = " AND ip.to_group_id = $group_id ";
}
if (api_is_allowed_to_edit(false, true) ||
($allowUserEditSetting && !api_is_anonymous())
) {
// A.1. you are a course admin with a USER filter
// => see only the messages of this specific user + the messages of the group (s)he is member of.
//if (!empty($user_id)) {
if (0) {
if (is_array($group_memberships) &&
count($group_memberships) > 0
) {
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND ip.c_id = announcement.c_id)
WHERE
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.tool = 'announcement' AND
(
ip.to_user_id = $user_id OR
ip.to_group_id IS NULL OR
ip.to_group_id IN (0, ".implode(", ", $group_memberships).")
) AND
ip.visibility IN ('1', '0')
$condition_session
$searchCondition
ORDER BY display_order DESC";
} else {
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND ip.c_id = announcement.c_id)
WHERE
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.tool ='announcement' AND
(ip.to_user_id = $user_id OR ip.to_group_id='0' OR ip.to_group_id IS NULL) AND
ip.visibility IN ('1', '0')
$condition_session
$searchCondition
ORDER BY display_order DESC";
}
} elseif ($group_id != 0) {
// A.2. you are a course admin with a GROUP filter
// => see only the messages of this specific group
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
ip.tool='announcement' AND
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.visibility<>'2' AND
(ip.to_group_id = $group_id OR ip.to_group_id='0' OR ip.to_group_id IS NULL)
$condition_session
$searchCondition
$extraGroupCondition
$groupBy
ORDER BY display_order DESC";
} else {
// A.3 you are a course admin without any group or user filter
// A.3.a you are a course admin without user or group filter but WITH studentview
// => see all the messages of all the users and groups without editing possibilities
if (isset($isStudentView) && $isStudentView == 'true') {
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
ip.tool='announcement' AND
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.visibility='1'
$condition_session
$searchCondition
$groupBy
ORDER BY display_order DESC";
} else {
// A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
// => see all the messages of all the users and groups with editing possibilities
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
ip.tool = 'announcement' AND
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
(ip.visibility='0' OR ip.visibility='1')
$condition_session
$searchCondition
$groupBy
ORDER BY display_order DESC";
}
}
} else {
// STUDENT
if (is_array($group_memberships) && count($group_memberships) > 0) {
if ($allowUserEditSetting && !api_is_anonymous()) {
if ($group_id == 0) {
// No group
$cond_user_id = " AND (
ip.lastedit_user_id = '".$user_id."' OR (
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) OR
(ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))
)
) ";
} else {
$cond_user_id = " AND (
ip.lastedit_user_id = '".$user_id."' OR ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id.")
)";
$cond_user_id .= $extraGroupCondition;
}
} else {
if ($group_id == 0) {
$cond_user_id = " AND (
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))
) ";
} else {
$cond_user_id = " AND (
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id."))
)";
$cond_user_id .= $extraGroupCondition;
}
}
$sql = "SELECT $select
FROM $tbl_announcement announcement INNER JOIN
$tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.tool='announcement'
$cond_user_id
$condition_session
$searchCondition
AND ip.visibility='1'
$groupBy
ORDER BY display_order DESC";
} else {
if ($user_id) {
if ($allowUserEditSetting && !api_is_anonymous()) {
$cond_user_id = " AND (
ip.lastedit_user_id = '".api_get_user_id()."' OR
((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id='0' OR ip.to_group_id IS NULL))
) ";
} else {
$cond_user_id = " AND ((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
}
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.tool='announcement'
$cond_user_id
$condition_session
$searchCondition
AND ip.visibility='1'
AND announcement.session_id IN(0, ".$session_id.")
$groupBy
ORDER BY display_order DESC";
} else {
if (($allowUserEditSetting && !api_is_anonymous())) {
$cond_user_id = " AND (
ip.lastedit_user_id = '".$user_id."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL
)";
} else {
$cond_user_id = " AND ip.to_group_id='0' OR ip.to_group_id IS NULL ";
}
$sql = "SELECT $select
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
announcement.c_id = $courseId AND
ip.c_id = $courseId AND
ip.tool='announcement'
$cond_user_id
$condition_session
$searchCondition AND
ip.visibility='1' AND
announcement.session_id IN ( 0,".api_get_session_id().")
$groupBy
";
}
}
}
if (!is_null($start) && !is_null($limit)) {
$start = intval($start);
$limit = intval($limit);
$sql .= " LIMIT $start, $limit";
}
$result = Database::query($sql);
if ($getCount) {
return $result;
$result = Database::fetch_array($result, 'ASSOC');
return $result['count'];
}
$iterator = 1;
@ -1644,107 +1874,141 @@ class AnnouncementManager
);
}
for ($z = 0; $z < count($result); $z += 2) {
/** @var CAnnouncement $a */
$a = $result[$z];
/** @var CItemProperty $i */
$i = $result[$z + 1];
while ($row = Database::fetch_array($result, 'ASSOC')) {
if (!in_array($row['id'], $displayed)) {
$sent_to_icon = '';
if ($row['email_sent'] == '1') {
$sent_to_icon = ' '.$emailIcon;
}
$groupReference = $row['to_group_id'] > 0 ? ' <span class="label label-info">'.get_lang(
'Group'
).'</span> ' : '';
$disableEdit = false;
$to = self::loadEditUsers('announcement', $row['id'], true);
$separated = CourseManager::separateUsersGroups($to);
if (!empty($group_id)) {
if (in_array($a->getId(), $displayed)) {
continue;
if (isset($separated['groups']) && count($separated['groups']) > 1) {
$disableEdit = true;
}
$sent_to_icon = $a->getEmailSent() ? " $emailIcon" : '';
$groupReference = $i->getGroup() !== null
? ' <span class="label label-info">'.get_lang('Group').'</span> '
: '';
$title = $a->getTitle().$groupReference.$sent_to_icon;
$item_visibility = api_get_item_visibility($courseInfo, TOOL_ANNOUNCEMENT, $a->getId(), $sessionId);
$i->setVisibility($item_visibility);
if (empty($separated['groups']) && empty($separated['users'])) {
$disableEdit = true;
}
// show attachment list
$attachment_list = self::get_attachment($a->getId());
if ($separated['groups'] > 1 && !in_array($group_id, $separated['groups'])) {
$disableEdit = true;
}
} else {
if (isset($separated['groups']) && count($separated['groups']) > 1) {
$groupReference = '';
}
}
$title = $row['title'].$groupReference.$sent_to_icon;
$item_visibility = api_get_item_visibility(
$courseInfo,
TOOL_ANNOUNCEMENT,
$row['id'],
$session_id
);
$row['visibility'] = $item_visibility;
// show attachment list
$attachment_list = self::get_attachment($row['id']);
$attachment_icon = '';
if (count($attachment_list) > 0) {
$attachment_icon = ' '.$attachmentIcon;
}
/* TITLE */
$user_info = api_get_user_info($row['insert_user_id']);
$username = sprintf(get_lang('LoginX'), $user_info['username']);
$username_span = Display::tag(
'span',
UserManager::formatUserFullName($i->getInsertUser()),
['title' => $i->getInsertUser()->getUsername()]
$user_info['complete_name'],
['title' => $username]
);
$title = Display::url(
$title.$attachment_icon,
$actionUrl.'&action=view&id='.$a->getId()
$actionUrl.'&action=view&id='.$row['id']
);
$aGroupId = $i->getGroup() ? $i->getGroup()->getId() : 0;
// we can edit if : we are the teacher OR the element belongs to
// the session we are coaching OR the option to allow users to edit is on
if (api_is_allowed_to_edit(false, true) ||
(api_is_session_general_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $a->getId())) ||
(api_is_session_general_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $row['id'])) ||
(api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) ||
($aGroupId == $group_id && $isTutor)
($row['to_group_id'] == $group_id && $isTutor)
) {
$modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$a->getId()."\">".$editIcon."</a>";
if ($i->getVisibility() == 1) {
if ($disableEdit === true) {
$modify_icons = "<a href='#'>".$editIconDisable."</a>";
} else {
$modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$row['id']."\">".$editIcon."</a>";
}
if ($row['visibility'] == 1) {
$image_visibility = "visible";
$alt_visibility = get_lang('Hide');
} else {
$image_visibility = "invisible";
$alt_visibility = get_lang('Visible');
}
$modify_icons .= "<a href=\"".$actionUrl."&action=showhide&id=".$a->getId()."&sec_token=".$stok."\">".
$modify_icons .= "<a href=\"".$actionUrl."&action=showhide&id=".$row['id']."&sec_token=".$stok."\">".
Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>";
// DISPLAY MOVE UP COMMAND only if it is not the top announcement
if ($iterator != 1) {
$modify_icons .= "<a href=\"".$actionUrl."&action=move&up=".$a->getId()."&sec_token=".$stok."\">".
$modify_icons .= "<a href=\"".$actionUrl."&action=move&up=".$row["id"]."&sec_token=".$stok."\">".
Display::return_icon('up.gif', get_lang('Up'))."</a>";
} else {
$modify_icons .= Display::return_icon('up_na.gif', get_lang('Up'));
}
if ($iterator < $bottomAnnouncement) {
$modify_icons .= "<a href=\"".$actionUrl."&action=move&down=".$a->getId()."&sec_token=".$stok."\">".
$modify_icons .= "<a href=\"".$actionUrl."&action=move&down=".$row["id"]."&sec_token=".$stok."\">".
Display::return_icon('down.gif', get_lang('Down'))."</a>";
} else {
$modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
}
if (api_is_allowed_to_edit(false, true)) {
$modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$a->getId()."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">".
if ($disableEdit === true) {
$modify_icons .= Display::url($deleteIconDisable, '#');
} else {
$modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$row['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(
api_htmlentities(
get_lang('ConfirmYourChoice'),
ENT_QUOTES,
api_get_system_encoding()
)
)."')) return false;\">".
$deleteIcon."</a>";
}
}
$iterator++;
} else {
$modify_icons = Display::url(
Display::return_icon('default.png'),
$actionUrl.'&action=view&id='.$a->getId()
$actionUrl.'&action=view&id='.$row['id']
);
}
$announcement = [
'id' => $a->getId(),
'id' => $row['id'],
'title' => $title,
'username' => $username_span,
'insert_date' => api_convert_and_format_date(
$i->getInsertDate(),
DATE_TIME_FORMAT_LONG
),
'lastedit_date' => api_convert_and_format_date(
$i->getLasteditDate(),
DATE_TIME_FORMAT_LONG
),
'insert_date' => api_convert_and_format_date($row['insert_date'], DATE_TIME_FORMAT_LONG),
'lastedit_date' => api_convert_and_format_date($row['lastedit_date'], DATE_TIME_FORMAT_LONG),
'actions' => $modify_icons,
];
$results[] = $announcement;
$displayed[] = $a->getId();
}
$displayed[] = $row['id'];
}
return $results;

@ -324,7 +324,7 @@ class ScheduledAnnouncement extends Model
}
if ($users) {
self::update(['id' => $result['id'], 'sent' => 1]);
$this->update(['id' => $result['id'], 'sent' => 1]);
$attachments = $this->getAttachmentToString($result['id']);
$subject = $result['subject'];
@ -371,8 +371,8 @@ class ScheduledAnnouncement extends Model
$generalCoach = '';
$generalCoachEmail = '';
if (!empty($sessionInfo['coach_id'])) {
$coachInfo = api_get_user_info($sessionInfo['coach_id']);
if (!empty($sessionInfo['id_coach'])) {
$coachInfo = api_get_user_info($sessionInfo['id_coach']);
if (!empty($coachInfo)) {
$generalCoach = $coachInfo['complete_name'];
$generalCoachEmail = $coachInfo['email'];

@ -6254,8 +6254,21 @@ function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true)
$encoding = api_detect_encoding($filename);
if (empty($encoding)) {
$encoding = 'ASCII';
if (!api_is_valid_ascii($filename)) {
// try iconv and try non standard ASCII a.k.a CP437
// see BT#15022
if (function_exists('iconv')) {
$result = iconv('CP437', 'UTF-8', $filename);
if (api_is_valid_utf8($result)) {
$filename = $result;
$encoding = 'UTF-8';
}
}
}
}
$filename = api_to_system_encoding($filename, $encoding);
$url = URLify::filter(
$filename,
250,
@ -8951,6 +8964,19 @@ function api_protect_limit_for_session_admin()
}
}
/**
* Limits that a session admin has access to list users.
* When limit_session_admin_list_users configuration variable is set to true.
*/
function api_protect_session_admin_list_users()
{
$limitAdmin = api_get_configuration_value('limit_session_admin_list_users');
if (api_is_session_admin() && true === $limitAdmin) {
api_not_allowed(true);
}
}
/**
* @return bool
*/

@ -223,7 +223,9 @@ class CourseManager
$conditionsLike = [],
$onlyThisCourseList = []
) {
$sql = "SELECT course.* FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course ";
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT course.*, course.id as real_id
FROM $courseTable course ";
if (!empty($urlId)) {
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -242,7 +244,7 @@ class CourseManager
$sql .= " AND visibility = $visibility ";
}
} else {
$sql .= "WHERE 1 ";
$sql .= 'WHERE 1 ';
if ($visibility !== -1) {
$sql .= " AND visibility = $visibility ";
}
@ -289,7 +291,7 @@ class CourseManager
if (!empty($orderby)) {
$sql .= " ORDER BY ".Database::escape_string($orderby)." ";
} else {
$sql .= " ORDER BY 1 ";
$sql .= ' ORDER BY 1 ';
}
if (!in_array($orderdirection, ['ASC', 'DESC'])) {
@ -332,6 +334,7 @@ class CourseManager
public static function getUserInCourseStatus($userId, $courseId)
{
$courseId = (int) $courseId;
$userId = (int) $userId;
if (empty($courseId)) {
return false;
}
@ -341,7 +344,7 @@ class CourseManager
"SELECT status FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE
c_id = $courseId AND
user_id = ".intval($userId)
user_id = $userId"
)
);
@ -438,7 +441,7 @@ class CourseManager
}
if (!empty($session_id)) {
$session_id = intval($session_id);
$session_id = (int) $session_id;
} else {
$session_id = api_get_session_id();
}
@ -1114,6 +1117,7 @@ class CourseManager
* @param int $user_id
* @param string $course_code , if this parameter is null, it'll check for all courses
* @param bool $in_a_session True for checking inside sessions too, by default is not checked
* @param int $session_id
*
* @return bool $session_id true if the user is registered in the course, false otherwise
*/
@ -1123,12 +1127,12 @@ class CourseManager
$in_a_session = false,
$session_id = 0
) {
$user_id = intval($user_id);
$user_id = (int) $user_id;
if (empty($session_id)) {
$session_id = api_get_session_id();
} else {
$session_id = intval($session_id);
$session_id = (int) $session_id;
}
$condition_course = '';
@ -1160,13 +1164,16 @@ class CourseManager
}
$tableSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql = 'SELECT 1 FROM '.$tableSessionCourseUser.
' WHERE user_id = '.$user_id.' '.$condition_course;
$sql = 'SELECT 1 FROM '.$tableSessionCourseUser.'
WHERE user_id = '.$user_id.' AND session_id = '.$session_id.' '.$condition_course;
if (Database::num_rows(Database::query($sql)) > 0) {
return true;
}
$sql = 'SELECT 1 FROM '.$tableSessionCourseUser.' WHERE user_id = '.$user_id.' AND status = 2 '.$condition_course;
$sql = 'SELECT 1 FROM '.$tableSessionCourseUser.'
WHERE user_id = '.$user_id.' AND session_id = '.$session_id.' AND status = 2 '.$condition_course;
if (Database::num_rows(Database::query($sql)) > 0) {
return true;
}

@ -2747,6 +2747,31 @@ HOTSPOT;
return $listInfo;
}
/**
* @param $score
* @param $weight
*
* @return array
*/
public static function convertScoreToPlatformSetting($score, $weight)
{
$result = ['score' => $score, 'weight' => $weight];
$maxNote = api_get_setting('exercise_max_score');
$minNote = api_get_setting('exercise_min_score');
if ($maxNote != '' && $minNote != '') {
if (!empty($weight) && intval($weight) != 0) {
$score = $minNote + ($maxNote - $minNote) * $score / $weight;
} else {
$score = $minNote;
}
$weight = $maxNote;
}
return ['score' => $score, 'weight' => $weight];
}
/**
* Converts the score with the exercise_max_note and exercise_min_score
* the platform settings + formats the results using the float_format function.
@ -2778,18 +2803,10 @@ HOTSPOT;
return '-';
}
$maxNote = api_get_setting('exercise_max_score');
$minNote = api_get_setting('exercise_min_score');
if ($use_platform_settings) {
if ($maxNote != '' && $minNote != '') {
if (!empty($weight) && intval($weight) != 0) {
$score = $minNote + ($maxNote - $minNote) * $score / $weight;
} else {
$score = $minNote;
}
$weight = $maxNote;
}
$result = self::convertScoreToPlatformSetting($score, $weight);
$score = $result['score'];
$weight = $result['weight'];
}
$percentage = (100 * $score) / ($weight != 0 ? $weight : 1);
// Formats values

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -2,11 +2,8 @@
$(function () {
var parent$ = window.parent.$,
$player = parent$('audio#lp_audio_media_player_html5');
if ($player.length === 0) {
$player = parent$('audio#lp_audio_media_player');
}
playerSelector = '#' + parent$('mediaelementwrapper').attr('id') + '_html5',
$player = parent$(playerSelector);
var player = $player.get(0),
def = $.Deferred();

@ -412,9 +412,15 @@ class PDF
//Fixing only images @todo do the same thing with other elements
$elements = $doc->getElementsByTagName('img');
$protocol = api_get_protocol();
$replaced = [];
if (!empty($elements)) {
foreach ($elements as $item) {
$old_src = $item->getAttribute('src');
if (in_array($old_src, $replaced)) {
continue;
}
if (strpos($old_src, $protocol) === false) {
if (strpos($old_src, '/main/default_course_document') === false) {
if (strpos($old_src, '/main/inc/lib/') === false &&
@ -432,6 +438,7 @@ class PDF
);
$new_path = $document_path.$old_src_fixed;
$document_html = str_replace($old_src, $new_path, $document_html);
$replaced[] = $old_src;
}
}
}

@ -4184,7 +4184,9 @@ class SessionManager
if (empty($id)) {
return [];
}
$id = intval($id);
$id = (int) $id;
$urlId = empty($urlId) ? api_get_current_access_url_id() : (int) $urlId;
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@ -4207,8 +4209,6 @@ class SessionManager
ON (au.user_id = u.user_id)
";
$urlId = empty($urlId) ? api_get_current_access_url_id() : (int) $urlId;
if (is_numeric($status)) {
$status = (int) $status;
$sql .= " WHERE su.relation_type = $status AND (au.access_url_id = $urlId OR au.access_url_id is null)";
@ -4216,7 +4216,7 @@ class SessionManager
$sql .= " WHERE (au.access_url_id = $urlId OR au.access_url_id is null )";
}
$sql .= " ORDER BY su.relation_type, ";
$sql .= ' ORDER BY su.relation_type, ';
$sql .= api_sort_by_first_name() ? ' u.firstname, u.lastname' : ' u.lastname, u.firstname';
$result = Database::query($sql);

@ -674,9 +674,9 @@ class Statistics
}
/**
* Show some stats about the accesses to the different course tools.
* Get course tools usage statistics for the whole platform (by URL if multi-url).
*/
public static function printToolStats()
public static function getToolsStats()
{
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -724,6 +724,19 @@ class Statistics
$result[$tool_names[$obj->access_tool]] = $obj->number_of_logins;
}
return $result;
}
/**
* Show some stats about the accesses to the different course tools.
*
* @param array $result If defined, this serves as data. Otherwise, will get the data from getToolsStats()
*/
public static function printToolStats($result = null)
{
if (empty($result)) {
$result = self::getToolsStats();
}
self::printStats(get_lang('PlatformToolAccess'), $result, true);
}

@ -168,9 +168,9 @@ class UserManager
* @param bool $sendEmailToAllAdmins
* @param FormValidator $form
* @param int $creatorId
* @param array $emailTemplate
*
* @return mixed new user id - if the new user creation succeeds, false otherwise
*
* @desc The function tries to retrieve user id from the session.
* If it exists, the current user id is the creator id. If a problem arises,
* @assert ('Sam','Gamegie',5,'sam@example.com','jo','jo') > 1
@ -198,7 +198,8 @@ class UserManager
$address = '',
$sendEmailToAllAdmins = false,
$form = null,
$creatorId = 0
$creatorId = 0,
$emailTemplate = []
) {
$creatorId = empty($creatorId) ? api_get_user_id() : 0;
$hook = HookCreateUser::create();
@ -436,9 +437,7 @@ class UserManager
false,
false
);
$layoutSubject = $tplSubject->get_template(
'mail/subject_registration_platform.tpl'
);
$layoutSubject = $tplSubject->get_template('mail/subject_registration_platform.tpl');
$emailSubject = $tplSubject->fetch($layoutSubject);
$sender_name = api_get_person_name(
api_get_setting('administratorName'),
@ -477,6 +476,9 @@ class UserManager
$layoutContent = $tplContent->get_template('mail/content_registration_platform.tpl');
$emailBody = $tplContent->fetch($layoutContent);
$userInfo = api_get_user_info($userId);
$mailTemplateManager = new MailTemplateManager();
$phoneNumber = isset($extra['mobile_phone_number']) ? $extra['mobile_phone_number'] : null;
$additionalParameters = [
@ -486,11 +488,33 @@ class UserManager
'password' => $original_password,
];
$emailBodyTemplate = '';
if (!empty($emailTemplate)) {
if (isset($emailTemplate['content_registration_platform.tpl']) &&
!empty($emailTemplate['content_registration_platform.tpl'])
) {
$emailBodyTemplate = $mailTemplateManager->parseTemplate(
$emailTemplate['content_registration_platform.tpl'],
$userInfo
);
}
}
$twoEmail = api_get_configuration_value('send_two_inscription_confirmation_mail');
if ($twoEmail === true) {
$layoutContent = $tplContent->get_template('mail/new_user_first_email_confirmation.tpl');
$emailBody = $tplContent->fetch($layoutContent);
if (!empty($emailBodyTemplate) &&
isset($emailTemplate['new_user_first_email_confirmation.tpl']) &&
!empty($emailTemplate['new_user_first_email_confirmation.tpl'])
) {
$emailBody = $mailTemplateManager->parseTemplate(
$emailTemplate['new_user_first_email_confirmation.tpl'],
$userInfo
);
}
api_mail_html(
$recipient_name,
$email,
@ -507,6 +531,16 @@ class UserManager
$layoutContent = $tplContent->get_template('mail/new_user_second_email_confirmation.tpl');
$emailBody = $tplContent->fetch($layoutContent);
if (!empty($emailBodyTemplate) &&
isset($emailTemplate['new_user_second_email_confirmation.tpl']) &&
!empty($emailTemplate['new_user_second_email_confirmation.tpl'])
) {
$emailBody = $mailTemplateManager->parseTemplate(
$emailTemplate['new_user_second_email_confirmation.tpl'],
$userInfo
);
}
api_mail_html(
$recipient_name,
$email,
@ -520,6 +554,9 @@ class UserManager
$additionalParameters
);
} else {
if (!empty($emailBodyTemplate)) {
$emailBody = $emailBodyTemplate;
}
$sendToInbox = api_get_configuration_value('send_inscription_msg_to_inbox');
if ($sendToInbox) {
$adminList = self::get_all_administrators();
@ -587,6 +624,17 @@ class UserManager
$layoutContent = $tplContent->get_template('mail/content_registration_platform_to_admin.tpl');
$emailBody = $tplContent->fetch($layoutContent);
if (!empty($emailBodyTemplate) &&
isset($emailTemplate['content_registration_platform_to_admin.tpl']) &&
!empty($emailTemplate['content_registration_platform_to_admin.tpl'])
) {
$emailBody = $mailTemplateManager->parseTemplate(
$emailTemplate['content_registration_platform_to_admin.tpl'],
$userInfo
);
}
$subject = get_lang('UserAdded');
foreach ($adminList as $adminId => $data) {
@ -629,6 +677,7 @@ class UserManager
* @param int $user_id The user id
*
* @return bool true if user can be deleted
*
* @assert (null) === false
* @assert (-1) === false
* @assert ('abc') === false
@ -1027,6 +1076,7 @@ class UserManager
* @param bool $send_email Whether to send an e-mail to the user after the update is complete
* @param int $reset_password Method used to reset password (0, 1, 2 or 3 - see usage examples for details)
* @param string $address
* @param array $emailTemplate
*
* @return bool|int False on error, or the user ID if the user information was updated
* @assert (false, false, false, false, false, false, false, false, false, false, false, false, false) === false
@ -1052,7 +1102,8 @@ class UserManager
$encrypt_method = '',
$send_email = false,
$reset_password = 0,
$address = null
$address = null,
$emailTemplate = []
) {
$hook = HookUpdateUser::create();
if (!empty($hook)) {
@ -1175,47 +1226,51 @@ class UserManager
PERSON_NAME_EMAIL_ADDRESS
);
$email_admin = api_get_setting('emailAdministrator');
$url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url = api_get_access_url($access_url_id);
$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".
get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".
get_lang('Username')." : ".$username.(($reset_password > 0) ? "\n".
get_lang('Pass')." : ".stripslashes($original_password) : "")."\n\n".
get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".$url['url']."\n\n".
get_lang('Problem')."\n\n".
get_lang('SignatureFormula').",\n\n".
api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname')
)."\n".
get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".
get_lang('Email')." : ".api_get_setting('emailAdministrator');
$url = $url['url'];
}
} else {
$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".
get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".
get_lang('Username')." : ".$username.(($reset_password > 0) ? "\n".
get_lang('Pass')." : ".stripslashes($original_password) : "")."\n\n".
get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)."\n\n".
get_lang('Problem')."\n\n".
get_lang('SignatureFormula').",\n\n".
api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname')
)."\n".
get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".
get_lang('Email')." : ".api_get_setting('emailAdministrator');
}
$emailbody = nl2br($emailbody);
$tplContent = new Template(
null,
false,
false,
false,
false,
false
);
// variables for the default template
$tplContent->assign('complete_name', stripslashes(api_get_person_name($firstname, $lastname)));
$tplContent->assign('login_name', $username);
$originalPassword = '';
if ($reset_password > 0) {
$originalPassword = stripslashes($original_password);
}
$tplContent->assign('original_password', $originalPassword);
$tplContent->assign('portal_url', $url);
$layoutContent = $tplContent->get_template('mail/user_edit_content.tpl');
$emailBody = $tplContent->fetch($layoutContent);
$mailTemplateManager = new MailTemplateManager();
if (!empty($emailTemplate) &&
isset($emailTemplate['user_edit_content.tpl']) &&
!empty($emailTemplate['user_edit_content.tpl'])
) {
$userInfo = api_get_user_info($user_id);
$emailBody = $mailTemplateManager->parseTemplate($emailTemplate['user_edit_content.tpl'], $userInfo);
}
api_mail_html(
$recipient_name,
$email,
$emailsubject,
$emailbody,
$emailBody,
$sender_name,
$email_admin
);

@ -2029,6 +2029,14 @@ class learnpath
}
}
$hideArrows = false;
if (isset($settings['display']) && isset($settings['display']['hide_lp_arrow_navigation'])) {
$hideArrows = $settings['display']['hide_lp_arrow_navigation'];
}
$previousIcon = '';
$nextIcon = '';
if ($hideArrows === false) {
$previousIcon = '
<a class="icon-toolbar" id="scorm-previous" href="#"
onclick="switch_item('.$mycurrentitemid.',\'previous\');return false;" title="'.$previousText.'">
@ -2040,8 +2048,9 @@ class learnpath
onclick="switch_item('.$mycurrentitemid.',\'next\');return false;" title="'.$nextText.'">
<span class="fa fa-chevron-right"></span><span class="sr-only">'.$nextText.'</span>
</a>';
}
if ($this->mode == 'fullscreen') {
if ($this->mode === 'fullscreen') {
$navbar = '
<span id="'.$idBar.'" class="buttons">
'.$reportingIcon.'
@ -13795,6 +13804,8 @@ EOD;
false
);
$courseBuilder->restoreDocumentsFromList();
$zipFile = CourseArchiver::createBackup($courseBuilder->course);
$zipPath = CourseArchiver::getBackupDir().$zipFile;
$result = DocumentManager::file_send_for_download(

@ -2582,6 +2582,24 @@ class learnpathItem
}
}
return $returnstatus;
} elseif ($itemToCheck->type === 'student_publication') {
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$workId = $items[$refs_list[$prereqs_string]]->path;
$count = get_work_count_by_student($user_id, $workId);
if ($count >= 1) {
$returnstatus = true;
} else {
$returnstatus = false;
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
if (self::DEBUG > 1) {
error_log(
'Student pub, prereq'.$prereqs_string.' not completed',
0
);
}
}
return $returnstatus;
} else {
$status = $itemToCheck->get_status(false);

@ -52,13 +52,12 @@ if ($myLP) {
$mediaplayer = $myLP->get_mediaplayer($lpItemId, $autostart);
if ($mediaplayer) {
echo $mediaplayer; ?>
<script>
echo $mediaplayer;
echo "<script>
$(function() {
jQuery('video:not(.skip), audio:not(.skip)').mediaelementplayer();
});
</script>
<?php
</script>";
}
}
session_write_close();

@ -16,8 +16,8 @@ $current_course_tool = TOOL_LEARNPATH;
api_protect_course_script(true);
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$lpId = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : 0;
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$lpId = isset($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0;
$courseInfo = api_get_course_info();
$courseCode = $courseInfo['code'];
$courseId = $courseInfo['real_id'];

@ -1,9 +1,10 @@
186,206,151,100
171,70,67,100
221,133,61,100
255,235,141,100
210,148,147,100
114,88,144,100
148,170,208,100
221,133,61,100
186,206,151,100
65,153,176,100
114,88,144,100
138,166,78,100
171,70,67,100
69,115,168,100

@ -26,25 +26,25 @@ $sessionUrl = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session
$htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[] = [
'url' => "session_list.php",
"name" => get_lang('SessionList'),
'url' => 'session_list.php',
'name' => get_lang('SessionList'),
];
$interbreadcrumb[] = [
'url' => $sessionUrl,
"name" => get_lang('SessionOverview'),
'name' => get_lang('SessionOverview'),
];
if ($action == 'add') {
$interbreadcrumb[] = [
'url' => api_get_self()."?session_id=".$sessionId,
"name" => get_lang('ScheduledAnnouncements'),
'url' => api_get_self().'?session_id='.$sessionId,
'name' => get_lang('ScheduledAnnouncements'),
];
$tool_name = get_lang('Add');
} elseif ($action == 'edit') {
$tool_name = get_lang('Edit');
$interbreadcrumb[] = [
'url' => api_get_self()."?session_id=".$sessionId,
"name" => get_lang('ScheduledAnnouncements'),
'url' => api_get_self().'?session_id='.$sessionId,
'name' => get_lang('ScheduledAnnouncements'),
];
} else {
$tool_name = get_lang('ScheduledAnnouncements');

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use ChamiloSession as Session;
/**
@ -8,15 +9,20 @@ use ChamiloSession as Session;
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$courseId = api_get_course_id();
$courseInfo = api_get_course_info($courseId);
$course_code = $courseCode = $courseInfo['code'];
$session_id = $sessionId = api_get_session_id();
$courseInfo = api_get_course_info(api_get_course_id());
$courseCode = $courseInfo['code'];
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = isset($_REQUEST['id_session']) ? (int) $_REQUEST['id_session'] : 0;
$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
$htmlHeadXtra[] = ' ';
$this_section = SECTION_COURSES;
if ($from == 'myspace') {
@ -65,7 +71,7 @@ if (api_is_drh()) {
// then check if he has also been given access to the corresponding courses
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$coursesFollowedList = array_keys($coursesFollowedList);
if (!in_array(api_get_course_id(), $coursesFollowedList)) {
if (!in_array($courseId, $coursesFollowedList)) {
api_not_allowed(true);
exit;
}
@ -86,6 +92,7 @@ if (!empty($columnsToHideFromSetting) && isset($columnsToHideFromSetting['column
$columnsToHide = json_encode($columnsToHide);
$csv_content = [];
// Scripts for reporting array hide/show columns
$js = "<script>
// hide column and display the button to unhide it
@ -136,8 +143,6 @@ $TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
$sessionId = api_get_session_id();
// Breadcrumbs.
if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = [
@ -157,22 +162,26 @@ if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$view = isset($_REQUEST['view']) ? $_REQUEST['view'] : '';
$nameTools = get_lang('Tracking');
// getting all the students of the course
$tpl = new Template($nameTools);
// getting all the students of the course
if (empty($session_id)) {
// Registered students in a course outside session.
$a_students = CourseManager::get_student_list_from_course_code(
api_get_course_id()
$courseId
);
} else {
// Registered students in session.
$a_students = CourseManager::get_student_list_from_course_code(
api_get_course_id(),
$courseId,
true,
$sessionId
);
}
$nbStudents = count($a_students);
$user_ids = array_keys($a_students);
$extra_info = [];
$userProfileInfo = [];
// Getting all the additional information of an additional profile field.
@ -243,6 +252,7 @@ echo Display::toolbarAction(
);
$course_name = get_lang('Course').' '.$courseInfo['name'];
if ($session_id) {
$titleSession = Display::return_icon(
'session.png',
@ -330,6 +340,84 @@ if ($showReporting) {
}
}
// Show the charts part only if there are students subscribed to this course/session
if ($nbStudents > 0) {
$usersTracking = TrackingCourseLog::get_user_data(null, $nbStudents, null, 'DESC');
$numberStudentsCompletedLP = 0;
$averageStudentsTestScore = 0;
$scoresDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$userScoreList = [];
$listStudentIds = [];
$timeStudent = [];
$certificateCount = 0;
$category = Category::load(
null,
null,
$course_code,
null,
null,
$session_id
);
foreach ($usersTracking as $userTracking) {
$userId = UserManager::get_user_id_from_username($userTracking[3]);
if ($userTracking[5] === '100%') {
$numberStudentsCompletedLP++;
}
$averageStudentTestScore = substr($userTracking[7], 0, -1);
$averageStudentsTestScore += $averageStudentTestScore;
if ($averageStudentTestScore === '100') {
$reducedAverage = 9;
} else {
$reducedAverage = floor($averageStudentTestScore / 10);
}
if (isset($scoresDistribution[$reducedAverage])) {
$scoresDistribution[$reducedAverage]++;
}
$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],
'score' => floor($scoreStudent / 2),
'total_time' => $minutes,
'avatar' => UserManager::getUserPicture($userId),
'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));
$tpl->assign('json_time_student', json_encode($userScoreList));
$tpl->assign('students_test_score', $averageStudentsTestScore);
$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;
}
$html .= Display::page_subheader2(get_lang('StudentList'));
// PERSON_NAME_DATA_EXPORT is buggy
@ -386,12 +474,13 @@ if (count($a_students) > 0) {
$all_datas = [];
$course_code = $_course['id'];
$user_ids = array_keys($a_students);
$table = new SortableTable(
'users_tracking',
['TrackingCourseLog', 'get_number_of_users'],
['TrackingCourseLog', 'get_user_data'],
function () use ($usersTracking) {
return $usersTracking;
},
1
);
@ -400,6 +489,7 @@ if (count($a_students) > 0) {
$parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null;
$table->set_additional_parameters($parameters);
$headers = [];
// tab of header texts
$table->set_header(0, get_lang('OfficialCode'), true);
@ -559,3 +649,8 @@ if ($export_csv) {
exit;
}
Display::display_footer();
function sort_by_order($a, $b)
{
return $a['score'] <= $b['score'];
}

@ -14,6 +14,11 @@ if (empty($workId)) {
api_not_allowed(true);
}
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if ($blockAddDocuments) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);

@ -6,6 +6,12 @@ $current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
api_not_allowed(true);
}
// Including files
require_once 'work.lib.php';

@ -14,6 +14,12 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();

@ -44,21 +44,23 @@ $token = Security::get_token();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
// @todo add an option to allow/block multiple attempts.
/*
if (!empty($workInfo) && !empty($workInfo['qualification'])) {
if ($onlyOnePublication) {
$count = get_work_count_by_student($user_id, $work_id);
if ($count >= 1) {
Display::display_header();
api_not_allowed(true);
/*Display::display_header();
if (api_get_course_setting('student_delete_own_publication') == '1') {
echo Display::return_message(get_lang('CantUploadDeleteYourPaperFirst'), 'warning');
} else {
echo Display::return_message(get_lang('YouAlreadySentAPaperYouCantUpload'), 'warning');
}
Display::display_footer();
exit;
exit;*/
}
}
}*/
$homework = get_work_assignment_by_id($workInfo['id']);
$validationStatus = getWorkDateValidationStatus($homework);

@ -28,6 +28,12 @@ $interbreadcrumb[] = [
$my_folder_data = get_work_data_by_id($work['parent_id']);
$courseInfo = api_get_course_info();
$blockScoreEdition = api_get_configuration_value('block_student_publication_score_edition');
if ($blockScoreEdition && !empty($work['qualification']) && !api_is_platform_admin()) {
api_not_allowed(true);
}
protectWork(api_get_course_info(), $work['parent_id']);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
@ -130,6 +136,11 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
}
}
$blockScoreEdition = api_get_configuration_value('block_student_publication_score_edition');
if ($blockScoreEdition && !api_is_platform_admin()) {
$url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$my_folder_data['id'];
}
header('Location: '.$url);
exit;
break;

@ -1404,6 +1404,7 @@ function getWorkListTeacher(
}
$url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq();
$blockEdition = api_get_configuration_value('block_student_publication_edition');
while ($work = Database::fetch_array($result, 'ASSOC')) {
$workId = $work['id'];
$work['type'] = Display::return_icon('work.png');
@ -1456,10 +1457,14 @@ function getWorkListTeacher(
$work['title'] .= ' '.Display::label(get_count_work($work['id']), 'success');
$work['sent_date'] = api_get_local_time($work['sent_date']);
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
} else {
$editLink = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL),
api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq()
);
}
$correctionLink = '&nbsp;'.Display::url(
Display::return_icon('upload_package.png', get_lang('UploadCorrections'), '', ICON_SIZE_SMALL),
@ -1932,6 +1937,9 @@ function get_work_user_list(
ICON_SIZE_SMALL
);
$blockEdition = api_get_configuration_value('block_student_publication_edition');
$blockScoreEdition = api_get_configuration_value('block_student_publication_score_edition');
while ($work = Database::fetch_array($result, 'ASSOC')) {
$item_id = $work['id'];
// Get the author ID for that document from the item_property table
@ -2015,7 +2023,10 @@ function get_work_user_list(
if ($qualification_exists) {
$feedback .= ' ';
}
$feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
$feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang(
'View'
).'">'.
$count.' '.Display::returnFontAwesomeIcon('comments-o').'</a> ';
}
@ -2049,9 +2060,13 @@ function get_work_user_list(
// Actions.
$action = '';
if (api_is_allowed_to_edit()) {
$action .= '<a
href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'"
title="'.get_lang('View').'">'.$rateIcon.'</a> ';
if ($blockScoreEdition && !api_is_platform_admin() && !empty($work['qualification_score'])) {
$rateLink = '';
} else {
$rateLink = '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
$rateIcon.'</a> ';
}
$action .= $rateLink;
if ($unoconv && empty($work['contains_file'])) {
$action .= '<a f
@ -2125,15 +2140,26 @@ function get_work_user_list(
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Comment'), [], ICON_SIZE_SMALL);
}
} else {
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
} else {
if ($qualification_exists) {
$action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Edit').'" >'.
$editLink = '<a href="'.$url.'edit.php?'.api_get_cidreq(
).'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang(
'Edit'
).'" >'.
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
$editLink = '<a href="'.$url.'edit.php?'.api_get_cidreq(
).'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang(
'Modify'
).'">'.
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>';
}
}
$action .= $editLink;
}
if ($work['contains_file']) {
if ($locked) {

@ -69,6 +69,7 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsRight = '';
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
$url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId;
$actionsRight = Display::url(
@ -83,6 +84,17 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_in
);
}
if ($onlyOnePublication) {
$count = get_work_count_by_student(
api_get_user_id(),
$my_folder_data['id']
);
if (!empty($count) && $count >= 1) {
$actionsRight = '';
}
}
$tpl = new Template('');
$content = Display::toolbarAction('toolbar-work', [$actionsLeft, $actionsRight]);

@ -169,8 +169,12 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if (!$blockAddDocuments) {
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('addworkuser.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
@ -181,8 +185,14 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
$display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$editLink .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
}
$actionsLeft .= $editLink;
$count = get_count_work($workId);
if ($count > 0) {

Loading…
Cancel
Save