How can teachers "publish" their questions to the site?

How can teachers "publish" their questions to the site?

by Joseph Rézeau -
Number of replies: 12
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Suppose as Admin I want to edit Teacher role on my Moodle site to allow all teachers to share their questions sitewide by putting them in the System category.

From Documentation:

Since Moodle 1.9 there are separate question category trees in each different 'context' in which questions are shared. The contexts available to you depend on whether you access the question bank from an activity or from a course and depend on the permissions assigned you for access to questions. See Question contexts for more information on these contexts.

So I go to Questions contexts where, at the bottom of the documentation page it says:

All Question capabilities are tested in the relevant context. So, for example, to add a question to a category you must have the add capability for that context. See roles and capability help for more info. If you don't have permission to do anything in a context, then the categories in that context will not be visible to you.

So I go to roles and capability help for more info... but nowhere do I find which capability I must Allow to enable my teachers to share their questions in System...

Any ideas to get me out of this maze?thoughtful

Joseph

Average of ratings: -
In reply to Joseph Rézeau

Re: How can teachers "publish" their questions to the site?

by John Isner -
Joseph,
You (as administrator) need to assign the appropriate permissions to users in the System context. I say "appropriate" because you probably want to give different permissions to different users: some should be able to create questions, others should only be able to use questions.

I would create two new roles
  • CanCreateQuestions -- set moodle/question:add = Allow and leave all other capabilities Not set
  • CanUseQuestions -- set moodle/question:useall = Allow and leave all other capabilities Not set
These roles are highly reusable because you can assign them in different contexts. To allow users to add/use questions to/from in the System context, assign the appropriate role to users in the System context (Site administration -> Users -> Permissions -> Assign system roles).

I may be forgetting one or two additional moodle/question:* capabilities that you need in each case, but this is the general idea.
In reply to John Isner

Re: How can teachers "publish" their questions to the site?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi John,

Thanks for the prompt answer and useful tip. I've created those 2 roles and assigned them to 2 teachers. It works as expected.

However I still don't understand why I need to create 2 roles to make things work the way I want.

As Admin I go to Administration Users Permissions Define roles -> Edit Role Teacher -> Permissions. There I can see that all of the Questions persmissions are set to Allow for the teacher role:

  • Edit question categories moodle/question:managecategory
  • Add new questions moodle/question:add
  • Edit your own questions moodle/question:editmine
  • Edit all questions moodle/question:editall
  • View your own questions moodle/question:viewmine
  • View all questions moodle/question:viewall
  • Use your own questions moodle/question:usemine
  • Use all questions moodle/question:useall
  • Move your own questions moodle/question:movemine
  • Move all questions moodle/question:moveall

So my question is: why do participants logged in with a teacher role not get those moodle/question:add and moodle/question:useall permissions automatically?

