Roles on Main page not working

Roles on Main page not working

Jeff Wood -
回帖数:14

In previous versions of moodle I was able to add "teachers" to the main page so that calendar events / site resources could be edited. Since upgrading to moodle 1.7 the users that I gave permission to are no longer able to edit the items.

I can set the "roles" to admin for the item on the main page, but the user still doesn't have the ability to make changes.

Any ideas?

Jeff

回复Jeff Wood

Re: Roles on Main page not working

Kok Chee Kean -
This might be related, but I can't seem to import groups into my courses anymore. I get a whole list of errors with each line in the following format:

(groupname) notaddedtonotinyourcapacity

Seems like the admin or teacher's role doesn't have the right to import groups? But I can add groups manually just fine. Strange...
回复Kok Chee Kean

Re: Roles on Main page not working

Jeff Wood -
Unfortunately I do not use groups, so I have not observed this behaviour.

Jeff
回复Kok Chee Kean

Re: Roles on Main page not working

Yu Zhang -
Hi,

This could be a bug, could you please file a bug and assign it to me? blush


Thanks,

Yu
回复Jeff Wood

Re: Roles on Main page not working

Yu Zhang -
Hi Jeff,

You can assign teachers from the (new) admin block at site level, just follow the link Users->Permissions->Assign Roles, and assign whoever you want into the teacher role. They will be able to edit any activities on the site page. Please note that because they have this role assigned at site level, this role will be carried down to all courses in the site. Effectively this makes them teachers in all courses.

Cheers,

Yu
回复Yu Zhang

Re: Roles on Main page not working

Jeff Wood -
Hi Yu,

Got your message from the bug I created - thanks.

This method is very problematic. As you mention assigning people as a "teacher" using Users->Permissions->Assign Roles means they are teachers of ALL course. tongueout

In previous versions of moodle people could be assigned as a teacher of course 1, giving them the abilities I want without making them teachers of ALL courses.

There must be a way to do this?!

As for students... I needed to give students the ability to do a survey on the main page and had to manually assign everyone using Users->Permissions->Assign Roles as a student so they could vote.

Well... this enrolled EVERYONE in ALL courses... what a nightmare.

It would seem that roles are still very buggy or I'm not understanding their use correctly.

Jeff
回复Jeff Wood

Re: Roles on Main page not working

Stephen Bourget -
Core developers的头像 Plugin developers的头像 Testers的头像
For you student scenario you can try this...

On the admin page under permission -> Define roles you can create or modify roles. Why not just create a new role called "users" and base the role on the guest role but add the permissions to participate in the survey (respond to survey)

On the admin page under permission -> user policies you can set a role for users when they are logged in, not logged in, and enrolled in a course. Just set the default role for all users to the new "user" role you create. This way all users who are logged in have the capability to participate in your survey but they are not enrolled in all of the courses

-Steve

回复Stephen Bourget

Re: Roles on Main page not working

Jeff Wood -
Tnx for the idea Steve.

By "Just set the default role for all users to the new "user" role you create." will admins/creators/teacher roles all override this?

I'm still fuzzy on how roles work. Does the more advanced role a person is assigned ALWAYS override the lest advanced role?

Jeff

Just created the new account and tried it with a test student.

Nothing. They can take the test but their data is NOT being displayed for me (as admin).

When I login is as a student from one of my course I get
"The results are not currently viewable." and am not able to take the choice.
回复Jeff Wood

Re: Roles on Main page not working

Stephen Bourget -
Core developers的头像 Plugin developers的头像 Testers的头像
OK Try this...

Give the group Allow rights for "record a choice" (mod/choice:choose).

That should allow the users to vote using the choice module. If you want them to view the responses then you will need to set "read responses" (
mod/choice:readresponses) to allow as well.

The "Respond to survey"
(mod/survey:participate) was for the survey module. I didn't realize you were using the choice module.

As for the how the roles work, The default setting for each capability is INHERIT which allows for another role to override the permissions and give the user access.

For Example:

User 1 has 2 seperate roles.

Role 1 allows user 1 to participate in choice activities
The permissions are as follows:

mod/choice:choose - ALLOW
mod/choice:readresponses - INHERIT
mod/choice:deleteresponses - INHERIT
mod/choice:downloadresponses - INHERIT

Role 2 allows user 1 to administer choice activities.
The permissions are as follows:

mod/choice:choose - ALLOW
mod/choice:readresponses - ALLOW
mod/choice:deleteresponses - ALLOW
mod/choice:downloadresponses - ALLOW


This would result in User 1 being able to both participate and administer the choice activity

However if Role 1 was defined as:
mod/choice:choose - ALLOW
mod/choice:readresponses - PREVENT
mod/choice:deleteresponses - PREVENT
mod/choice:downloadresponses - PREVENT

Then User 1 would only be able to participate, because the ALLOW + PREVENT = PREVENT (Or at least this is how I understand it to work)

I hope this helps

-Steve
回复Stephen Bourget

Re: Roles on Main page not working

Jeff Wood -
Steve,

Thanks for the great info.

I did create the "user" group and give it permission to record a choice.

The problem then was as site admin, and the one who created the survey, I could see that there were 7 responses, but when viewed the responses I would only see the responses from me (site admin) and one of the course creators. This really meant that 7 votes were cast but I could only see 2.

When I added all users as students at the site level I could see the other 5 replies, but this (adding users as students at the site level) created all sorts of other problems.

Jeff
回复Jeff Wood

Re: Roles on Main page not working

Roger Rué -
In http://moodle.org/mod/forum/discuss.php?d=58548 I suggested the creation of a new profile, that I named "user", from the "guest" role allowing to do the things we need in the main page.

This worked well for a forum activity but I tested it with a choice and I see the problem you explain. I supposed that the problem was in the source code and not in the roles, so I take a look to the php files in choice folder.

I found that in order to make the table with the answers to the choice, the report.php and lib.php files use the get_course_users function to fill the $users variable. This function relys on the moodle/course.view capability, so the users with the "user" profile I created were not found.

I changed the function to:

$users = get_users_by_capability($context, 'mod/choice:choose', 'u.*, ul.timeaccess as lastaccess', 'ul.timeaccess DESC', '','','','', false);

and it seems it works...

If you give it a try, tell me about the problems that this change can cause. I'm not a great programmer and I don't know very much about the programming issues with moodle. This is my second attempt to modify the source code, so be careful.

Roger

回复Roger Rué

Re: Roles on Main page not working

Stephen Bourget -
Core developers的头像 Plugin developers的头像 Testers的头像
It definitely seems to be a bug in the choice module... I've filed a bug report as MDL-7590
回复Stephen Bourget

Re: Roles on Main page not working

Jeff Wood -
Thanks Stephen & Roger.

Jeff
回复Jeff Wood

Re: Roles on Main page not working

Chardelle Busch -
Core developers的头像
What's the bottom line on getting registered users to automatically (I really don't want to have to assign a role to each registered user manually) be students in course 1. Like Jeff, I have activities that I add to the site page that I need to be "writeable" by site users--whether they are enrolled in a "regular" course or not.

Thanks