I can see this being a very useful feature but also a very tedious feature to enable, if each pupil needs to have the parent added manually.
Manual linking seems much too cumbersome. Could there be some way to connect the allocation of parent roles to a database [we have a database that contains parent info for each student] - or would it need periodic exporting of that info to a flat file?
In fact is linking to a database something I should be thinking about to keep student records up to date?
[I have uploaded pupil course allocations with a csv file, and use LDAP authentication - which we would want to keep]
Sorry - I missed your reply.
I'm not sure I can be as clear as you would like - here goes:
We keep our records on a Filemaker database - actually I guess it's several related databases. Now I can use the database, but I've no idea how it is set up or how to make it communicate with Moodle.
As far as producing parent accounts from the database is concerned , I guess that data is not going to change much - we could do a termly complete update with manual editing in between.
However, I have only been trialling Moodle within two Departments. I have been enrolling students using a flat file taken from the database. I'd like to extend it across the school [we have 1000+ students] - this is where we would need to keep course enrollment data more up-to-date so that student course membership data could be read from the database - this data is going to be more volatile than parent data.
I don't know if this makes sense?
My idea was to create a script that would run each night like cron to populate the mdl_role_assignments table with the correct roles. The problem with my idea is that the contextid that is taken from the mdl_context table confuses me.
I'm trying to do similar things (but not sure I'm up to "creating extra columns in tables" to do what I want).
We import student data (and course enrolment) from flat files, generated from our database by fairly simple queries.
We could easily do the same for parents, but then how to link each parent with pupils. Again, the info is in the database, so could be generated OK, if Moodle could then import it.
My main problem at the moment that I cannot even overcome manually, is how to allow each parent to SEE each course that their child is enrolled on, without enrolling the parent too . . .any thoughts?
I'm interested in the same thing - do not want to face the task of doing this manually. Although it might be bearable if there were a slick AJAX-ish user manager which could handle tasks such as enrolling a user in multiple classes at once. The file uploader is too advanced for our registrar.
Let us know if you come up with a solution.
I imagine a column for "parent username" could be added to the upload users script, and then the script could be altered to map students to parents based on username. Is this what everyone is looking for?
Yes - in my case - broadly. That is I am interested in parents (fathers/mothers/guardians) of pupils/students being registered so that they could see the COURSES on which their children were enrolled.
Unfortunately, it is a many to many relationship, in that (when some families are split) one child can relate to several parents, and one parent can relate to several children/students.
I think our MIS database can hadle all of this, BUT I just cannot find out how to enable a mentor to VIEW the courses of his/her mentees.
Has anyone managed to get this to work (either via PhpMyAdmin or CSV upload files?).
I've got a list of parents I would like to import, with child username in the list. Apart from populating the mdl_user and mdl_role_assignment database, what other tables do I need to populate to create the link from child to parent?
I was thinking of attempting this with phpMyAdmin if it was at all possible.....look forward to any responses?
Typically what I have done is I import the list of parents (or whatever other data I'm working with) into the MySQL database and then use phpMyAdmin queries from there. Of course I typically run these on production data on a test server first (OK, ideally I do that). I'd say give it a shot and see what happens. Peace - Anthony
I wouldn't mind having a little bit of help with the SQL if you're upto it. Yes I am also using a local test server... before I put this code in a production environment.
I've got my parents uploaded, but what I can't seem to suss out is how I can relate my parents to the children. the fields in mdl_role_assignments look fine(understandable) apart from contextid....not sure what that means
I would also like some help on the sql to achieve these manual configuration of role assignments. The context field confuses me :P. Could you maybe give some generic scripts that achieve this?
When you import the parents how do you initially associate them with the students? I thought that adding a parent column to the mdl_user table would be a good way to handle this but if you have a better way, it would help me out greatly.
Thanks a lot!
The idea of MDL-15187 is to extend admin/uploaduser.php to be able to assign any role in any context (currently, it only assigns roles in course contexts; you specify the course using the course shortname). Any context can be specified by two numbers: the context type and the context instance. The User context type is 30. So, for example, my user context on moodle.org is (30,104240).
With this change, the administrator could create a csv file with a row for each parent. For example, if my parent is Ebeneezer Isner...
John, may I ask you something about roles.
We are working on another approach for parent account:
Everytime a student visits a course:
- we check if there is a parent account for this student
- we check if the student is a teacher
- if both answers are NO:
- we create a parent account with a random password and we extend the unique username of the student with parent_
- we add the course to the account of the parent
- if there is already an account, we add the course to the parent courselist
- we offer the admin two buttons on the user overview page: one for a PDF and one for an exceldump with the list of parents accounts.
- One of the wishes is that a parent could fill an ask-the-teacher-block and students have another ask-the-teacher-block
Now the question: which role should we give the parent:
- with this last wish
- without this last wish
I like the automatic approach! It makes sense until the step
we add the course to the account of the parent
What do you mean? Do you assign the parent a role in the Course context? If so, what role do you assign?
In the standard setup for parents (Parent role and Mentees block), parents are not assigned roles in courses. They are assigned roles in their child's User context. From the User context they get a keyhole view into their child's courses which allows them to see only their child's work and grades. I don't think it is possible to define a role that would give such a restricted view if assigned in the course context (it would either be able to see too much or too little).
So maybe you should modify this step
- we add the course to the account of the parent
- we assign the Parent role to the parent in the child's User context
Can we clear this up first? Then we can discuss your "last wish."
mm, So I must change that:
We now force for everyone the use of my page, so when a parent logs in with his own parent_username/random password, he sees the parent_abaker_mypage of the child abaker:
on that page he sees:
- the mentees block, forced as a permantent block (but I must set the rights better: he gets now the answer no rights: roleid is like blocks-id a dynamic value! )
- (after a patch) the list of courses of his child, but if i activate the href, he is asked to become member of that course, what we do not wish
Question: if it is not possible to see the course through the eyes of the child (is loginas not possible as a forced parameter in the href-link?) is it possible to add a param to the href which gives the parent guest-access?
Well, guest access is even more legant:
the parent can see the profile aAND the course + activiteis without interfering the process, .. just guest access would be nice!
- Access Administration > Users > Permissions > Define roles
- Click the button "Add a new role"
- Give the role a name e.g. Parent, short name and description
- Change moodle/user:viewdetails to allow
- Change any/all of the following capabilities to allow
- Click the button "Add a new role"
Re loginas: did you notice the risks? I wouldn't even give it to teachers.
Parents should never be able to enter any course (they should never have moodle/course:view = Allow).
- Create the Parent role, as described in docs.
- Assign the Parent role to the parent in the child's User context (click the Roles tab on the child's user information page (user/view.php), then click Locally assigned roles then click Parent, then assign the role to the parent.
- Site administration -> Modules -> Blocks -> Sticky blocks -> Configure MyMoodle -> Blocks add... -> Mentee block.
I understand from your earlier post that you want to automate some of these steps, and that is a good thing to do. But I think you should follow the standard approach (Parent role assigned in child's User context + Mentees block), rather than trying to reinvent the wheel.
John, you are right: I see on your picture above/I realise that the parent already can enter the courses on the user profile page: this gives the parent a global view: resources yes, test content and assignments not.
After correcting the roleid in the code for the parent-account, everything is working now! We get a parent account when the student enters a course and this parent gets as a bonus a nice my page: we stick to your role concept. (We even do not allow to change the child's profile page.)
So, having these parent_account active, we can now start to think about filtering blocks by role-type..
Thanks for the comments, you too Antony, I agree on the privacy and interfering points.
I'm glad it's working. Remember, the parent never "enters" any course. The parent can only peek into the slice of the course related to the child. The parent is confined to the child's User context (see image -- child wearing hat).
we can now start to think about filtering blocks by role-type
Now that I see your MyMoodle screenshot, I understand the problem. You don't want parents to see the same blocks that students see, but only the Mentees block. It is an interesting problem, but I doubt you can solve it with roles, since there is no way to tell a parent from a child when they first login, because they have the same role (Authenticated user) when they first login and are in the System context. Then the child goes "down" into his course context, and the parent goes "down" into the child's User context. Now they have different roles (Student for child, Parent for parent), but it is too late, since they are no longer on the MyMoodle page. I think it shoudl be a new issue in the tracker.
Interesting, how complex!!
Mmm, thanks, I have to find another direction then roles to solve that:
- they only arrive on the my page when they login succesful
- Because the usernames of all parent accounts start with the prefix parent_ we can put the check on this as a filter in block conditions:
- if head of username is parent_ ..show special parent block
- if head of username is parent_ ..hide some other blocks
something like the login block
I see you use Parents at the beginning - I was just thinking of doing that for the purpose of sorting them more easily when I have to manually search because there is no other way to sort users, correct? Similarly, I was thinking of naming all students as Student_lastname and then Parent_lastname. is this a good idea or will I regret this? (200 students, 25 teachers, moodle 1.9, apache)
Thanks, I'm following your thread.
"Remember, the parent never "enters" any course."
At the moment I have Parent and Student set up and linked. When I log in as a Parent I see the child and can click and see his profile. If I click on a course from there I can see the outline and complete activity reports (with any assigned grades etc.). However if I click on any of the materials - handed in work, forum posts etc. it tells me "You are about to enrol yourself as a member of this course." If it is passworded I get no further and if not it lets makes my parent a student in his own right! (Activity report says there is one Forum post but the Forum tab tells me there are no posts - either way I can't see it.)
So does anyone have an idea what I have missed?
(I have to document our approach better, sorry)
I read the tracker link and discussion - am I correct that using a CSV upload of parents assigned to their kids (mentees) will not be available until moodele 2.0? Or can we do it now? I don't get the instance number - if users are 30, but you want the parent to be assigned to them in ALL instances (courses), then what would you use? (so it looks just like it should - parents log in and in mentees block they see their kids)? THanks
I think "will" is too strong a word. Right now it is just an issue in the tracker and it has not been assigned to a developer yet. Once it is assigned, there will probably be further discussion. It will be dropped if there is not enough support for it, or if the developers consider it too difficult to implement. In the best case scenario it will be included in Moodle 2.0. Thanks for voting for it.
you want the parent to be assigned to them in ALL instances
No! You never assign the Parent role in a course context. You assign the Parent role to the parent user in the child's User context. This SINGLE role assignment gives the parent the ability to peek into all of the child's courses.
Regarding the number 30: I was suggesting a general way of specifying contexts in csv files. My suggestion was to use two numbers: (context type,context id).
The number 30 is the internal Moodle code meaning User context. The number 104240 is my user id. To specify my User context here on moodle.org, I used the pair of numbers (30,104240). This is the context I would specify when assigning the Parent role to my father.
The two-number scheme can be used to specify any context, not just User contexts. To assign a role in the Roles and Capabilities forum (this forum), I would write (70,6826). 70 is the internal code meaning "Module context" and 6826 is the forum id.
Thanks, I know how to assign the parent role inside a child account but I did not realize how to describe it. Thanks for clarifying it is a role, not a course.
For now, how can I best assign parents to each Mentee? (manually is a pain with 200 students). I saw Anthony Borrow's download but I did not understand it - the part on creating a sql database linking parents and students. Do you know a hack so I can do a csv upload (which I get) or can you explain Anthony's mass mentee import download? Thanks John,
Anyone who wants to see a general solution to this problem (not one specific to Parent role assigment) should vote for MDL-15187.
Most folks get the idea of creating the role_assignment; however, the concept of contexts throws a wrench in things. There are various context levels - the context level for a user is 30 and then the instanceid refers to the users mdl_user id field. So the parent gets assigned the role of parent for the context of the child. I am attaching a sql script to be used as a rough reference for one way of attacking this issue of doing a mass import of parents. It is meant to be used as a guide to show the steps that I used on a test server with test data. Please let me know if you think there are dangerous oversights that might corrupt data. Use the script in so far as it is helpful and otherwise avoid it. Peace - Anthony
Your script works an absolute treat! I made one small alteration on line 52,substituting mr.name to mdl_role.name
Thanks Again, you've saved me alot of work(I was at one stage contemplating manually entering these in)!
Inaki may have some ideas. Essentially the username or userid of the student would need somewhere in the ActiveDirectory information (probably as a comma separated list). Either way there would have to be some agreement about the name of the field, etc.
My initial response would be to not have LDAP create the account and go ahead and create the account in Moodle and assign the parent roles and then let them authenticate using LDAP. A little work at the beginning will likely save you time and worry down the road.
I do not see how it would be possible for a parent to see a child's courses without being enrolled in the course. The mental association that we make between a parent and child is not one that Moodle makes. In other words, there is no inherent connection between users. Each user has capabilities to perform various activities in given contexts (one of which is the user context).
One option is to avoid parent accounts and encourage the parent to sit down with their child as the student is logged in. This allows the parent to see what the student sees while allowing the student to remain responsible for his or her own learning.
Peace - Anthony
If anyone is familiar with customizing the LDAP code and would like to help me out with the other major step please see - http://moodle.org/mod/forum/discuss.php?d=77062#p342708
I've attached the php file I created with the help of Anthony's sql file. If anyone would like to clean it up and make it work better/faster/stronger by all means do but please repost the results so that we all can share in the enjoyment.
- Script pulls parent name from column created manually in mdl_user table.
- I'm not a super strong php or sql writer, so be kind if you are one.
- I was planning to have this script run each night along with cron.php
I know anthony is too busy to re-write this code. However, it appears both Anthony and Justin already made it work in the mass parent creation and assign parent modules. I really need this to work but don't understand how to create the sql table it reads from or where to place this php.
My situation has changed dramatically. Our moodle courses were opened up to many more students than I had expected. Plus, my main IT admin could not tell me which students are going to use our Moodle course and which will homeschool on their own (why I am trying to understand). I was recieving so many emails (50 a day) from frustrated users with no username/login that I had to import EVERY student 7th to 12th. That way any errors are user errors knowing how to login. I automate this weekly now and create parents accounts with their same name for ease of finding the right one to attach. (stu_johnsmith and Par_johnsmith)
That's over 2000 users now! It's painful attaching them manually. Plus I have to attach teachers to all of them so they too can check on their students. Now they want to add 6th too! Currently I am so overwhelmed with emails that I can only do a handful of attachments at a time. I trained a secretary to help but she is limited on time too. I sort by most recently logged in assuming those not using it don't need this feature yet and won't complain.
Please help me understand how to make this php plugin work or a way to sort users to see who does NOT have an attachment but IS using moodle (enrolled in a course). I like Ger's auto attach when enrolling but don't know how to set it up either. Thank you for any help on the mass creation or assign parent module setup.
//Split apart supervisor table element
$sup = explode(" ", $row_pull_name['supervisor']);
//Count array elements
$sup_count = count($sup);
//Save supervisors first name
$sup_fname = $sup;
//Save supervisors last name
$sup_lname = $sup[$sup_count-1];
Justin - looking at this code, I was unsure of what was happening in the supervisor field. Is there a specific format required for the supervisor? eg: firstname lastname or similar?
Is your question also about using the mass parent creation for mentees? If so, perhaps we can work together to figure out how it works. Someone already made it and used it, so it must work if we figure it out. I'm stuck on creating tables in the step below- do you know how to do that? I see database now in server props, but don't know how to add a table? I feel so close now.
==> ??? using ODBC or some other method create a table called parent_list which contains the parent and child usernames paired together as one record. The script assumes the field name are parent_username and child_username
CREATE TABLE `parent_role_assignments` (
`parent_username` varchar(100) NOT NULL default '',
`child_username` varchar(100) NOT NULL default '',
==> ??? pull in the data from your parent list table that contains parent_username and child_username\
I will be looking at this with some others on Monday. Will let you know how we get along.
I also started a new thread in this forum because this thread, as is so often the case can get a bit convoluted, so its there if you want to use it....
Also posted it to Developers Forum
Thanks - glad to know this is active again! I would love it to work, which it was working at least once before but just needs upgrading and instructions - they main part confusing me on Anthony's directions was directions to making an sql table in moodle. Thanks for working on this and replying.
what did you find out about making the mentees parent mass creation work in 1.9? Looking forward to your reply - please keep this moving forward! It seems so close if it already worked in 1.8 by Anthony come it can't work for 1.9. I need to learn PHP as I just can't take it any longer and would solve things myself but don't know anything except vba programming! Thanks for your expertise
Greetings to everyone...
This is actually my first post in a moodle forum.. I have been using moodle for a while and now the school where I work wants me to focus on the administration of our virtual campus (http://188.8.131.52/aula/)...
I am focusing on the creation of parents' roles but I have to confess that I have no idea about how to use the SQL scripts that you have shared here. I understand the code, but I honestly don't know how to use it into moodle...
Can anyone help me with this??? Is there any wikihow about it???
Thanks again for your help.
I love the idea of mass parent creation and am stuck on how to do it. I imported parents just fine but I do not have much knowledge of how to create a sql database. Can anyone give me detailed instructions step by step of how to do this? I have 200 students to enter and I could really use this feature. Thanks in advance for helping this novice admin out.
Then we would add a link to import mentee assignments which would go in and create the role assignments for each listing, reporting progress and errors along the lines of:
assignment successful: abaker_parent is mentee of abaker
mentee's username not found: cdempsey_parent
student's username not found: efish
mentee's username not found: ghall_parent
student's username not found: ghall
If the role assignment already exists, I think I will just report it as being a successful assignment. Does this sound like a reasonable/helpful approach?
Peace - Anthony
That would be great! Would this replace your previous mass mentee download method?
As a background to my questions, my school has 2000 homeschoolers:
300 are High School students
25 Moodle h.s. course teachers
75 ES's - "homeroom" teachers who must track, not grade, student progress
I created two roles for mentees, parents and ESteacher. Parents rarely change (some do- custody reasons) but ES ("homeroom teacher) student's change often. ES's have the same privileges as parents so I could use just one but I was trying to give ES's the ability to grade ONE assignment monthly for the progress they see. This failed as mentors should not be able to enter course of mentee. So Instead, my current plan is for 75 teachers to send me monthly progress for their students on excel which I link on one master which I can sort by course and then will export as csv and then import into each course as a one grade - ug!)
I'm thinking of using Parent_jsmith and Student_jsmith so I can sort them easier.
1. If I want each parent to have their own name, not a generic parent_jsmith, could the csv handle multiple ones by adding them with commas?
JSmith, parent_SueSmith, parent_JerrySmith
2. What about other roles like parents (my ES role) - could it handle more than one mentee defined role?
3. When students change for the ES or parents, will I have to delete that role manually or can it automate UNlinking a parent/ES to a mentee?
jsmith, ES_LarryMcdoogle, - ES_BradHunt
I hope I'm making sense. Also, in Moodle Tracker MDL-15391 I explain that it makes more sense to me to link them the other way around:
parent (or ES) with different students and use specific parent NAME
I have up to 30 students to select for any one ES, so that would save me time to list the parent or ES first, and then their students or kids. It's more intuitive too, at least for me.
parent_Dsmith, student_jsmith, Student_Csmith, Student_lsmith
Parent_WJones, Student_jsmith, Student_Csmith, Student_lsmith, student_bjones
ES_pborba, student_jsmith, Student_CLee, Student_lharris, . . . . . . .
The ES's 30 students may change during the year.
again, a way to remove a mentee's parent/es would be helpful with adding: -student_lharris or something like that.
I hope some of this makes sense
Where will you be posting this csv download? Or will it be an update to the cvs code in moodle? I don't know if you saw the tracker MDL-15187 which is the same solution you are working on. John there says it is worded strange but that this link
talks about global roles in csv updates and somewhere else John talked about mentees roles. Anyway, this tracker was 'hoping by 2.0' it could be implemented - so I'm hoping too but instead that you might figure it out before August when I have 200 students and 200 parents to link and 75 ES's that change students all the time! Thanks for your help and please post where you will put this download or update so I can try it - thanks Anthony
Bummer, I was hoping to see it but I know you are very busy and in high demand for many important projects. I guess 200 is not much but once we get started I may be asked to have all 2000 in some Moodle related activity to satisfy our computer goals and parent requests. The hardest part for me is the 75 ES's with 25-30 students each that keeps changing monthly. Having that automated like a csv file would really help me out. Since MDL-15187 may not happen until Moodle 2.0, can you explain how to use your original mass import download?
There's a lot of info in the past that goes *whoosh* over my head - so apologies if this has been asked and answered!
We are using the PLP block and need to assign tutors to students so they can feedback on their Personal Reports.
Doing this is proving very time consuming - is there a mass way of doing this?
Hope someone can help!
Parent access is my next big job, and I will probably be re-visiting this code and cleaning it up/ making it more flexible.
If you've got any questions ask away,
I know it's quite an old thread but AFAIK, it's the one that contains to more useful information about parent role in Moodle.
I updated a piece of code written by Penny Leach to sync parent role from an external DB to work with Moodle 2.3.
In short, you need an external DB with 3 columns: student_username, parent_username and role_shortname. That's it! The plugin will assign (and unassign if needed) the role accordingly.
You can find to code here:
I havn't had the time to test it as I would like to but it seems to work well. Let me know if you find any bug in it.
I might need to rename a couple of thing in there because it could be used for mentor/mentee relationship as well. Also, keep in mind that it's still in beta state.
We finally realized that it was better to get the child-parent relationship from LDAP, so I created a new plugin importing user role from LDAP.
You can find the code here:
All parent/mentor entries in LDAP must have an attribute containing the list of chlid/mentee unique identifiers.
Let me know what you think about this.
Thank you so much for doing all this work. I have a question, though. When I run the sync.php from the command line (I am using Xammp on Windows), it starts the synchronization process and then just stops. I have set up the database correctly, I think, but if you could perhaps provide an example of the settings one should use, that would be great.
Sorry for not answering to your post, I didn't get any notice about your reply...
In case someone else have this problem, I suggest adding the "-v" option to activate verbose mode.
If you find the solution in the meantime, maybe you could share it