Moving database entry from one group to another

Moving database entry from one group to another

by Marina Non -
Number of replies: 4

Hello all,

First : thank you so much for your documentation, forum and tracker, theses are awesome resources.

Second, there is my actual problem :

In previous version of Moodle (let's say 2.4), in a database activity, I remember it was possible for the teacher to move an entry from one group to another (switching the dropdown menu before re-validate the entry).

In 3.0 (and 3.1), I realize I cannot do this anymore (neither in visible nor in separate group).

Is that a normal behaviour ?

Thanks by advance,

a french moodle user for years (my english is not perfect).

Average of ratings: -
In reply to Marina Non

Re: Moving database entry from one group to another

by William Lu -
Picture of Particularly helpful Moodlers

Hi Marina,

Group is related to user, not entry.

The Group features in the earlier version (say 2.8) was not working properly. 

To move an entry from one group to another, you have to move user first.

In reply to William Lu

Re: Moving database entry from one group to another

by Marina Non -

Hi William,

thank you for your answer !

Can you explain how to do (change the group of an entry) ?

In fact, I tested various scenario and I cannot move the entry : it keeps belonging to the group the user was in when he created this entry. Plus it seems that editing the entry by the teacher after that has no effect either (whether he's in the good group or in no group).

Thanks by advance

In reply to Marina Non

Re: Moving database entry from one group to another

by William Lu -
Picture of Particularly helpful Moodlers

Hi Marina,

I tested too, you are right, moving users from one group to another could NOT move their entries.

I guess the existing entries tend to stay as they were. Changing user's group status has no effect on an existing entry. 

To move an existing entry, we need a trigger to 'update' it. Sadly, user group update won't do anything to a database entry.

You may have to alter your Moodle database table straightaway, but it is not practical and risky.


Workaround:

Remove all group settings (select No group) > Create a required drop-down menu field for your groups > Ask your users to select the correct group they should be > Use the search field to generate a quick link to each group and publish the links at the description area of your activity. 

Then, students and teachers can move entries from 'group' to 'group' freely.

The drawback of this method is: users can see all entries from every group.


HTH

In reply to William Lu

Re: Moving database entry from one group to another

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Marina and William,

A database activity is spread out in four tables.

mdl_data - contains the info about the activity

mdl_data_content - contains the actual data, which fieldid it belongs to, and which record it is part of

mdl_data_fields - contains the field type, name, description, etc.

The table you are interested in is:

mdl_data_records - contains the user id, dataid, timecreated, timemodified, approved, AND groupid

It's that last item, groupid that you need to change. Changing the students group has no affect on that item, but if you know the groupid you have moved the student to, you can change prior entries to the new groupid using something like phpMyAdmin, and then you will see them listed in the group you want them in.

Average of ratings: Useful (1)