Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 62... Línea 62...
62
        $this->workshop = null;
62
        $this->workshop = null;
63
        $this->strategy = null;
63
        $this->strategy = null;
64
        parent::tearDown();
64
        parent::tearDown();
65
    }
65
    }
Línea 66... Línea 66...
66
 
66
 
67
    public function test_calculate_peer_grade_null_grade() {
67
    public function test_calculate_peer_grade_null_grade(): void {
68
        // fixture set-up
68
        // fixture set-up
69
        $this->strategy->dimensions = array();
69
        $this->strategy->dimensions = array();
70
        $grades = array();
70
        $grades = array();
71
        // exercise SUT
71
        // exercise SUT
72
        $suggested = $this->strategy->calculate_peer_grade($grades);
72
        $suggested = $this->strategy->calculate_peer_grade($grades);
73
        // validate
73
        // validate
74
        $this->assertNull($suggested);
74
        $this->assertNull($suggested);
Línea 75... Línea 75...
75
    }
75
    }
76
 
76
 
77
    public function test_calculate_peer_grade_one_numerical() {
77
    public function test_calculate_peer_grade_one_numerical(): void {
78
        // fixture set-up
78
        // fixture set-up
79
        $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '1');
79
        $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '1');
80
        $grades[] = (object)array('dimensionid' => 1003, 'grade' => '5.00000');
80
        $grades[] = (object)array('dimensionid' => 1003, 'grade' => '5.00000');
81
        // exercise SUT
81
        // exercise SUT
82
        $suggested = $this->strategy->calculate_peer_grade($grades);
82
        $suggested = $this->strategy->calculate_peer_grade($grades);
83
        // validate
83
        // validate
Línea 84... Línea 84...
84
        $this->assertEquals(grade_floatval(5/20 * 100), $suggested);
84
        $this->assertEquals(grade_floatval(5/20 * 100), $suggested);
85
    }
85
    }
86
 
86
 
87
    public function test_calculate_peer_grade_negative_weight() {
87
    public function test_calculate_peer_grade_negative_weight(): void {
88
        // fixture set-up
88
        // fixture set-up
89
        $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '-1');
89
        $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '-1');
90
        $grades[] = (object)array('dimensionid' => 1003, 'grade' => '20');
90
        $grades[] = (object)array('dimensionid' => 1003, 'grade' => '20');
91
        // exercise SUT
91
        // exercise SUT
Línea 92... Línea 92...
92
        $this->expectException(\coding_exception::class);
92
        $this->expectException(\coding_exception::class);
93
        $suggested = $this->strategy->calculate_peer_grade($grades);
93
        $suggested = $this->strategy->calculate_peer_grade($grades);
94
    }
94
    }
95
 
95
 
96
    public function test_calculate_peer_grade_one_numerical_weighted() {
96
    public function test_calculate_peer_grade_one_numerical_weighted(): void {
97
        // fixture set-up
97
        // fixture set-up
98
        $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '3');
98
        $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '3');
99
        $grades[] = (object)array('dimensionid' => '1003', 'grade' => '5');
99
        $grades[] = (object)array('dimensionid' => '1003', 'grade' => '5');
100
        // exercise SUT
100
        // exercise SUT
Línea 101... Línea 101...
101
        $suggested = $this->strategy->calculate_peer_grade($grades);
101
        $suggested = $this->strategy->calculate_peer_grade($grades);
102
        // validate
102
        // validate
103
        $this->assertEquals(grade_floatval(5/20 * 100), $suggested);
103
        $this->assertEquals(grade_floatval(5/20 * 100), $suggested);
104
    }
104
    }
105
 
105
 
106
    public function test_calculate_peer_grade_three_numericals_same_weight() {
106
    public function test_calculate_peer_grade_three_numericals_same_weight(): void {
Línea 117... Línea 117...
117
 
117
 
118
        // validate
118
        // validate
119
        $this->assertEquals(grade_floatval((11/20 + 87/100 + 10/10)/3 * 100), $suggested);
119
        $this->assertEquals(grade_floatval((11/20 + 87/100 + 10/10)/3 * 100), $suggested);
Línea 120... Línea 120...
120
    }
120
    }
