MDL-30453 New renderable classes for assessments of example submissions

The patch introduces two new classes for rendering assessments of
example submission - both the training one and the reference one.
Together with the cooking functions for obtaining instances of these
classes.
This commit is contained in:
David Mudrak
2011-11-25 18:41:07 +01:00
parent 1de9151c6f
commit e30f6ff338
2 changed files with 169 additions and 0 deletions
+50
View File
@@ -374,4 +374,54 @@ class workshop_internal_api_test extends UnitTestCase {
// verify
$this->assertEqual($lcm, 15);
}
public function test_prepare_example_assessment() {
// fixture setup
$fakerawrecord = (object)array(
'id' => 42,
'submissionid' => 56,
'weight' => 0,
'timecreated' => time() - 10,
'timemodified' => time() - 5,
'grade' => null,
'gradinggrade' => null,
'gradinggradeover' => null,
);
// excersise SUT
$a = $this->workshop->prepare_example_assessment($fakerawrecord);
// verify
$this->assertTrue($a instanceof workshop_example_assessment);
$this->assertTrue($a->url instanceof moodle_url);
// modify setup
$fakerawrecord->weight = 1;
$this->expectException('coding_exception');
// excersise SUT
$a = $this->workshop->prepare_example_assessment($fakerawrecord);
}
public function test_prepare_example_reference_assessment() {
global $USER;
// fixture setup
$fakerawrecord = (object)array(
'id' => 38,
'submissionid' => 56,
'weight' => 1,
'timecreated' => time() - 100,
'timemodified' => time() - 50,
'grade' => 0.75000,
'gradinggrade' => 1.00000,
'gradinggradeover' => null,
);
// excersise SUT
$a = $this->workshop->prepare_example_reference_assessment($fakerawrecord);
// verify
$this->assertTrue($a instanceof workshop_example_reference_assessment);
// modify setup
$fakerawrecord->weight = 0;
$this->expectException('coding_exception');
// excersise SUT
$a = $this->workshop->prepare_example_reference_assessment($fakerawrecord);
}
}