File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
public/main/gradebook/lib/be Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments