New myCourses block released

New myCourses block released

by Julian Ridden -
Number of replies: 211

This block was originally part of the old FN_Moodle project and has been used by some in this community for quite some time.

Having finally gotten round to getting some PHP training (yes, finally I know what I am doing..a bit) I have updated this block for 1.7.1 and above.

The myCourses block provides a collaspable tree to allow for the browsing of courses. It makes it very easy for users to navigate between courses in multiple categories.

This new version now uses lang packs (I have suplied en_utf8) and is no longer dependant on the original fn_course format being installed.

The code could do with a clean up as I have not removed all the old FN, references. However, that being said it is working very happily and I am pretty confident that it should be safe on a production server.

If someone with better coding skills than my own wants to attempt a better code clean up, I encourage them to do so. 

I have added this to the Modules and Plugins database. But it may take a little while to appear. In the meantime you can also access it by clicking here

Attachment myCourses-Demo.jpg
Average of ratings: -
In reply to Julian Ridden

Svar: New myCourses block released

by Anders Berggren -
This is really cool!
Works like a charm
in Moodle 1.7.1
In reply to Anders Berggren

Re: Svar: New myCourses block released

by Julian Ridden -
Great. Also had a few PM's on this. It also works in 1.8 as well.
In reply to Julian Ridden

Re: New myCourses block released

by Heinz Krettek -
Hi,

i have integrated mycourses and it´s much better than the standard, THANKS

Heinz
In reply to Julian Ridden

Re: New myCourses block released

by Shaun Daubney -

Having a problem with this block and page width, can anyone help?

The block doesn't appear to handle long course catagories, instead it makes the right column stretch. Tried with many different themes and IE6, IE7 and FF2. All have similar issues. Is there any way to resolve this? Thanks.

screenshot

In reply to Shaun Daubney

Re: New myCourses block released

by Mark Little -
Hi,

We had the same problem so we chopped some of the wording off by changing line 678 in the treemenu.php file under the module.

substr(str_replace("'", "\\'", $nodeObj->text),0,15), /* change this to modify menu system */

When it reaches 15 characters

I hope this helps...
In reply to Mark Little

Re: New myCourses block released

by Barbara Lawrence -
I would like the course names to wrap rather than truncate them - please can anyone tell me how to do this?
In reply to Shaun Daubney

Re: New myCourses block released

by Anatol Bogun -
Hi,

If long category or course names stretch the block a simple CSS solution would be to just define the width of the block and set the overflow to hidden (this rhymes with "Julian Ridden"). Just add this to the CSS stylesheet of your theme:


.block_mycourses {
width: 210px;
overflow: hidden;
}


Adjust the width to your theme if necessary.

Thank you for this very useful block!

Cheers!
Anatol
In reply to Julian Ridden

Re: troubles with New myCourses block

by A. T. Wyatt -
Greetings, Julian!

I am still having some trouble with this. With respect to the "enrol in another course" link at the bottom,

moodle/config.php reports
$CFG->wwwroot = 'http://localhost';

If the mycourses block is on the front page, it works fine. The "enrol in another course" link at the bottom goes here:
http://localhost/course

But if you put the block inside a COURSE, the link at the bottom tries to go to the wrong place:
http://localhost/course/course

How can I fix this?
line 660 of treemenu.php reads:
$html .= "\n// ]]>\n</script><a href=\"$CFG->wwwroot course\">$enrol</a>";

Thanks,
atw
In reply to A. T. Wyatt

Re: troubles with New myCourses block, solved?

by A. T. Wyatt -
I think the problem was line 660 of tremenu.php missing a slash.

Changed to this and working so far!
$html .= "\n// ]]>\n</script><a href=\"$CFG->wwwroot /course\">$enrol</a>";

atw
In reply to Julian Ridden

Re: New myCourses block released

by Dave Kichler -
I believe there is a bug in this block which is causing the problems some people have been reporting about the 'Enrol in another course' link near the bottom of the block. Several people have reported that the link does not point to the correct location when added to the Course Page (actually, the same error occurs when added to My Moodle as well).

The bug occurs in the toHTML() function which prepares the content for printing as HTML. The 'Enrol in another course' link is generated in this function using the $CFG->wwwroot global variable to build the path to the courses page (/moodlehome/course/index.php). Basically the global var was not initialized and the path is not generated correctly which is why the link ends up pointing to the wrong location (instead becomes a relative path ' course', which depends on the directory of the file linking from).

To fix the bug, simply add this line to the beginning of the function (near line 630):
global $CFG;

There is also a small typo in the actual link tag on line 660. There is a missing forward slash after the global var and an extra space before course. The correct link tag should look like this:
<a href=\"$CFG->wwwroot/course\">

After making these changes, the block worked perfectly from every page (Front Page, My Moodle, Course Page)

Average of ratings: Useful (1)
In reply to Dave Kichler

Re: New myCourses block released

by Julian Ridden -
Thanks Dave, this has been bugging many of us.

Your changes have been added to an updated release now available for download.

If you feel up to the challenge, there is also included a partially finished (i.e. I cant get the bloody thing to work) config_global.html file included.

I thought it would be good to have the character limit definable through the block settings.

The issue is, when I enable the config file, all I get in the settings screen is a blank page. It is driving me nuts.

Any help is apprecitaed. I think this minor addition would make the block better than ever.

JR
In reply to Julian Ridden

Re: New myCourses block released

by Monico Briseño -
Picture of Testers
Hi, Julian. Great job with this block cool ! I've installed on Moodle 1.8.2 and it works properly.

Cheers

Mónico


Attachment mycourses.jpg
In reply to Monico Briseño

Re: New myCourses block released

by Jim Shewbridge -

I am having trouble with this block from the student perspective. I can see the courses perfectly when I am logged in as an Admin but when I logout then log back in as a student, none of the courses I have enrolled in display.

Any thoughts?

Thanks in advance!

Jim

In reply to Jim Shewbridge

Re: New myCourses block released

by Julian Ridden -
I cant help you there. I have this running in Moodle 1.(7, 8 and 9) and it works frin from the student side. We use this in production for my main moodle site.

Maybe you have a corrupt install?

JR
In reply to Jim Shewbridge

Re: New myCourses block released

by Matt Campbell -
Another item to consider would be hidden categories ~ I've noticed on my install that it works properly for users with the capability to view them, but for normal users, they are only able to see their courses if they are outside hidden categories. I'm going to look into this more next week.

Thanks,
Matt
In reply to Matt Campbell

Re: New myCourses block released

by Charlie Owen -
I'd prefer to see this as an option: e.g. "Show courses in hidden categories?"

My own two big requests would be:
  1. The ability to wrap long courses / category names (as mentioned by others)
  2. A <noscript> output, so that users with JS disabled in their browsers can see something.
Otherwise, absolutely fantabulous - thank you Julian!
In reply to Julian Ridden

Re: New myCourses block released

by Matthew Rigdon -
I am not able to get the courses to show for anyone but admin users.  Please advise?  My admin users see every course while my non-admin users see nothing but the Primary Home.  Can anyone help me?
In reply to Matthew Rigdon

Re: New myCourses block released

by Andrés Chandía -
Check maintenance mode, may be by mistake you enable it, if so desable it.
In reply to Andrés Chandía

Re: New myCourses block released

by Matthew Rigdon -
I am not in maintenance mode.  My users can login, but the issue is that the MyCourses block is not working correct.  Please any advice?  I would like to get this up and running asap.
In reply to Matthew Rigdon

Re: New myCourses block released

by Thomas Forsberg -
Check if the owner and access rights on the new module folder and files is correct. Typically when you copy in a new module it has the rights of the user who copied it, the web server must get rights to use the module. On linux you would do something like:

chown -R apache:apache mymodulefoled
chmod -R 755 mymodulefolder


T
In reply to Julian Ridden

Re: New myCourses block released

by Mariusz Krasinski -
Is it possible to use MyCourses as something like AllCourses? The idea is to remove filters for guest user to let him see all available courses.

There is in Moodle the ordinary "courses" menu block but it is not expandable. When more than one category exists I can see only categeries but not tree. I want expandable tree of all courses (like in MyCourses) visible to guest. Is it possible to use MyCourses block as an basis for making AllCouses block?

In reply to Julian Ridden

Re: New myCourses block released

by Mario Schellenberger -
Hello Julian, hello all,

I just made some modifications to the myCourses block that I wanted to share with you:

- height and width can be configured
- names are no longer truncated, instead a scrollbar is displayed if necessary
- inserted a <noscript> function: if javascript is disabled a link to the MyMoodle page will be shown instead

feel free to adopt whatever you want for an upcoming release smile

there are two files which need to be changed!
all text to be inserted is marked green, text to be deleted is marked red.

first file:
MOODLE_DIR/blocks/myCourses/HTML_TreeMenu-1.2.0/TreeMenu.php

height and width can be defined within the code, if you want height to be flexible just remove that part!

code should be starting around line 618:

/**
* Returns the HTML for the menu. This method can be
* used instead of printMenu() to use the menu system
* with a template system.
*
* @access public
* @return string The HTML for the menu
*/
function toHTML()
{
static $count = 0;
$menuObj = $this->jsObjectName . '_' . ++$count;
global $CFG;
$html = "\n";
$html = '<div style="width:168px; height:250px; overflow:auto; border:solid 0px">';
$html .= '<script Xlanguage="javascript" type="text/javascript">' . "\n//<![CDATA[\n\t";
$html .= sprintf('%s = new TreeMenu("%s", "%s", "%s", "%s", %s, %s);',
$menuObj,
$this->images,
$menuObj,
$this->linkTarget,
$this->defaultClass,
$this->usePersistence ? 'true' : 'false',
$this->noTopLevelImages ? 'true' : 'false');

$html .= "\n";

/**
* Loop through subnodes
*/
if (isset($this->menu->items)) {
for ($i=0; $i<count($this->menu->items); $i++) {
$html .= $this->_nodeToHTML($this->menu->items[$i], $menuObj);
}
}

$html .= sprintf("\n\t%s.drawMenu();", $menuObj);
$html .= sprintf("\n\t%s.writeOutput();", $menuObj);

if ($this->usePersistence && $this->isDynamic) {
$html .= sprintf("\n\t%s.resetBranches();", $menuObj);
}
$enrol = get_string('enrol','block_myCourses');
$mymoodle = get_string('mymoodle','block_myCourses');
$html .= "\n// ]]>\n</script><noscript><center><a href=\"$CFG->wwwroot/my\">$mymoodle</a></center></noscript></div><center><a href=\"$CFG->wwwroot/course\">$enrol</a></center>";


return $html;
}

/**
* Prints a node of the menu
*
* @access private
*/
function _nodeToHTML($nodeObj, $prefix, $return = 'newNode', $currentDepth = 0, $maxDepthPrefix = null)
{
$prefix = empty($maxDepthPrefix) ? $prefix : $maxDepthPrefix;
$charLength = $CFG->block_myCourses_charLength;
$expanded = $this->isDynamic ? ($nodeObj->expanded ? 'true' : 'false') : 'true';
$isDynamic = $this->isDynamic ? ($nodeObj->isDynamic ? 'true' : 'false') : 'false';
$html = sprintf("\t %s = %s.addItem(new TreeNode('%s', %s, %s, %s, %s, '%s', '%s', %s));\n",
$return,
$prefix,
substr(str_replace("'", "\\'", $nodeObj->text),0,35),
!empty($nodeObj->icon) ? "'" . $nodeObj->icon . "'" : 'null',
!empty($nodeObj->link) ? "'" . $nodeObj->link . "'" : 'null',
$expanded,
$isDynamic,
$nodeObj->cssClass,
$nodeObj->linkTarget,
!empty($nodeObj->expandedIcon) ? "'" . $nodeObj->expandedIcon . "'" : 'null');

foreach ($nodeObj->events as $event => $handler) {
$html .= sprintf("\t %s.setEvent('%s', '%s');\n",
$return,
$event,
str_replace(array("\r", "\n", "'"), array('\r', '\n', "\'"), $handler));
}

if ($this->maxDepth > 0 AND $currentDepth == $this->maxDepth) {
$maxDepthPrefix = $prefix;
}




second file:
MOODLE_DIR/blocks/myCourses/lang/en_utf8/block_myCourses.php

here you can define what is shown, wenn javascript is disabled.

enter a new line right beneath the last string-definition:

$string['mymoodle'] = 'Show MyMoodle';



any comments welcome!

have fun,
mario
In reply to Mario Schellenberger

Re: New myCourses block released

by Rosario Carcò -

Hello,

I wanted to install the original FN my_courses block already last year on our 1.7.1+ but for lack of time I am trying to install it on our Test-Server (SuSe Linux) with Moodle 1.9+

I downloaded Julian's version (thanks a lot) and copied the needed files into the folder moodleroot/blocks/my_courses and as the block did not appear in the admin/Modules/Blocks/Manage Blocks, I copied block_myCourses.php into the moodleroot/lang/en_utf8 folder, just to be sure.

But no luck: the block still does not appear.

Did I miss something? Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Oh something very strange happened:

  • first I realized that the directory should be named moodleroot/blocks/myCourses
  • then I removed block_myCourses.php from the moodleroot/lang/en_utf8 folder because it is obviously NOT needed any more

As nothing happend, I navigated to NOTIFICATIONS where I could read "myCourses... all tables were successfully created" or something similar with a button to klick on to continue. What I wanted to do is enable debugging to see what was keeping to go wrong. But after dismissing this notification I was fianally able to see the myCourses Block in the according admin-Manage-Blocks-section.

And it seems to work well in 1.9+

Now I will look for a hack to make it display all available categories and courses, even when people are not logged in. And it would be nice to have it displayed not in a block on the side, but in the central part of the front page where you can display News Items, Course List, Category List, or as I have done here (https://moodle.fhnw.ch/moodleTest) with Kevin Treussier's Category and Course navigation menu which can be integrated as part of your Theme instead of a block.

Thanks again, Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Sr. Miguel -

Hello,

Did you figured this out?

"Now I will look for a hack to make it display all available categories and courses, even when people are not logged in. "

Thank you!

In reply to Sr. Miguel

Re: New myCourses block released

by Rosario Carcò -

Sorry, I was out for vacations and just finished the following hacks:

a) loading all courses in all categories even for not logged in people, assuming that they are allowed to navigate to any course and must log in just when trying to enter it. This is intended not for showing only "my courses" as it's original purpose was, but to facilitate navigation with a hierarchical tree with collapsed and expanded folder-trees.

b) our site has about 500 courses, so loading this navigation blocks stalls the display of the according page for an uncomfortable amount of time, 7 seconds or so. That's why I modified my first intention a) to c)

c) I now load only ALL categories, no courses. This loads very fast compared to a) - So I had to do quite some more hacks to get the main nodes (categories) loaded and displayed and to enable them with a link. Fortunately there is roughly no difference between a category and a course in Moodle's database. So I had only to figure out how to load categories instead of courses and how to have them displayed despite being empty. The original course did not display any category nor course, if the user had no course at all or no course in a given category.

d) I added language support for german, myCourses/lang/de_utf8 and could do the same for french, italian, spanish and maybe portuguese

Give me some more days to clean up the whole code and post it back to you. I am asking myself, if I coud put all that into a config-section, so that the admin could decide whether he wants the navigation block to behave like a), b) or c) - Obviously this means going far beyond a simple hack and needs some more time. I realised also that the code should be cleaned up from its original FN relicts, as Mario started already.

Rosario

In reply to Mario Schellenberger

Re: New myCourses block released

by Rosario Carcò -

Mario, I just modified the lines to have a horizontal slider if Category or course names grow to long. It works fine.

