microsoft / o365-moodle

Office 365 and Azure Active Directory plugins for Moodle
GNU General Public License v3.0
183 stars 137 forks source link

Teams not being created for Moodle courses. #1733

Open vdiscipio opened 3 years ago

vdiscipio commented 3 years ago

Moodle 3.11 Microsoft 365 Integration local_office365 3.10.120201109

The plugin is installed and passes all tests. In Site administration -> Plugins -> Local plugins -> Microsoft 365 Integration -> Sync Settings under course sync the "All Features Enabled" is checked. The process only created 2 courses when ran from scheduler and shows no errors when ran from the command line. We have 580 courses and have verified all have at least a "teacher" role assigned to a person.

select * from mdl_local_o365_objects where type = "group"; shows 4 entries and course and courseteam entry for the 2 courses that have teams created.

the table mdl_local_o365_teams_cache has the same number of rows as the teams admin center shows.
select * from mdl_local_o365_coursegroupdata; returns the empty set.

running the scheduled task from the command line yields no errors and creates no teams.

php /srv/www/htdocs/admin/tool/task/cli/schedule_task.php --execute="\local_o365\task\groupcreate" Execute scheduled task: Create user groups in Microsoft 365 (local_o365\task\groupcreate) All courses have a group recorded. Attempting to fetch teams Build existing cache records cache Update cache records Delete old cache records ... used 3836 dbqueries ... used 18.624874830246 seconds Scheduled task complete: Create user groups in Microsoft 365 (local_o365\task\groupcreate)

Any thoughts on what to check or how to get the teams created for the courses would be appreciated.

vdiscipio commented 3 years ago

Since the original post above, 2 more course teams were created, but there is nothing special or differentiating between the 4 total courses that have teams and the 578 courses that do not.

weilai-irl commented 3 years ago

Hi @vdiscipio,

The plugins haven't been officially tested on Moodle 3.11 yet. We are setting up an environment for Moodle 3.11 at this moment and will perform tests as soon as it's done, and release a version of the plugins for 3.11 in the coming weeks.

However, I don't expect issues like this to happen as none of the changes in the 3.11 seems could have caused this.

For the first thing to check, could you confirm the visibility of the Moodle courses please. In the current design, only visible Moodle courses are synced to Team.

If all courses are set to be shown to students, could you run the following query in your database, and let me know how many records are returned please.

SELECT crs.*
FROM mdl_course crs
LEFT JOIN mdl_local_o365_objects obj ON obj.type = 'group' AND obj.subtype = 'course' AND obj.moodleid = crs.id
WHERE obj.id IS NULL AND crs.id != 1 AND crs.visible != 0;

This is essentially the script used to gather all courses that need to be synced.

Please let me know what you have found.

Regards, Lai

vdiscipio commented 3 years ago

Lai,

I must have missed the release note on the course visibility required to create a course team. We have a lot of our faculty like to fully build the course before making it visible. At this point we have used PowerShell to create all the teams courses and associated them with Moodle courses in the interface. Below is the output from the sql you asked as well as a list of all visible courses.

MariaDB [moodle]> SELECT id, shortname FROM mdl_course WHERE visible != 0; +-----+----------------------+ | id | shortname | +-----+----------------------+ | 1 | Moodle | | 5 | EDTC-10000-03-SC | | 8 | EDTC-10000-04-SC | | 9 | EDTC-10000-05-SC | | 126 | PHIL-21300-01-2122FA | | 462 | FYSM-10100-10-2122FA | +-----+----------------------+ 6 rows in set (0.001 sec)

MariaDB [moodle]> SELECT crs.* -> FROM mdl_course crs -> LEFT JOIN mdl_local_o365_objects obj ON obj.type = 'group' AND obj.subtype = 'course' AND obj.moodleid = crs.id -> WHERE obj.id IS NULL AND crs.id != 1 AND crs.visible != 0; Empty set (0.003 sec)

MariaDB [moodle]>

weilai-irl commented 3 years ago

Hi @vdiscipio,

The requirement of course being visible to be synced was implemented before we took over the maintenance of the plugins, so it must have been part of the original requirement. I'm not sure how valid it is now.

If your case, you can create a simple patch to remove the AND crs.visible != 0 at https://github.com/microsoft/o365-moodle/blob/1a6d4ad384ce2a83f5a1be2d42e3b30762bb0886/local/o365/classes/feature/usergroups/coursegroups.php#L115 to allow teams to be created for all courses, regardless of visibility setting. You will need to maintain the patch yourself though.

Alternatively you can log a request to make this an option so that site admins to decide if course visibility is considered when doing course sync.

Regards, Lai

darius-m commented 3 years ago

Hello, @weilai-irl, The visibility part of the query may have been a fix for the course copying issue (#1448) that I have proposed in the past. Unfortunately, at that point I could not figure an alternative that could be used to differentiate between "finished" courses and the ones that are currently being processed for copies. I do not know a better solution for that issue, but the course-team renaming synchronization may be a better alternative (with the proper warning message for the naming sync option, where if disabled copied courses may end up with the wrong names). An option to disable synchronization for hidden courses may still be useful, since students would be added to a team created for a course they cannot see.