From ff6de753960c56694e326f2a90f598212b4fe0e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= <crazyserver@gmail.com>
Date: Wed, 22 Jun 2016 12:40:43 +0200
Subject: [PATCH] MDL-54991 assign: Invalid submissiongroup when not using
 groups

---
 mod/assign/externallib.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mod/assign/externallib.php b/mod/assign/externallib.php
index d0924caafa0..f901c307c8a 100644
--- a/mod/assign/externallib.php
+++ b/mod/assign/externallib.php
@@ -2433,7 +2433,10 @@ class mod_assign_external extends external_api {
             // We need to change the type of some of the structures retrieved from the renderable.
             if (!empty($lastattempt->submissiongroup)) {
                 $lastattempt->submissiongroup = $lastattempt->submissiongroup->id;
+            } else {
+                unset($lastattempt->submissiongroup);
             }
+
             if (!empty($lastattempt->usergroups)) {
                 $lastattempt->usergroups = array_keys($lastattempt->usergroups);
             }