Do you know what those Config-Variables were ment for:

$CFG->block_myCourses_chars = 35;
$CFG->block_myCourses_charLength = 45;

I wonder if a block could be made larger than all the others anyway.

Thanks a lot, Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Julian Ridden -
I have just updated this block to address the issues listed in the forum. Now when you enter debug mode there should be no errors appearing.

I am using this now on my site with no issues but don't take this as an iron clad guarantee. Users who have installed the first version are encouraged to gran the new code from the Modules and Plugins database. Please let me know if any more issues occur.

Julian
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

According to my previous posts and ideas this is what I am planning to do starting next week. Please feel free to send me any suggestions:

/**
*
* @author Rosario Carco, Fachhochschule Nordwestschweiz
* @version 1.9.01, 2008050901
*
* I took the myCourses Block which was originally released as part of the FN Moodle
*
* This block was partially revised and enhanced by Julian Ridden and Mario Schellenberger
*
* See the following thread:
http://moodle.org/mod/forum/discuss.php?d=67494
*
* I modified the code to address the following issues:
*
* Development history:
*
* Date       | Author | Text
*************+********+*****
* 2008/05/09   Cr       - adapted to reflect Moodle 1.9 programming of blocks according to
*                        
http://docs.moodle.org/en/Development:Blocks
*                       - adapted to use new configuration settings/interface
*                       - removed all code relicts of FN and all code not strictly necessary
*                       - removed also all errors displayed with DEBUGGING on
*                       - added language support for GE, FR, IT, maybe spanish and portuguese
*
*                       - made TWO different blocks, so that they can be used concurrently in
*                         different courses and the Front Page:
*                      
*                       a) the original block name and purpose remane the same: myCourses
*                           - show only courses of logged in user
*                             - @todo What should be displayed if user is the site-administrator?
*
*                       b) changed name of second block to better reflect its purpose to: siteNavigation
*                          this block offers two params/settings:
*
*                          - siteNavByCategories -> show only categories, no courses for a fast display
*                            of the whole category-tree (loading 500 courses and more takes 7 seconds
*                            and more)
*
*                          - siteNavByCourses -> show all categories AND all courses (only appropriate
*                            for small sites with few courses, maybe less than 100)
*                            - @todo I am looking at the code of the built in block_admin_tree which
*                              also uses open/closed folders in a hierarchical tree. I guess that this
*                              code is faster to render the whole tree than the HTML_TreeMenu-1.2.0
*                              actually used.
*
*
*
*/

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Today I realized that the best thing to do is to start over with the original code. I just made the version mentioned at the end work with 1.9 so that also the three admin-squares in the right title-bar work again (show/hide MyCourses, show/hide Active Courses, show/hide Inactive Courses). For the moment I do not fully understand what these admin-options were exactly meant for. But show/hide inactive Courses works fine and as expected so that the admin can choose whether to see those courses or not. The other two do not work as expected. I suppose that the flag for "active" courses has changed. And I still do not understand why an admin would want to display "MyCourses", i.e. courses he is enrolled in himself or not. Anyway, I guess that I could make show/hide Active Courses work correctly and maybe someone knows what show/hide MyCourses was meant for.

So I will definitely use the following code-base for the new two blocks "myCourses" and "siteNavigation" and keep the suggestions of Mario Schellenberger to have vertical and horizontal scrollbars, no truncated category/course names and link for disabled java-script, the file's date is 2006-oct-04:

<?PHP //$Id: block_FN_my_courses.php,v 1.1.2.1 2006/06/23 14:59:40 mchurch Exp $

require_once($CFG->libdir.'/HTML_TreeMenu-1.2.0/TreeMenu.php');
require_once($CFG->dirroot.'/course/format/FN/lib.php');

class block_FN_my_courses extends block_base {
    function init() {
        $this->title = get_string('blocktitle', 'block_FN_my_courses');
        $this->version = 2005061000;
    }

In reply to Rosario Carcò

Re: New myCourses block released

by Sr. Miguel -

Hello,

I have a need similar to something I said before:

I would like that all people acessing the site would be able to see and navigate throught all the courses in the site using Mycourses block. However, for non-logged users, if they click on a course in the menu, I would like them to be taken to the login page instead of the course page.

Is this difficult to achieve?

Thank you

In reply to Rosario Carcò

Re: New myCourses block released

by Julian Ridden -
Thanks for looking into this. The modifications I made were at the best of my ability. Having a proper developer re-work the code will only be advantageous. big grin

If you are looking at changing functionality, it may be best to release under a different name as many use this as is quite happily. However, enhancing functionality has my utmost support and blessings. The code is messy and could also do with a very good clean up. It does work, but certainly could be made more efficient.

Julian
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Ok, I just finished a first alpha version. As described before, the main intention was NOT to change anything, but simply to free the code from its original FN Code relicts and to update the code to reflect 1.9 recommendations to programming Moodle blocks.

As Julian suggested, we could consider changing the name also for this block. But I hope, we can bring this code base to do exactly what you were accustomed to do before I entered the game.

So please help me and test the code in the attachment. I really do not know, how the previous code behaved. When I tested it, it worked fine (except some debug errors), but showed no options for admins and teachers to toggle the display. I made this run again by taking the original code as mentioned in my previous post.

I had to make one choice however: maybe I did not understand thoroughly the logic to display myCourses, active courses and inactive courses of teachers and admins. So for the moment I changed the code to do this logic:

