@@ -1341,8 +1341,17 @@ protected function coursecat_subcategories(coursecat_helper $chelper, $coursecat
1341
1341
$ content .= $ pagingbar ;
1342
1342
}
1343
1343
1344
+ //MUDANÇA PARA ALTERAR COLLAPSE
1345
+
1346
+ $ isFirst = 1 ;
1347
+
1344
1348
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
+ }
1346
1355
}
1347
1356
1348
1357
if (!empty ($ pagingbar )) {
@@ -1395,9 +1404,9 @@ protected function coursecat_category_content(coursecat_helper $chelper, $course
1395
1404
// Courses
1396
1405
if ($ chelper ->get_show_courses () > core_course_renderer::COURSECAT_SHOW_COURSES_COUNT ) {
1397
1406
$ courses = array ();
1398
- if (! $ chelper -> get_courses_display_option ( ' nodisplay ' )) {
1407
+
1399
1408
$ courses = $ coursecat ->get_courses ($ chelper ->get_courses_display_options ());
1400
- }
1409
+
1401
1410
if ($ viewmoreurl = $ chelper ->get_courses_display_option ('viewmoreurl ' )) {
1402
1411
// the option for 'View more' link was specified, display more link (if it is link to category view page, add category id)
1403
1412
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
1426
1435
* @param int $depth depth of this category in the current tree
1427
1436
* @return string
1428
1437
*/
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
1431
1439
$ classes = array ('category ' );
1432
1440
if (empty ($ coursecat ->visible )) {
1433
1441
$ classes [] = 'dimmed_category ' ;
1434
1442
}
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
+ }
1443
1471
}
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
+ }
1450
1479
}
1451
1480
}
1452
1481
0 commit comments