General help

Hiding teachers in 1.7

 
 
Picture of Ron Mitchell
Hiding teachers in 1.7
 
Hi apologies if this has already been answered or I'm just being dim but having upgraded an installation to 1.7 I can't find where to hide the teachers so they don't show in the list of courses. This was straightforward in 1.6 and the same facility doesn't appear to be available in 1.7 but perhaps I'm missing something?
 
Average of ratings: -
Ray Lawrence
Re: Hiding teachers in 1.7
Group Particularly helpful Moodlers
"I can't find where to hide the teachers so they don't show in the list of courses."

Me neither, Ron. I've looked everywhere I can think of including the Tracker. Possibly needs a feature request.
 
Average of ratings: -
Picture of Helen Foster
Re: Hiding teachers in 1.7
Group Core developersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup TestersGroup Translators
Ray, thanks for your report in the tracker - MDL-7544 approve and Yu, thanks for fixing it in 1.8. approve
 
Average of ratings: -
Picture of Bob Siegfried
Re: Hiding teachers in 1.7
 
While we wait for a stable 1.8 to appear with Yu's fix (thank you, Yu) to the hidden roles bug in 1.7, has anyone come up a work-around for hiding roles when listing courses? Or a hack, perhaps? Or pointer to where in the 1.7 file system a hack might be needed?
Thanks.
 
Average of ratings: -
Picture of chris dennison
Re: Hiding teachers in 1.7
 

I have a solution for part of the problem- I didn't want non-teaching course creating staff to be listed with each course, but I did want to have course creators.

The patch I have made simply means that the role "Course creator" is not listed.

You could of course create a new role with "name" and change the patch to omit "name" roles.

Edit /course/lib.php    (v 1.446.2.7 2007/01/08)

insert line 1563     If ($role->name != "Course creator"){

insert line 1567     }

so that the foreach loop now looks like:

        foreach ($teachers as $teacher) {
            if (!$teacher->hidden || $canseehidden) {
                $roles = get_user_roles($context, $teacher->id, true, 'r.sortorder ASC');
                $role = array_shift($roles);  // First one
                mtrace($role->name);
                If ($role->name != "Course creator"){
                $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
                $namesarray[] = format_string($role->name).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
                                  $teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
                                  }
            }
        }

Now you can asign course creators at the site level and they don't get listed with the courses smile

If anyone knows what the '$teacher->hidden ' parameter is supposed to do, would be nice toknow...

 
Average of ratings: -
Picture of Bee Bell
Re: Hiding teachers in 1.7
 
This is creating the biggest problem in our site which is not public. I'm not sure that I can hack the code in a commercial server that host my site.

Any other way to fix this problem. I need to hide the teachers as I did in all previous versions.

Help, please!
 
Average of ratings: -
Picture of chris dennison
Re: Hiding teachers in 1.7
 

Can you ftp into your site?  You'll need log, password etc.  And and ftp client.

 
Average of ratings: -
Picture of Russell Myers
Re: Hiding teachers in 1.7
 
Hi, thanks for the hack, unfortunately it doesn't work for me...

This is my code:

foreach ($teachers as $teacher) {
if (!$teacher->hidden || $canseehidden) {
$roles = get_user_roles($context, $teacher->id, true, 'r.sortorder ASC');
$role = array_shift($roles); // First one
mtrace($role->name);
If ($role->name != "Course creator"){
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = format_string($role->name).': wwwroot.'/user/view.php?id='.
$teacher->id.'&course='.SITEID.'">'.$fullname.'
';
}
}
}


I think it looks the same, am I wrong? Do in need to do anything to initiate the change? Thanks!
 
Average of ratings: -
Picture of chris dennison
Re: Hiding teachers in 1.7
 

Hi Russell.

Do you get any ouput?  I've just noticed the call to mtrace is still in the code.  Once everything is working it should be deleted.  But while it is there you should see every listed teacher's role twice. 

If your not, perhaps your modifying a file that's not active?

