Course home changes

- Tool images moved inside public/img/tools
- New tool_id in c_tool table
- Load courses tools with entities
- Disabled course notifications
pull/3064/head
Julio 5 years ago
parent a34f18afe3
commit 5b8ae57de9
  1. BIN
      public/img/tools/agenda.png
  2. BIN
      public/img/tools/agenda_na.png
  3. BIN
      public/img/tools/announcement.png
  4. BIN
      public/img/tools/announcement_na.png
  5. BIN
      public/img/tools/attendance.png
  6. BIN
      public/img/tools/attendance_na.png
  7. BIN
      public/img/tools/blog.png
  8. BIN
      public/img/tools/blog_na.png
  9. BIN
      public/img/tools/chat.png
  10. BIN
      public/img/tools/chat_na.png
  11. BIN
      public/img/tools/courese_description_na.png
  12. BIN
      public/img/tools/course_description.png
  13. BIN
      public/img/tools/course_maintenance.png
  14. BIN
      public/img/tools/course_maintenance_na.png
  15. BIN
      public/img/tools/course_progress.png
  16. BIN
      public/img/tools/course_progress_na.png
  17. BIN
      public/img/tools/course_setting.png
  18. BIN
      public/img/tools/course_setting_na.png
  19. BIN
      public/img/tools/document.png
  20. BIN
      public/img/tools/document_na.png
  21. BIN
      public/img/tools/dropbox.png
  22. BIN
      public/img/tools/dropbox_na.png
  23. BIN
      public/img/tools/forum.png
  24. BIN
      public/img/tools/forum_na.png
  25. BIN
      public/img/tools/glossary.png
  26. BIN
      public/img/tools/glossary_na.png
  27. BIN
      public/img/tools/gradebook.png
  28. BIN
      public/img/tools/gradebook_na.png
  29. BIN
      public/img/tools/group.png
  30. BIN
      public/img/tools/group_na.png
  31. BIN
      public/img/tools/learnpath.png
  32. BIN
      public/img/tools/learnpath_na.png
  33. BIN
      public/img/tools/link.png
  34. BIN
      public/img/tools/links_na.png
  35. BIN
      public/img/tools/member.png
  36. BIN
      public/img/tools/member_Na.png
  37. BIN
      public/img/tools/notebook.png
  38. BIN
      public/img/tools/notebook_na.png
  39. BIN
      public/img/tools/quiz.png
  40. BIN
      public/img/tools/quiz_na.png
  41. BIN
      public/img/tools/statistics_na.png
  42. BIN
      public/img/tools/student_publication.png
  43. BIN
      public/img/tools/student_publication_na.png
  44. BIN
      public/img/tools/survey.png
  45. BIN
      public/img/tools/survey_na.png
  46. BIN
      public/img/tools/tracking.png
  47. BIN
      public/img/tools/wiki.png
  48. BIN
      public/img/tools/wiki_na.png
  49. 776
      public/main/inc/lib/course_home.lib.php
  50. 43
      public/main/inc/lib/display.lib.php
  51. 195
      src/CoreBundle/Controller/CourseHomeController.php
  52. 1
      src/CoreBundle/Controller/ResourceController.php
  53. 3
      src/CoreBundle/Entity/Listener/CourseListener.php
  54. 4
      src/CoreBundle/Entity/Tool.php
  55. 102
      src/CoreBundle/Resources/config/tools.yml
  56. 23
      src/CoreBundle/ToolChain.php
  57. 309
      src/CourseBundle/Entity/CTool.php
  58. 89
      src/ThemeBundle/Resources/views/Course/home.html.twig

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

