Skip to content

Commit 3a65468

Browse files
committed
Customização na visualização de categorias
1 parent 4ccd26a commit 3a65468

File tree

2 files changed

+53
-21
lines changed

2 files changed

+53
-21
lines changed

course/index.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@
5959
}
6060

6161
if ($categoryid && !$category->visible && !has_capability('moodle/category:viewhiddencategories', $PAGE->context)) {
62-
throw new moodle_exception('unknowncategory');
62+
$content = "Ainda não há cursos disponíveis para esta categoria";
63+
}
64+
else {
65+
$content = $courserenderer->course_category($categoryid);
6366
}
6467

6568
$PAGE->set_heading($site->fullname);
66-
$content = $courserenderer->course_category($categoryid);
69+
//$content = $courserenderer->course_category($categoryid);
6770

6871
echo $OUTPUT->header();
6972
echo $OUTPUT->skip_link_target();

course/renderer.php

+48-19
Original file line numberDiff line numberDiff line change
@@ -1341,8 +1341,17 @@ protected function coursecat_subcategories(coursecat_helper $chelper, $coursecat
13411341
$content .= $pagingbar;
13421342
}
13431343

1344+
//MUDANÇA PARA ALTERAR COLLAPSE
1345+
1346+
$isFirst = 1;
1347+
13441348
foreach ($subcategories as $subcategory) {
1345-
$content .= $this->coursecat_category($chelper, $subcategory, $depth + 1);
1349+
if($isFirst == 1){
1350+
$content .= $this->coursecat_category(1, $chelper, $subcategory, $depth + 1);
1351+
$isFirst = 0;
1352+
}else{
1353+
$content .= $this->coursecat_category(0, $chelper, $subcategory, $depth + 1);
1354+
}
13461355
}
13471356

13481357
if (!empty($pagingbar)) {
@@ -1395,9 +1404,9 @@ protected function coursecat_category_content(coursecat_helper $chelper, $course
13951404
// Courses
13961405
if ($chelper->get_show_courses() > core_course_renderer::COURSECAT_SHOW_COURSES_COUNT) {
13971406
$courses = array();
1398-
if (!$chelper->get_courses_display_option('nodisplay')) {
1407+
13991408
$courses = $coursecat->get_courses($chelper->get_courses_display_options());
1400-
}
1409+
14011410
if ($viewmoreurl = $chelper->get_courses_display_option('viewmoreurl')) {
14021411
// the option for 'View more' link was specified, display more link (if it is link to category view page, add category id)
14031412
if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
@@ -1426,27 +1435,47 @@ protected function coursecat_category_content(coursecat_helper $chelper, $course
14261435
* @param int $depth depth of this category in the current tree
14271436
* @return string
14281437
*/
1429-
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth) {
1430-
// open category tag
1438+
protected function coursecat_category($key, coursecat_helper $chelper, $coursecat, $depth) { // open category tag
14311439
$classes = array('category');
14321440
if (empty($coursecat->visible)) {
14331441
$classes[] = 'dimmed_category';
14341442
}
1435-
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
1436-
// do not load content
1437-
$categorycontent = '';
1438-
$classes[] = 'notloaded';
1439-
if ($coursecat->get_children_count() ||
1440-
($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count())) {
1441-
$classes[] = 'with_children';
1442-
$classes[] = 'collapsed';
1443+
if($key == 1){
1444+
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
1445+
// load category content
1446+
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
1447+
$classes[] = 'loaded';
1448+
if (!empty($categorycontent)) {
1449+
$classes[] = 'with_children';
1450+
}
1451+
} else {
1452+
// do not load content
1453+
$categorycontent = '';
1454+
$classes[] = 'notloaded';
1455+
if ($coursecat->get_children_count() ||
1456+
($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count())) {
1457+
$classes[] = 'with_children';
1458+
$classes[] = 'collapsed';
1459+
}
1460+
}
1461+
}else{
1462+
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
1463+
// do not load content
1464+
$categorycontent = '';
1465+
$classes[] = 'notloaded';
1466+
if ($coursecat->get_children_count() ||
1467+
($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count())) {
1468+
$classes[] = 'with_children';
1469+
$classes[] = 'collapsed';
1470+
}
14431471
}
1444-
} else {
1445-
// load category content
1446-
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
1447-
$classes[] = 'loaded';
1448-
if (!empty($categorycontent)) {
1449-
$classes[] = 'with_children';
1472+
else {
1473+
// load category content
1474+
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
1475+
$classes[] = 'loaded';
1476+
if (!empty($categorycontent)) {
1477+
$classes[] = 'with_children';
1478+
}
14501479
}
14511480
}
14521481

0 commit comments

Comments
 (0)