I notice that your teacher link is not a hyperlink - but I don't see why that should make any difference.

Regards Chris

 
Average of ratings: -
Picture of Russell Myers
Re: Hiding teachers in 1.7
 
Thanks Chris,

I'm not sure I know what you mean by output?

I'm also not sure what you mean when you say "should see every listed teachers role twice" I still only see the teachers listed once in each course. I have tried it with and without the mtrace.

I'm sure I'm modifying the correct moodle site, am I modifying the wrong file within the site?

any other thoughts??

Thanks, Rusty
 
Average of ratings: -
Picture of chris dennison
Re: Hiding teachers in 1.7
 

Russell,

The file is course/lib.php.  I have created some courses in Miscellaneous, when i click on the miscellaneous catagory the courses are listed on my screen, each course in a separate box.  The teacher/creators are listed in each box.

With the mtrace call  in as shown you should see the role of the person listed just before each box - so you see the role twice.

If in doubt insert something like

mtrace("line number xxx ");

You should see this on your screen when the codse is executed.  If you don't then you are editing the wrong bit of code (imho).

Rgds Chris

 
Average of ratings: -
Picture of Agostino Di Ciaccio
Re: Hiding teachers in 1.7
 
a temporary solution can be found at http://moodle.org/mod/forum/discuss.php?d=63569
 
Average of ratings: -
Picture of George Hunka
Re: Hiding teachers in 1.7
 
There's a similar problem with hiding administrators in 1.7. Although I understand that it's been fixed in 1.8, it would be VERY nice to have a patch with clear instructions for integration for 1.7 users (who just upgraded less than two months ago).
 
Average of ratings: -
Picture of Russell Myers
Re: Hiding teachers in 1.7
 
Did you try changing "Course creator" to Administrator"

Before:

foreach ($teachers as $teacher) {
if (!$teacher->hidden || $canseehidden) {
$roles = get_user_roles($context, $teacher->id, true, 'r.sortorder ASC');
$role = array_shift($roles); // First one
If ($role->name != "Course creator"){
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = format_string($role->name).': '.$fullname.'';
}


}
}


After:

foreach ($teachers as $teacher) {
if (!$teacher->hidden || $canseehidden) {
$roles = get_user_roles($context, $teacher->id, true, 'r.sortorder ASC');
$role = array_shift($roles); // First one
If ($role->name != "Administrator"){
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = format_string($role->name).': '.$fullname.'';
}


}
}


Don't know if that will help you, I don't know much about moodle code.

It doesn't work for me though.
Good Luck!
 
Average of ratings: -
Picture of Agostino Di Ciaccio
Re: Hiding teachers in 1.7
 

Really the problem, I think, is due to the language used in the installation. If you look in the data-base table "mdl_role" you can see the real name assigned to each role. In italian we have "Creatori di corsi" not "Course creators". Anyway the best thing to do is to look at the number of the role we want to skip in the list, in my case I want to skip the Course creators (usually id=2) and a new role I creted (id=7). The code is now:

foreach ($teachers as $teacher) {

   If ($teacher->id != 7 && $teacher->id != 2){

           if (!$teacher->hidden || $canseehidden) {

               $roles = get_user_roles($context, $teacher->id, true, 'r.sortorder ASC');

               $role = array_shift($roles); // First one

               $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));

               $namesarray[] = format_string($role->name).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.

               $teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';

             }

     }

}

Good luck!

 
Average of ratings: -
Picture of uday ramakrishna
Re: Hiding teachers in 1.7
 

Hi

I am sure this is out of context but we are using moodle 1.7+. We have created a few courses and we would like to use one of the courses in a different format and hence we would like to hide them from general enrollment but make it available via a drop down on the homepage. Is there a way to avoid making it enrollable/available on the All courses list? We tried hiding it but what happened was that it was not available to students completely.

To clarify we are using the same course in a new format but with lesser number of items. Also on the course there is a number displayed for each section is there a way I can hide this auto number?

Regards

Uday

 
Average of ratings: -