According to Jean Michels hint, open your <moodle_root_dir>/mod/folder/module.js file.
If you do not want to edit two files, just edit this one. Find the if conditional which checks for the expand_all option and comment out the following line.
if (expand_all) {
//tree.expandAll();
}
Next, to select the top folder to be opened on page load, add right before the call of the render() function the following line:
tree.getNodeByIndex(1).expand();
tree.render();
Your whole module.js file should look like this:
/**
* Javascript helper function for Folder module
*
* @package mod
* @subpackage folder
* @copyright 2009 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.mod_folder = {};
M.mod_folder.init_tree = function(Y, expand_all) {
Y.use('yui2-treeview', function(Y) {
var tree = new Y.YUI2.widget.TreeView("folder_tree");
tree.subscribe("clickEvent", function(node, event) {
// we want normal clicking which redirects to url
return false;
});
if (expand_all) {
//tree.expandAll();
}
tree.getNodeByIndex(1).expand();
tree.render();
});
}