Moodle

[PATCH] New front page setting: collapsing category tree

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9.2
  • Fix Version/s: None
  • Component/s: Unknown
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

When this setting is turned on, course sub-categories are shown in a collapsing tree.

This is very useful for sites which have a very large number of nested categories.

(Tested in Firefox and IE6)

  1. collapsing_categories4.diff
    21/Oct/08 12:02 PM
    8 kB
    Francois Marier
  1. arw_off.gif
    0.1 kB
    23/Jul/08 12:58 PM
  2. arw_on.gif
    0.1 kB
    23/Jul/08 12:58 PM
  3. screenshot.gif
    22 kB
    22/Jul/08 5:11 PM

Activity

Hide
Francois Marier added a comment -

Updated version of the patch. This version doesn't put an onclick event on the category name, only on the arrows.

That way, all of the individual category pages (and the courses they contain) are accessible.

Show
Francois Marier added a comment - Updated version of the patch. This version doesn't put an onclick event on the category name, only on the arrows. That way, all of the individual category pages (and the courses they contain) are accessible.
Hide
Francois Marier added a comment -

Images that should be part of this patch.

Show
Francois Marier added a comment - Images that should be part of this patch.
Hide
Scott Karren added a comment -

With sites that have multiple categories and sub-categories it is essential that users be able to collapse or expand the category that they need. This also makes the frontpage view much cleaner and easier to navigate without having to scroll alot. I vote for this to be added to the 2.0 core.

Show
Scott Karren added a comment - With sites that have multiple categories and sub-categories it is essential that users be able to collapse or expand the category that they need. This also makes the frontpage view much cleaner and easier to navigate without having to scroll alot. I vote for this to be added to the 2.0 core.
Hide
Francois Marier added a comment -

Updated patch (version 3) fixes a small problem when the setting is turned off. Now the behaviour is the same as it is on an unpatched codebase.

Show
Francois Marier added a comment - Updated patch (version 3) fixes a small problem when the setting is turned off. Now the behaviour is the same as it is on an unpatched codebase.
Hide
Francois Marier added a comment -

Make use of require_js() for the javascript code.

Show
Francois Marier added a comment - Make use of require_js() for the javascript code.
Hide
Eloy Lafuente (stronk7) added a comment -

Looks good to be. +1

But I think we should discuss a bit a about how to implement these sort of collapsible/tree artefacts within Moodle. Custom scripts like this? Or YUI provided utilities?

I can see a lot of places where code like this has sense (categories, course activities, grades...). Adding MD here as watcher to let him know.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Looks good to be. +1 But I think we should discuss a bit a about how to implement these sort of collapsible/tree artefacts within Moodle. Custom scripts like this? Or YUI provided utilities? I can see a lot of places where code like this has sense (categories, course activities, grades...). Adding MD here as watcher to let him know. Ciao
Hide
Petr Škoda (skodak) added a comment -

my +1 for 2.0, if you want to push it into 1.9.x please ask MD - only he can decide that.

thanks!

Show
Petr Škoda (skodak) added a comment - my +1 for 2.0, if you want to push it into 1.9.x please ask MD - only he can decide that. thanks!
Hide
Eloy Lafuente (stronk7) added a comment -

Assigning to Francois and addressing initially to 2.0. Backport to 19_STABLE decission pending from MD.

Thanks and ciao

Show
Eloy Lafuente (stronk7) added a comment - Assigning to Francois and addressing initially to 2.0. Backport to 19_STABLE decission pending from MD. Thanks and ciao
Hide
Matt Gibson added a comment -

YUI treeview makes this very easy and can be set to auto populate from a nested set of <ul>s, so its good from a HIJAX/progressive enhancement perspective. I'd say it was far better to use a YUI widget as it will make other stuff load faster if the same libraries are called. Really like the idea of course - could it be extended to the my courses block as well?

Show
Matt Gibson added a comment - YUI treeview makes this very easy and can be set to auto populate from a nested set of <ul>s, so its good from a HIJAX/progressive enhancement perspective. I'd say it was far better to use a YUI widget as it will make other stuff load faster if the same libraries are called. Really like the idea of course - could it be extended to the my courses block as well?
Hide
Howard Liverance added a comment -

