Administration block for studetns

Administration block for studetns

by Joe Griffin -
Number of replies: 10
Hi

Sorry for cross posting, maybe this is the better forum for asking my question.

The Administration block my students see has only two items visible, Grades and Profile. However I see in other places, eg http://docs.moodle.org/en/Student_tutorials that more items can be displayed in this block. I just can't find out how to add these to the Administration block the student sees. I've experimented with many of the role capabilities but to no avail and aslo read pretty much all the documentation on blocks sad

Any possible help out there?

Thanks

PS I'm using version 1.9.3
Average of ratings: -
In reply to Joe Griffin

Re: Administration block for studetns

by Joe Griffin -
I've been reading the Moodle 1.9 book (W. Rice) and in there it says that only the Grades item will be visible on the Administration block for students. But I can see both the Grades and the Profile items. So various Moodle resources seem to be giving me different answers to my initial question.

I would really appreciate some (any?) response to this thread. I've spent about seven hours already trying to resolve the issue to no avail.

Many thanks
In reply to Joe Griffin

Re: Administration block for studetns

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The way it works it that there are a whole bunch of links that may appear in the course admin block, and each of them has a permissions check associated with them. When the block is displayed, Moodle makes all the permissions checks, and shows the links that this user is allowed to use. So exactly which links students can see depends on how permissions are set up on your Moodle site.

(The code is in http://cvs.moodle.org/moodle/blocks/admin/block_admin.php?revision=1.122&view=markup, it is quite readable.)
In reply to Tim Hunt

Re: Administration block for studetns

by Joe Griffin -
Tim

That was very helpful link if a little obscure (I'm not a strong programmer). I found how to include the link on the student course admin bloc and now have the Reports icon showing. However this allows the student to view the logs for all other students in his group.

So my next question, to you or anybody else who might be able to help, is how do I restrict the reports so that a student can just see their own activity? Basically the event I want to make available is the same as happens when I click on Participants|student|ActivityReports tab| if this makes sense?

Thanks
In reply to Joe Griffin

Re: Administration block for studetns

by Chris Potter -
My understanding is that this can be done via "Course Settings" by an instructor (meaning it's on a per-course basis). The option to choose "Yes" to would be "Show activity reports". Give that a try. smile
In reply to Chris Potter

Re: Administration block for studetns

by Joe Griffin -
Chris

Thanks for the suggestion. The Course settings turns on the tab in the student profile. I wanted the equivalent event to be executed from a link in the Administration bloc that the student sees. This setting doesn't, unfortunately do this. Perhaps it's not possible to do what I want without messing with the code??

Joe
In reply to Joe Griffin

Re: Administration block for studetns

by Chris Potter -
I see what you're asking. Unfortunately, you're probably correct then. Why not just have them click the "Profile" link and then the "Activity" tab when they're in that course? I realize it's two clicks and not one, but if you're not comfortable with the modifications, I think it's more hassle than it's worth IMHO. Not to mention the change would have to be made each time Moodle is updated on your site.

That being said however, it shouldn't be that difficult to add the code necessary to allow the student the right to look at the log. It's just constructing a URL after checking the permissions. The URL (in 1.9) looks like this:

http://yourschool.edu/moodle/course/user.php?id=##&user=###&mode=complete

## = CourseID (I assume! Double check)
### = UserID

So, using the $COURSE->id and $USER->id, you should be able to construct the url you need (make sure the appropriate checks are in place to see if they are allowed and if not, I wouldn't even display the option).

You would want to place the code somewhere that made sense in the adminstration block (bottom, after link to profile) and name it something that was different than that of the course "Reports" link (because this would show a link to the user's report as well and you don't want to confuse instructors). Maybe "User report"?

It might look something like this (no claims this will even work or work in a secure manner, I'm just guessing off the top of my head):

$coursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->$id);
$personalcontext = get_context_instance(CONTEXT_USER, $USER->id);

if (has_capability('moodle/site:viewreports', $coursecontext) or ($course->showreports and $USER->id == $user->id) or has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
echo $CFG->wwwroot.'/course/user.php?id='.$COURSE->id.'&user=.'$USER->id.'&mode=complete';
}

Sooo... that's what it MIGHT look like. Again, the usual disclaimer applies that I'm not a Moodle "expert" with code... so proceed at your own risk.

Hope this is helpful. smile

Average of ratings: Useful (1)
In reply to Chris Potter

Re: Administration block for studetns

by Joe Griffin -
HI Chris

Thanks for the comprehensive reply. I might give it a go although I can see what you mean about the risks. I just wanted to make it easier for students to access their own reports (formative assessment and feedback being something I am looking at to encourage learning). But perhaps it is too much hassle and of course it might just encourage students to continuously use this and place more burden on the server.
Anyway thanks again

Joe

In reply to Joe Griffin

Re: Administration block for studetns

by Ingo Baumann -
I would like to allow only admin users to view admin block. Students and guests must not see the admin block. One solution I found is override permissions in block "Administration" manually.

In order to avoid overriding permissions manually for the admin block whenever a new course is created, I tried to insert permissions in table mdl_role_capabilities and it works too. But I suppose there is another way to solve this problem.

Does anybody know another solution to prevent students and guests from admin block without overriding permissions?

Thanks!

Ingo



In reply to Ingo Baumann

Re: Administration block for studetns

by Carvell Fenton -

I have implemented something like what Ingo is trying to do, but I am not sure it would work for Joe.

I wanted to make users with a very restricted set of permissions, so I duplicated the roles that I thought were closest to what I wanted, and then modified the duplicate permissions and took away all the things I didn't want that role to be able to do. Then, when assigning roles within a context, I assigned my new role to the user rather than the Moodle default (e.g. rather than assign a student the Moodle Student role in a course, I assigned my new Student role). I would not recommend modifying the Moodle default roles. According to what I have read in the Moodle docs and various tutorials, it is generally a bad idea to mess with the defaults. Always good to keep them just in case. Of course it is open source, so feel free to do what you want! wink

I did this all though the Users -> Permissions -> Define roles page in Moodle. If you go to that page, then click on the Role that you want to duplicate (click on its hyperlinked name), you will get a page that has a "Duplicate role" button. Duplicate the role, then edit the new role's permissions. I have been able to tailor pretty much exactly what I want each user to have access to in each context. Be warned: there are a lot of permissions, and it may take some trial and error to get the combination that you want, but it has worked for me.

Perhaps that would be a way to do it for you rather than overriding permissions.

I did all this in version 1.9.4, and that's the only version I have used so far.

Carvell

In reply to Ingo Baumann

Re: Administration block for students

by Ingo Baumann -
Found another solutions with the disadvantage of changing the code in block_admin.php:

1. create access.php for admin block with following capability definition:

$block_admin_capabilities = array(

'block/admin:view' => array(

'captype' => 'read',
'contextlevel' => CONTEXT_BLOCK,
'legacy' => array(
'user' => CAP_PROHIBIT,
'guest' => CAP_PROHIBIT,
'student' => CAP_PROHIBIT,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
);

2. check capability in block_admin.php

$blockcontext = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
if (!has_capability('block/admin:view', $blockcontext )) {
return $this->content;
}

Does anybody know another solution without changing code in block_admin.php?

Many thanks
Ingo