Skip to content

Commit a461f75

Browse files
Merge pull request #5708 from christianbeeznest/ofaj-21911
Internal: Fix error when importing gradebook in session course addition - refs BT#21911
2 parents 77fb77a + 0e91a07 commit a461f75

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

public/main/gradebook/lib/be/evaluation.class.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,22 @@ public static function load(
300300

301301
/**
302302
* Insert this evaluation into the database.
303-
* @throws \Doctrine\ORM\Exception\ORMException
304303
*/
305-
public function add()
304+
public function add(): bool
306305
{
307306
if (isset($this->name) &&
308307
isset($this->user_id) &&
309308
isset($this->weight) &&
310309
isset($this->eval_max) &&
311310
isset($this->visible)
312311
) {
312+
313+
$user = api_get_user_entity($this->get_user_id());
314+
315+
if (null === $user) {
316+
return false;
317+
}
318+
313319
if (empty($this->type)) {
314320
$this->type = 'evaluation';
315321
}
@@ -328,7 +334,7 @@ public function add()
328334
->setCourse(api_get_course_entity($courseId))
329335
->setTitle($this->get_name())
330336
->setCategory($category)
331-
->setUser(api_get_user_entity($this->get_user_id()))
337+
->setUser($user)
332338
->setWeight(api_float_val($this->get_weight()))
333339
->setMax(api_float_val($this->get_max()))
334340
->setVisible($this->is_visible())
@@ -337,6 +343,8 @@ public function add()
337343
$em->persist($evaluation);
338344
$em->flush();
339345
$this->set_id($evaluation->getId());
346+
347+
return true;
340348
}
341349

342350
return false;

0 commit comments

Comments
 (0)