From b82e6007231a9fc82ade14e47570336098a38fe1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Massart?= <fred@branchup.tech>
Date: Thu, 19 Apr 2018 13:05:51 +0800
Subject: [PATCH] MDL-61970 mod_survey: Do not assume context passed is one of
 survey

---
 mod/survey/classes/privacy/provider.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mod/survey/classes/privacy/provider.php b/mod/survey/classes/privacy/provider.php
index ac541f76d2f..683fc2a381e 100644
--- a/mod/survey/classes/privacy/provider.php
+++ b/mod/survey/classes/privacy/provider.php
@@ -281,8 +281,8 @@ class provider implements
      * @return int
      */
     protected static function get_survey_id_from_context(context_module $context) {
-        $cm = get_coursemodule_from_id('survey', $context->instanceid, 0, false, MUST_EXIST);
-        return (int) $cm->instance;
+        $cm = get_coursemodule_from_id('survey', $context->instanceid);
+        return $cm ? (int) $cm->instance : 0;
     }
     /**
      * Loop and export from a recordset.