  • admins get the options to show/hide active courses and show/hide inactive courses. myCourses, i.e courses they are enrolled in, does not make a lot of sense in my opinion. I reduced accordingly the sqares to toggle these options from 3 to 2. If this really made sense, we would have to find a solution to displaying myCourses AND active courses, which means ALL courses and displaying only myCourses or only active courses without the other ones. This seems to be mutually exclusive.
  • teachers get the options to show/hide myCourses, i.e. courses they are enrolled in as teachers and show/hide inactive courses. We have no problems here because in either case the courses are myCourses, because teachers are not allowed to see all courses.

So, if you are afraid my version could behave differently from yours, be sure to back up your block or rename my block to something different before implementing it in Moodle's block directory. If you have a Moodle instance to test with, the best thing is to implement it there.

I must stress that there are still many lines of code I do not understand thoroughly, so be patient with me. I will wait developing the second block "siteNavigation" until we have a proper code base for myCourses behaving as you were accustomed to. Again, feel free to send me suggestions and requests to get the functionality back you had before, if you miss something.

For the moment I left most of the original code simply commented out. But I will remove it, as soon as I get your OK to do so. If you want to know more details, have a look at the header of block_myCourses.php

Rosario

Average of ratings: Useful (2)
In reply to Rosario Carcò

Re: New myCourses block released

by Rick Barnes -
This block looks excellent and I look forward to testing it soon.
I am looking for a block that will list all of the courses in a category as a set of quick links for pupils. One of our courses is broken into units each has a course for delivering the unit and we have one course as a portfolio of evidence.

Rick.
In reply to Rick Barnes

Re: New myCourses block released

by Nigel Osborne -

This is a great block, and with only minor amendments does just what I needed. (I'm referring to the 'original' one as available in Moodle plugins page, version 2007032202). I'm running it on Moodle 1.8.4.

The minor mods I did were :

  1. to change the title to 'Courses, rather than My Courses (just personal preference). I was surprised that I had to do that in the core code though, as language file diesn't seem to be used for that (even after I corrected tthat file name to block_myCourses.php instead of block_mycourses.php
  2. to remove the "enrol me in other course' link completely.

I 'think' however that I should also have some admin options if I got to Admin->Modules->blocks-MyCourse->settings - or am I wrong? All I get is a blank page with the header "Be careful modifying these settings - strange values could cause problems."

In reply to Nigel Osborne

Re: New myCourses block released

by Rosario Carcò -

Unfortunately the original code I found here had no Interface for any settings.

But as I announced, I would like to create one for my new siteNavigation where the Admin should be able to select whether users should be logged in  or not to see the categories/courses.

We then would end up with two blocks: myCourses to display only the user's courses after login and siteNavigation which should be configurable.

In the next days I will remove another chunk of FN code and then start my siteNavigation block as announced previously.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Ali Hastie -

Thanks for the reply Resario,

I did read that post but our installation takes much longer than 7 seconds to load. Needed to satisfy my thoughts.

The siteNavigation sounds interesting, will keep an eye out for this one.

Thanks again,

Ali

In reply to Ali Hastie

Re: New myCourses block released

by Geoffrey Rowland -
Picture of Plugin developers
We have also found the myCourses block results in slooooooow page loads (we have 1000+ courses) for admins and even teachers with many courses. This is a shame as many of our users (with a low number of courses!) really appreciate its functionality.
In reply to Julian Ridden

Re: New myCourses block released

by Ali Hastie -

Hi

This block is what we have been looking for but when we login as ourselves (administrator) the page loads painfully slow where ever we have the block installed. When we login as a normal (test) student the page renders as normal. 

Has anyone else has the same problem or could you brief me what may be causing this?

Running the block on Moodle v1.9.2

Ali

In reply to Ali Hastie

Re: New myCourses block released

by Rosario Carcò -

That's because it loads ALL courses, see my posts here where I say "7 seconds for roughly 500 courses". For Users the original code loads onl MY-COURSES, i.e. only the logged in users' courses, which of course load quickly.

Rosario

In reply to Ali Hastie

Re: New myCourses block released

by Jason Cashel -
Hi Ali,
We have fixed this on our site with a quick code edit.

Around line 200 in block_myCourses.php it says:
----------------------------------------------------
if (isset($USER->id) && !(isadmin() && $adminseesall)) { // Just print My Courses
if (!($courses = get_my_courses($USER->id))) {
$courses = array();
}
} else {
if (!($courses = get_records('course'))) {
$courses = array();
}
}
-------------------------------------------------------

Replace that with this:
--------------------------------------------------------
if (isset($USER->id)) { // Just print My Courses
if (!($courses = get_my_courses($USER->id))) {
$courses = array();
}
} else {
$courses = array();
}
--------------------------------------------------------

And have the admins get to the courses through the normal Moodle Course Categories block.

Hope this helps,
Jason
In reply to Jason Cashel

Re: New myCourses block released

by Ali Hastie -

Hi Jason

We tried your code edit and it does not work for us. We still have all courses present for admin and the page also loads slow as before. We are using the older version - 2007032202.

Thanks for the post.

Ali.

In reply to Ali Hastie

Re: New myCourses block released

by Jason Cashel -
Sorry Ali,
I am new to myCourses and don't know the differences between the versions. The version I am using is the latest one (which seems to have the same version number as yours). Also the change does rely on the admin people not being enrolled in all of the courses.

I will email my php file to your hotmail account.

Jason
In reply to Julian Ridden

Re: New myCourses block released

by Ruchi Raina -
I recently installed Moodle 1.9.2.
The 'my course' block does not seem to be available in this version or am I looking at the wrong places?

My earlier Moodle version was 1.8.3. I don't remember seeing it there also, though I have a categories block. In 1.9.2, the categories block also does not seem to be available.

I am missing something for sure. What exactly am I missing?

Thanks,
Ruchi
In reply to Ruchi Raina

Re: New myCourses block released

by Rosario Carcò -

The myCourses block is not Standard Moodle. It is a third party block, read this whole thread.

If you are in a hurry, you may download my version in one of the previous posts. I just tested it also for 1.9.2+ and it works fine.

I will be posting the last stable version of the "original" but revised code here next week.

As told, I will then take this stable code base to develop a new block called siteNavigation. This block will be configurable:

  • siteNavByCategories -> show only categories, no courses for a fast display of the whole category-tree
  • siteNavByCourses -> show all categories AND all courses (only appropriate for small sites with few courses (@todo I am looking at the code of the built in block_admin_tree which also uses open/closed folders in a hierarchical tree. I guess that this code is faster to render the whole tree than the HTML_TreeMenu-1.2.0 used in the original myCourses block. This will only be when I have finished the siteNavigation block which will still use HTML_TreeMenu)
  • loginRequested -> if YES, only logged in users may use the block
                               if NO, all users may use it. Login will be required as soon as they enter a course

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Genner Cerna -
hopefully this will be included in the official moodle release
In reply to Rosario Carcò

Re: New myCourses block released

by Geoffrey Rowland -
Picture of Plugin developers
Rosario
A big thanks for your work on this. Looking forward to the new siteNavigation block. The proposed functionality and performance enhancements will be most welcome cool.
In reply to Rosario Carcò

Re: New myCourses block released

by debbie wombwell -

Hi I have My Courses Block 2 installed on our Moodle 1.94 site which works well. 
I have two queries:
Query - I would like to know if it possible for this block to be available for Admin users as it only shows to students and non edit teachers

Query -  I would like to know if there is the option to hide the "all courses" option so learners can not view all courses and will be able to see their enrolled courses only. Example below

Sales Programme

In reply to debbie wombwell

Re: New myCourses block released

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Debbie,

The version I have posted in CONTRIB-2032 does only display courses that students are enrolled in but Rosario's most recent version does this as well. I cannot get the most recent version to display categories but it does only display courses to a user that the user is enrolled in.

As for your first query, you can remove the "Show all courses" link from the block admin settings page found at

Site Administration > Modules > Blocks > myCourses

Untick the "Show all courses link" to have the link removed from the block.

I'm not sure but if this doesn't work you may need to upgrade to a newer version of Moodle...?

Jason

P.S. The version I have posted in CONTRIB-2032 does not have an admin settings page and also does not display the "Show all courses" link.
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

So, there it is: myCourses as it was in its original FN code but with the enhancements of Julian and Mario and all the corrections and debugs I did to comply with 1.9.x Block development. There should be NO new functionality. The new functionality and features will all be in the new block called siteNavigation. I will start developing it next week, so be patient another few days/weeks.

This is Version 1.9.3 (which means: Moodle 1.9 myCourses Version 3) and its moodle Version number is 2008080801

Please use it, check it even with Moodle's debug option enabled and report back eventual problems or bugs.

To install it, proceed as with all blocks:

  • decompress the archive somewhere
  • copy the needed directories and files into moodle/htdocs/blocks/myCourses
  • be sure to change owner and file permissions as needed on your system
  • navigate to NOTIFICATIONS in the Site-Admin-Block using your browser

You should see a notification stating that the block was installed correctly.

If you already have an older version, I suggest renaming its directory first, e.g. myCourses -> myCoursesOld or (re)moving it completely outside of your moodle/htdocs/blocks directory, so that you will have a backup copy to fall back if you needed to.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

There was a little bug out of the FN-Code with the link to the category.

New Version is 1.9.4 (2008081801)

In reply to Rosario Carcò

Re: New myCourses block released

by Julian Ridden -
Thanks for the hard work you are putting into this.

One thing I am not liking, not sure if maybe it is just a bug though, is that the height has now been set rather than the block automatically resizing itself.

Any chance of having it so the auto resize like it used to?

Julian
Attachment mycourses.jpg
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

As you can see, I added the vertical and horizontal scrollbars, as suggested by Mario Schellenberger.

I thought this was a good idea for large sites. Otherwise the block would grow too long/high.

So, if you want to revert back this I think you have to edit the line(s) indicated by Mario in the TreeMenu.php file.

I will have a look at that as soon as possible. Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Julian Ridden -
any way of turning this into a block config setting for users to turn on and off at will?

I see the point about large sites, but would hate to restrict those with smaller ones. Just a thought.
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

Julian, would you like to have a customization only on the vertical or also on the horizontal direction?

I mean, if it were possible, to let the Admin choose:

1) Show horizontal scroll bar -> YES/NO

2) Show vertical scroll bar -> YES/NO

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

Julian,

I just finished a non final release to see what you think about it:

  • there is a config option setting now to show/hide the scrollbars
  • there is another config option I back-ported from the siteNavigation block, to show/hide the "show all courses" link

When no scrollbars are shown, the block grows vertically but - obviously - not horizontally, as the preferred width of blocks can not be more than 210 Pixels in Moodle. Before I entered the game in such cases the links were reduced to 35 letters, which in turn someone else turned into a hard coded config setting tu put directly into the main config.php file. Now that I have block config settings running I would prefer to put it here, if necessary. As the horizontal text gets truncated anyway, I do not see the necessity of introducing such a config setting.

Let me know if you would like further enhancements, otherwise the next release will hopefully reimplement the Admin being able to choose to show his own courses as well.

To install, unzip into a temporary working directory, copy everything to your moodle/htdoc/blocks/myCourses, set needed owner and file access permissions and point to notifications in your site admin block to load the new version.

Rosario

In reply to Rosario Carcò

Modified the js file so clicking on the category expands/collapses the menu

by Lynda Thater -
Hi Everyone, We have implemented myCourses on our site and have had great feedback! However, one thing that caused some problems was the fact that users had to click on the + or - to expand and collapse the menu. Most people kept clicking on the category (in our case, department names) waiting for the menu to expand. So I made the following changes to: blocks/myCourses/HTML_TreeMenu-1.2.0/TreeMenu.js Now, if you click on either the + or the category name, the menu expands. If you click on the - or the category name the menu contracts. And if you click on the course, you go to the course. Here are the changes. Replace the line in TreeMenu.js: (around line 226) /*var linkStart = nodes[i].link ? this.stringFormat('', linkTarget, onMDown) : ''; } else { var linkStart = nodes[i].link ? this.stringFormat('', nodes[i].link, linkTarget) : ''; Hope this might help someone. Cheers, Lynda Thater Endeavour College of Natural Health Brisbane Australia
In reply to Lynda Thater

Re: Modified the js file so clicking on the category expands/collapses the menu

by Lynda Thater -

Here is the code with formatting!

Changes are in :

blocks/myCourses/HTML_TreeMenu-1.2.0/TreeMenu.js

Replace the line:  (around line 226)

var linkStart = nodes[i].link ? this.stringFormat('<a href="{0}" target="{1}"', nodes[i].link, linkTarget) : '';
 
with the following lines
           

if (this.doesMenu() && nodes[i].n.length) {
     var linkStart = nodes[i].link ? this.stringFormat('<a target="{0}" {1}>', linkTarget, onMDown) : '';
} else {
     var linkStart = nodes[i].link ? this.stringFormat('<a href="{0}" target="{1}">', nodes[i].link, linkTarget) : '';               
}

In reply to Lynda Thater

Re: Modified the js file so clicking on the category expands/collapses the menu

by Rosario Carcò -

Hi Lynda,

this feature, to enable or disable the links on the folders was already requested also in the siteNavigation block. So I will implement this config option in the next release, even if it sounds strange that users are not capable or willing to distinguish the folder's link and the folder's expand and collapse icons.

Rosario

In reply to Lynda Thater

Re: Modified the js file so clicking on the category expands/collapses the menu

by Rosario Carcò -

Edit and Additions to my previous post:

I do not like the folder behaving the same way as the + and - to expand/collapse. So my config option will only allow to toggle the folders' category links on and off.

Of course, folders and category links do not make much sense in the myCourses block. There is only one reason to leave them active: if the users want to navigate up to different categories to get Moodle's course list.

That's why the next release will offer a new config option to show/hide the categories as folders. This way the myCourses block will be able to display a flat list of the user's courses.

And the so configured myCourses block will best be used in combination with the siteNavigation block, which will always show the categories as folders. But again, the folders' links can be toggled on or off in the config setting starting with the next release.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Birgit May -
Hello,

the MyCourse Block worked wonderful all the time but since a view weeks it's not showing anymore the wright courses where I'm enrolled ... the showing of the courses doesn't make any sense to me and I don't know what's going wrong .. is anybody running into the same problems or can help me?

Cheers
Birgit
In reply to Birgit May

Re: New myCourses block released

by Rosario Carcò -
Dear Birgit,

as you contacted me by eMail we will try to track this down next week by phone.

I upgraded both my test-Server and my production Server to the latest build 1.9.3+ of this week and both blocks siteNavigation and myCourses continue to work correctly. You may have a look here on my production system, which offers the navigation without login:

https://moodle.fhnw.ch

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by li shen -

instead of using scroll bar, there is any way to wrap long name to next line within the block?

moodle version 2.8.6,  mycourses block version 2012111503.


Thanks a lot,

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

This is hopefully sort of a final release: Version 1.9.05 (2008081901) with minor bug fixes and spanish language added.

And I just finished the first release of the announced

siteNavigation

I just opened a new thread here:

http://moodle.org/mod/forum/discuss.php?d=103703

So all those waiting for it, have a look there please to download it.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
This is a great block... we're testing now on 1.92. Would be wonderful to have back the functionality of an Admin seeing only the courses in which they have a role in addition to being the Admin (like the old block).
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -

Bob, as I explained in the posts above, an ADMIN having any other role in a course is the point I really did not understand: it makes no sense to me.

Let me explain: either I am the Admin and have access to all courses or I am anything else, e.g. Teacher or Student or any other role. But in this case I would prefer having an own account to play around with those other roles. Maybe I would even create a real personal account for that like I did for my own person: rosario.carco on our moodle. This way I can login as a normal user and use the myCourses Block as any other Teacher or Student. And in the other case I login as Admin, in which case, in my opinion, it doesn't make sense to have other roles than Admin in all courses.

If you really need to be enrolled in courses with other roles when using your Admin account, and you would like to have the third button back to display/hide own courses, there would be sort of a contradiction to be solved. Quote from my previous posts:

we would have to find a solution to displaying myCourses AND active courses, which means ALL courses and displaying only myCourses or only active courses without the other ones. This seems to be mutually exclusive.

I guess I have to think about that logic once again. Maybe we could really treat the three buttons as simple ON/OFF buttons to toggle on "myCourses", "activeCourses" and "inactiveCourses", which in turn means that all three must be ON for the Admin to really see all courses.

But I need some time to achieve this, because our new academic year is going to begin shortly. Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
I respect your thinking through the whole matter and the logic you used to determine an Admin shouldn't need other course-level roles defined. I believe the major limiting factors of why this doesn't actually work in practice is because:
  • Moodle allows only one login per system at a time (multiple windows from the same authentication)
  • Most Moodle admins are logged into Moodle all the time as Admin because they are doing admin functions with multiple Moodle windows open
  • Still there is a need to quickly access those courses in which you have other responsibilities.
That may be why this was previously a config parameter I believe, "CFG->adminseesowncourses")

Thanks for the good work.
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -

>>That may be why this was previously a config parameter I believe, "CFG->adminseesowncourses"

Indeed this was (and still IS) the parameter used in the built in block originally called "myCourses" from which was deduced the FN block with the same name. (Later the built in block was renamed to "course_list"). But the FN block code had yet a more sofisticated combination of courses they called "marked courses". As I explained, I could not reconstruct the whole logic and hence preferred getting rid of all FN code and achieve a clear division from the built in block "course_list".

So give me some time and I will give it a second try. Rosario

In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Dear Bob,

I am actually revising the code to see whether I can get your missed functionality back. Can you help me to get the idea?

As Admin you would like to see the courses you are enrolled in as TEACHER? or as STUDENT? or both??

Could you please contact me through the messaging system or add me to your contacts?

Yours, Rosario
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, I just finished a second Beta Version of 1.9.06

I simply attach the block_myCoursesForAdmins.php file here und ask you to test it. Please rename it back to block_myCourses.php after making a backup of your file in use. The logic for logged in ADMIN is as follows (hoping I got the idea as you wanted it back). For Students and Teachers there should be no change, but test thoroughly please. myCourses of an ADMIN are courses, in which he is enrolled as Teacher or Student. This is what the built in function get_my_courses returns, whilst all other courses is what the built in function get_records('course') returns:

  • blue button toggles myCourses on and off
  • orange button toggles active courses on and off
  • grey button toggles inactive courses on and off
  • if all buttons are ON, you see ONLY myCourses, because myCourses excludes all other ones
  • if blue button is off, you see all others courses, including the own ones, because it seems to be difficult to build an according set without further work
  • if grey button is off, you see all courses, except inactive ones
  • if orange button is off, you see only inactive ones
  • and any combination of them is possible, but remember that toggling the blue button to on, will act like a main switch to toggle on and off the admin's own courses
Of course get_my_courses() and get_records('course') are mutually exclusive. Nonetheless I feel that I could reengineer the whole thing to get an additive behaviour like this:


  • blue button on + orange button on + grey button on = ALL COURSES
  • blue button off + orange button on + grey button on = all courses, except own ones
  • blue button off + orange button off + grey button on = only inactive courses
  • blue button off + orange button off + grey button off = no courses
  • any combinations of them
The only problem is, that this would require a lot of time, may be not beeing worth the clearer logic. But I will think on it.

If you are satisfied with this intermediate result, I will clean up the code and add the promised options in the next release.

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Karen Taylor -
Hi All,

I have installed the mycourses block in Moodle 1.9.
But I have 2 issues...
1. I can't see any of the colored boxes beside the course name as I did in our previous moodle - thus I can't tell if a course is hidden. When looking at the code it appears to have 'NULL'
2. How can I have the course name display the 'long name' rather than the course code?

Any ideas?

Thanks
Karen
In reply to Karen Taylor

Re: New myCourses block released

by Rosario Carcò -

Hi Karen,

the blue and orange icons appear only for teachers and admins. The users see only the normal standard course icon of Moodle, as the myCourses block displays only the courses they are enrolled to. And these can not be hidden.

As for the long name, I could invert the display to 'long name' and 'short name' in the next release, but I feel that this way round it would not make a lot of sense. If you want to invert it on your own, I think you have to check the code in TreeMenu.php

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Clark Moodler -
This block is great - I wish it were possible to place it in the center of the Frontpage so that users could use it instead of the standard frontpage My courses listing....

But also, I'm trying to figure out how I can include "hidden categories" in the listings. We use hidden categories, but allow courses to be open/available within a hidden category. This is because we have 1000 courses created by our student information system (Banner) but only a fraction of them are actually in use. So this way, faculty can choose whether the course is open or not, and we can tell much easier who is actually using the courses.

Anyway, my problem is that the My Courses block doesn't seem to show the hidden categories, even though I want it to. I've messed around with various role settings and can't find the right one to enable this. I have noted that 1 user who is a system-wide Course Creator is able to see the hidden categories in the My Courses block as I want it to happen, but I can't put my finger on what I would do to enable this for all the other users...

anyone?
thanks in advance,
clark

In reply to Clark Moodler

Re: New myCourses block released

by Clark Moodler -
Another further - after some more testing, it seems the only way I can get users to be able to see hidden categories is if they are assigned a "global role" which has that capability.

It would be really handy if there were an "override" for this block to allow users to view hidden categories without assigning them a global role.

Or is this part of the new release that will replace this block?

thanks,
clark
In reply to Clark Moodler

Re: New myCourses block released

by Rosario Carcò -
Dear Clark,

before we start to dig into the code, check whether you enabled the option to see/show hidden categories for Teachers, Students and other possible roles. There is a global setting for this in the Admin-Block where you set Users -> Permissions -> Define Roles. Click on the Role you wish to ovvride and set the moodle/category:viewhiddencategories Option as you wish. (you need Moodle 1.9x for this)

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Tech 8055 -
HI Julian, i have downloaded block and made working on my moodle site 1.9, but problem is when i am looging as student or teacher or course creator the block is showning all the available courses not just enrolled course. I want the block to display only enrolled courses.

Any Suggestions or Any help?

Thanks in Advance.

Cheers

Kieran
In reply to Tech 8055

Re: New myCourses block released

by Dickie Layden -
Hi

Forgive me if this isnt the correct place to post...

We're loving this block - particularly from an admin point of view (so much easier than navigating the add/edit course list).

Only problem is that now the admin user sees no courses at all.
Slightly worrying because (to my knowledge) nothing on the system has changed.

I've checked the Course block and the option for 'admin sees all courses' is definitely selected (even tried flipping to admin sees only own courses and back again).

We have another two instances of moodle same version (1.9.2) and they are fine and the myCourses block shows all for admin.

If someone could give me any pointers I'd be very grateful.

Dickie
In reply to Dickie Layden

Re: New myCourses block released

by Dickie Layden -
SOLVED (and it might be useful for someone)

I was getting javascript errors saying 'unterminated string constant' when displaying the myCourses block.

Turns out one of my course categories had a strange character in it which was causing the javascript to cry.

I edited the category and we're back to normal again. yippeeee

Dickie



In reply to Dickie Layden

Re: New myCourses block released

by Faren Heit -

Hi

I get the following error in firefox 3.03

Attachment mycourses.JPG
In reply to Faren Heit

Re: New myCourses block released

by Rosario Carcò -
Dear Faren,

your Browser seems to display the javaScript code. Maybe you have to enable javaScript EXECUTION in your security settings.

Rosario
In reply to Dickie Layden

Re: New myCourses block released

by Rosario Carcò -
Dear Dickie,

I apologize for the long delay but I was very busy. Please remember, that the option "Admin sees all courses" IS NOT used by our myCourses Block. This option is used in the built in course_list block, which in version 1.9x appears as COURSES in the Admin -> Moules -> Blocks -> mangageBlocks -> Courses

Remember that every Block has it's own set of options. myCourses offers only two settings for the moment, more are planned for the next release:

block_myCourses_withScrollBars and block_myCourses_showAllCoursesLink

Rosario
In reply to Tech 8055

Re: New myCourses block released

by Rosario Carcò -
Kieran,

the myCourses Block is designed to ONLY SHOW courses you are enrolled in. Which version did you download and install??

My version of myCourses shows only the users' own courses. The second Block I programmed with the same code base is called siteNavigation. This latter block shows ALL courses and ALL categories as it is intended as a siteNavigation facility. siteNavigation offers some options to show only categories or both categories AND courses, depending on the number of categories/courses of your site, which could slow down the rendering of the desired HTML-page.

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Karen Taylor -
Hi all,
I have noticed that course creators assigned to a particular category do not have the courses appear in the block. However teachers assigned to an entire category do.
Any idea how I can fix this other than making all my course creators.. teachers?

Thanks
karen


In reply to Karen Taylor

Re: New myCourses block released

by Rosario Carcò -
Moodle's role system may be a little tricky here: Teachers are ment to be Teachers of every course of the category which also makes them appear as Teachers in every new course you put in the according category.

Course Creators however, are NOT Teachers of every course you or they create in the given category.

This is a matter of definition inside Moodle's role logic.

Of course we could write code which would check first the role of a given user in a given category and then loop over all the courses contained in that category. But I feel we should respect Moodle's role logic here.

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -
Could anybody help to test the intermediate version I prepared to get the functionality back, Bob asked for in this part of the thread?

http://moodle.org/mod/forum/discuss.php?d=67494#p460372

See my instructions there on how to install/test the code and tell me if you would like to keep the displaying of myCourses of the Moodle-Admin.

Thanks, Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
Sorry, Rosario,
I missed the posting with the attachment. I'll be testing later this week. I hacked the previous in a couple places because for some reason, my teachers don't seem to get the clicking the '+' sign and clicking the name get different results, so now all clicks display the subcontents. Also added a course search control at the footer. So... I'll need to throw those things at this one so I can see how it works. Thanks for your good work.
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Never mind, I just saw your reply to my post in the general problems forum and wanted to get back at you, but you were quicker...

Ok, besides the admin functionality I planned the following options, so if you already have code for some of them I will be glad to integrate them:

  • for Moodle Net, I have to integrate also the get_my_remotecourses() to gather all the users' courses
  • option to choose a flat navigation, i.e. NO folder at all, only the course links of the users are displayed
  • search course field, as you already implemented (just pass me the code or I will grab it from the normal Course List page of Moodle)
  • language strings must be all lowercase to comply with coding guidelines
  • the directory for the block must be renamed from myCourses to my_courses to comply with naming conventions
  • indentation in code must be 4 spaces, I use only 2, to comply with coding guidelines
  • all variables must be lowercase, no underscores to comply
  • upload to modules/plugins section
So I am glad to get your test results here, Rosario

Edit: the + sign clicking worked already in the original FN Code and I did not change/hack anything in that code, so could it be that your teachers have javaScript disabled on some workstations?? Or are you using a special Theme?
In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
This looks quite good and I'll be implementing it in our test server today. The code for search box follows:
else{
$this->content->footer = '';
}
+ $id = "coursesearch";
+ $output = '<form id="'.$id.'" action="'.$CFG->wwwroot.'/course/search.php" method="get">';
+ $output .= '<fieldset class="coursesearchbox invisiblefieldset">';
+ $output .= '<label for="shortsearchbox">'.'Search'.': </label>';
+ $output .= '<input type="text" id="shortsearchbox" size="12" name="search" alt=Search Courses"'.'" value="'.'" />';
+ $output .= '<input type="submit" value="'.get_string('go').'" />';
+ $output .= '</fieldset></form>';
+ $this->content->footer = '<br >'.$output;


return $this->content;

EDIT: The SESSION variables for the Admin settings are not kept or retrieved. It will keep the expansion/ compaction settings but not the "show/hide" button settings for either the Admin or any other user.
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Thanks for the code sample.

The expansion / compaction settings are stored automatically by the HTML-Tree library in a cookie.

The show/hide settings work in all my versions and so should also for the admin settings. See attached screenshots, unless I do not understand you correctly. In this case it is best, if you contact me by eMail/Messaging.

Rosario
Attachment adminSettings01.gif
In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
Hi Rosario,
Your email isn't visible. I was merely stating that the show/hide settings don't stick between sessions.
Bob Puffer
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Aahh, now I see: that's because I initialize the settings at every login. As the block appears on the Front Page on my Moodle, and I did not want to wait a long delay, I initialize the settings to not display any courses for Admins. Teachers and Students should get their courses in any case because I initialize them to see all their courses.

So this could become a customization option too, to let the admin choose between "show all courses" and "show no courses", which I could add to the scheduled list for the next release.

If we would like to keep the options between sessions, I should delve into the HTML-Tree code to learn, how this is done with the folders state stored in cookies. This is a piece of code that was not in the original Block, but would, of course be interesting to add.

How should we proceed? I already mentioned the scheduled works. Could we append the fast hack with "show all courses" / "show no courses" for release 06 and add the longer/better solution with preservation of the settings in a cookie for release 07?

Is the desired admin option to show/hide own courses, as it was before and as you asked for?

If this is the case, I will keep this intermediate code base and implement the rest for release 06 and schedule preservation inbetween sessions for release 07.

You are right, the eMail Address is not visible, but the messages are redirected to it. Anyway it is simply my name rosario.carco At the domain of our moodle, i.e. fhnw.ch

Rosario
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, there is a documented moodle api function call in course/lib.php. The function displays automatically all international language texts in the search box, which is better than your hard-coded sample above:

function print_course_search($value="", $return=false, $format="plain")

So I use this one call if the corresponding option was chosen in the settings of the block. Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
I also note that if a category contains other categories AND courses, the courses are not displayed.
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, do you mean for Students or for Teachers or for Admins??

I guess for admins, as they are the only ones who can see every course and category.

In the released version 1.9.05 everything is displayed correctly, see attached screenshot. Are you talking about 1.9.06 beta, where I modified things to show also admin's *own* courses?

Rosario
Attachment myCourses.gif
In reply to Rosario Carcò

Re: New myCourses block released

by Deleted user -
Hello Rosario Carcò,

Do this my courses block will work in moodle2.0, If possible what are the changes i need to go ahead? Please help me
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, also my 1.9.06 Beta shows correctly, see screenshot. Maybe you have to note the displaying settings of the admin (hide own courses). Which is the combination of hide/show causing your problem?


Attachment myCourses06.gif
In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
I encountered a rather nasty problem yesterday with the block... it didn't like the use of an umlaut in the course name. When I added a course with the name, "Münster Program" contained, myCourses block would only show me (and everyone else on campus) one course per category.
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, bless you, you probably discovered why Birgit was missing a lot of courses in the siteNavigation Block which uses the same code base.

The built in functions get_courses() and get_my_courses() are standard Moodle-API, so I suppose they do return the course names in utf8 and not in ready to use HTML-coded strings. The same must apply also for get_categories().

This means that I must find a moodle function converting the utf8 chars to HTML-coded strings, where Umlauts are coded like this &auml;

I scheduled this for the next release. Rosario
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, I could not reproduce the problem you got with Umlaut in "Münster Program", see attached screenshot. Could it be, you used some characters that are not admitted in the Course ID Field?

As you can see, I got Umlaut in my Course categories ever since I started with this block. Apparently the Moodle-Engine that displays the HTML-Texts takes care of every conversion from utf8 to HTML-Tags like &uuml;, so there is nothing to change in the block's code.

Rosario
Attachment myCoursesWithSpecialChars.gif
In reply to Julian Ridden

Re: New myCourses block released

by Fco Javier Rojas -
I would like to have the full name of courses insted of the short name in the tree. How can I get this changed? Could you please help me?
In reply to Fco Javier Rojas

Re: New myCourses block released

by Rosario Carcò -
There is already more than a hint in this thread. But it will be a config option anyway in the next release scheduled for this or next week.

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Michael Buchanan -
This is a great block! But I'm having trouble with multi-language filtering.

I put in a multi-language string for the site name (MoodleAnywhere (english) Moodle ParTout (french). I also put in a string for the category -offline (english) and HorService(french). The string used was:

<span lang="en" class="multilang">MoodleAnyWhere</span><span lang="fr" class="multilang">MoodleParTout</span>

This displays the site name and category correctly for the two languages but in the MyCourses box, both languages are displayed for the site name and category.

Is there a fix for this?

Thanks!



moodleanywhere.gif
In reply to Michael Buchanan

Re: New myCourses block released

by Shawn Drake -
Hi guys,

First of all, I LOVE this block!!

That being said, I'd like to customize it a tad to suit our company's needs. Hopefully someone here will be willing to help me out, I'm no programmer. I don't believe, however, that what I want to do will be very hard for any of you guys.

Basically, if the user is a non-editing teacher (or above), I'd like for them to see this block exactly as it is. If they are anything else, I want them to see the original course list block that comes standard with Moodle. And that's it.

Any input would be greatly appreciated, I want to get this thing installed on our production server soon!

Thanks again,

Drake
In reply to Shawn Drake

Re: New myCourses block released

by Fernando Oliveira -
Picture of Plugin developers

Hi Drake,

I think you could do that with the"override roles" function at the block level. You'll need to edit the "view block" setting for each block according to your needs.

Please post if you need more info.

Fernando

In reply to Fernando Oliveira

Re: New myCourses block released

by Shawn Drake -
Hi Fernando,

Thanks for responding. I have a couple of problems with doing it the way you suggest. The first, and biggest, is that the blocks don't use the user's site role if they aren't defined locally. In other words, I can override the student role inside the block so that it won't see the block, but that will only affect anyone who has been locally assigned as a student in the block. That would be a nightmare for me to maintain between 2 blocks.

Second, Admins would have both blocks visible on the screen. This isn't a huge issue, as there are only a few people with admin rights on our server, but is still an unwelcome clutter.

Thanks for the suggestion, though. If the blocks would use the default site roles, that would work beautifully (except for the admins, which we could just deal with at that point). But given that they don't, I'd like to manipulate the code to display one or the other based on the user's permissions.

Drake
In reply to Shawn Drake

Re: New myCourses block released

by Rosario Carcò -
Where would you want your Moodle-Default-Course-List to be displayed??

The code in this Block can display things only inside the block. So while it is easy to display the link to the default "all courses", it would be a big problem to display this list inside the block.

It would not be hard to check the roles from non-editing teacher up, though. As you suggest, we could display the courses for them as is, and if the role is anything below, e.g student, show only the "all courses" link.

Anyway this block is a block to display the logged in user's courses, that means his *own* courses, and I do not understand, why you would want not to show them for students.

For the moment I am busy with the promised enhancements and bug fixes. But when I have more time I could send you a private version, tailored as you want it.

Rosario
In reply to Michael Buchanan

Re: New myCourses block released

by Rosario Carcò -
Michael, here is the code snippet that takes the Site's name. To process your multilanguage Tag we should find the moodle function that does this type of processing before displaying them in all other situations:

if ($this->course->id == $SITE->id) { //Cr: if we are on the front page, show node text in bold
 $url = $CFG->wwwroot.'" title="'.$SITE->fullname; //Cr: title= will show up a tool tip text on mouse hover
 $text = ' <span style="font-weight: bold;" title="'.$SITE->fullname.'">'.$SITE->shortname.'</span>';
 $cssclass = 'treeMenuBold';
 $icon = 'home.gif';
 $expandedIcon = 'home.gif';
 } else { //Cr: else show it in plain
 $url = $CFG->wwwroot.'" title="'.$SITE->fullname;
 $text = ' <span style="font-weight: plain;" title="'.$SITE->fullname.'">'.$SITE->shortname.'</span>';
 $cssclass = 'treeMenuDefault';
 $icon = 'home.gif';
 $expandedIcon = 'home.gif';
 }

But for the moment I am busy with the promised enhancements. If anybody knows or finds this function, let me know.

Rosario
In reply to Michael Buchanan

Re: New myCourses block released

by Rosario Carcò -
Michael, I found that format_text() and format_string() are the two functions to process multilanguage tags correctly. I think these are called anyway before Moodle displays any text. I tried to call them explicitly in the myCourses block, but with no success. So I think that multilanguage tags are not supported in the site's short and full names.

I could not reproduce a correct display of the site-Name if I navigate to NOTIFICATIONS, the name is still displayed in english even after selecting GERMAN as interface language, see attached screenshot. So where do you feel

>>This displays the site name and category correctly for the two languages??

Rosario
Attachment multilanguage.gif
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -
Dear all, this is the last, i.e. third beta of 1.9.06 (2009052201).

I implemented almost all of the promised options. The only ones that lack are:

  • get_my_remote_courses() for mNet
  • admin option to show all or no courses after login
  • individual user config options instead of global
  • renaming of the folder and block to my_Courses
I will finish next week and post the final 06 release. In the meantime you may test the new version. As usual, backup your current version first in case you need a fallback. Extract the Zip-Archive in a temporary directory and copy everything into your moodle/htdocs/blocks/myCourses directory. Adjust access-rights as needed and point to the Notifications Link in your admin-block.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
Please note that I had to change the config options variable names to all lowercase to comply with Moodle coding guidelines. This has a little drawback: in the mdl_config table you should edit all block_myCourses_xxx variables to the names, as they appear in the block's config setting:

  • block_myCourses_withscrollbars
  • block_myCourses_showallcourseslink
  • block_myCourses_showlongnames
  • block_myCourses_showcategorylinks
  • block_myCourses_showflatlist
  • block_myCourses_showsearchbox
  • block_myCourses_adminshowmycourses
  • block_myCourses_adminshowactivecourses
  • block_myCourses_adminshowinactivecourses

If you want, you can also delete them with phpMyAdmin and go back to the Notifications link to have them recreated automatically.

If you do not adjust the variable names, the Notifications link will continue to prompt you, that new config settings were added.

And the major drawback is that I was asked to change the block's name to my_courses, again to comply with coding guidelines. This means that we will end up with a new block name, block directory and variable names as listed above.

But I do not want you to lose all the block instances in your courses. So, before I rename the whole block, I will investigate on how we could upgrade without losing anything.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
This is the final 1.9.06 (2009052601) release version. To distinguish the zip archive from the previous one I added the letter 'r' in the name.

I left the two last options for an eventual next release:

  • individual user config options instead of global ones
  • renaming of the folder and block to my_courses
Both mean a lot of work.

As stated before, the HTML_TreeMenu Library is a lot of unnecessary overhead, particularly if you use the block with the "Show flat list" option to construct a list of courses without hierarchical folders. The flat list is best combined with the other block I developed out of this same code base: siteNavigation

An eventual next release would imply an upload into the modules and plugins section after renaming the block and directory to all lowercase: my_courses

I am pondering if the two blocks myCourses and siteNavigation should not be combined/merged into ONE block with user individual config options. This would mean, that the user can decide on the fly whether he wants to only see his own courses in a flat or hierarchical view, or whether he wants to see all courses and hence the whole siteNavigation. He could dynamically switch the content of the block as the admin is actually doing in myCourses.

What do you think about that?

Rosario
Average of ratings: Useful (1)
In reply to Rosario Carcò

Re: New myCourses block released

by Jon Breitenbucher -
I just installed myCourses06r as per the instructions here. I changed the name of the directory in blocks to myCourses. I logged in as admin and was greeted with the successful table creation message and after clicking was greeted with the options page for myCourses. I then went to the homepage of the test server and enabled the block. What resulted was no display of the block and the loss of the Block block (i.e., the menu used to add blocks disappeared). The only way to get the Blocks menu back is to delete the myCourses block from the server. Any idea what is happening? I really want to use this block. All of this is on a fresh 1.9.5 install. Thanks.
In reply to Rosario Carcò

Re: New myCourses block released

by Andy Hawkins -
Rosario - I am moving the response to your help on site Navigation here as the block we really need is myCourses and if we can get that working it would be really good.

Thanks for your supportive suggestions (see siteNavigation discussion - Oct 2009).

I though we would be best starting again on our test server so we do not mess up our live one.

So I removed the block from Moodle, and the folder from the blocks folder, and after your comment also checked the mdl_config table and found settings still there - so removed these. (interestingly the 'working' test server still had mycourses settings in the table - removed these also)

  • Downloaded myCourses06r from the myCourses discussion and uploaded it to the blocks folder after renaming to myCourses
  • Errors set to developer

Following behaviour was noticed -


  • Firefox - logged in as admin - front page changed - site news block took over whole page width and turn edit on button disappeared. Other blocks disappeared incuding moodle admin. (before adding myCourses block anywhere) No errors reported
  • Firefox - logged in as another user, front page looked OK (tested by browsing users as admin and choosing login as from their profile) No errors reported
  • IE8 - not logged in - looked OK No errors reported
  • IE8 - logged in as admin - only site news block shows (correct width, not across page) and no moodle admin block shows; turn editing on button not showing. No errors shown.
  • Firefox - logged in as admin - on notfications page - turn blocks editing on and added mycourses block. Block added OK on left, with only to plevel showing, despite admin haviong all 3 options ticked - own courses, active and inactive. Link to all courses OK, and category link seemed to work, No errors shown.
  • Firefox - logged in as admin - added mycourses as sticky block to course view - went to course view and added myCourses - got error - see attached image- block shows on course page but only with main site link at top and all courses and search box showing.

Switching on all the options makes no difference except the search and show all links turn up.
Settings in mdl_config seem ok and match those in GUI

Need to fix admin view of front page so can add the block - until then cannot test further.

Not sure where to go from here - hope the single error may point in some direction - it means little to us.
TIA


PS your bulk course upload is great and working well. Thanks.
Attachment mycourses-sticky-error.jpg
In reply to Andy Hawkins

Re: New myCourses block released

by Rosario Carcò -
Andy, let me go through your points and help you, as far as I can:

  • Firefox - logged in as admin - front page changed - site news block took over whole page width and turn edit on button disappeared. Other blocks disappeared incuding moodle admin. (before adding myCourses block anywhere) No errors reported
I have the same setup with my 1.9.4+ Server, so have a look at it here:

https://moodle.fhnw.ch/moodleTest

You may log in with the following Test-Account: myblocks (pw: myBlocks)

As you say, you have first to rearrange/fix your frontpage display. Try removing every Block and other displays from Admin-Block->FrontPage. Use this link, if you are not able to see your Admin-Block: http://yourMoodleURL/admin/settings.php?section=frontpagesettings
IE8 - logged in as admin - only site news block shows (correct width, not across page) and no moodle admin block shows; turn editing on button not showing. No errors shown.
  • Firefox - logged in as admin - on notfications page - turn blocks editing on and added mycourses block. Block added OK on left, with only to plevel showing, despite admin haviong all 3 options ticked - own courses, active and inactive. Link to all courses OK, and category link seemed to work, No errors shown.
ATTENTION: as I explained in a post before, ALL Buttons ON, means to display ONLY ADMIN'S own courses. And that's nothing, if he is not enrolled in any course. So simply tick the blue button to OFF, and ALL active AND ALL inactive Courses are displayed.
  • Firefox - logged in as admin - added mycourses as sticky block to course view - went to course view and added myCourses - got error - see attached image- block shows on course page but only with main site link at top and all courses and search box showing.
ATTENTION: if you are not logged in as ADMIN or TEACHER, you do not get ANY of the buttons, because Students can see only their own courses. If you log in as TEACHER, you got TWO Buttons to control the display of ACTIVE and INACTIVE (i.e. hidden) Courses. And if you log in as ADMIN, you get THREE Buttons to control also your own courses.

  • undefined property Error
This Error is not critical, as it shows up only in DEVELOPER's DEBUG Modus. But I will have a look at this variable and correct in the next release. Most probably it is not correctly initialized and hence is undefined on that line 216, where it is used.

Ok, I just had a look at it: I CAN NOT FIND anything similar on line 216, my code does not reference $pageid directly but as $this->instance->pageid

Could you please give me the first few lines of block_myCourses.php? They should be:

/**
 * Main block class for myCourses block
 *
 * @package myCourses
 * @category blocks
 * @author Rosario Carco, Fachhochschule Nordwestschweiz
 * @version 1.9.06, 2009052602

The best is to send them to my eMail, rosario.carco[ATourDomain]fhnw.ch

But WAIT, what's STICKY BLOCKS?? I just verified and read this:

"If any block you add here is already present in a particular page, it will result in a duplicate.
Only the pinned block will be non-editable, the duplicate will still be editable."

So please pay attention again: myCourses Block CAN NOT APPEAR twice on a page due to the underlying HTML-TreeMenu Library used. To have siteNavigation and myCourses Blocks on a same course-page, I had to change some Variable Names of this Library to avoid conflicts.

So why would you want to put a sticky block? editable or non editable? myCourses is NOT editable anyway.

If you want to configure Blocks that should appear on any new course page per default, you can use the following line in your main config.php File:

$CFG->defaultblocks_override = 'participants,activity_modules,search_forums,admin,siteNavigation,myCourses:news_items,calendar_upcoming,recent_activity';

All blocks left of the : are displayed on the left side and all others on the right side.

Hope this helps, Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Andy Hawkins -
Rosario

Many thanks for your very detailed (and patient) response.

From a cursory glance of your post it seems we may have misinterpreted some of your previous comments - apologies.

I will find a suitable time slot in the coming week to go through your comments (we are currently on mid term break) and will let you know how we get on.

Andy

In reply to Rosario Carcò

Re: New myCourses block released

by Andy Hawkins -
Rosario

Many thanks for your helpful comments.

On our test server, it seems the existing FN-mycourses menu had obstructed your mycourses in some way - perhaps by having 2 HTMLtrees - not sure.

After considerable permutations based on your suggestions, we now have mycourses working on the test server. (I had written a very long email with many screenshots - but fortunately it is not needed at the moment)

However, at present we are still struggling to do so on the live server, even though we think we have followed the same steps.

Time is against us right now as other project waves are breaking on the shore and we need to attend to them as well as put time into supporting the content of the production site.

We will return to this at some point (soon).

In the meantime - very many thanks again for your support and patience. approve

Andy
In reply to Andy Hawkins

Re: New myCourses block released

by Rosario Carcò -
As I documented in the code, myCourses and siteNavigation could not CO-Exist on the same page without some changes in the underlying HTML-TreeMenu library. And the same applies if you are using the original FN-myCourses Block at the same time as one of my two blocks.

Why would you want to continue to use the FN-Original? It was written for Moodle 1.5 or so and produces a lot of Error-Lines if you put your server into DEBUG Mode for Developers.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Andy Hawkins -
As we said in our earlier post, we were continuing with FN-menu on our production site as we needed something that was working OK until we changed over. (without debug in developer mode it seemed to be fine despite its aged pedigree)

This was before we discovered what was under the hood of both blocks (ie HTML treemenu) and its incompatibilities with itself. (we are not familiar with coding, as you are)

What is surprising is that we are using the topics-tree course format which we also think uses HTMLtreemenu on both test and production servers, and on the former, mycourses and the topicstree courses appear to work OK together. (I am guessing that this may be because it is in a different context - course format - rather than being in the same context ie a block)

We do want to use myCourses with its neat tree menu but something is causing a problem on our production server. Finding the problem will take some time we don't have at the moment and so for the time being we are reverting sadly to the standard courses block. (rather than re-install FNmenu which may cause problems when investigating)

We will return to this - just not at the moment. Thanks again.
Andy

In reply to Julian Ridden

Re: New myCourses block released

by Richard Whitfield -

Hi - this block looks really good! I've downloaded it as per the instructions, run notifications and it said that installation was successful. I then stuck it on the front page of the site and the block went on OK. However, if I turn editing off it disappears.

I'm currently logged on as an admin and enrolled on a course but it still does not open and display my course/any files/folders, etc, etc. No icons are in the block folder.

Am I doing something really stupid or are there some hidden boxes/code I have to tick/change??

Any help would be ace as I'm new to moodle and need to get this working asap

Cheers Folks

Rich

In reply to Richard Whitfield

Re: New myCourses block released

by Rosario Carcò -
Can you access the config options page in Admin -> Modules -> Blocks -> myCourses??

If not, something with the installation went wrong. Check again the correct installation path (yourMoodleRoot/blocks/myCourses, pay attention to correct spelling) and adjust the acces-rights of every directory and file in it.

If yes, turn on all the config options to see something. I turn off everything per default, to have a fast display, especially on the FrontPage.

Try different positions of the block, left, right, on top and bottom of every other block. I know that siteNavigation and myCourses can have distorted displays if myCourses precedes siteNavigation. Have a look at my production server, where I use both: https://moodle.fhnw.ch, siteNavigation is open to not logged in users. If you need a test-account on my test-server, let me know.

If you are looking for a means to navigate the whole site rather than displaying the user's courses, check my other block siteNavigation mentioned in this thread.

The Moodle built in function get_my_courses() returns only courses in which you are enrolled either as teacher or student. Other roles are not checked (or more technically: it returns only the courses the user is allowed to 'view'), so since the role system was introduced, I should perhaps switch to the function get_user_courses_bycap(), which returns the courses on a 'capacity' criterion. But then we would have to define the roles/capacities we would like to check here. As Admins may add any new roles and capacities, this would become a very dynamic block, if it were to check every role and capacity.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rafael Scapin -
Hi Rosario,

I have installed the latest version of myCourses module on a Moodle 1.9.4+ server.

I get 2 errors though:

**************************************************************

Notice: Undefined variable: course in /var/www/html/blocks/myCourses/block_myCourses.php on line 20


function specialization() {

/// Need the bigger course object.
if ($this->instance->pageid == SITEID) {
} else {
$this->course = $course; ------> line 20
}




Notice: Undefined property: object::$block_title_edit in /var/www/html/blocks/myCourses/block_myCourses.php on line 115


function get_header() {
global $CFG, $FULLME, $SESSION;

if (!$this->admin ||
/// This is needed in order for this block to work with custom title hack.
/// Return just the title (no filters) if we are editing the title.
(($this->edit_controls !== null) &&
($SESSION->block_title_edit[$this->instance->id] === true))) { ---> line 115
return $this->title;
}

***************************************************************


Could you please help me on this?

Thanks a lot!

Rafael
In reply to Rafael Scapin

Re: New myCourses block released

by Rosario Carcò -
Rafael, what do you mean by LATEST VERSION??

You are probably using the old FN original adapted by Julian at the top.

My own versions do not contain your code lines any more. Take myCourses06r.zip deinstall in the Admin->Modules->Blocks->myCourses and replace everything in your .../blocks/myCourses Directory with my own code, EVERYTHING, since a lot of things got changed here.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rafael Scapin -
Hi Rosario,

Thanks for your reply. Sorry I got the old FN. I have just installed your module and it works great!!!!! Thank you so much!!!!!

Rafael
In reply to Rafael Scapin

Re: New myCourses block released

by Rosario Carcò -
I am pleased to hear great news. Please help to decide, whether we should combine this block again with the possibilities of the siteNavigation (see thread mentioned earlier), so as to have only one block, to spare place, to be flexible on the user's side and to have only one source to maintain in future.

I see no reason to show the three buttons in the header only to admins to toggle myCourses, activeCourses and inactiveCourses. We could rather ADD some more buttons to toggle siteNavigation (show all Categories/Courses, as does this block), show siteNavigationByCategories (show only Categories, no Courses, which is good for large sites with more than 500 courses, as the underlying HTML-TreeMenu Library is rather slow to render such a large number of nodes and subnodes, reason for which I am still looking for a faster code base) also for teachers and students.

I think there should be not even a problem with the option to show/hide the block to not logged in or only to logged in people. This could still remain an Admin option as it is in siteNavigation.

Try also this block, which at the moment is a good combination with the myCourses block and report back your opinion or have a look at my production server, where I use both: https://moodle.fhnw.ch, siteNavigation is open to not logged in users. If you need a test-account on my test-server, let me know.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Richard Whitfield -

Cheers for the detailed reply - I'll try out your suggestions & see what happens. 

 Richard

In reply to Richard Whitfield

Re: New myCourses block released

by Nigel Osborne -
Can you explain why this block appears on my site for Guests (not-logged in), but none of the courses below the top level that do allow guest access are listed.

If I want that option, is the siteNavigation block the only alternative?

What I really want is something between the two - that will display the blocks any users is allowed to access, but only those blocks.
In reply to Nigel Osborne

Re: New myCourses block released

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I would like to know if this is the same myCourses block shared by Julian Ridden in the Modules and Plugins database. If it is an updated version I would like to take steps to get the primary maintainer identified so that further development can proceed without having various zip files in the forums. Thanks for any information on the history of the various myCourses blocks and what I might be able to do to facilitate it's further development and maintenance. Peace - Anthony
In reply to Nigel Osborne

Re: New myCourses block released

by Rosario Carcò -
Nigel, I think this is that way because the Guest User is allowed to enter some courses, but he is NOT enrolled automatically in a course as normal Students do.

I do not even know whether you could enrol the guest user in one of your courses despite being open for guests. If you can, try to do so.

If not, siteNavigation is the only alternative, as it shows categories only or categories and courses, depending on the corresponding config options you can set.

If we stick to the definition of myCourses, it should only show courses the given user is enrolled in. To enrol in a course, normally you have to log into the system. And the guest user is sort of a user outside the system, anonymous and one account for everybody. Hence enrolling in this or that course does not really make sense.

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Olaf Nöhring -
Looks great. Maybe make it possible to sort the entries: Cat ascending/descending as well as courses.
The sort should not be permanent since the given order mitgh be important to the teacher.

Olaf
In reply to Olaf Nöhring

Re: New myCourses block released

by Rosario Carcò -
Olaf, good idea. I will retain these config options to sort categories and courses independently for the next release.

>>The sort should not be permanent since the given order mitgh be important to the teacher.

For the moment the config options are "global" admin options, so that the block behaves the same way for everybody.

But as mentioned earlier, I am working on a merge of myCourses and siteNavigation which makes sense only if the users are able to choose their own config options or change them on the fly, e.g.

  • display myCourses only
  • display siteNavigation
  • display siteNavigation with categories only
  • display siteNavigation with categories AND courses
  • display categories/courses in alpabetical order (asc/desc, as you propose)
  • etc.

Rosario
Average of ratings: Useful (1)
In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
Hi Rosario,
Sorry if I missed it but I've not seen anyone posting that the categories don't expand consistently in Safari or Chrome. Click on one category and it will expand. As you move down you eventually hit a category where nothing shows up underneath it (even though there are courses that should show up). In my instance, once this category is hit, all categories below it act the same way.
In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, I am glad you came back, because I fell into the same problem you and Birgit related, just yesterday:

As I had already supposed, some Category (and I suppose also Course Names) may contain special characters that cause the php-script to break and to exit without finishing and hence not displaying anything at all (my own case) or display only partial categories and contents (your case and Birgit's)

As I knew what I had done the day before, I could track down the problem:

it is not the special chars like äöüç()-, etc. it is the APOSTROPHE (') which caused the problem. I had named one category

Bases de l'optométrie

Now I know the APOSTROPHE is an important string delimiter in PHP, so this may effectively break the code if it is not treated accordingly when Moodle retrieves the data from the database.

I have still to track down further to see, whether it is only this char to break things or whether there are still other chars around. I hope you can check on your own system for chars that stop the correct display. If you go through top down, you can localize the category or the course Name which causes the problem.

As these special chars, including the APOSTROPHE do not cause any other problem in Moodle's display I guess that I must use a certain function myself in my code, eg. strip_slashes or the opposite or the like.

If you have a hint, let me know. I will report back next week as soon as I find the time to do some more tests and search for such a function that could correctly deal with that nasty APOSTROPHE.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
My investigations showed that it is the tool tip help text which breaks everything if some special chars are in the site, category or course names.

As I have seen in the TreeMenu.js and TreeMenu.php the link/url and the text to display were already in it. But the idea of displaying a tool tip help text like the long name if short names are displayed and vice-versa, was maybe a fortunate addition of sombody else before I started to recode the block.

The tooltip help text was simply added to the url which gives the link to the category or course in Moodle's fashion and no meaningful text. So someone put the course or category name in it and this works fine if your names do not contain special characters.

I did not research all the possible characters that break the url tag. I know, as Bob, Birgit and myself reported, that there are some, like the Apostrophe in french l'avion, or Bases de l'Optométrie. While é, ü, ö, etc. do not break the tag.

The tag is composed like this:

<a href="url.to.your.moodle/course/view.php?id=111" title="Bases de l'Optométrie">Bases de l'Optométrie</a>

So this tag is broken by some special characters in the title= section

See the post and release below.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Deleted user -
please help me how to add this block to moodle2.0
In reply to Deleted user

Re: New myCourses block released

by Rosario Carcò -

NOT possible for the moment. But Moodle 2.x has its own navigation block. Unfortunately it lacks a lot of functionality we have in myCourses and siteNavigation.

In reply to Bob Puffer

Re: New myCourses block released

by Rosario Carcò -
Bob, as usual I am very busy these times, programming a bulk course import, see here if you are interested in this code:

http://moodle.org/mod/forum/discuss.php?d=128317

and installing a new moodle server.

Could you check whether I need to use a function like add_slashes to solve this problem? It's documented in Moodle's PHP-Xref.

Thanks, Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
In the meantime I had a look myself and studying other moodle-code I saw that every line of text taken from the database is treated with addslashes() which seems to be a built in function of php, and not Moodle, as I thought.

So please be patient, until I find time to finish version 1.9.07

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -
Dear all,

I was using the siteNavigation and myCourses block not only on the FrontPage, but by default on any course page.

After migrating our production server to a Virtual Machine, we had serious problems with the CPU utilization of mysqld so that I had to migrate back everything to the previous physical server.

As on the physical server the same symptoms arised, most probably the reason was in some corrupted tables (mdl_log, mdl_backup_log). After I emptied/truncated them, I switched also off backup and statistics cron-jobs, which seem to have made the trick.

During the last days I did some load-tests and discussed the results with a moodle-partner firm.

We saw that loading the FrontPage and any other course page displays more than 1'000 queries if you enable the Admin->Debugging->Performance info switch and

define('MDL_PERFDB', true); //to show number of queries per page in the performance footer

in your moodle/config.php file. On our site we have roughly 2'000 courses nested in many categories.

So we discovered that the original myCourses code which served also for the siteNavigation block is using queries in loops and recursive calls, which maybe was the only solution when the block was programmed for the FN_Moodle, and may still be ok for small sites. But it is definitely not ok for medium and large scale sites.

So, at the moment being, I have to stop further development until I find simpler queries yielding all the data we need so that we can process only data in a loop without doing more queries to the database than necessary.

NOTE: this may be true ONLY for the admin user and NOT for the TEACHERS and STUDENTS as they get in any case only the result of the get_my_courses function which is a standard Moodle API call. But you can not see the performance footer output if you log in as a normal user. We will have to find that code first to display it also for normal users to check whether the number of queries are acceptable or not.

I apologize for any inconveniences so far: it seems to be a bad idea to trust older Moodle Code and it is hard to follow at the speed Moodle Development continues, at least for a hobbyist-programmer like me.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
This is another intermediate version on the way to 1.9.07

It addresses the following issues which were reported by Birgit May and Bob Puffer, when using special chars in site, category and course names, and by Michael Buchanan when using multilanguage strings in site, category and course names:

* 2009/11/13 Cr - investigated the code to avoid problems with
* course names containing special chars like the APOSTROPHE!
* UNFORTUNATELY addslashes, htmlspecialchars and htmlentities
* do not correctly translate some special characters. If you
* use one of those characters in your category or course names
* the title="some tool tip text" inside the <a href="url"
* title="some tool tip text">link to course or category</a> will
* break and not display anything in the block.
*
* So either you use one of those tricks:
* - you remove the special char which causes the trouble from
* your category or course name or you replace it with another
* substitute like the Back-Tick for Apostrophe like l`avion
* instead of l'avion
* - you encode the special char in your category or course
* name with &apos; or &uuml;
* - you insert a substr_replace() to replace the critical char
* only for the tool tip texts
* - you comment the lines in this code which provide the tool
* tip help to avoid displaying it. I might add another
* config option for this later on. The lines to comment are:
*
* title="'.format_string($course->shortname); or
* title="'.format_string($course->fullname); or
* title="'.format_string($SITE->shortname); or
* title="'.format_string($SITE->fullname); or
* title="'.format_string($catnode->name);
*
* 2009/11/11 Cr - added format_string() to correctly show multilanguage cat
* and course names

Simply copy the attached block_myCourses.php to your /block/myCourses Directory. You may want to copy your existing version to another place in case you have to revert back.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
Sorry, today I realized that htmlspecialchars() needs an optional parameter to correctly convert single and double quotes:

>>''' (single quote) becomes '&#039;' only when ENT_QUOTES is set

So I made some quick tests and it seems to work. It could help us circumvent the previous mentioned workarounds to correctly display course and category names having special characters in the tool tip help texts.

I am not sure, however, if using

>>htmlspecialchars(format_string($catnode->name), ENT_QUOTES)

could interfere with Moodle's displaying and rendering functions.

In the course_list block I saw another trick which could help us:

>>title=\"" . format_string($course->shortname) . "\" "

I will make some more tests and report here the results.



Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
I just tested on Version 1.9.9+ and the block still works.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Rosario,

Sorry, it certainly isn't my intention to cause problems but could you tell me where to obtain the entire package (latest version)? I have downloaded the various pieces uploaded here in this forum and tested all of them but they do not function as I anticipate. (i.e. they display all courses instead of categories, or no function at all, etc.).

For some of them however, I have been simply replacing the one file (block_MyCourses.php) because that was all that was posted. The latest I can find is:

block_MyCourses.php file posted on 11/14/2009 in this thread

&

MyCourses06r.zip package posted on 5/26/2009

I have taken the package and replaced the block_MyCourses.php file with the most recent version and the block does not function as I require. It does work but it displays all courses in one long list with no categories.

See the screen shot attached.

This is not the functionality from the original MyCourses block which is what I need. The version I posted in CONTRIB-2032 does display categories (what I need). I understand the issue with recursive queries but have not had an issue yet. Our site has 906 courses now with many categories (sorry I don't have an exact count) and the only delay experienced on the front page (or wherever the block appears) is by the admin and even then it is a very short delay (2 to 3 seconds depending on the browser).

I'm just wondering if there is any way that we can have the version that displays categories returned to Modules and Plugins or if your latest version is supposed to display categories and just isn't working for me...?

Regards

Jason
Attachment MyCoursesNoCategories.jpg
In reply to Jason Hollowell

Re: New myCourses block released

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Here is a screen shot of the block with the version of MyCourses that I am using. This is from the exact same setup as the previous screen shot. All I did was replace the most recent package of your block (explained above) with the one I am using and refreshed the page. (the one posted in CONTRIB-2032). This is the type of behavior I would like to have as long as it's not going to be excessively burdening my database with recursive queries.

Jason

P.S. This is on 1.9.8+ but I did just test it on 1.9.9+ yesterday and got the same thing.
Attachment MyCoursesWithCategories.jpg
In reply to Jason Hollowell

Re: New myCourses block released

by Rosario Carcò -
Jason, I guess you missed the MANY MANY Admin-Config-Options I introduced to my Version of myCourses.

Please check there, I presented all those config-options in this very thread, and please report back, if you still have problems with the latest version which is 1.9.06r with some minor changes on the way to the next release which will be 1.9.07 to better deal with multi-language-Titels of courses and categories.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
And the long course list is because you log in as admin. So you should click on the blue button to toggle on/off the display of the courses you are enrolled in.

But you would not enrol in any course as admin anyway, would you??

I explained in one of my posts, why I have at least TWO accounts, one for administering and one to work as normal teacher, another one to work as student, etc. depending on the role and the tasks I want to do.

And I explained also, why I removed this functionality first, and reintroduced it again because Bob Puffer wanted it back again.

So check the block also when you log in as Teacher and Student. For those two roles the block shows only the courses the user is enrolled in.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Rosario,

No, actually I didn't miss the 9 Admin-Config-Options. I thought I had them all set correctly but obviously I hadn't looked closely enough smile

I see that I need to untick the "Show flat list" box to get the categories to appear as I am accustomed to. Sorry for not being able to figure this out. sad

There are a couple of additional little things that aren't immediately clear that I had to play with a little more to figure out. One being that when "show scroll bars" is enabled the height of the myCourses box seems to be static and is set to a size that is much bigger than I need given the number of categories I have. But that is all the more reason to just turn it off, right smile

Anyway, once again, I am VERY SORRY to have missed the functionality here. Is there any way we can beg and plead with Anthony to have this returned to the Modules and Plugins page as a direct download?

Jason

P.S. I like the functionality of being able to click on the category link to go to the corresponding category page!! I know that's not all that new for your block but it is a new and very appreciated one for me.
In reply to Jason Hollowell

Re: New myCourses block released

by Rosario Carcò -
Jason, I am very pleased to hear that you succeeded in installing and correctly configuring this block.

Now

  • Forget about all previous versions and features of this block. From now on we talk only about this one and all necessary bug fixes and feature enhancements will be done on myCourses and siteNavigation which can neatly be combined on every Front and Course Page (see www.fhnw.ch): myCourses to display the users courses and siteNavigation to let all people navigate through your Categories and Courses. The siteNavigation Block can be configured to let users navigate only after login or, if you prefer like we do, WITHOUT logging in.

  • I was not ready to put this block into the Plugins-Database because of the major two points pointed out in this thread, in the siteNavigation thread and also here on the Moodle Tracker: http://tracker.moodle.org/browse/CONTRIB-1442
So, as Fernando Oliveira, the programmer of the original FN myCourses block, has jumped in again, we are pondering on the next steps to take to merge siteNavigation and myCourses into one block.

Rosario
Average of ratings: Useful (1)
In reply to Rosario Carcò

Re: New myCourses block released

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Rosario,

smile Yes, any future reference to upgrading this block and/or having it added to the Modules and Plugins page will be made in reference to this version. I will watch attentively in CONTRIB 1442 and comment when necessary on the progress. Would it be possible to put a fully packaged version of both of these in the CONTRIB area rather than having the pieces floating around here in the forums?

Once again, I am sorry for not "figuring it all out" sooner. I'll redirect my energies into cheering for you and others who are working to get these two blocks merged and presentable for the Moodle community. smile

In the meantime I guess I'll have to refer others to this forum if they want to download and use the block(s).

Jason
In reply to Jason Hollowell

Re: New myCourses block released

by Rosario Carcò -
As announced, Version 1.9.07 will be the next release of both, myCourses and siteNavigation, as soon as possible.

And depending on the strategic decisions we make to merge or freeze up these two blocks to conentrate on the navigation mentioned in Contrib 1442 (see thread of siteNavigation: http://moodle.org/mod/forum/discuss.php?d=103703), we will either

a) freeze up everything at this stage, but continue to support and bug-fix the 1.9.x line

b) backport the Moodle 2.x navigation (whatever this is, I do not even know it. Is it a handy block, which would be the easiest to port back, or is it a lot of code built in like the bread-crumbs on every course page, which would be more of the hell to port back into the Moodle 1.9.x line)

c) merge the two blocks into one to have ONE block (in stead of two) with a lot of on the fly functionality and switches so that the users can decide what the block should display

Rosario
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -
Thanks a lot for your patience. This is what I did in the last few days:

Bob, Jason,

I just discovered, that the myCourses Block DOES display EVERY course for admins independently of our blue button to toggle own courses on and off.

I feel this depends on the installed Moodle version. It worked as intended with versions before 1.9.4 when I reimplemented this feature. But it seems to have gone because of a change in the Moodle Api functions:

get_my_courses() AND/OR

isteacheredit()

which could have been revised since November 9th 2009, which is now documented as follows:

"return (has_capability('moodle/legacy:editingteacher', $context, $userid, false)
or has_capability('moodle/legacy:admin', $context, $userid, false));"

So I can no longer use it to distinguish the admin's OWN and other courses.

get_my_courses() is now documented as follows:

"For admins and others with access to *every* course in the system, we should
try to get courses with explicit RAs. Convenience function - lists courses that a user has access to view"

Which means we should check for Role-Assignments/capacities because Admins have the capability to VIEW ALL COURSES, even if they are not enrolled in any one explicitly. And further:

"If you really want to know what courses are assigned to the user,
without any hiding or scheming, call the lower-level
get_user_courses_bycap()"

So I will have to study and implement this function if we want to stick at the idea, that an admin can be enrolled in certain courses. I already told why this seems to be a bad idea to confuse admin role with other roles like Teacher, Student, etc. in courses. I strictly use according separate accounts to enrol and work in courses. And I do the same also for all the different Moodle-Admins I have delegated the Admin role in a certain Category. Roughly we have 8 Universities, each in one Category with its own Admin. I created separate Admin accounts for them so that they can log in as admins or teacher or students with 3 separate accounts.

Anyway if we want that functionality back, there is another convention we must agree: as the cited function returns the courses based on the Role we want to check, we must define that admin's OWN COURSES are courses in which he is enrolled either as TEACHER or as STUDENT, as it was until now.

Or would you like me to program rather that he gets any course in which he is enrolled in any Role??

OK, I feel the logic should be to return all the courses in which the admin account has been enrolled, i.e. admin, coursecreator, editingteacher, non-editing teacher, student, guest, and all self created possible roles.

OR SHOULD WE DEFINITIVELY ABANDON THIS FEATURE for sake of clarity and simplicity ??

and advice the admins NEVER to enrol in courses with the Moodle Admin account, but to use separate accounts depending on what they want to do/test. As Bob reported, you can only log in with one account per internet browser, but that is why I ALWAYS USE TWO and more browsers at the same time, to log in with different accounts and to test look&feel on different browsers.

Please tell me your preferences.


For the moment I see the capabilities

moodle/course:update AND moodle/legacy:editingteacher AND moodle/legacy:student if we want to check only those three

which could do the trick with the get_user_courses_bycap() function without having to loop over all possible roles an admin could have in a course.

AND THIS IS WHAT I HAVE IMPLEMENTED for the moment being. I check for the legacy:editingteacher and legacy:student capabilities of Admin in every course that should be displayed as OWN course. Anything else will be implemented or removed in the new merged version called sitenavigation (see corresponding thread).

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
And here is the promised version 1.907 (2010072201)

PLEASE NOTE:

* 2009/07/20 Cr - this is the final version before we start over with a merged
* version of both the blocks myCourses and siteNavigation.
* You will find any further development and comments in the
* siteNavigation thread on moodle.org Forums.
* - corrected display of admin's own courses which could not be
* toggled on/off any more, because unfortunately since 20091109
* isteacheredit() returns true both for teachers and admins so
* I had to correct this here with single capabilities. Maybe we
* should check for more capabilities in future, depending on the
* roles you enrol in your courses with your Moodle admin
* account. ANYWAY I feel it to be a bad idea to enrol into
* courses with your Moodle admin account, you would better use
* separate accounts for this.
*
* 2010/07/15 Cr - tried also htmlentities($string, ENT_QUOTES) instead of
* htmlspecialchars() but this breaks the tool tip texts also.
* So for the moment I leave it with htmlspecialchars.

I will of course continue to support this block as long as you will use it on the Moodle 1.9.x line. And you will find a corresponding 1.9.07 version of the siteNavigation block in its thread here: http://moodle.org/mod/forum/discuss.php?d=103703

Any new features and development will be done on the merged block called sitenavigation (all lowercase letters), to distinguish it and to use and test it concurrently to the existing myCourses and siteNavigation blocks.

Please unzip, copy to your moodleroot/blocks/myCourses directory and adjust any needed access-permissions on the files on a test-server first. If you want to test on the production server, be sure to back up the whole myCourses directory first, so that you can quickly revert to your previous version in case of need.

Rosario
Average of ratings: Useful (1)
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
In this version I noticed a side-effect: if teachers toggle off the myCourses and the inactive courses buttons, they see a list of courses where they are enrolled as STUDENT and/or NON-EDITING-TEACHERS...

which is fancy too, but was not intended and not possible before because we checked only for isadmin() and/or isteacher()

Now, with capabilities, the filter options are more granular and we have to really decide what we want to display.

But not in this thread. This talk will be done with the merged new sitenavigation block, as announced.

I had to backengineer another function because the TEACHERS did not see any courses per default like Admins. So expect another version in the next few days.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -
Here is version 1.9.07 (2010082301)

I only add the modified block_myCourses.php source. Simply copy it into your ../blocks/myCourses Directory and point onto your NOTIFICATIONS link on the FrontPage.

Rename any previous versions for backup, in case you need to revert back.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Fred Yankowski -
I just tried in this version, 1.9.07, 2010072201, with moodle 1.9.10. The problem I see is that an ampersand in our site name is showing up as "&amp;" in the myCourses block. That is, our site title is similar to "Teaching & Learning" and when that title is displayed in the myCourses block it appears as "Teaching &amp; Learning". It appears as if HTML entity encoding is being performed twice when it should have been only once. (I had to use HTML entities in this very message to get an ampersand to display)
In reply to Fred Yankowski

Re: New myCourses block released

by Rosario Carcò -

Fred, I documented a few workarounds in the block_myCourses.php Header Comments. Snippet:

*               - This is the code sent to the client browser if we use
*                 htmlspecialchars(), where the apostrophe gets encoded to &#039;
*
*newNode_8_3_2_1 = newNode_8_3_2.addItem(new TreeNode1(' Bases de l\'apostrophe öäüéàèÜÖËÈÙÌôûêâ optométrie',
*                    'folder.gif', 'https://moodle2.test.fhnw.ch/course/category.php?id=441"
*                    title="Bases de l&#039;apostrophe öäüéàèÜÖËÈÙÌôûêâ optométrie',
*                    false, true, 'treeMenuDefault', '', 'folder-expanded.gif'));
*
*               - Anyway it seems we have
*                 still to avoid some special chars in category or course
*                 names. See my proposed workaraounds below.

So maybe your Ampersand is not correctly treated by htmlspecialchars()

Tell me, if you need more assistance by eMail.

In reply to Fred Yankowski

Re: New myCourses block released

by Rosario Carcò -

Dear Fred, I just saw that on my Test-Server I have a category with an Ampersand and it shows up correctly. There is no difference between site-Name and category-Name, unless it gets stored differently in the database. You could make a test on your own with a category name and then have a look with phpMyAdmin into the mdl_courses and mdl_course_categories tables.

siteNavigation.gif

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Fred, as you reported, there are also categories and course names which use the Ampersand (&) and I guess also other characters which could break the tooltip-text. So for the moment being we avoid the breaking but the following chars will appear according to the transformation scheme of the function htmlspecialchars() in the tool-tip texts:

>>
The translations performed are:

  • '&' (ampersand) becomes '&amp;'
  • '"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set.
  • ''' (single quote) becomes '&#039;' only when ENT_QUOTES is set.
  • '<' (less than) becomes '&lt;'
  • '>' (greater than) becomes '&gt;'

>>

So using htmlspecialchars() may be not the last and definitive solution.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Bob Puffer -
Sorry, Rosario, I'm out-of-pocket right now and didn't really even get a chance to read your whole posting, just scanned it so my comment may not be germane... I've got version 2008090801 of myCourses block operating as I would expect it to on Moodle 20100609 with regards to Admin's blue button filtering courses for which he's not an instructor.
In reply to Bob Puffer

Re: New myCourses block released

by Phil Raymond -
1. Just thought I'd mention that when administrators are also non-editing teachers in certain courses, those courses don't show up in their myCourses block, although when they are editing teachers, the courses do show up. Not sure if this is intended behavior or not.

2. Also, I would love to be able to exclude categories.

Thanks so much for your hard work.

Phil
In reply to Phil Raymond

Re: New myCourses block released

by Rosario Carcò -
>>non-editing teachers

You are right, until now only (editing)TEACHER and STUDENT was showed and it was meant this way.

As I wrote, with capabilities this could lead us very far and beyond the scope of showing MY-COURSES in which the logged in user is enrolled either as Teacher or Student.

The Admin was a special case anyway because the code checked for view-capability and the Admin, as per definition, has view-capability on EVERY course. So I had to filter with the blue button to find only those ones where he is enrolled as Teacher or Student.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by jay conk -

Hello All,

This is potentially a great block for my needs; however students seem to be able to see all courses whether assigned to them or not. Also, it would be great if a student could see courses they have taken, and courses they need to complete, that would be great too.

If anyone can shed light on this that would be great. We use external DB authentication. I tried assigning permissions via the block itself but that doesn't work either. I'm using 1.9.9+ It appeared to work until we went to external auth via DB.

thanks for the great work, and of course any feedback on my delimma is greatly appreciated.

Jay.

In reply to jay conk

Re: New myCourses block released

by Rosario Carcò -
I proposed my two cents regarding the Students being able to toggle the courses to be OLD/inactive courses and RUNNING/active courses in another thread:

http://moodle.org/mod/forum/discuss.php?d=118423
http://moodle.org/mod/forum/discuss.php?d=119588

The myCourses block was meant to display whatever the built in Moodle-API-Function get_my_courses() returned.

So with the only exception of the Moodle-Admin we show STUDENT's and TEACHER's own courses, if they are active/visible.

I have no clue why your students should see all courses like the admin. I used LDAP auth ever since and I just switched to Shibboleth and the myCourse block continues to behave as expected. The API function mentioned returns only courses the logged in user is enrolled in, nothing else. This can not be related to the auth module you choose. The users and their profiles are stored in the database of Moodle and that is where get_my_courses() gathers information about any user enrolled in any course.

Rosario


In reply to Rosario Carcò

Re: New myCourses block released

by Héctor Reyes -
Hi all

i have moodle 1.9.9+ from 20/09/2010 and when a course and a sub category are in the same sub-level the course is not showed and the user has teacher(editor) role, i attached the image comparing the blocks courses (default in moodle), My courses 2 and My Courses Block (2010072201)

Attachment my_courses.jpg
In reply to Héctor Reyes

Re: New myCourses block released

by Rosario Carcò -

Oh, in your image above, you have to toggle ON the blue button/switch ! to see the OWN courses. See still Version 1.9.07a where the logic / GUI has changed a little bit.

In reply to Phil Raymond

Re: New myCourses block released

by Rosario Carcò -

Please see my previous posts on that subject: which courses are considered to be the ADMIN user's OWN courses??

I still defend my opinion, that the admin user SHOULD NOT enrol in any courses. Use separate accounts for that.

See my next Version 1.9.07a I am going to release today, where I decided to consider ADMIN user's own courses where he has editingteacher, teacher and student roles. Any other roles could be added, but everything gets very complicated as soon as you define own roles and you would want them to be considered also to be the admin's own courses.

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Leo Dil -
Download link doesn't work anymore!!!
In reply to Leo Dil

Re: New myCourses block released

by Rosario Carcò -
No, because Julian removed the block from the contrib-Modules&Plugins section. So download and use my latest version here.

We will introduce the next merged version of myCourses and siteNavigation into the contrib-Modules&Plugins again.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Richard van Iwaarden -
Picture of Particularly helpful Moodlers

Hello Rosario,

Could you post a full working download link of your mod? I tried to install several versions from this thread, but all I get is this error:

Module myCourses: D:\MoodleWindowsInstaller-latest-19\server\moodle/mod/myCourses/version.php was not readable
The error is logical, because this file does not exist. It seems I'm missing files here, because after manually adding a version.php file it complains about .sql files missing.
I'm running the latest Moodle on a WAMP setup.
In reply to Richard van Iwaarden

Re: New myCourses block released

by Rosario Carcò -

Oooh, I guess you simply missed that myCourses and siteNavigation ARE BLOCKS!! not MODULES, so the correct Directory to place them in is: your $CFG->dirroot/blocks/myCourses or your $CFG->dirroot/blocks/siteNavigation respectively.

I offer a new zip-File in Version 1.9.07a, I am going to release today.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Rosario,

Is there any way I can plead with you to have the latest version of MyCourses added to the Modules and Plugins page?

I would very much like to include instructions for downloading this block in a book I am writing and would prefer to reference Modules and Plugins instead of the forums.

I am using version 20091126 (I think...at least that's what I can determine from the block_myCourses.php file) and am not having any problems with it. As admin I can see all courses by toggling off the blue button and toggling on the orange button so I don't see any problems with the functionality. I haven't tried the most recent version yet to see what it offers because I am not having any problems with the version I mentioned above.

At any rate, is there any way we can get this added to Modules and Plugins so we don't have to sift through the forums here to find the block?

Sincerely

Jason

In reply to Jason Hollowell

Re: New myCourses block released

by Rosario Carcò -

I have good news: after having partially resolved the performance issue on medium to large scale sites with more than 1'500 courses (we have more than 3'500 on our Moodle site), I feel I could start to upload myCourses with Version 1.9.07a, I am going to release today.

Though I have to figure out how to do it first. So be patient.

Rosario

Average of ratings: Useful (1)
In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

I just finished Version 1.9.07a (2010110401)

I named the Zip-File myCourses07a.zip to distinguish it from the previous version.

Once again, unzip in a local folder first, then copy everything to your $CFG->dirroot/blocks/myCourses Directory. Adjust access-rights if necessary and backup the whole myCourses Directory first, just in case you have to revert back to the previous working version.

NOTHING NEW in this version either.

But I enhanced the logic to gain speed if an admin is logged in and wants to use the three buttons/toggles to display own courses (blue), active courses (orange) and or inactive courses (gray).

As announced in the Tracker (http://tracker.moodle.org/browse/CONTRIB-1442), I had to use an own and slightly modified copy of the get_my_courses function (I called it get_my_courses_bycap), so that I can collect only the courses where the admin user has moodle/legacy:editingteacher, moodle/legacy:teacher, moodle/legacy:student capabilities. This now yields correctly a litle course list compared to what get_my_courses returned in the previous versions.

You remember that the Moodle-API-functioin get_my_courses started to return ALL courses for admins after capabilities and roles were introduced. And as I explained in previous posts, this is because get_my_courses now began to return all courses in which the logged in user has moodle/course:view capability, which is still correct for TEACHERS and STUDENTS but no more for admins who have VIEW capability on ALL courses per default. So even if all toggles/buttons were switched to off, the original logic of myCourses loaded ALL courses (over 3'500 on our site) and only in a further function call later on, filtered the courses to be actually displayed or not, depending on the options toggled on/off by the admin. myCourses worked fine as it was until we passed the mark of 1'500 courses.

Still the original logic and underlying HTML-TreeMenu need even more enhancements for medium to large scale sites. I suggest to do this work in the merged version.

These are the speed figures on our site with 3'386 mdl_course entries and 914 mdl_course_category entries, when I log in as admin user:

Version 1.9.07

with show my courses ON (blue button): DB queries: 4'350, 2.9 secs to load the page

with hide all courses (blue, orange, gray button all off): DB queries: 4'378, 4.5 secs to load a page

Version 1.9.07a

with show my courses ON (blue button): DB queries: 1'011, 0.9 secs to load the page

with hide all courses (blue, orange, gray button all off): DB queries: 999, 0.5 secs to load a page

with show all courses (orange, gray button on): DB queries: 4'337, 7.8 secs to load a page

NOTE: these figures apply ONLY for ADMIN users. There are no performance issues for Teachers and Students.

As I adjusted the logic to load the admin's own courses, the User-Interface changed a little bit for admins and Teachers:

  • the blue button acts as main switch to show/hide own courses or to show/hide ALL courses respectively
  • if the blue button is ON, admins and teachers see their own courses
  • admins can toggle on/off active and/or inactive courses in either case (own or all courses)
  • teachers are not alllowed to see all active courses, so they can only toggle on/off their own courses, i.e. active and/or inactive courses
  • if the blue button is OFF, admins see ALL courses if active (orange) and/or inactive (grey) buttons are ON
  • if active (orange) and inactive (grey) buttons are toggled OFF, NO COURSES are displayed which removes the little side-effect introduced with version 1.9.07 where courses with non-editingTeacher and/or Student roles were displayed

So the default combination of all OFF will allow admins to work more quickly now. Speed well begin to slow down if one of the options is toggled ON, depending on the number of courses that have to be retrieved and rendered.

Rosario

Average of ratings: Useful (2)
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

I just had a look at the new navigation block in Moodle 2.x

Strangely it displays only a FLAT list of courses, no nested categories. Every course I created is located in an according category/subcategory indicated by the numbers. And more strangely the similar navigation block on moodle.org, even in this thread, displays the courses neatly nested in their categories/subcategories, which is what we want:

moodle2xNavigation.gifmoodle2xNavigationMoodleOrg.gif

DOES anyone know why??

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Oh, I am sorry, apologies: Using Moodle IS a course, not a category, so General, Getting started, etc. are only topics containing the different forums. So the new navigation offers really only a flat list of courses, which means that we could port our new merged sitenavigation block also to Moodle 2.x

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

I installed my own Moodle 2.03 testserver and the new navigation can be customized to behave rughly as our siteNavigation block, i.e. with links to the categories, display of nested cats, and so on.

Navigaition Moodle 2x with nested cats and links

And docking is a good alternative to my popUp windows, offering also an acceptable width for longer category and/or course names.

Navigaition Moodle 2x in Dock

So for the moment I do not see any reasons to port our merged siteNavigation to Moodle 2.x

But if you have suggestions, let me know.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Geoffrey Rowland -
Picture of Plugin developers

Hi Rosario

Yes, I have also come to the view that the new navigation in Moodle 2.x means that there is less need for myCourses or siteNavigation. Indeed, I suspect the design of myCourses and siteNavigation may have influenced the design of the new navigation.

So, let me thank you, and everyone else involved, for all your work in developing these menus. It is very much appreciated.

Anyway, I'll keep using them as long as we keep a 1.9.x Moodle.

Regards

Geoff

 

 

In reply to Geoffrey Rowland

Re: New myCourses block released

by Rosario Carcò -

Geoff, my production server will stay at 1.9x as long as the new file system will not convince me from a system admin's point of view, as we and others discuss in different threads here.

Do you have any performance figures with the new navigation on Moodle 2.x ??

On my Test-Server I have only a couple of courses and nested categories, so I can not test it. Whilst on my production server we have just reached more than 4'700 courses in 1'139 nested categories.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

I have good news: I just uploaded Version 1.9.07 of siteNavigation into its thread.

And since I corrected performance in the myCourses block, I have better figures now if you combine both blocks on your FrontPage or on every course page. We have more than 3'500 courses in more than 900 categories:

1.161376 secs
RAM: 23MB

RAM peak: 25.7MB
Included 193 files
DB queries 1878

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

As announced long time ago, we have to ponder whether the underlying HTML-TreeMenu Library is

a) still  modern

b) fast enough to render long and deeply nested trees like in our Moodle Site with 3'500 courses and 900 categories, still increasing

I saw that in Moodle 2.x there is a clear advice to use the YUI libraries. So I just finished my first tests with one component of it which is of our interest. It's treeview which can be used to compose and render nested treeviews as we are doing in our block.

Please have a look at this modified source-code with FireFox and Fire-Bug enabled to measure time-behaviour:

https://moodle.fhnw.ch/lib/yui/treeview/tv_tooltip5100.html

I get this: 2831.159ms, 637'048 function-calls

In the code I simulate the creation of 20'450 nested nodes simply by looping and recursively creating nodes. (No links for the moment, but tooltips work on every node/leaf!)

For the moment I can not compare with the php-code which composes the javascript for HTML-TreeMenu. Unfortunately this will only be possbile after reengineering our Block to use YUI's treeview library.

So I guess that one step towards a merged version of myCourses and siteNavigation is also renewing and replacing the HTML-TreeMenu library.
Expect a prototype in about 1 or 2 weeks.

Rosario
In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

I had to investigate a little problem first, something I noticed when users navigate from one course page to another and both course pages do contain the siteNavigation (and/or myCourses) block, the state of the tree was miraculously preserved, i.e. all expanded and collapsed folders remain and keep their state.

I thought this was sort of a side effect of the HTML-TreeMenu Library we are using. But as I discovered today, it IS using cookies. Look at them in your FireFox while you expand/collapse the folders.

So I researched how to achieve this with YUI treeview for a couple of days and found a solution today, again, using the YUI cookie library but without being aware that HTML-TreeMenu used the same approach.

You can find my first YUI treeview sample with cookies here:

https://moodle.fhnw.ch/lib/yui/treeview/tv_tooltip5100PreserveWithCookies.html

Next step will be to implement this code into siteNavigation and myCourses blocks.

BTW the navigation block in this forum does not preserve what you expand/collapse. It shows only the path to this topic and so does navigation in Moodle 2.x, which means we should port our block also to Moodle 2.x

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

I am uploading Version 1.9.07a (2010111601) just for completeness of this line.

I only added another speed improvement if you use the block on the FrontPage and users have not logged in yet.

Simply replace your block_myCourses.php file with this one (after backup of the previous one, as always, just in case you need to revert back.)

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Here I announce another intermediate version 1.9.08, merged both blocks into one, but still using the old HTML-Tree Library, and displaying the navigation in popUp-windows, if you prefer: http://moodle.org/mod/forum/discuss.php?d=103703#p768474

I am banging my head against a wall to find the good decision. Please help me:

  • of course siteNavigation and myCourses can still be displayed as before, but in one block instead of two (for those who want to continue with two separate blocks, I can continue to support the 1.9.07 line which has come to an acceptable end stage anyway)
  • independently of the display, there are two major issues:
  1. should we keep the blue, orange and grey toggles for admins and teachers to toggle on/off the display of their active, inactive and for admins ALL courses? If yes, this will be a problem when displaying the blocks in their popUp-Windows because technically speaking a click on one of the buttons sends a request to the server and the response goes back to the main window and not to the popUp-Window. So if we stick on it, I must find a solution first. On the other hand, I was always against it because in my opinion admin-accounts are meant for admin operations and not to enrol in courses. To enrol in courses as teachers and students, admins should use separate accounts so as to separate things completely at role level. What I wanted to add to the myCourses Block anyway, was a means for the students to display only the courses they really want to see, which would free them from the teachers forgetting to unenroll students from old courses or wanting to keep them in because of the grades, which makes the myCourses list grow longer and longer with each semester in our universities. So this would mean to develop a new solution anyway.
  2. to display the siteNavigation and the myCourses lists in popUp windows, I have to write the whole output to files and if I write to files, there comes up another question: how do we delete the old files? Normally you do this simply with a nightly cron-job like rm *_siteNavigation.html and rm *_myCourses.html, but I am not sure whether you all have the means to run your own server and add such a cron-job. I already explained the performance blast we get by writing and reading the output into/from files instead of composing the same output on every course page the users visit. But technically speaking we never know when the user quits the session without using the logoff button/link. So these files are going to be orphaned in the $CFG->dataroot/1/ directory. If we decide to create the siteNavigation file only once a day or at predefined time intervals of 15 minutes to 6 hours, there is no problem to use always the same file and create it after the given time intervals expire. But it is different for the myCourses files because they are individual and we never know when the users quit. Of course we could use always the same user's file, e.g. username_myCourses.html, but only the active users files would be reused this way. The users you delete from Moodle would leave an orphaned username_myCourses.html file. So my best offer is to resolve that case with cron-jobs. Using cron-jobs to nightly purge the siteNavigation and myCourses files means also that we can use admin options to control the generation of the siteNavigation tree. Eg. a time interval of 0 (zero) means that the tree is generated on the fly when the users log in. This is how it was handeled before with the only difference, that the tree is only generated once for every user session and not on every page he visits. A time interval of 1 and more minutes means that we generate only ONE siteNavigation file for all users to use, at the given time interval. For those who have no means of controlling their own server I could leave the display of both trees in one block, i.e. without popUp windows, as it was before. So there would be no gain in performance and hence this would remain a solution only for small to medium sized sites. Starting with more than 1'000 courses, siteNavigation can only be used to display the categories as I did until now on my own site (https://moodle.fhnw.ch, no login required to navigate through the roughly 1'000 deeply nested categories). And starting with more than 2'000 courses the siteNavigation can no longer be displayed on every course page because it would take too long to render even in category-only mode. At the same time this display could be used by those admins who want to keep the blue, orange and grey buttons. (At least until I find a solution to do it also in the popUp windows, if there is a solution)

Let me know, if you have suggestions, and keep watching development on my test server: https://moodle.fhnw.ch/moodleTest

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Ok, I just found a workaround for all those who want to preserve the blue, orange and gray button functionality also in the popUp window. But it is at the cost of performance because I have to rewrite the file on the fly and you would have to click on the link "show myCourses in popUp window" again, and as the browser is lazy, you have to right-click in the popUp window contents to force the content to RELOAD again.

Let me know, if you would like an admin option for this. Otherwise we leave the functionality in the block-display only.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

I am uploading the first beta of Version 1.9.08 in the siteNavigation thread in a few moments. Starting with this version you will find all the discussion and updates of the merged blocks there:

http://moodle.org/mod/forum/discuss.php?d=103703

I will return to this thread only to maintain the old 1.9.07 line.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

For completeness I am uploading version 1.9.10 (Build 2012112101) of the merged sitenavigation to the Modules & Plugins Database. As I do not know whether more than one version can stay there for download, I will eventually upload it to the siteNavigation thread.

I backported the option to toggle on/off old/not visited courses from myCourses 07b and 23.01, so that you can still continue to use it on Moodle 1.9

Next Version is 23.01 to be used on Moodle 2.3

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Fiona MacAlister -

Hi Rosario

I'm currently using Moodle 2.3 and have installed myCourses version 2012111201.  The block itself is working as it should but the myCourses New Settings still keeps on coming up when I click on Notifications in Site Administration.  Changes made on this page are not saved i.e. no indication is giving that any changes have been saved and it simply reverts to the New Settings page.  Turning debugging on doesn't reveal anything.

I can make changes, which are definitely saved, in Plugins-Block-myCourses so saving any changes is not a problem.  However, this has no affect on the myCourses New Settings page in Notifications - it keeps on reappearing.

Your help would be appreciated.

In reply to Fiona MacAlister

Re: New myCourses block released

by Rosario Carcò -

Fiona, was there already a previous version of MY OWN myCourses block installed? or of my new, merged sitenavigation?

Then you would have to have a look at your mdl_config table where those settings are stored. Check capitalization, as I had to convert every setting to all lowercase letters. There is already a previous post on this here.

Let me know if it helps.

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

Again, for completeness of the line, I am uploading Version 1.9.07b, (Build: 2012112001).

I backported the functionality to show/hide "old" courses from Version 23.01 below and corrected a typo in the german language file.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Benjamin Young -

I was wondering if anyone has had this issue or has found a solution to the bug.

We are using the myCourses block in a Moodle 1.9.18 enviroment (LAMP stack setup) and have the issue of when an instructor, administrator, or student log's into the site they can only see some of the courses he/she is enrolled in.

For example there is a category with 7 courses an instructor is enrolled in by the block only randomly shows 1 of the courses within that category.

The block was working for a while nicely but then suddenly stopped showing all the courses.

Nothing seems to have changed with enrollments or privileges on the site.

Any ideas or suggestions? 

In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

I just uploaded version 1.9.09 of the merged line into the new Modules & Plugins Database (waiting for approval):

http://moodle.org/plugins/view.php?plugin=block_sitenavigation

I wonder if it is better to leave the 07 line here for download to avoid confusion. Or maybe it is better to have the three blocks myCourses07, siteNavigation07 and sitenavigation09 upward in the same place. But I must check, if I can upload several zip-files into the same place.

PLEASE NOTE: to comply with the Moodle programming guidelines I had to convert everything to lowercase letters. So if you decide to install sitnavigation09 you will have to delete the according entries in mdl_config named block_siteNavigation... otherwise you will not be able to store the new values. As also the directory name changes from sitNavigation to sitenavigation, you will have to delete the block from the Admin->Modules->Blocks->Manage Blocks, then rename the directory, copy the new sitnavigation09 files into it and finally click on the NOTIFICATIONS link in your Moodle GUI.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

I has been approved now and is available for download. I am actually pondering whether to add myCourses and siteNavigation which are the standalone Blocks into the same distribution file, so that you do not have to search for the latest versions in different places. The next planned feature will be to offer the Teachers and Students an option/switch to display only recent courses instead of displaying the whole myCourses-List with a lot of courses the teachers might have forgotten to unenrol the students.

In reply to Rosario Carcò

Re: New myCourses block released

by Ann Jensen -

Hello,

The version of Moodle that we use has diverged so much from the original Moodle 1.9 and has been worked on and customised by many different people.  Unfortunately the admin notifications funcationlity no longer works and I want to ask is it possible to take on your MyCourses plugin manually...without using admin notifications?  I am a developer and have some familiarity with Moodle php code.

Any advice greatly appreciated,

Regards,

Ann

In reply to Ann Jensen

Re: New myCourses block released

by Rosario Carcò -

Sorry, I do not understand what you mean with admin notifications? and what you would want to do with myCourses block.

In reply to Julian Ridden

Re: New myCourses block released

by Rosario Carcò -

Dear all, this is Version 2301 which means, it runs on Moodle 2.3

Nothing new, only a green button added so that the students can toggle on/off old courses. I think we could define as "old courses" courses, that were not visited for longer than 30 or 60 days. But it is not implemented yet.

Unzip as usual into a local directory. Create a directory mycourses (all lowercase now!) in your moodleRoot/blocks directory and copy the contents of mycourses2301 onto your server moodleRoot/blocks/mycourses and finally click on the notifications link in your Moodle GUI.

I tested on the 2.3 beta, but it should work also on 2.3 as released. Only after adding the block, you are not automatically redirected to the course page where you insert the block. And docking does not show the block title correctly. These are bugs I have to investigate in the next days. SO CONSIDER THIS A FIRST BETA and install it only on TEST-SERVERS!

If you like it, I will upload it into the PLUGINS&MODULES database and continue to maintain it as separate block. The same applies for siteNavigation and also the combined sitenavigation, as soon as this one works.

Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

And this is version 2301 (Build 2012111503) with the promised feature to toggle on/off old courses.

Old courses is defined as courses not having been visited since the number of days given in the corresponding admin config option. If you leave the default number of zero days, the users will NOT be able to toggle on/off their old courses.

Language folder names have changed fromt xx_utf8 to simply xx

So if you installed my previous version, change the names of those directories or remove everything before copying this version to your server.

Enjoy and let me know if you find bugs. Rosario

In reply to Rosario Carcò

Re: New myCourses block released

by Rosario Carcò -

If you want to check the toggle for old courses, proceed as follows:

  • open your database, eg. with phpMyAdmin and access the mdl_user_lastaccess table
  • you will find entries like this

    id     userid    courseid    timeaccess
    78    2           151            1352736637
    75    2           150            1343332014
    74    2           149            1343331653

  • copy the timeaccess value and do some little arithmetic subtracting 86400 for each day you want to rewind the user's last access to the given courseid. Let's say you want to go back 60 days. So subtract 60 * 86400 from the value in timeaccess and set the new value into this database field and save it
  • set your admin config option notvisitedsince to 30 days
  • as now you have set last access to 60 days ago, the user should not see his "old" course any more if he toggles off the show old courses button

NOTE: as soon as the user clicks onto a link to access one of his old courses, the value in user_lastaccess will automatically be updated and from then on he has to wait until the preset number of days expires until his course disappears again. This way you can reset the value in the database quickly and start over for your tests.

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Fiona MacAlister -

I am currently experiencing a display problem with sitenavigation (2012112201) in Moodle 2.3.3 (Build 20121230).  It is splitting sitenavigation and mycourses for some reason, putting one below the other, as shown in the screencap below.  I have sitenavigation (20121112) installed and running, without any problems, on the same server under Moodle 2.3.2 (Build 20121018).  I have also tried installing that earlier version on 2.3.3 but I get the same result.

What could be causing this issue in 2.3.3?

sitenavigation233

In reply to Fiona MacAlister

Re: New myCourses block released

by Rosario Carcò -

Fiona, as I wrote in both threads, myCourses and siteNavigation, I merged both blocks into one, so as to offer

a) both blocks in one, to use only one block instead of two

b) offer better performance and user interface experience on larger screens, as you can open both block in their respective floating windows

In the merged block you can still decide via admin config options, whether you want to display only sitenavigation or mycourses individually or whether you want to display both. And you can decide wheter to display INLINE in the block area or in popUp-Windows you can leave open for the whole Moodle-Session. So simply check your admin-config of the sitenavigation Block to get your display corrected.

ALTERNATIVELY you can still continue to use mycourses as single separate block, as I reengineered it also to be used on Moodle 2.3

For Download you have to take the latest version here in this thread, whilst the merged version sitnavigation is to be found in the Modules&Plugins Database. If mycourses is to be used as separate block also in Moodle 2.3 I will put it also into the Modules&Plugins Database, but this depends on the user's will, as in the merged version you can choose as you please what navigation to display.

Could you resolve your admin config options problem as you posted before in this thread?

Please note: I am bugfixing the sitenavigation block with another user who found some minor bugs. So with a little luck I will upload a new version this week of the merged sitenavigation into the Modules&Plugins Database. (only display sitenavigation as List is affected, everything else should work fine.)

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by Larry Elchuck -

Hi Rosario

Thanks for your help earlier.  I think I will go with the mycourses block so that I can utilize the fullname option for students' My Courses.  2 questions.

1. Currently the block allows a drill-down (using the twisties) to the activity/resource level.  Can you suggest code changes that I could make so that it only goes as deep as the topic/section level (so that the resources/activities do not show).  I would like students to have the option of either (A) opening a course or (B) going directly to the section of the course to see a section in it's entirety rather than individual resources/activities within that section.  Currently, clicking on the section name only shows those resources/activities. I'm sure it can be made to work at the section level as it does by clicking on the course.... but I'm no coder!

(2) is there a git repository for this block so that future changes can be picked up using that method

 

Thanks in advance.

Attachment mycourses-delta.png
In reply to Julian Ridden

Re: New myCourses block released

by Larry Elchuck -

Even though I have selected "Show long name", th shortnames still appear. I'm using mycourses2301. I purged all cache and opened the user in a new browser, as well.

Attachment showlongnames3.jpg
In reply to Larry Elchuck

Re: New myCourses block released

by Rosario Carcò -

Dear Larry, this seems NOT TO BE my Block. This is the BUILT IN Block of Moodle's Navigation.

See screenshots in previous posts to see how my own Block shows up.

Using my siteNavigation Block, you can select it to show only categories, but no contained courses.

The myCourses Block is still distributed in this thread. The sitenavigation, which is a two-in-one block, as it contains both blocks in one, myCourses AND siteNavigation can be found in the Modules&Plugins Database. Git may follow if users are still interested. There are also possibilities to customize the built in navigation block. There is a good thread talking about customizing the built in navigation block.

Rosario

In reply to Julian Ridden

Re: New myCourses block released

by li shen -

instead of using scroll bar, there is any way to wrap long name to next line within the block?

moodle version 2.8.6,  mycourses block version 2012111503.


Thanks a lot,