Gentlemen, is this enhancemment backportable to 1.9.3, or do we have to wait for 2.0?

Show
Howard Liverance added a comment - Gentlemen, is this enhancemment backportable to 1.9.3, or do we have to wait for 2.0?
Hide
Francois Marier added a comment -

The patch should apply fairly cleanly to 1.9.3 as well. I'm using it on a few 1.9.3 in fact.

As far as 2.0 is concerned, the patch will probably need to be redone using the YUI treeview before it makes it to core.

Show
Francois Marier added a comment - The patch should apply fairly cleanly to 1.9.3 as well. I'm using it on a few 1.9.3 in fact. As far as 2.0 is concerned, the patch will probably need to be redone using the YUI treeview before it makes it to core.
Hide
Chris Murad added a comment -

Has anyone gotten this to work on 1.9.4?

Thanks
Chris

Show
Chris Murad added a comment - Has anyone gotten this to work on 1.9.4? Thanks Chris
Hide
Francois Marier added a comment -

Yes, it works fine on 1.9.4 as well.

Show
Francois Marier added a comment - Yes, it works fine on 1.9.4 as well.
Hide
sudeep gaadhe added a comment -

whenever i run this patch using netbean editor i got prompt on screen "patch is applied partially" & finally i didn't see any effect on front page course categories. it display as usual as previously. please guide me on this issue.

Show
sudeep gaadhe added a comment - whenever i run this patch using netbean editor i got prompt on screen "patch is applied partially" & finally i didn't see any effect on front page course categories. it display as usual as previously. please guide me on this issue.
Hide
Francois Marier added a comment -

Sudeep: if the partch doesn't fully apply, then you won't be able to enable this feature.

See this page for more instructions on how to apply a patch:

http://docs.moodle.org/en/Development:How_to_apply_a_patch

Show
Francois Marier added a comment - Sudeep: if the partch doesn't fully apply, then you won't be able to enable this feature. See this page for more instructions on how to apply a patch: http://docs.moodle.org/en/Development:How_to_apply_a_patch
Hide
Jacques Monnard added a comment -

