From 0e91a0736786a369b24424850594729bad666fef Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Mon, 5 Aug 2024 23:48:46 -0500 Subject: [PATCH] Internal: Fix error when importing gradebook in session course addition - refs BT#21911 --- public/main/gradebook/lib/be/evaluation.class.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/public/main/gradebook/lib/be/evaluation.class.php b/public/main/gradebook/lib/be/evaluation.class.php index 0b8ea125097..9716b2a8ef6 100644 --- a/public/main/gradebook/lib/be/evaluation.class.php +++ b/public/main/gradebook/lib/be/evaluation.class.php @@ -300,9 +300,8 @@ public static function load( /** * Insert this evaluation into the database. - * @throws \Doctrine\ORM\Exception\ORMException */ - public function add() + public function add(): bool { if (isset($this->name) && isset($this->user_id) && @@ -310,6 +309,13 @@ public function add() isset($this->eval_max) && isset($this->visible) ) { + + $user = api_get_user_entity($this->get_user_id()); + + if (null === $user) { + return false; + } + if (empty($this->type)) { $this->type = 'evaluation'; } @@ -328,7 +334,7 @@ public function add() ->setCourse(api_get_course_entity($courseId)) ->setTitle($this->get_name()) ->setCategory($category) - ->setUser(api_get_user_entity($this->get_user_id())) + ->setUser($user) ->setWeight(api_float_val($this->get_weight())) ->setMax(api_float_val($this->get_max())) ->setVisible($this->is_visible()) @@ -337,6 +343,8 @@ public function add() $em->persist($evaluation); $em->flush(); $this->set_id($evaluation->getId()); + + return true; } return false;