121
 
121
 
122
    public function test_calculate_peer_grade_three_numericals_different_weights() {
122
    public function test_calculate_peer_grade_three_numericals_different_weights(): void {
123
        // fixture set-up
123
        // fixture set-up
124
        $this->strategy->dimensions[1003] = (object)array('grade' => '15', 'weight' => 3);
124
        $this->strategy->dimensions[1003] = (object)array('grade' => '15', 'weight' => 3);
125
        $this->strategy->dimensions[1004] = (object)array('grade' => '80', 'weight' => 1);
125
        $this->strategy->dimensions[1004] = (object)array('grade' => '80', 'weight' => 1);
Línea 133... Línea 133...
133
 
133
 
134
        // validate
134
        // validate
135
        $this->assertEquals(grade_floatval((7/15*3 + 66/80*1 + 4/5*2)/6 * 100), $suggested);
135
        $this->assertEquals(grade_floatval((7/15*3 + 66/80*1 + 4/5*2)/6 * 100), $suggested);
Línea 136... Línea 136...
136
    }
136
    }
137
 
137
 
Línea 138... Línea 138...
138
    public function test_calculate_peer_grade_one_scale_max() {
138
    public function test_calculate_peer_grade_one_scale_max(): void {
139
        $this->resetAfterTest(true);
139
        $this->resetAfterTest(true);
140
 
140
 
Línea 148... Línea 148...
148
 
148
 
149
        // validate
149
        // validate
150
        $this->assertEquals(100.00000, $suggested);
150
        $this->assertEquals(100.00000, $suggested);
Línea 151... Línea 151...
151
    }
151
    }
152
 
152
 
Línea 153... Línea 153...
153
    public function test_calculate_peer_grade_one_scale_min_with_scale_caching() {
153
    public function test_calculate_peer_grade_one_scale_min_with_scale_caching(): void {
154
        $this->resetAfterTest(true);
154
        $this->resetAfterTest(true);
155
 
155
 
Línea 163... Línea 163...
163
 
163
 
164
        // validate
164
        // validate
165
        $this->assertEquals(0.00000, $suggested);
165
        $this->assertEquals(0.00000, $suggested);
Línea 166... Línea 166...
166
    }
166
    }
167
 
167
 
168
    public function test_calculate_peer_grade_two_scales_weighted() {
168
    public function test_calculate_peer_grade_two_scales_weighted(): void {
169
        $this->resetAfterTest(true);
169
        $this->resetAfterTest(true);
170
        // fixture set-up
170
        // fixture set-up
171
        $scale13 = $this->getDataGenerator()->create_scale(array('scale'=>'Poor,Good,Excellent', 'id'=>13));
171
        $scale13 = $this->getDataGenerator()->create_scale(array('scale'=>'Poor,Good,Excellent', 'id'=>13));
Línea 180... Línea 180...
180
 
180
 
181
        // validate
181
        // validate
182
        $this->assertEquals(grade_floatval((1/2*2 + 4/6*3)/5 * 100), $suggested);
182
        $this->assertEquals(grade_floatval((1/2*2 + 4/6*3)/5 * 100), $suggested);
Línea 183... Línea 183...
183
    }
183
    }
184
 
184
 
185
    public function test_calculate_peer_grade_scale_exception() {
185
    public function test_calculate_peer_grade_scale_exception(): void {
186
        $this->resetAfterTest(true);
186
        $this->resetAfterTest(true);
187
        // fixture set-up
187
        // fixture set-up
188
        $scale13 = $this->getDataGenerator()->create_scale(array('scale'=>'Poor,Good,Excellent', 'id'=>13));
188
        $scale13 = $this->getDataGenerator()->create_scale(array('scale'=>'Poor,Good,Excellent', 'id'=>13));