prohibiting student role from enable/disable email address

prohibiting student role from enable/disable email address

by Tiffany Morgan -
Number of replies: 9
This seems like it should be so straightforward so I'm not sure what I'm missing.

Since we use dummy emails for our students I want to keep students from changing their email from disabled to enabled. (
Enable/disable email address moodle/course:useremail)

I set the authenticated user permission at inherit and the student permission at prohibit. I cleared the cache and tested and I was still able to change the email setting and save the setting.

I set the authenticated user permission at prohibit and the student permission at prohibit. Still was able to change the email setting and save the setting.

What am I missing?

Thanks!

Average of ratings: -
In reply to Tiffany Morgan

Re: prohibiting student role from enable/disable email address

by Mark Pearson -
Tiffany,
I know this sounds obvious, but did you make sure that you had logged in as a student when you did your tests? As administrator you can go to a student profile and click the 'Login As' button and then do the testing that way. Otherwise if you're changing the setting and then immediately testing as a privileged admin user you'll get the behaviour that you observed.
Hope this helps

Mark
In reply to Mark Pearson

Re: prohibiting student role from enable/disable email address

by Tiffany Morgan -
Hi Mark
I did do the testing using the login as, and I even went further and used separate accounts I created just for testing.

I am having the same problem now with View hidden role assignments moodle/role:viewhiddenassigns , too. I have the authenticated user set to inherit and the course creator set to allow and still course creators cannot see hidden assignments.

ack! this all worked just fine a week ago...
In reply to Tiffany Morgan

Re: prohibiting student role from enable/disable email address

by Michael Woods -
Picture of Core developers
Hi Tiffany,

As far as I know it's not possible using roles/capabilities - or at least I couldn't make it happen when I tried.

We run a regular MySQL statement to re-disable the addresses where students have enabled them. All our fake student addresses are of the format f.l@f.v.e.a (where F=first initial and L=last initial), therefore, the following query works for us.

UPDATE mdl_user
SET emailstop = 1
WHERE deleted = 0
and email = lcase(concat(left(firstname,1),'.',left(lastname,1),'@f.v.e.a'))
and emailstop = 0

If scheduling from a cron (and if you use MySQL), you could call a file that has the following text:

mysql -e "use moodleour;
UPDATE mdl_user
SET emailstop = 1
WHERE deleted = 0
and email = lcase(concat(left(firstname,1),'.',left(lastname,1),'@f.v.e.a'))
and emailstop = 0"

By the way, we run quite a few sql statements like this on a regular basis (hourly/daily) for other random things like removing messaging blocks students have placed on teachers, making parent role assignments hidden, adding/removing teachers to a global role based on their membership to a particular course etc... It's a handy way of keeping things tidy.

As always, be careful when messing with the database. Backup, backup, backup smile

Kind regards,
Michael

In reply to Tiffany Morgan

Re: prohibiting student role from enable/disable email address

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Tiffany,

The reason why setting the capability moodle/course:useremail to prevent didn't work is because the capability relates to enabling/disabling other users' email addresses.

You could instead make use of the capability moodle/user:editownprofile though preventing this would also prevent the user from changing other items in their profile.
In reply to Helen Foster

Re: prohibiting student role from enable/disable email address

by Tiffany Morgan -
ooh! It was the OTHER people's email that I was clearly missing. Apparently reading really is fundamental smile

I thought about locking the profiles down, but some of our teachers are doing really interesting getting started activities using the user profile and I don't want to stifle it...guess I will take the bad with the good.

Thanks!
In reply to Helen Foster

Re: prohibiting student role from enable/disable email address

by Clark Moodler -
Hello,
I was just looking for a way to disable the ability of users to enable/disable their email address and came upon this thread. It appears it's not currently possible as the only options are to:

-prevent them from enabling/disabling other users' email addresses
-prevent them from editing their own profile entirely.

It would be great to bring "Profiles" into the Roles and Capabilities for each user definition, and then break it out to the various items within the profile: picture, email enable/disable, password, interests field, etc... so that it would be possible to allow or disallow each item separately.

http://tracker.moodle.org/browse/MDL-20282

Best,
Clark

Average of ratings: Useful (1)
In reply to Clark Moodler

Re: prohibiting student role from enable/disable email address

by Ger Tielemans -
In the meantime in /user/editlib.php

$choices = array();
$choices['0'] = get_string('emailenable');
if (isadmin()) {
$choices['1'] = get_string('emaildisable');
}
$mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
$mform->setDefault('emailenable', 1);



Would be nicer if someone wrote a if (has_capability(...) )

Average of ratings: Useful (1)
In reply to Ger Tielemans

Re: prohibiting student role from enable/disable email address

by Ger Tielemans -
if (has_capability('moodle/course:create', $systemcontext)) { ..} //for coursecreator on top-level??
In reply to Ger Tielemans

Re: prohibiting student role from enable/disable email address

by N Hansen -
I would like to see this too as sometimes it is important that all messages get to students via email.