| Línea 247... | Línea 247... | 
          
            | 247 |         $this->assertEquals($gradeitems[0]->id, $structure->get_slot_by_number(1)->quizgradeitemid);
 | 247 |         $this->assertEquals($gradeitems[0]->id, $structure->get_slot_by_number(1)->quizgradeitemid);
 | 
          
            | 248 |         $this->assertEquals($gradeitems[0]->id, $structure->get_slot_by_number(2)->quizgradeitemid);
 | 248 |         $this->assertEquals($gradeitems[0]->id, $structure->get_slot_by_number(2)->quizgradeitemid);
 | 
          
            | 249 |         $this->assertEquals($gradeitems[1]->id, $structure->get_slot_by_number(3)->quizgradeitemid);
 | 249 |         $this->assertEquals($gradeitems[1]->id, $structure->get_slot_by_number(3)->quizgradeitemid);
 | 
          
            | 250 |     }
 | 250 |     }
 | 
          
            | Línea -... | Línea 251... | 
          
            | - |   | 251 |  
 | 
          
            | - |   | 252 |     public function test_create_grade_item_per_section_with_descriptions(): void {
 | 
          
            | - |   | 253 |         global $SITE;
 | 
          
            | - |   | 254 |         $this->resetAfterTest();
 | 
          
            | - |   | 255 |         $this->setAdminUser();
 | 
          
            | - |   | 256 |  
 | 
          
            | - |   | 257 |         // Create a quiz with no grade items yet, but two sections.
 | 
          
            | - |   | 258 |         /** @var \mod_quiz_generator $quizgenerator */
 | 
          
            | - |   | 259 |         $quizgenerator = $this->getDataGenerator()->get_plugin_generator('mod_quiz');
 | 
          
            | - |   | 260 |         $quiz = $quizgenerator->create_instance(['course' => $SITE->id]);
 | 
          
            | - |   | 261 |  
 | 
          
            | - |   | 262 |         // Create three questions.
 | 
          
            | - |   | 263 |         /** @var core_question_generator $questiongenerator */
 | 
          
            | - |   | 264 |         $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
 | 
          
            | - |   | 265 |         $cat = $questiongenerator->create_question_category();
 | 
          
            | - |   | 266 |         $desc1 = $questiongenerator->create_question('description', null, ['category' => $cat->id]);
 | 
          
            | - |   | 267 |         $desc2 = $questiongenerator->create_question('description', null, ['category' => $cat->id]);
 | 
          
            | - |   | 268 |         $saq1 = $questiongenerator->create_question('shortanswer', null, ['category' => $cat->id]);
 | 
          
            | - |   | 269 |  
 | 
          
            | - |   | 270 |         // Add them to the quiz.
 | 
          
            | - |   | 271 |         quiz_add_quiz_question($desc1->id, $quiz, 1);
 | 
          
            | - |   | 272 |         quiz_add_quiz_question($desc2->id, $quiz, 2);
 | 
          
            | - |   | 273 |         quiz_add_quiz_question($saq1->id, $quiz, 2, 7);
 | 
          
            | - |   | 274 |  
 | 
          
            | - |   | 275 |         // Create two sections.
 | 
          
            | - |   | 276 |         $quizobj = quiz_settings::create($quiz->id);
 | 
          
            | - |   | 277 |         $structure = $quizobj->get_structure();
 | 
          
            | - |   | 278 |         $defaultsection = array_values($structure->get_sections())[0];
 | 
          
            | - |   | 279 |         $structure->set_section_heading($defaultsection->id, 'Introduction');
 | 
          
            | - |   | 280 |         $structure->add_section_heading(2, 'The question');
 | 
          
            | - |   | 281 |  
 | 
          
            | - |   | 282 |         // Call the method we are testing.
 | 
          
            | - |   | 283 |         create_grade_item_per_section::execute($quizobj->get_quizid());
 | 
          
            | - |   | 284 |  
 | 
          
            | - |   | 285 |         // Verify.
 | 
          
            | - |   | 286 |         $structure = $quizobj->get_structure();
 | 
          
            | - |   | 287 |  
 | 
          
            | - |   | 288 |         $gradeitems = array_values($structure->get_grade_items());
 | 
          
            | - |   | 289 |         $this->assertCount(1, $gradeitems);
 | 
          
            | - |   | 290 |         $this->assertEquals('The question', $gradeitems[0]->name);
 | 
          
            | - |   | 291 |         $this->assertEquals(1, $gradeitems[0]->sortorder);
 | 
          
            | - |   | 292 |  
 | 
          
            | - |   | 293 |         $this->assertNull($structure->get_slot_by_number(1)->quizgradeitemid);
 | 
          
            | - |   | 294 |         $this->assertNull($structure->get_slot_by_number(2)->quizgradeitemid);
 | 
          
            | - |   | 295 |         $this->assertEquals($gradeitems[0]->id, $structure->get_slot_by_number(3)->quizgradeitemid);
 | 
          
            | - |   | 296 |     }
 | 
          
            | 251 |  
 | 297 |  
 | 
          
            | 252 |     public function test_create_grade_item_per_section_service_checks_permissions(): void {
 | 298 |     public function test_create_grade_item_per_section_service_checks_permissions(): void {
 | 
          
            | 253 |         global $SITE;
 | 299 |         global $SITE;
 | 
          
            | Línea 254... | Línea 300... | 
          
            | 254 |         $this->resetAfterTest();
 | 300 |         $this->resetAfterTest();
 |