@ -1,8 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Entity\CLpCategory;
use Chamilo\CourseBundle\Entity\CTool;
use Doctrine\Common\Collections\Criteria;
/**
* Class CourseHome.
@ -14,7 +16,8 @@ class CourseHome
* by show_tools_category().
*
* @param string $course_tool_category contains the category of tools to
* display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform", "toolplugin"
* display: "toolauthoring", "toolinteraction", "tooladmin",
* "tooladminplatform", "toolplugin"
* @param int $courseId Optional
* @param int $sessionId Optional
*
@ -42,291 +45,79 @@ class CourseHome
't.session_id'
);
$lpTable = Database::get_course_table(TABLE_LP_MAIN);
$tblLpCategory = Database::get_course_table(TABLE_LP_CATEGORY);
$studentView = api_is_student_view_active();
$orderBy = ' ORDER BY id ';
$em = Database::getManager();
$repo = $em->getRepository('ChamiloCourseBundle:CTool');
$qb = $repo->createQueryBuilder('tool');
$criteria = \Doctrine\Common\Collections\Criteria::create();
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
$conditions = ' WHERE visibility = 1 AND
(category = "authoring" OR category = "interaction" OR category = "plugin") AND
t.name <> "notebookteacher" ';
if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && !$studentView) {
$criteria
->where(Criteria::expr()->eq('visibility', 1))
->andWhere(Criteria::expr()->in('category', ['authoring', 'interaction']))
;
/*if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && !$studentView) {
$conditions = ' WHERE (
visibility = 1 AND (
category = "authoring" OR
category = "interaction" OR
category = "authoring" OR
category = "interaction" OR
category = "plugin"
) OR (t.name = "'.TOOL_TRACKING.'")
) OR (t.name = "'.TOOL_TRACKING.'")
)';
}
// Add order if there are LPs
$sql = "SELECT t.* FROM $course_tool_table t
LEFT JOIN $lpTable l
ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%'))
LEFT JOIN $tblLpCategory lc
ON (t.c_id = lc.c_id AND l.category_id = lc.iid)
$conditions AND
t.c_id = $course_id $condition_session
ORDER BY
CASE WHEN l.category_id IS NULL THEN 0 ELSE 1 END,
CASE WHEN l.display_order IS NULL THEN 0 ELSE 1 END,
lc.position,
l.display_order,
t.id";
$orderBy = '';
}*/
break;
case TOOL_AUTHORING:
$sql = "SELECT t.* FROM $course_tool_table t
LEFT JOIN $lpTable l
ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%'))
LEFT JOIN $tblLpCategory lc
ON (t.c_id = lc.c_id AND l.category_id = lc.iid)
WHERE
category = 'authoring' AND t.c_id = $course_id $condition_session
ORDER BY
CASE WHEN l.category_id IS NULL THEN 0 ELSE 1 END,
CASE WHEN l.display_order IS NULL THEN 0 ELSE 1 END,
lc.position,
l.display_order,
t.id";
$orderBy = '';
$criteria
->where(Criteria::expr()->in('category', ['authoring']))
;
break;
case TOOL_INTERACTION:
$sql = "SELECT * FROM $course_tool_table t
WHERE category = 'interaction' AND c_id = $course_id $condition_session
";
$criteria
->where(Criteria::expr()->in('category', ['interaction']))
;
break;
case TOOL_ADMIN_VISIBLE:
$sql = "SELECT * FROM $course_tool_table t
WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session
";
$criteria
->where(Criteria::expr()->eq('visibility', 1))
->andWhere(Criteria::expr()->in('category', ['admin']))
;
break;
case TOOL_ADMIN_PLATFORM:
$sql = "SELECT * FROM $course_tool_table t
WHERE category = 'admin' AND c_id = $course_id $condition_session
";
$criteria
->andWhere(Criteria::expr()->in('category', ['admin']))
;
break;
case TOOL_DRH:
$sql = "SELECT * FROM $course_tool_table t
WHERE t.name IN ('tracking') AND c_id = $course_id $condition_session
";
$criteria
->andWhere(Criteria::expr()->in('tool.tool.name', ['tracking']))
;
break;
case TOOL_COURSE_PLUGIN:
/*case TOOL_COURSE_PLUGIN:
//Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id
// but plugins are not present in the tool table, only globally and inside the course_settings table once configured
$sql = "SELECT * FROM $course_tool_table t
WHERE category = 'plugin' AND name <> 'courseblock' AND c_id = $course_id $condition_session
";
";*/
break;
}
$sql .= $orderBy;
$result = Database::query($sql);
$tools = [];
while ($row = Database::fetch_assoc($result)) {
$tools[] = $row;
}
// Get the list of hidden tools - this might imply performance slowdowns
// if the course homepage is loaded many times, so the list of hidden
// tools might benefit from a shared memory storage later on
$list = api_get_settings('Tools', 'list', api_get_current_access_url_id());
$hide_list = [];
$check = false;
foreach ($list as $line) {
// Admin can see all tools even if the course_hide_tools configuration is set
if ($is_platform_admin) {
continue;
}
if ($line['variable'] == 'course_hide_tools' && $line['selected_value'] == 'true') {
$hide_list[] = $line['subkey'];
$check = true;
}
}
$allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
// If exists same tool (by name) from session in base course then avoid it. Allow them pass in other cases
$tools = array_filter($tools, function (array $toolToFilter) use ($sessionId, $tools) {
if (!empty($toolToFilter['session_id'])) {
foreach ($tools as $originalTool) {
if ($toolToFilter['name'] == $originalTool['name'] && empty($originalTool['session_id'])) {
return false;
}
}
}
return true;
});
$criteria
->andWhere(Criteria::expr()->eq('course', api_get_course_entity($courseId)))
;
foreach ($tools as $temp_row) {
$add = false;
if ($check) {
if (!in_array($temp_row['name'], $hide_list)) {
$add = true;
}
} else {
$add = true;
}
//$condition_session = $condition_add." ( $session_field = $session_id OR $session_field = 0 OR $session_field IS NULL) ";
/*$criteria
->andWhere(Criteria::expr()->eq('session', $courseId))
;*/
if ($allowEditionInSession && !empty($sessionId)) {
// Checking if exist row in session
$criteria = [
'course' => $course_id,
'name' => $temp_row['name'],
'sessionId' => $sessionId,
];
/** @var CTool $toolObj */
$toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria);
if ($toolObj) {
if (api_is_allowed_to_edit() == false && $toolObj->getVisibility() == false) {
continue;
}
}
}
$qb->addCriteria($criteria);
switch ($temp_row['image']) {
case 'scormbuilder.gif':
$lpId = self::getPublishedLpIdFromLink($temp_row['link']);
$lp = new learnpath(
api_get_course_id(),
$lpId,
$userId
);
$path = $lp->get_preview_image_path(ICON_SIZE_BIG);
if (api_is_allowed_to_edit(null, true)) {
$add = true;
} else {
$add = learnpath::is_lp_visible_for_student(
$lpId,
$userId,
$courseInfo,
$sessionId
);
}
if ($path) {
$temp_row['custom_image'] = $path;
}
break;
case 'lp_category.gif':
$lpCategory = self::getPublishedLpCategoryFromLink(
$temp_row['link']
);
$add = learnpath::categoryIsVisibleForStudent(
$lpCategory,
$user
);
break;
}
if ($add) {
$all_tools_list[] = $temp_row;
}
}
// Grabbing all the links that have the property on_homepage set to 1
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$condition_session = api_get_session_condition(
$sessionId,
true,
true,
'tip.session_id'
);
switch ($course_tool_category) {
case TOOL_AUTHORING:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tip.ref=tl.id
WHERE
tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage='1' $condition_session";
break;
case TOOL_INTERACTION:
$sql_links = null;
/*
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' ";
*/
break;
case TOOL_STUDENT_VIEW:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tip.ref=tl.id
WHERE
tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage ='1' $condition_session";
break;
case TOOL_ADMIN:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tip.ref=tl.id
WHERE
tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage='1' $condition_session";
break;
default:
$sql_links = null;
break;
}
// Edited by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
if ($sql_links != null) {
$result_links = Database::query($sql_links);
if (Database::num_rows($result_links) > 0) {
while ($links_row = Database::fetch_array($result_links, 'ASSOC')) {
$properties = [];
$properties['name'] = $links_row['title'];
$properties['session_id'] = $links_row['session_id'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['image'] = $links_row['visibility'] == '0' ? 'file_html.png' : 'file_html.png';
$properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
$properties['target'] = $links_row['target'];
$tmp_all_tools_list[] = $properties;
}
}
}
if (isset($tmp_all_tools_list)) {
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
foreach ($tmp_all_tools_list as $tool) {
if ($tool['image'] == 'blog.gif') {
// Get blog id
$blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link']));
// Get blog members
if ($is_platform_admin) {
$sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id = ".$blog_id;
} else {
$sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id = ".$blog_id." AND user_id = ".$userId;
}
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$all_tools_list[] = $tool;
}
} else {
$all_tools_list[] = $tool;
}
}
}
$list = self::filterPluginTools($all_tools_list, $course_tool_category);
return $list;
return $qb->getQuery()->getResult();
}
/**
@ -336,30 +127,13 @@ class CourseHome
*
* @return array
*/
public static function show_tools_category($all_tools_list)
public static function show_tools_category($all_tools_list, ToolChain $toolChain)
{
$_user = api_get_user_info();
$theme = api_get_setting('homepage_view');
if ($theme === 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = [];
if (is_array($all_tools_list) && count($all_tools_list) > 0) {
foreach ($all_tools_list as $key => $new_tool) {
$tool_name = self::translate_tool_name($new_tool);
$order_tool_list[$key] = $tool_name;
}
natsort($order_tool_list);
$my_temp_tool_array = [];
foreach ($order_tool_list as $key => $new_tool) {
$my_temp_tool_array[] = $all_tools_list[$key];
}
$all_tools_list = $my_temp_tool_array;
} else {
$all_tools_list = [];
}
if (empty($all_tools_list)) {
return [];
}
$web_code_path = api_get_path(WEB_CODE_PATH);
$_user = api_get_user_info();
$session_id = api_get_session_id();
$is_platform_admin = api_is_platform_admin();
$allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
@ -372,108 +146,52 @@ class CourseHome
}
}
$items = [];
$app_plugin = new AppPlugin();
if (isset($all_tools_list)) {
$lnk = '';
foreach ($all_tools_list as &$tool) {
$item = [];
$studentview = false;
$tool['original_link'] = $tool['link'];
if ($tool['image'] === 'scormbuilder.gif') {
// Check if the published learnpath is visible for student
$lpId = self::getPublishedLpIdFromLink($tool['link']);
if (api_is_allowed_to_edit(null, true)) {
$studentview = true;
/** @var CTool $tool */
foreach ($all_tools_list as $tool) {
$item = [];
$studentview = false;
$toolAdmin = false;
$toolModel = $toolChain->getToolFromName($tool->getTool()->getName());
if ($is_allowed_to_edit) {
if (empty($session_id)) {
if ($tool->getVisibility() == '1' && $toolAdmin != '1') {
$link['name'] = Display::return_icon(
'visible.png',
get_lang('Deactivate'),
['id' => 'linktool_'.$tool->getIid()],
ICON_SIZE_SMALL,
false
);
}
if (!api_is_allowed_to_edit(null, true) &&
!learnpath::is_lp_visible_for_student(
$lpId,
api_get_user_id(),
api_get_course_info(),
api_get_session_id()
)
) {
continue;
if ($tool->getVisibility() == '0' && $toolAdmin != '1') {
$link['name'] = Display::return_icon(
'invisible.png',
get_lang('Activate'),
['id' => 'linktool_'.$tool->getIid()],
ICON_SIZE_SMALL,
false
);
}
}
if ($session_id != 0 && in_array($tool['name'], ['course_setting'])) {
continue;
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
$item['extra'] = null;
$toolAdmin = isset($tool['admin']) ? $tool['admin'] : '';
if ($is_allowed_to_edit) {
if (empty($session_id)) {
if (isset($tool['id'])) {
if ($tool['visibility'] == '1' && $toolAdmin != '1') {
$link['name'] = Display::return_icon(
'visible.png',
get_lang('Deactivate'),
['id' => 'linktool_'.$tool['iid']],
ICON_SIZE_SMALL,
false
);
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
}
if ($tool['visibility'] == '0' && $toolAdmin != '1') {
$link['name'] = Display::return_icon(
'invisible.png',
get_lang('Activate'),
['id' => 'linktool_'.$tool['iid']],
ICON_SIZE_SMALL,
false
);
$link['cmd'] = 'restore=yes';
$lnk[] = $link;
}
}
} elseif ($allowEditionInSession) {
$criteria = [
'course' => api_get_course_int_id(),
'name' => $tool['name'],
'sessionId' => $session_id,
];
/** @var CTool $tool */
$toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria);
if ($toolObj) {
$visibility = (int) $toolObj->getVisibility();
switch ($visibility) {
case '0':
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']);
$tool['image'] = $basename.'_na.'.$info['extension'];
$link['name'] = Display::return_icon(
'invisible.png',
get_lang('Activate'),
['id' => 'linktool_'.$tool['iid']],
ICON_SIZE_SMALL,
false
);
$link['cmd'] = 'restore=yes';
$lnk[] = $link;
break;
case '1':
$link['name'] = Display::return_icon(
'visible.png',
get_lang('Deactivate'),
['id' => 'linktool_'.$tool['iid']],
ICON_SIZE_SMALL,
false
);
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
break;
}
} else {
} elseif ($allowEditionInSession) {
$visibility = (int) $tool->getVisibility();
switch ($visibility) {
case '0':
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']);
$tool['image'] = $basename.'_na.'.$info['extension'];
$link['name'] = Display::return_icon(
'invisible.png',
get_lang('Activate'),
['id' => 'linktool_'.$tool['iid']],
ICON_SIZE_SMALL,
false
);
$link['cmd'] = 'restore=yes';
$lnk[] = $link;
break;
case '1':
$link['name'] = Display::return_icon(
'visible.png',
get_lang('Deactivate'),
@ -483,185 +201,76 @@ class CourseHome
);
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
}
}
if (!empty($tool['adminlink'])) {
$item['extra'] = '<a href="'.$tool['adminlink'].'">'.
Display::return_icon('edit.gif', get_lang('Edit')).
'</a>';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($toolAdmin != '1') {
$link['cmd'] = 'hide=yes';
break;
}
}
}
$item['visibility'] = '';
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($tool['adminlink'])) {
$item['visibility'] .=
'<a class="make_visible_and_invisible" href="'.api_get_self().'?'.api_get_cidreq().'&id='.$tool['iid'].'&'.$this_link['cmd'].'">'.
$this_link['name'].'</a>';
}
}
}
// NOTE : Table contains only the image file name, not full path
if (stripos($tool['link'], 'http://') === false &&
stripos($tool['link'], 'https://') === false &&
stripos($tool['link'], 'ftp://') === false
) {
$tool['link'] = $web_code_path.$tool['link'];
}
$class = '';
if ($tool['visibility'] == '0' && $toolAdmin != '1') {
$class = 'text-muted';
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']);
$tool['image'] = $basename.'_na.'.$info['extension'];
}
$qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
// If it's a link, we don't add the cidReq
if ($tool['image'] === 'file_html.png' || $tool['image'] === 'file_html_na.png') {
$tool['link'] = $tool['link'];
} else {
$tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
}
$toolIid = isset($tool['iid']) ? $tool['iid'] : null;
//@todo this visio stuff should be removed
if (strpos($tool['name'], 'visio_') !== false) {
$tool_link_params = [
'id' => 'tooldesc_'.$toolIid,
'href' => '"javascript: void(0);"',
'class' => $class,
'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')',
'target' => $tool['target'],
];
} elseif (strpos($tool['name'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window')
) {
$tool_link_params = [
'id' => 'tooldesc_'.$toolIid,
'class' => $class,
'href' => 'javascript: void(0);',
'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', //Chat Open Windows
'target' => $tool['target'],
];
} else {
$tool_link_params = [
'id' => 'tooldesc_'.$toolIid,
'href' => $tool['link'],
'class' => $class,
'target' => $tool['target'],
];
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($toolAdmin != '1') {
$link['cmd'] = 'hide=yes';
}
}
$tool_name = self::translate_tool_name($tool);
// Including Courses Plugins
// Creating title and the link
if (isset($tool['category']) && $tool['category'] == 'plugin') {
$plugin_info = $app_plugin->getPluginInfo($tool['name']);
if (isset($plugin_info) && isset($plugin_info['title'])) {
$tool_name = $plugin_info['title'];
}
$item['visibility'] = '';
if (!file_exists(api_get_path(SYS_CODE_PATH).'img/'.$tool['image']) &&
!file_exists(api_get_path(SYS_CODE_PATH).'img/icons/64/'.$tool['image'])) {
$tool['image'] = 'plugins.png';
}
$tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH)
.$tool['original_link'].$qm_or_amp.api_get_cidreq();
}
$class = '';
if ($tool->getVisibility() == '0' && $toolAdmin != '1') {
$class = 'text-muted';
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']);
$tool['image'] = $basename.'_na.'.$info['extension'];
}
// Use in the course home
$icon = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_BIG,
false
);
$toolIid = $tool->getIid();
// Used in the top bar
$iconMedium = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_MEDIUM,
false
);
$tool_link_params = [
'id' => 'tooldesc_'.$toolIid,
'href' => $toolModel->getLink().'?'.api_get_cidreq(),
'class' => $class,
];
// Used for vertical navigation
$iconSmall = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-img', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_SMALL,
false
);
$tool_name = $tool->getTool()->getName();
/*if (!empty($tool['custom_icon'])) {
$image = self::getCustomWebIconPath().$tool['custom_icon'];
$icon = Display::img(
$image,
$tool['description'],
array(
'class' => 'tool-icon',
'id' => 'toolimage_'.$tool['id']
)
);
}*/
$image = 'admin.png';
// Use in the course home
$icon = Display::return_icon(
$image,
$tool_name,
['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_BIG,
false
);
// Validation when belongs to a session
// Validation when belongs to a session
$session_img = '';
if (!empty($tool->getSession())) {
$session_img = api_get_session_image(
$tool['session_id'],
$tool->getSession()->getId(),
!empty($_user['status']) ? $_user['status'] : ''
);
if ($studentview) {
$tool_link_params['href'] .= '&isStudentView=true';
}
$item['url_params'] = $tool_link_params;
$item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
$item['only_icon'] = $icon;
$item['only_icon_medium'] = $iconMedium;
$item['only_icon_small'] = $iconSmall;
$item['only_href'] = $tool_link_params['href'];
$item['tool'] = $tool;
$item['name'] = $tool_name;
$tool_link_params['id'] = 'is'.$tool_link_params['id'];
$item['link'] = Display::url(
$tool_name.$session_img,
$tool_link_params['href'],
$tool_link_params
);
$items[] = $item;
}
}
foreach ($items as &$item) {
$originalImage = self::getToolIcon($item, ICON_SIZE_BIG);
$item['tool']['only_icon_medium'] = self::getToolIcon($item, ICON_SIZE_MEDIUM, false);
$item['tool']['only_icon_small'] = self::getToolIcon($item, ICON_SIZE_SMALL, false);
if ($theme === 'activity_big') {
$item['tool']['image'] = Display::url(
$originalImage,
$item['url_params']['href'],
$item['url_params']
);
if ($studentview) {
$tool_link_params['href'] .= '&isStudentView=true';
}
$item['url_params'] = $tool_link_params;
$item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
$item['tool'] = $tool;
$item['name'] = $tool_name;
$item['href'] = $tool_link_params['href'];
$tool_link_params['id'] = 'is'.$tool_link_params['id'];
$item['link'] = Display::url(
$tool_name.$session_img,
$tool_link_params['href'],
$tool_link_params
);
$items[] = $item;
}
return $items;
}
@ -721,7 +330,7 @@ class CourseHome
*
* @return string returns the name of the corresponding tool
*/
public static function translate_tool_name(&$tool)
public static function translate_tool_name(CTool $tool)
{
static $already_translated_icons = [
'file_html.gif',
@ -736,7 +345,9 @@ class CourseHome
'external_na.gif',
];
$toolName = Security::remove_XSS(stripslashes(strip_tags($tool['name'])));
$toolName = Security::remove_XSS(stripslashes(strip_tags($tool->getTool()->getName())));
return $toolName;
if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) {
return $toolName;
@ -1101,33 +712,25 @@ class CourseHome
/**
* @return array
*/
public static function getCourseAdminBlocks()
public static function getCourseAdminBlocks($toolChain)
{
$blocks = [];
$my_list = self::get_tools_category(TOOL_AUTHORING);
$blocks[] = [
'title' => get_lang('Authoring'),
'class' => 'course-tools-author',
'content' => self::show_tools_category($my_list),
'content' => self::show_tools_category(self::get_tools_category(TOOL_AUTHORING), $toolChain),
];
$list1 = self::get_tools_category(TOOL_INTERACTION);
$list2 = self::get_tools_category(TOOL_COURSE_PLUGIN);
$my_list = array_merge($list1, $list2);
$blocks[] = [
'title' => get_lang('Interaction'),
'class' => 'course-tools-interaction',
'content' => self::show_tools_category($my_list),
'content' => self::show_tools_category(self::get_tools_category(TOOL_INTERACTION), $toolChain),
];
$my_list = self::get_tools_category(TOOL_ADMIN_PLATFORM);
$blocks[] = [
'title' => get_lang('Administration'),
'class' => 'course-tools-administration',
'content' => self::show_tools_category($my_list),
'content' => self::show_tools_category(self::get_tools_category(TOOL_ADMIN_PLATFORM), $toolChain),
];
return $blocks;
@ -1136,13 +739,13 @@ class CourseHome
/**
* @return array
*/
public static function getCoachBlocks()
public static function getCoachBlocks(ToolChain $toolChain)
{
$blocks = [];
$my_list = self::get_tools_category(TOOL_STUDENT_VIEW);
$blocks[] = [
'content' => self::show_tools_category($my_list),
'content' => self::show_tools_category($my_list, $toolChain),
];
$sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
@ -1161,7 +764,7 @@ class CourseHome
$blocks[] = [
'title' => get_lang('Administration'),
'content' => self::show_tools_category($onlyMaintenanceList),
'content' => self::show_tools_category($onlyMaintenanceList, $toolChain),
];
}
@ -1171,7 +774,7 @@ class CourseHome
/**
* @return array
*/
public static function getStudentBlocks()
public static function getStudentBlocks(ToolChain $toolChain)
{
$blocks = [];
$tools = self::get_tools_category(TOOL_STUDENT_VIEW);
@ -1208,12 +811,12 @@ class CourseHome
}
if (count($tools) > 0) {
$blocks[] = ['content' => self::show_tools_category($tools)];
$blocks[] = ['content' => self::show_tools_category($tools, $toolChain)];
}
if ($isDrhOfCourse) {
$drhTool = self::get_tools_category(TOOL_DRH);
$blocks[] = ['content' => self::show_tools_category($drhTool)];
$blocks[] = ['content' => self::show_tools_category($drhTool, $toolChain)];
}
return $blocks;
@ -1222,16 +825,16 @@ class CourseHome
/**
* @return array
*/
public static function getUserBlocks()
public static function getUserBlocks($toolChain)
{
$sessionId = api_get_session_id();
// Start of tools for CourseAdmins (teachers/tutors)
if ($sessionId === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$blocks = self::getCourseAdminBlocks();
$blocks = self::getCourseAdminBlocks($toolChain);
} elseif (api_is_coach()) {
$blocks = self::getCoachBlocks();
$blocks = self::getCoachBlocks($toolChain);
} else {
$blocks = self::getStudentBlocks();
$blocks = self::getStudentBlocks($toolChain);
}
return $blocks;
@ -1293,53 +896,4 @@ class CourseHome
return $dataIcons;
}
/**
* Find the tool icon when homepage_view is activity_big.
*
* @param int $iconSize
* @param bool $generateId
*
* @return string
*/
private static function getToolIcon(array $item, $iconSize, $generateId = true)
{
$image = str_replace('.gif', '.png', $item['tool']['image']);
$toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null;
if (isset($item['tool']['custom_image'])) {
return Display::img(
$item['tool']['custom_image'],
$item['name'],
['id' => 'toolimage_'.$toolIid]
);
}
if (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) {
$customIcon = $item['tool']['custom_icon'];
if ($item['tool']['visibility'] == '0') {
$customIcon = self::getDisableIcon($item['tool']['custom_icon']);
}
return Display::img(
self::getCustomWebIconPath().$customIcon,
$item['name'],
['id' => 'toolimage_'.$toolIid]
);
}
$id = '';
if ($generateId) {
$id = 'toolimage_'.$toolIid;
}
return Display::return_icon(
$image,
$item['name'],
['id' => $id],
$iconSize,
false
);
}
}

@ -1538,6 +1538,7 @@ class Display
if (empty($courseInfo)) {
return '';
}
return '';
$t_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
@ -1567,7 +1568,7 @@ class Display
c_id = $course_id AND
access_user_id = '$user_id' AND
access_session_id ='".$sessionId."'
ORDER BY access_date DESC
ORDER BY access_date DESC
LIMIT 1
";
$result = Database::query($sql);
@ -1588,12 +1589,12 @@ class Display
$hideTools = [TOOL_NOTEBOOK, TOOL_CHAT];
// Get current tools in course
$sql = "SELECT name, link, image
FROM $course_tool_table
WHERE
c_id = $course_id AND
$sql = "SELECT name
FROM $course_tool_table
WHERE
c_id = $course_id AND
visibility = '1' AND
name NOT IN ('".implode("','", $hideTools)."')
name NOT IN ('".implode("','", $hideTools)." ')
";
$result = Database::query($sql);
$tools = Database::store_result($result);
@ -1613,7 +1614,7 @@ class Display
$toolName = addslashes($toolName);
$sql = "SELECT * FROM $tool_edit_table
$sql = "SELECT * FROM $tool_edit_table
WHERE
c_id = $course_id AND
$toolCondition
@ -2709,12 +2710,12 @@ class Display
$ariaExpanded = $open ? 'true' : 'false';
$html = <<<HTML
<div class="card" id="$id">
<div class="card-header">
$title
</div>
<div class="card-body">$content</div>
<div class="card-header">
$title
</div>
<div class="card-body">$content</div>
</div>
HTML;
} else {
@ -2778,14 +2779,14 @@ HTML;
$toolbar = '<div class="btn-group pull-right">'.$toolbar.'</div>';
}
return '<div id="user_card_'.$userInfo['id'].'" class="card d-flex flex-row">
return '<div id="user_card_'.$userInfo['id'].'" class="card d-flex flex-row">
<img src="'.$userInfo['avatar'].'" class="rounded">
<h3 class="card-title">'.$userInfo['complete_name'].'</h3>
<div class="card-body">
<h3 class="card-title">'.$userInfo['complete_name'].'</h3>
<div class="card-body">
<div class="card-title">
'.$status.'
'.$toolbar.'
</div>
</div>
</div>
<hr />
</div>';
@ -2881,7 +2882,7 @@ HTML;
$.frameReady(function() {
$(function () {
$("video:not(.skip), audio:not(.skip)").mediaelementplayer({
pluginPath: "'.$webPublicPath.'assets/mediaelement/plugins/",
pluginPath: "'.$webPublicPath.'assets/mediaelement/plugins/",
features: [\''.$videoFeatures.'\'],
success: function(mediaElement, originalNode, instance) {
'.ChamiloApi::getQuizMarkersRollsJS().'
@ -2889,25 +2890,25 @@ HTML;
vrPath: "'.$webPublicPath.'assets/vrview/build/vrview.js"
});
});
},
},
"'.$frameName.'",
[
{type:"script", src:"'.api_get_jquery_web_path().'", deps: [
{type:"script", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
{type:"script", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"},
{type:"script", src:"'.api_get_jquery_ui_js_web_path().'"},
{type:"script", src: "'.$webPublicPath.'build/libs/mediaelement/mediaelement-and-player.min.js",
{type:"script", src: "'.$webPublicPath.'build/libs/mediaelement/mediaelement-and-player.min.js",
deps: [
{type:"script", src: "'.$webPublicPath.'build/libs/mediaelement/plugins/vrview/vrview.js"},
{type:"script", src: "'.$webPublicPath.'build/libs/mediaelement/plugins/markersrolls/markersrolls.js"},
'.$videoPluginFiles.'
]},
]},
'.$translateHtml.'
]},
'.$videoPluginCssFiles.'
{type:"script", src:"'.$webPublicPath.'build/libs/mathjax/MathJax.js?config=AM_HTMLorMML"},
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/jquery-ui.min.css"},
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/theme.css"},
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/theme.css"},
]);';
return $frameReady;

@ -3,6 +3,7 @@
namespace Chamilo\CoreBundle\Controller;
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Controller\ToolBaseController;
use Chamilo\CourseBundle\Entity\CTool;
use Chamilosession as Session;
@ -31,7 +32,7 @@ class CourseHomeController extends ToolBaseController
*
* @Entity("course", expr="repository.find(cid)")
*/
public function indexAction(Request $request)
public function indexAction(Request $request, ToolChain $toolChain)
{
$course = $this->getCourse();
$result = $this->autoLaunch();
@ -39,7 +40,6 @@ class CourseHomeController extends ToolBaseController
$htmlHeadXtra[] = $js;
$userId = $this->getUser()->getId();
$courseCode = $course->getCode();
$courseId = $course->getId();
$sessionId = $this->getSessionId();
@ -134,8 +134,8 @@ class CourseHomeController extends ToolBaseController
if (!empty($session_id)) {
$condition = api_get_session_condition($session_id);
$sql = "SELECT id FROM $lp_table
WHERE c_id = $course_id AND autolaunch = 1 $condition
LIMIT 1";
WHERE c_id = $course_id AND autolaunch = 1 $condition
LIMIT 1";
$result = Database::query($sql);
// If we found nothing in the session we just called the session_id = 0 autolaunch
if (Database::num_rows($result) == 0) {
@ -144,8 +144,8 @@ class CourseHomeController extends ToolBaseController
}
$sql = "SELECT id FROM $lp_table
WHERE c_id = $course_id AND autolaunch = 1 $condition
LIMIT 1";
WHERE c_id = $course_id AND autolaunch = 1 $condition
LIMIT 1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$lp_data = Database::fetch_array($result, 'ASSOC');
@ -276,7 +276,6 @@ class CourseHomeController extends ToolBaseController
);
}
//require 'activity.php';
// Activity start
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$course_id = api_get_course_int_id();
@ -288,9 +287,9 @@ class CourseHomeController extends ToolBaseController
// visibility 0,1->2
if (!empty($_GET['askDelete'])) {
$content .= '<div id="toolhide">'.get_lang('Do you really want to delete this link?').'<br />&nbsp;&nbsp;&nbsp;
<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
<a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
</div>';
<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
<a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
</div>';
} elseif (isset($_GET['delete']) && $_GET['delete']) {
/*
* Process hiding a tools from available tools.
@ -330,8 +329,7 @@ class CourseHomeController extends ToolBaseController
}
}
$blocks = CourseHome::getUserBlocks();
// Activity end
$blocks = CourseHome::getUserBlocks($toolChain);
// Get session-career diagram
$diagram = '';
@ -487,7 +485,7 @@ class CourseHomeController extends ToolBaseController
$em = $this->getDoctrine()->getManager();
$repo = $this->getDoctrine()->getRepository('ChamiloCourseBundle:CTool');
$sessionId = intval($request->get('id_session'));
$sessionId = (int) $request->get('id_session');
$itemsFromSession = [];
if (!empty($sessionId)) {
$query = $repo->createQueryBuilder('a');
@ -670,177 +668,6 @@ class CourseHomeController extends ToolBaseController
return $this->redirect($url);
}
/**
* @param string $title
* @param string $content
* @param string $class
*
* @return string
*/
private function return_block($title, $content, $class = null)
{
$html = '<div class="row">
<div class="col-xs-12 col-md-12">
<div class="title-tools">'.$title.'</div>
</div>
</div>
<div class="row '.$class.'">'.$content.'</div>';
return $html;
}
/**
* @return array
*/
private function renderActivityView()
{
$session_id = api_get_session_id();
$urlGenerator = $this->get('router');
$content = '';
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
$pluginExtra = null;
if ($enabled === 'true') {
/*require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php';
$plugin = CourseLegalPlugin::create();
$pluginExtra = $plugin->getTeacherLink();*/
}
// Start of tools for CourseAdmins (teachers/tutors)
$totalList = [];
// Start of tools for CourseAdmins (teachers/tutors)
if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$content .= '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;">
<div class="normal-message" id="id_normal_message" style="display:none">';
$content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= get_lang('Please stand by...');
$content .= '</div>
<div class="alert alert-success" id="id_confirmation_message" style="display:none"></div>
</div>';
$content .= $pluginExtra;
if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
$content .= '
<div class="row">
<div class="col-xs-12 col-md-12">
<span class="viewcaption">'.get_lang('Session\'s data').'</span>
<table class="course_activity_home">'.
CourseHome::show_session_data($session_id).'
</table>
</div>
</div>';
}
$my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
$blocks[] = [
'title' => get_lang('Authoring'),
'class' => 'course-tools-author',
'content' => CourseHome::show_tools_category($my_list),
];
$list1 = CourseHome::get_tools_category(TOOL_INTERACTION);
$list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
$my_list = array_merge($list1, $list2);
$blocks[] = [
'title' => get_lang('Interaction'),
'class' => 'course-tools-interaction',
'content' => CourseHome::show_tools_category($my_list),
];
$my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
$blocks[] = [
'title' => get_lang('Administration'),
'class' => 'course-tools-administration',
'content' => CourseHome::show_tools_category($my_list),
];
} elseif (api_is_coach()) {
$content .= $pluginExtra;
if (api_get_setting('show_session_data') === 'true' && $session_id > 0) {
$content .= '<div class="row">
<div class="col-xs-12 col-md-12">
<span class="viewcaption">'.get_lang('Session\'s data').'</span>
<table class="course_activity_home">';
$content .= CourseHome::show_session_data($session_id);
$content .= '</table></div></div>';
}
$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
$blocks[] = [
'content' => CourseHome::show_tools_category($my_list),
];
$sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
if ($sessionsCopy === 'true') {
// Adding only maintenance for coaches.
$myList = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
$onlyMaintenanceList = [];
foreach ($myList as $item) {
if ($item['name'] === 'course_maintenance') {
$item['link'] = 'course_info/maintenance_coach.php';
$onlyMaintenanceList[] = $item;
}
}
$blocks[] = [
'title' => get_lang('Administration'),
'content' => CourseHome::show_tools_category($onlyMaintenanceList),
];
}
} else {
$tools = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
$isDrhOfCourse = \CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
// Force user icon for DRH
if ($isDrhOfCourse) {
$addUserTool = true;
foreach ($tools as $tool) {
if ($tool['name'] === 'user') {
$addUserTool = false;
break;
}
}
if ($addUserTool) {
$tools[] = [
'c_id' => api_get_course_int_id(),
'name' => 'user',
'link' => 'user/user.php',
'image' => 'members.gif',
'visibility' => '1',
'admin' => '0',
'address' => 'squaregrey.gif',
'added_tool' => '0',
'target' => '_self',
'category' => 'interaction',
'session_id' => api_get_session_id(),
];
}
}
if (count($tools) > 0) {
$blocks[] = ['content' => CourseHome::show_tools_category($tools)];
}
if ($isDrhOfCourse) {
$drhTool = CourseHome::get_tools_category(TOOL_DRH);
$blocks[] = ['content' => CourseHome::show_tools_category($drhTool)];
}
}
return $blocks;
}
/**
* @return array

@ -130,6 +130,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
// The group 'resource' is set in the @GRID\Source annotation in the entity.
$source = new Entity($class, 'resource');
/** @var ResourceNode $parentNode */
$parentNode = $repository->getResourceNodeRepository()->find($resourceNodeId);
$this->denyAccessUnlessGranted(

@ -52,13 +52,14 @@ class CourseListener
public function prePersist(Course $course, LifecycleEventArgs $args)
{
/** @var AccessUrlRelCourse $urlRelCourse */
if ($course) {
/*$urlRelCourse = $course->getUrls()->first();
$url = $urlRelCourse->getUrl();*/
//$url = $course->getCurrentUrl();
//$repo = $args->getEntityManager()->getRepository('ChamiloCoreBundle:Course');
///$this->checkLimit($repo, $course, $url);
$this->toolChain->addToolsInCourse($course, $this->settingsManager);
$this->toolChain->addToolsInCourse($args->getEntityManager(), $course, $this->settingsManager);
}
}

@ -19,7 +19,7 @@ class Tool
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false, unique=false)
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
@ -28,7 +28,7 @@ class Tool
/**
* @var string
*
* @ORM\Column(name="name", type="string", nullable=false, unique=false)
* @ORM\Column(name="name", type="string", nullable=false, unique=true)
*/
protected $name;

@ -47,8 +47,8 @@ services:
arguments:
- 'agenda'
- 'authoring'
- 'calendar/agenda.php'
- chamilo_course.settings.agenda
- '/main/calendar/agenda.php'
- '@chamilo_course.settings.agenda'
-
events:
repository: Chamilo\CourseBundle\Repository\CCalendarEventRepository
@ -64,7 +64,7 @@ services:
arguments:
- 'announcement'
- 'authoring'
- 'announcements/announcements.php'
- '/main/announcements/announcements.php'
- '@chamilo_course.settings.announcement'
-
announcements:
@ -80,8 +80,8 @@ services:
arguments:
- 'student_publication'
- 'interaction'
- 'work/work.php'
- chamilo_course.settings.assignment
- '/main/work/work.php'
- '@chamilo_course.settings.assignment'
-
student_publications:
repository: Chamilo\CourseBundle\Repository\CStudentPublicationRepository
@ -96,7 +96,7 @@ services:
arguments:
- 'attendance'
- 'authoring'
- 'attendance/index.php'
- '/main/attendance/index.php'
- '@chamilo_course.settings.attendance'
-
attendances:
@ -110,7 +110,7 @@ services:
arguments:
- 'blog'
- 'admin'
- 'blog/blog_admin.php'
- '/main/blog/blog_admin.php'
- '@chamilo_course.settings.blog'
-
blogs:
@ -122,9 +122,9 @@ services:
chamilo_core.tool.course_description:
class: Chamilo\CoreBundle\Tool\CourseDescription
arguments:
- course_description
- authoring
- course_description/index.php
- 'course_description'
- 'authoring'
- '/main/course_description/index.php'
- '@chamilo_course.settings.course_description'
-
course_descriptions:
@ -136,9 +136,9 @@ services:
chamilo_core.tool.chat:
class: Chamilo\CoreBundle\Tool\Chat
arguments:
- chat
- interaction
- chat/chat.php
- 'chat'
- 'interaction'
- '/main/chat/chat.php'
- '@chamilo_course.settings.chat'
- ~
- 0
@ -148,9 +148,9 @@ services:
chamilo_core.tool.course_progress:
class: Chamilo\CoreBundle\Tool\CourseProgress
arguments:
- course_progress
- authoring
- course_progress/index.php
- 'course_progress'
- 'authoring'
- '/main/course_progress/index.php'
- '@chamilo_course.settings.course_progress'
-
thematics:
@ -166,9 +166,9 @@ services:
chamilo_core.tool.document:
class: Chamilo\CoreBundle\Tool\Document
arguments:
- document
- authoring
- document/document.php
- 'document'
- 'authoring'
- '/resources/document/files'
- '@chamilo_course.settings.document'
-
files:
@ -180,9 +180,9 @@ services:
chamilo_core.tool.dropbox:
class: Chamilo\CoreBundle\Tool\Dropbox
arguments:
- dropbox
- interaction
- dropbox/index.php
- 'dropbox'
- 'interaction'
- '/main/dropbox/index.php'
- '@chamilo_course.settings.dropbox'
-
dropbox:
@ -194,9 +194,9 @@ services:
chamilo_core.tool.exercise:
class: Chamilo\CoreBundle\Tool\Exercise
arguments:
- quiz
- authoring
- exercise/exercise.php
- 'quiz'
- 'authoring'
- '/main/exercise/exercise.php'
- '@chamilo_course.settings.exercise'
-
exercises:
@ -214,9 +214,9 @@ services:
chamilo_core.tool.forum:
class: Chamilo\CoreBundle\Tool\Forum
arguments:
- forum
- interaction
- forum/index.php
- 'forum'
- 'interaction'
- '/main/forum/index.php'
- '@chamilo_course.settings.forum'
-
forums:
@ -236,9 +236,9 @@ services:
chamilo_core.tool.glossary:
class: Chamilo\CoreBundle\Tool\Glossary
arguments:
- glossary
- authoring
- glossary/index.php
- 'glossary'
- 'authoring'
- '/main/glossary/index.php'
- '@chamilo_course.settings.glossary'
-
glossaries:
@ -250,9 +250,9 @@ services:
chamilo_core.tool.gradebook:
class: Chamilo\CoreBundle\Tool\Gradebook
arguments:
- gradebook
- authoring
- gradebook/index.php
- 'gradebook'
- 'authoring'
- '/main/gradebook/index.php'
- '@chamilo_course.settings.gradebook'
-
gradebook_categories:
@ -271,7 +271,7 @@ services:
arguments:
- 'group'
- 'interaction'
- 'group/group.php'
- '/main/group/group.php'
- '@chamilo_course.settings.group'
-
groups:
@ -289,7 +289,7 @@ services:
arguments:
- 'learnpath'
- 'authoring'
- 'lp/lp_controller.php'
- '/main/lp/lp_controller.php'
- '@chamilo_course.settings.learning_path'
-
lps:
@ -305,7 +305,7 @@ services:
arguments:
- 'link'
- 'authoring'
- 'link/link.php'
- '/main/link/link.php'
- '@chamilo_course.settings.link'
-
links:
@ -327,7 +327,7 @@ services:
arguments:
- 'member'
- 'interaction'
- 'user/user.php'
- '/main/user/user.php'
- '@chamilo_course.settings.user'
- ~
- 0
@ -339,7 +339,7 @@ services:
arguments:
- 'course_maintenance'
- 'admin'
- 'course_info/maintenance.php'
- '/main/course_info/maintenance.php'
- '@chamilo_course.settings.maintenance'
- ~
- 0
@ -351,7 +351,7 @@ services:
arguments:
- 'notebook'
- 'interaction'
- 'notebook/index.php'
- '/main/notebook/index.php'
- '@chamilo_course.settings.notebook'
-
notebooks:
@ -364,8 +364,8 @@ services:
class: Chamilo\CoreBundle\Tool\Settings
arguments:
- 'course_setting'
- admin
- course_info/infocours.php
- 'admin'
- '/main/course_info/infocours.php'
- '@chamilo_course.settings.settings'
- ~
- 0
@ -378,7 +378,7 @@ services:
arguments:
- 'survey'
- 'interaction'
- 'survey/survey_list.php'
- '/main/survey/survey_list.php'
- '@chamilo_course.settings.survey'
-
surveys:
@ -392,9 +392,9 @@ services:
chamilo_core.tool.tracking:
class: Chamilo\CoreBundle\Tool\Tracking
arguments:
- tracking
- admin
- tracking/courseLog.php
- 'tracking'
- 'admin'
- '/main/tracking/courseLog.php'
- '@chamilo_course.settings.tracking'
- ~
- 0
@ -404,8 +404,8 @@ services:
chamilo_core.tool.user:
class: Chamilo\CoreBundle\Tool\User
arguments:
- user
- interaction
- 'user'
- 'interaction'
- ~
- ~
-
@ -418,9 +418,9 @@ services:
chamilo_core.tool.wiki:
class: Chamilo\CoreBundle\Tool\Wiki
arguments:
- wiki
- interaction
- wiki/index.php
- 'wiki'
- 'interaction'
- '/main/wiki/index.php'
- '@chamilo_course.settings.wiki'
-
wikis:

@ -12,6 +12,7 @@ use Chamilo\CoreBundle\Tool\AbstractTool;
use Chamilo\CourseBundle\Entity\CTool;
use Chamilo\SettingsBundle\Manager\SettingsManager;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
/**
@ -154,26 +155,30 @@ class ToolChain
$tool->addToolResourceRight($toolResourceRightReader);
}
public function addToolsInCourse(Course $course, SettingsManager $settingsManager): Course
public function addToolsInCourse(EntityManagerInterface $manager, Course $course, SettingsManager $settingsManager): Course
{
$tools = $this->getTools();
$toolVisibility = $settingsManager->getSetting('course.active_tools_on_create');
/** @var AbstractTool $tool */
foreach ($tools as $tool) {
$toolEntity = new CTool();
$visibility = in_array($tool->getName(), $toolVisibility);
$courseTool = new CTool();
$visibility = in_array($tool->getName(), $toolVisibility, true);
$criteria = ['name' => $tool->getName()];
$toolEntity = $manager->getRepository('ChamiloCoreBundle:Tool')->findOneBy($criteria);
$toolEntity
$courseTool
->setTool($toolEntity)
->setCourse($course)
->setImage($tool->getImage())
->setName($tool->getName())
//->setImage($tool->getImage())
//->setName($tool->getName())
->setVisibility($visibility)
->setLink($tool->getLink())
->setTarget($tool->getTarget())
//->setLink($tool->getLink())
//->setTarget($tool->getTarget())
->setCategory($tool->getCategory());
$course->addTools($toolEntity);
$course->addTools($courseTool);
}
return $course;

@ -4,6 +4,8 @@
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\Tool;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
@ -22,8 +24,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CTool
{
protected $originalImage;
/**
* @var int
*
@ -40,27 +40,6 @@ class CTool
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="text", nullable=false)
*/
protected $name;
/**
* @var string
*
* @ORM\Column(name="link", type="string", length=255, nullable=false)
*/
protected $link;
/**
* @var string
*
* @ORM\Column(name="image", type="string", length=255, nullable=true)
*/
protected $image;
/**
* @var bool
*
@ -68,34 +47,6 @@ class CTool
*/
protected $visibility;
/**
* @var string
*
* @ORM\Column(name="admin", type="string", length=255, nullable=true)
*/
protected $admin;
/**
* @var string
*
* @ORM\Column(name="address", type="string", length=255, nullable=true)
*/
protected $address;
/**
* @var bool
*
* @ORM\Column(name="added_tool", type="boolean", nullable=true)
*/
protected $addedTool;
/**
* @var string
*
* @ORM\Column(name="target", type="string", length=20, nullable=false)
*/
protected $target;
/**
* @var string
*
@ -104,33 +55,35 @@ class CTool
protected $category;
/**
* @var int
* @var string
*
* @ORM\Column(name="session_id", type="integer", nullable=true)
* @ORM\Column(name="custom_icon", type="string", length=255, nullable=true)
*/
protected $sessionId;
protected $customIcon;
/**
* @var string
* @var Course
*
* @ORM\Column(name="description", type="text", nullable=true)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="tools")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
*/
protected $description;
protected $course;
/**
* @var string
* @var Session
*
* @ORM\Column(name="custom_icon", type="string", length=255, nullable=true)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true)
*/
protected $customIcon;
protected $session;
/**
* @var Course
* @var Tool
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="tools")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Tool")
* @ORM\JoinColumn(name="tool_id", referencedColumnName="id", nullable=false)
*/
protected $course;
protected $tool;
/**
* Constructor.
@ -139,8 +92,6 @@ class CTool
{
// Default values
$this->id = 0;
$this->sessionId = 0;
$this->address = 'squaregrey.gif';
}
/**
@ -178,89 +129,37 @@ class CTool
return $this->course;
}
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint(
'customIcon',
new Assert\File(['mimeTypes' => ['image/png']])
);
$metadata->addPropertyConstraint(
'customIcon',
new Assert\Image(['maxWidth' => 64, 'minHeight' => 64])
);
$metadata->addPropertyConstraint('cId', new Assert\NotBlank());
}
/**
* Set name.
*
* @param string $name
*
* @return CTool
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set link.
*
* @param string $link
*
* @return CTool
* @return Session
*/
public function setLink($link)
public function getSession(): ?Session
{
$this->link = $link;
return $this;
return $this->session;
}
/**
* Get link.
*
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* Set image.
*
* @param string $image
* @param Session $session
*
* @return CTool
*/
public function setImage($image)
public function setSession(Session $session = null): CTool
{
$this->image = $image;
$this->session = $session;
return $this;
}
/**
* Get image.
*
* @return string
*/
public function getImage()
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
return $this->image;
/*$metadata->addPropertyConstraint(
'customIcon',
new Assert\File(['mimeTypes' => ['image/png']])
);
$metadata->addPropertyConstraint(
'customIcon',
new Assert\Image(['maxWidth' => 64, 'minHeight' => 64])
);
$metadata->addPropertyConstraint('cId', new Assert\NotBlank());*/
}
/**
@ -287,102 +186,6 @@ class CTool
return $this->visibility;
}
/**
* Set admin.
*
* @param string $admin
*
* @return CTool
*/
public function setAdmin($admin)
{
$this->admin = $admin;
return $this;
}
/**
* Get admin.
*
* @return string
*/
public function getAdmin()
{
return $this->admin;
}
/**
* Set address.
*
* @param string $address
*
* @return CTool
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get address.
*
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set addedTool.
*
* @param bool $addedTool
*
* @return CTool
*/
public function setAddedTool($addedTool)
{
$this->addedTool = $addedTool;
return $this;
}
/**
* Get addedTool.
*
* @return bool
*/
public function getAddedTool()
{
return $this->addedTool;
}
/**
* Set target.
*
* @param string $target
*
* @return CTool
*/
public function setTarget($target)
{
$this->target = $target;
return $this;
}
/**
* Get target.
*
* @return string
*/
public function getTarget()
{
return $this->target;
}
/**
* Set category.
*
@ -407,30 +210,6 @@ class CTool
return $this->category;
}
/**
* Set sessionId.
*
* @param int $sessionId
*
* @return CTool
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId.
*
* @return int
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* Set id.
*
@ -458,39 +237,39 @@ class CTool
/**
* @return string
*/
public function getDescription()
public function getCustomIcon()
{
return $this->description;
return $this->customIcon;
}
/**
* @param string $description
* @param string $customIcon
*
* @return CTool
*/
public function setDescription($description)
public function setCustomIcon($customIcon)
{
$this->description = $description;
$this->customIcon = $customIcon;
return $this;
}
/**
* @return string
* @return Tool
*/
public function getCustomIcon()
public function getTool(): Tool
{
return $this->customIcon;
return $this->tool;
}
/**
* @param string $customIcon
* @param Tool $tool
*
* @return CTool
*/
public function setCustomIcon($customIcon)
public function setTool(Tool $tool): CTool
{
$this->customIcon = $customIcon;
$this->tool = $tool;
return $this;
}

@ -71,14 +71,19 @@
});
</script>
{% if app.user.status != 5 %} <!-- main/template/default/course_home/activity.html.twig -->
{% if app.user.status != 5 %}
<div class="accordion accordion-b4" id="course-tools">
{% for block in blocks %}
<div class="card">
<div class="card-header" id="heading-{{ block.class }}">
{% if block.title %}
<h5 class="card-title">
<a class="{{ ( block.title == 'Authoring') ? ' ' : 'collapse' }}" role="button" data-toggle="collapse" data-target="#collapse-{{ block.class }}" aria-expanded="{{ ( block.title == 'Authoring') ? 'true' : 'false' }}" aria-controls="collapse-{{ block.class }}">
<a class="{{ ( block.title == 'Authoring') ? ' ' : 'collapse' }}"
role="button" data-toggle="collapse"
data-target="#collapse-{{ block.class }}"
aria-expanded="{{ ( block.title == 'Authoring') ? 'true' : 'false' }}"
aria-controls="collapse-{{ block.class }}"
>
{{ block.title }}
</a>
</h5>
@ -87,36 +92,27 @@
<div id="collapse-{{ block.class }}" class="collapse show" aria-labelledby="heading-{{ block.class }}" data-parent="#course-tools">
<div class="grid-tools">
{% if 'homepage_view'|api_get_setting == 'activity' %}
{% for item in block.content %}
<div class="col-md-4 course-tool">
{{ item.extra|raw }}
{{ item.visibility|raw }}
{{ item.icon|raw }}
{{ item.link|raw }}
</div>
{% endfor %}
{% endif %}
{% if 'homepage_view'|api_get_setting == 'activity_big' %}
{% for item in block.content %}
<div class="items-tools ">
<div class="tools mt-3 mb-3">
<div class="big_icon">
{{ item.tool.image|raw }}
</div>
<div class="content pt-2 pb-2">
{{ item.extra|raw }}
{{ item.link|raw }}
{% if item.visibility is not empty %}
<div class="view">
{{ item.visibility|raw }}
</div>
{% endif %}
</div>
{% for item in block.content %}
<div class="items-tools ">
<div class="tools mt-3 mb-3">
<div class="big_icon">
<a href=" {{ item.href|raw }}" >
<img src="{{ asset('img/tools/' ~ item.tool.tool.name ~ '.png') }}" />
</a>
</div>
<div class="content pt-2 pb-2">
<a href=" {{ item.href|raw }}" >
{{ item.tool.tool.name }}
</a>
{% if item.visibility is not empty %}
<div class="view">
{# {{ item.visibility|raw }}#}
</div>
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
</div>
</div>
@ -125,29 +121,24 @@
{% else %}
<div class="grid-tools">
{% for block in blocks %}
{% if 'homepage_view'|api_get_setting == 'activity_big' %}
{% for item in block.content %}
<div class="items-tools">
<div class="tools mt-3 mb-3">
<div class="big_icon">
{{ item.tool.image|raw }}
</div>
<div class="content pt-2 pb-2">
{{ item.extra|raw }}
{{ item.link|raw }}
{% if item.visibility is not empty %}
<div class="view">
{{ item.visibility|raw }}
</div>
{% endif %}
</div>
{% for item in block.content %}
<div class="items-tools">
<div class="tools mt-3 mb-3">
<div class="big_icon">
<a href=" {{ item.href|raw }}" >
<img src="{{ asset('img/tools/' ~ item.tool.tool.name ~ '.png') }}" />
</a>
</div>
<div class="content pt-2 pb-2">
<a href=" {{ item.href|raw }}" >
{{ item.tool.tool.name }}
</a>
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% endfor %}
{% endfor %}
</div>
{% endif %}
{% endautoescape %}
{% endblock %}

Loading…
Cancel
Save