Once more something in the logic of the Moodle roles & capabilities escapes me (and I'm not the only one).thoughtful

Can you throw some light on this?

TIA

Joseph

In reply to Joseph Rézeau

Re: How can teachers "publish" their questions to the site?

by John Isner -
Can you throw some light on this?

To do things with System questions, users need the permission in the System context. The Teacher role is assigned in the course context. The assignment is what gives them the permission. That's how they get the ability to add and use course questions.

You must give them permission in the System context. You can do this by assigning them a role in that context, or editing an existing role that is assigned in the System context. Of the latter, there is only Authenticated user, which you definitely don't want to edit, since it will give the ability to all logged in users (including students)
In reply to John Isner

Re: How can teachers "publish" their questions to the site?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Thanks John, now I understand why I did not understand, which is the beginning of understanding.wink
So for what I want I do need to create one or more roles at Site/System level.
Joseph
In reply to Joseph Rézeau

Re: How can teachers "publish" their questions to the site?

by John Isner -
create one or more roles at Site/System level

You need to create (Moodle uses the word define) the roles and you need to assign them to users in the System context.

It doesn't make sense to say "create roles in the System context" because roles themselves aren't associated with contexts. They're just definitions created by the administrator. When you assign a role, you associate the role with a user in a context.

Don't feel bad about having trouble understanding this. It makes my brain hurt too.
In reply to Joseph Rézeau

Re: How can teachers "publish" their questions to the site?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
In the course of implementing my 2 new roles and testing them out I came across this bug MDL-14676. Can anyone replicate it and, if so, vote for it?
Joseph
In reply to Joseph Rézeau

Re: How can teachers "publish" their questions to the site?

by John Isner -
Hi Joseph,
Yes, I have read MDL-14676 and I will try to duplicate it.

Meanwhile, I just wanted to comment on a couple of things you wrote in MDL-14676.

You say that you created a role called CanCreateSystemQuestions. I have a problem with that name. The role should be called CanCreateQuestions (or better, CanAddQuestions). Why do you have "System" as part of the role name? You can assign this role in any context, not just System. For example, you can assign it in a category context, giving users the ability to add questions there. Naturally I have the same objection to CanUseSystemQuestions.

Also, when you said " Assign these 2 roles to all teachers on your moodle site" it is an ambiguous statement. An assignment associates a role with a user in a context. "All teachers on your moodle site" tells me who the users are, and I know the roles you assigned, but in what context did you make the assignment? In System? (Site administration -> Users -> Permissions -> Assign System roles). If so, you should say "Assign these 2 roles to all teachers in the System context."

I seem to remember a post by Tim Hunt about the move permission being needed in some case that was not obvious, but I can't find it. Maybe I imagined it.


In reply to John Isner

Re: How can teachers "publish" their questions to the site?

by John Isner -
Here is the post by Tim Hunt in the discussion I remembered. I was trying to get Tim to clarify the difference between 'view' and 'use'. Tim says

to edit the question itself, rather than doing Save as, you need 'edit', in order to overwrite the original question

It looks like 'move' is needed, not 'edit'.
In reply to Joseph Rézeau

Re: How can teachers "publish" their questions to the site?

by Miren Ugalde -
Hello Tim, Joseph and John:

we have a problem with a huge site (thousands of courses) and this context/roles issue.

When we upgraded from version 1.8 to 1.9 we lost the capability the rol techer already have of publishing and reusing questions at site level.

Now, if I want to show all question categories of all teachers in the site I have to create a new role and assign it to those same thousands of users? And, worst of all, do I have to assign it to any future user with that teacher role? triste Because we have an automatic nightly creation of those accounts in moodle and it would mean a lot of aditional work to change that.

Any idea in order to maintain this without any new role creation?

Thanks in advance,

Miren


In reply to Miren Ugalde

Re: How can teachers "publish" their questions to the site?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Sorry, you have to create a new role.

I don't think it is that hard to arrange for all teachers to have the new role. I think this query returns a list of userids of people who do not have the question sharer role, but who are a teacher in one or more courses. Then you just need to create a new role assignment for these people.

SELECT DISTINCT ra.userid
FROM mdl_role_assignments ra
JOIN mdl_context con ON ra.contextid = con.id
WHERE ra.roleid = $teacherroleid
con.contextlevel = 50
AND NOT EXIST (SELECT * FROM mdl_role_assignments sub_ra
WHERE sub_ra.role = $questionsharerroleid
AND sub_ra.userid = ra.userid
AND sub_ra.contextid = $systemcontextid)
In reply to Tim Hunt

Re: How can teachers "publish" their questions to the site?

by Tran Duy Loc -
Hello Tim,

I have a question.
I created a new role name "Question creator" and assigned it permissions to:

  • * moodle/question:add
    * moodle/question:editmine
    * moodle/question:viewmine
    * moodle/question:usemine
    * moodle/question:movemine
But this role can't create question category for himself so I give him permission to:

* moodle/question:managecategory

But if I do that the "question creator" role can edit and delete all the sub-category in System context.

I want the "question creator" role can't edit category in System context.

Can you help me, please.