As far as I can see, this patch creates the whole list of courses when the page is loaded. If there are many courses (we have more than 2500 at our university), this means that the page takes a very long time to load (see http://moodle.unifr.ch). Other people have developped a collapsible course list using the library "PHP DBTreeView" (http://sourceforge.net/projects/php-dbtreeview/) which only loads the courses in a category when it is opened. You can see it in action here : http://cyberlearn.hes-so.ch/. They are planning to release their code as soon as it is documented (you can already find it here - in French - http://blog.cyberlearn.ch/?p=73).

If Moodle 2.0 is to include a collapsible course list, I would suggest that it uses the above library, or that it reuses some of the code from Cyberlearn, so that it is really up-to-date (i.e. Ajax-based).

Show
Jacques Monnard added a comment - As far as I can see, this patch creates the whole list of courses when the page is loaded. If there are many courses (we have more than 2500 at our university), this means that the page takes a very long time to load (see http://moodle.unifr.ch). Other people have developped a collapsible course list using the library "PHP DBTreeView" (http://sourceforge.net/projects/php-dbtreeview/) which only loads the courses in a category when it is opened. You can see it in action here : http://cyberlearn.hes-so.ch/. They are planning to release their code as soon as it is documented (you can already find it here - in French - http://blog.cyberlearn.ch/?p=73). If Moodle 2.0 is to include a collapsible course list, I would suggest that it uses the above library, or that it reuses some of the code from Cyberlearn, so that it is really up-to-date (i.e. Ajax-based).
Hide
Howard Liverance added a comment -

Gentlemen, I'd like to apply this patch to the current 1.9.5+, has anyone done it?

Show
Howard Liverance added a comment - Gentlemen, I'd like to apply this patch to the current 1.9.5+, has anyone done it?
Hide
Howard Liverance added a comment -

I tried a dry run on applying the diff file to 1.9.5+ and it applied correctly in all but the lib.php file, where 4 of 6 hunks failed. Can anyone help or recommend a way to patch the lib.php file to get this running. I don't feel confident enough with PHP to try to manually fix the failed hunks. Please see below:

patching file admin/settings/frontpage.php
Hunk #1 succeeded at 48 (offset 8 lines).
patching file course/lib.php
Hunk #1 FAILED at 1643.
Hunk #2 FAILED at 1660.
Hunk #3 succeeded at 1777 (offset 103 lines).
Hunk #4 FAILED at 1800.
Hunk #5 FAILED at 1826.
Hunk #6 succeeded at 1817 (offset 10 lines).
4 out of 6 hunks FAILED – saving rejects to file course/lib.php.rej
patching file index.php
Hunk #1 succeeded at 279 (offset 3 lines).
patching file lang/en_utf8/admin.php
Hunk #1 succeeded at 50 (offset 2 lines).
Hunk #2 succeeded at 78 (offset 3 lines).
patching file lib/collapsing_categories.js

Show
Howard Liverance added a comment - I tried a dry run on applying the diff file to 1.9.5+ and it applied correctly in all but the lib.php file, where 4 of 6 hunks failed. Can anyone help or recommend a way to patch the lib.php file to get this running. I don't feel confident enough with PHP to try to manually fix the failed hunks. Please see below: patching file admin/settings/frontpage.php Hunk #1 succeeded at 48 (offset 8 lines). patching file course/lib.php Hunk #1 FAILED at 1643. Hunk #2 FAILED at 1660. Hunk #3 succeeded at 1777 (offset 103 lines). Hunk #4 FAILED at 1800. Hunk #5 FAILED at 1826. Hunk #6 succeeded at 1817 (offset 10 lines). 4 out of 6 hunks FAILED – saving rejects to file course/lib.php.rej patching file index.php Hunk #1 succeeded at 279 (offset 3 lines). patching file lang/en_utf8/admin.php Hunk #1 succeeded at 50 (offset 2 lines). Hunk #2 succeeded at 78 (offset 3 lines). patching file lib/collapsing_categories.js
Hide
Amir Elion added a comment -

I managed to get this working on 1.9.5+
You need to change the name of the variable $files on the various location on the patch to $showcourses

This got this working on the frontpage.
However, there is a problem with the course/index.php page.
I added this to the php:

require_once("../config.php");
require_once("lib.php");
+ require_js($CFG->wwwroot .'/lib/collapsing_categories.js');

and this at the end of the file:
<script type="text/javascript">
//<![CDATA[
var pixpath = "<?php echo $CFG->pixpath; ?>";
//]]>
</script>

This did get the expand/contract option to work there as well, but I get error on page and even when expanded a category remains with unexpanded icon arw_off.gif

Any ideas anyone?

Show
Amir Elion added a comment - I managed to get this working on 1.9.5+ You need to change the name of the variable $files on the various location on the patch to $showcourses This got this working on the frontpage. However, there is a problem with the course/index.php page. I added this to the php: require_once("../config.php"); require_once("lib.php"); + require_js($CFG->wwwroot .'/lib/collapsing_categories.js'); and this at the end of the file: <script type="text/javascript"> //<![CDATA[ var pixpath = "<?php echo $CFG->pixpath; ?>"; //]]> </script> This did get the expand/contract option to work there as well, but I get error on page and even when expanded a category remains with unexpanded icon arw_off.gif Any ideas anyone?
Hide
Amir Elion added a comment -

Got this problem fixed as well:
Added this to theme's footer.html

<script type="text/javascript">
//<![CDATA[
var pixpath = "<?php echo $CFG->pixpath; ?>";
//]]>
</script>
at the start of the file.

and deleted it form index.php and course/index.php

Show
Amir Elion added a comment - Got this problem fixed as well: Added this to theme's footer.html <script type="text/javascript"> //<![CDATA[ var pixpath = "<?php echo $CFG->pixpath; ?>"; //]]> </script> at the start of the file. and deleted it form index.php and course/index.php
Hide
Nadav Kavalerchik added a comment -

works great on our system too (tikshuv.org.il/moodle)
we use moodle version 1.9.2

thanks !

Show
Nadav Kavalerchik added a comment - works great on our system too (tikshuv.org.il/moodle) we use moodle version 1.9.2 thanks !
Hide
Francois Marier added a comment -

This is a very old patch that should just be abandoned. The code has moved on since.

Show
Francois Marier added a comment - This is a very old patch that should just be abandoned. The code has moved on since.

Dates

  • Created:
    Updated:
    Resolved: