Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 44... Línea 44...
44
 * @package   mod_bigbluebuttonbn
44
 * @package   mod_bigbluebuttonbn
45
 * @copyright 2018 - present, Blindside Networks Inc
45
 * @copyright 2018 - present, Blindside Networks Inc
46
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
46
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
47
 * @author    Laurent David (laurent@call-learning.fr)
47
 * @author    Laurent David (laurent@call-learning.fr)
48
 */
48
 */
49
class lib_test extends \advanced_testcase {
49
final class lib_test extends \advanced_testcase {
50
    use testcase_helper_trait;
50
    use testcase_helper_trait;
Línea 51... Línea 51...
51
 
51
 
52
    /**
52
    /**
53
     * Check support
53
     * Check support
Línea 56... Línea 56...
56
     */
56
     */
57
    public function test_bigbluebuttonbn_supports(): void {
57
    public function test_bigbluebuttonbn_supports(): void {
58
        $this->resetAfterTest();
58
        $this->resetAfterTest();
59
        $this->assertTrue(bigbluebuttonbn_supports(FEATURE_IDNUMBER));
59
        $this->assertTrue(bigbluebuttonbn_supports(FEATURE_IDNUMBER));
60
        $this->assertTrue(bigbluebuttonbn_supports(FEATURE_MOD_INTRO));
60
        $this->assertTrue(bigbluebuttonbn_supports(FEATURE_MOD_INTRO));
61
        $this->assertFalse(bigbluebuttonbn_supports(FEATURE_GRADE_HAS_GRADE));
61
        $this->assertTrue(bigbluebuttonbn_supports(FEATURE_GRADE_HAS_GRADE));
62
    }
62
    }
Línea 63... Línea 63...
63
 
63
 
64
    /**
64
    /**
65
     * Check add instance
65
     * Check add instance
Línea 546... Línea 546...
546
        bigbluebuttonbn_reset_userdata($data);
546
        bigbluebuttonbn_reset_userdata($data);
547
        $this->assertCount(2, $DB->get_records('bigbluebuttonbn_logs', ['bigbluebuttonbnid' => $bbactivity->id]));
547
        $this->assertCount(2, $DB->get_records('bigbluebuttonbn_logs', ['bigbluebuttonbnid' => $bbactivity->id]));
548
    }
548
    }
Línea 549... Línea 549...
549
 
549
 
-
 
550
    /**
-
 
551
     * Reset user data and make sure grades are reset.
-
 
552
     *
-
 
553
     * @covers ::bigbluebuttonbn_reset_userdata
-
 
554
     */
-
 
555
    public function test_bigbluebuttonbn_reset_userdata_with_grades(): void {
-
 
556
        global $DB;
-
 
557
        $this->resetAfterTest();
-
 
558
        $user = $this->getDataGenerator()->create_user();
-
 
559
        list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance($this->course,
-
 
560
            ['grade' => 100]);
-
 
561
        $this->getDataGenerator()->enrol_user($user->id, $this->course->id);
-
 
562
        $this->setUser($user);
-
 
563
 
-
 
564
        // Pass a user grade.
-
 
565
        $grade = [];
-
 
566
        $gradeitem = $DB->get_record('grade_items', [
-
 
567
            'courseid' => $this->course->id,
-
 
568
            'itemtype' => 'mod',
-
 
569
            'itemmodule' => 'bigbluebuttonbn',
-
 
570
            'iteminstance' => $bbactivity->id,
-
 
571
        ]);
-
 
572
        $grade[$user->id] = [
-
 
573
            'userid' => $user->id,
-
 
574
            'rawgrade' => 75,
-
 
575
        ];
-
 
576
        grade_update(
-
 
577
            source: 'mod/bigbluebuttonbn',
-
 
578
            courseid: $this->course->id,
-
 
579
            itemtype: 'mod',
-
 
580
            itemmodule: 'bigbluebuttonbn',
-
 
581
            iteminstance: $bbactivity->id,
-
 
582
            itemnumber: 0,
-
 
583
            grades: $grade
-
 
584
        );
-
 
585
        $params = [
-
 
586
            'userid' => $user->id,
-
 
587
            'itemid' => $gradeitem->id,
-
 
588
            'rawgrade' => 75,
-
 
589
        ];
-
 
590
        $gradegrades = $DB->get_records('grade_grades', $params);
-
 
591
        $this->assertCount(1, $gradegrades);
-
 
592
 
-
 
593
        // Reset user data.
-
 
594
        $data = new stdClass();
-
 
595
        $data->courseid = $this->course->id;
-
 
596
        $data->course = $bbactivity->course;
-
 
597
        $data->reset_gradebook_grades = 1;
-
 
598
        bigbluebuttonbn_reset_userdata($data);
-
 
599
 
-
 
600
        // Check grades have been reset.
-
 
601
        $gradegrades = $DB->get_records('grade_grades', $params);
-
 
602
        $this->assertCount(0, $gradegrades);
-
 
603
    }
-
 
604
 
550
    /**
605
    /**
551
     * Check course module
606
     * Check course module
552
     *
607
     *
553
     * @covers ::bigbluebuttonbn_get_coursemodule_info
608
     * @covers ::bigbluebuttonbn_get_coursemodule_info
554
     */
609
     */
Línea 566... Línea 621...
566
     */
621
     */
567
    public function test_bigbluebuttonbn_check_updates_since(): void {
622
    public function test_bigbluebuttonbn_check_updates_since(): void {
568
        $this->resetAfterTest();
623
        $this->resetAfterTest();
569
        list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
624
        list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
570
        $result = bigbluebuttonbn_check_updates_since($bbactivitycm, 0);
625
        $result = bigbluebuttonbn_check_updates_since($bbactivitycm, 0);
571
        $this->assertEquals(
626
        $expected = json_encode([
572
            '{"configuration":{"updated":false},"contentfiles":{"updated":false},"introfiles":' .
627
            'configuration' => [
573
            '{"updated":false},"completion":{"updated":false}}',
628
                'updated' => false,
-
 
629
            ],
574
            json_encode($result)
630
            'contentfiles' => [
-
 
631
                'updated' => false,
-
 
632
            ],
-
 
633
            'introfiles' => [
-
 
634
                'updated' => false,
-
 
635
            ],
-
 
636
            'completion' => [
-
 
637
                'updated' => false,
-
 
638
            ],
-
 
639
            'gradeitems' => [
-
 
640
                'updated' => false,
-
 
641
            ],
-
 
642
            'outcomes' => [
-
 
643
                'updated' => false,
-
 
644
            ],
575
        );
645
        ]);
-
 
646
        $this->assertEquals($expected, json_encode($result));
576
    }
647
    }
Línea 577... Línea 648...
577
 
648
 
578
    /**
649
    /**
579
     * Check event action (calendar)
650
     * Check event action (calendar)