@@ -311,6 +311,7 @@ public function test_quiz_get_user_timeclose() {
311311 // Create generator, course and quizzes.
312312 $ student1 = $ this ->getDataGenerator ()->create_user ();
313313 $ student2 = $ this ->getDataGenerator ()->create_user ();
314+ $ student3 = $ this ->getDataGenerator ()->create_user ();
314315 $ teacher = $ this ->getDataGenerator ()->create_user ();
315316 $ course = $ this ->getDataGenerator ()->create_course ();
316317 $ quizgenerator = $ this ->getDataGenerator ()->get_plugin_generator ('mod_quiz ' );
@@ -323,13 +324,15 @@ public function test_quiz_get_user_timeclose() {
323324
324325 $ student1id = $ student1 ->id ;
325326 $ student2id = $ student2 ->id ;
327+ $ student3id = $ student3 ->id ;
326328 $ teacherid = $ teacher ->id ;
327329
328330 // Users enrolments.
329331 $ studentrole = $ DB ->get_record ('role ' , array ('shortname ' => 'student ' ));
330332 $ teacherrole = $ DB ->get_record ('role ' , array ('shortname ' => 'editingteacher ' ));
331333 $ this ->getDataGenerator ()->enrol_user ($ student1id , $ course ->id , $ studentrole ->id , 'manual ' );
332334 $ this ->getDataGenerator ()->enrol_user ($ student2id , $ course ->id , $ studentrole ->id , 'manual ' );
335+ $ this ->getDataGenerator ()->enrol_user ($ student3id , $ course ->id , $ studentrole ->id , 'manual ' );
333336 $ this ->getDataGenerator ()->enrol_user ($ teacherid , $ course ->id , $ teacherrole ->id , 'manual ' );
334337
335338 // Create groups.
@@ -357,14 +360,31 @@ public function test_quiz_get_user_timeclose() {
357360 $ object = new stdClass ();
358361 $ object ->id = $ quiz1 ->id ;
359362 $ object ->usertimeclose = $ basetimestamp + 10800 ; // The overriden timeclose for quiz 1.
360- $ object ->usertimelimit = 0 ;
361363
362364 $ comparearray [$ quiz1 ->id ] = $ object ;
363365
364366 $ object = new stdClass ();
365367 $ object ->id = $ quiz2 ->id ;
366368 $ object ->usertimeclose = $ basetimestamp + 7200 ; // The unchanged timeclose for quiz 2.
367- $ object ->usertimelimit = 0 ;
369+
370+ $ comparearray [$ quiz2 ->id ] = $ object ;
371+
372+ $ this ->assertEquals ($ comparearray , quiz_get_user_timeclose ($ course ->id ));
373+
374+ // Let's test quiz 1 closes in two hours (the original value) for user student 3 since member of no group.
375+ $ this ->setUser ($ student3id );
376+ $ params = new stdClass ();
377+
378+ $ comparearray = array ();
379+ $ object = new stdClass ();
380+ $ object ->id = $ quiz1 ->id ;
381+ $ object ->usertimeclose = $ basetimestamp + 7200 ; // The original timeclose for quiz 1.
382+
383+ $ comparearray [$ quiz1 ->id ] = $ object ;
384+
385+ $ object = new stdClass ();
386+ $ object ->id = $ quiz2 ->id ;
387+ $ object ->usertimeclose = $ basetimestamp + 7200 ; // The original timeclose for quiz 2.
368388
369389 $ comparearray [$ quiz2 ->id ] = $ object ;
370390
@@ -386,14 +406,12 @@ public function test_quiz_get_user_timeclose() {
386406 $ object = new stdClass ();
387407 $ object ->id = $ quiz1 ->id ;
388408 $ object ->usertimeclose = $ basetimestamp + 14400 ; // The overriden timeclose for quiz 1.
389- $ object ->usertimelimit = 0 ;
390409
391410 $ comparearray [$ quiz1 ->id ] = $ object ;
392411
393412 $ object = new stdClass ();
394413 $ object ->id = $ quiz2 ->id ;
395414 $ object ->usertimeclose = $ basetimestamp + 7200 ; // The unchanged timeclose for quiz 2.
396- $ object ->usertimelimit = 0 ;
397415
398416 $ comparearray [$ quiz2 ->id ] = $ object ;
399417
@@ -407,14 +425,12 @@ public function test_quiz_get_user_timeclose() {
407425 $ object = new stdClass ();
408426 $ object ->id = $ quiz1 ->id ;
409427 $ object ->usertimeclose = $ basetimestamp + 7200 ; // The unchanged timeclose for quiz 1.
410- $ object ->usertimelimit = 0 ;
411428
412429 $ comparearray [$ quiz1 ->id ] = $ object ;
413430
414431 $ object = new stdClass ();
415432 $ object ->id = $ quiz2 ->id ;
416433 $ object ->usertimeclose = $ basetimestamp + 7200 ; // The unchanged timeclose for quiz 2.
417- $ object ->usertimelimit = 0 ;
418434
419435 $ comparearray [$ quiz2 ->id ] = $ object ;
420436
0 commit comments