Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 553... Línea 553...
553
        $graders = \gradereport_history\helper::get_graders($c3->id);
553
        $graders = \gradereport_history\helper::get_graders($c3->id);
554
        $this->assertCount(1, $graders); // Including "all graders" .
554
        $this->assertCount(1, $graders); // Including "all graders" .
555
    }
555
    }
Línea 556... Línea 556...
556
 
556
 
-
 
557
    /**
-
 
558
     * Test grade history with grade updated by different sources
-
 
559
     *
-
 
560
     * @covers \gradereport_history\output\tablelog::get_sql_and_params
-
 
561
     *
-
 
562
     * @return void
-
 
563
     */
-
 
564
    public function test_grade_history_with_different_sources(): void {
-
 
565
        $this->resetAfterTest();
-
 
566
 
-
 
567
        // Create a course.
-
 
568
        $course = $this->getDataGenerator()->create_course();
-
 
569
 
-
 
570
        // Create a user and enrol them in the course.
-
 
571
        $user = $teacher = $this->getDataGenerator()->create_and_enrol($course, 'student');
-
 
572
 
-
 
573
        // Create an assignment.
-
 
574
        $assign = $this->getDataGenerator()->create_module('assign', ['course' => $course]);
-
 
575
 
-
 
576
        // Create a grade item.
-
 
577
        $gi = \grade_item::fetch(['iteminstance' => $assign->id, 'itemtype' => 'mod', 'itemmodule' => 'assign']);
-
 
578
 
-
 
579
        // Create some grade history entries with same time modifies.
-
 
580
        $time = time();
-
 
581
        $this->create_grade_history([
-
 
582
            'itemid' => $gi->id,
-
 
583
            'userid' => $user->id,
-
 
584
            'usermodified' => $teacher->id,
-
 
585
            'finalgrade' => 50,
-
 
586
            'source' => 'mod/assign',
-
 
587
            'timemodified' => $time,
-
 
588
        ]);
-
 
589
        $this->create_grade_history([
-
 
590
            'itemid' => $gi->id,
-
 
591
            'userid' => $user->id,
-
 
592
            'usermodified' => $teacher->id,
-
 
593
            'finalgrade' => 60,
-
 
594
            'source' => 'cli',
-
 
595
            'timemodified' => $time,
-
 
596
        ]);
-
 
597
 
-
 
598
        // Fetch the grade history.
-
 
599
        $results = $this->get_tablelog_results(\context_course::instance($course->id));
-
 
600
 
-
 
601
        // Check the grade history.
-
 
602
        $this->assertCount(2, $results);
-
 
603
        $assigngrade = array_pop($results);
-
 
604
        $cligrade = array_pop($results);
-
 
605
 
-
 
606
        // Check their values.
-
 
607
        $this->assertEquals(60, $cligrade->finalgrade);
-
 
608
        $this->assertEquals(50, $cligrade->prevgrade);
-
 
609
        $this->assertEquals('cli', $cligrade->source);
-
 
610
        $this->assertEquals(50, $assigngrade->finalgrade);
-
 
611
        $this->assertEquals(null, $assigngrade->prevgrade);
-
 
612
        $this->assertEquals('mod/assign', $assigngrade->source);
-
 
613
    }
-
 
614
 
557
    /**
615
    /**
558
     * Asserts that the array of grade objects contains exactly the right IDs.
616
     * Asserts that the array of grade objects contains exactly the right IDs.
559
     *
617
     *
560
     * @param array $expectedids Array of expected IDs.
618
     * @param array $expectedids Array of expected IDs.
561
     * @param array $objects Array of objects returned by the table.
619
     * @param array $objects Array of objects returned by the table.