From 6f26fcd7e08ec231fbe143dcb60fb3bb35d4f02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 10 Jun 2016 16:36:00 +0200 Subject: [PATCH] MDL-54894 comments: Get course from context if not informed --- comment/lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/comment/lib.php b/comment/lib.php index 7df025caad4..42b3d425dec 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -153,7 +153,11 @@ class comment { } else if (!empty($options->courseid)) { $this->courseid = $options->courseid; } else { - $this->courseid = SITEID; + if ($coursecontext = $this->context->get_course_context(false)) { + $this->courseid = $coursecontext->instanceid; + } else { + $this->courseid = SITEID; + } } // setup coursemodule