Comment 1 for bug 1972922

Revision history for this message
Robert Lyon (robertl-9) wrote (last edit ):

Hmm, odd we only get this error if we go through the PluginModuleSubmissions::add_submission() function. And the 2 calls to this function are wrapped in a check that a group id exists.

Ah, reading the bug report again it sounds like we need to somehow differentiate the add submission when dealing with an internal group versus dealing with a 'fake' LTI group when Submissions plugin is active.

Looking at the 'lti_assessment' table there is a 'group' column we can use - so if the id of the group we are dealing with is not listed there then it's not an LTI group.

So we to change the places from:

if (PluginModuleSubmissions::is_active() && $group) { ... }

To something along the lines of:

if (PluginModuleSubmissions::is_active() && $group !group_external_group($group)) { ... }

and have a new function in lib/groups.php file:

function group_external_group($group) {
    if (is_str($group)) {
      $group = get_record('group', 'id', $group);
   }
   if (record_exists('lti_assessment', 'group', $group->id)) {
      return true;
  }
  return false;
}