芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/question/behaviour/adaptive/tests/mark_display_test.php
. /** * This file contains tests that just test the display mark/penalty information. * * @package qbehaviour_adaptive * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once(__DIR__ . '/../../../engine/lib.php'); require_once(__DIR__ . '/../behaviour.php'); /** * Unit tests for the adaptive behaviour the display of mark/penalty information. * * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qbehaviour_adaptive_mark_display_test extends basic_testcase { /** @var qbehaviour_adaptive_renderer the renderer to test. */ protected $renderer; /** @var question_display_options display options to use when rendering. */ protected $options; protected function setUp() { global $PAGE; parent::setUp(); $this->renderer = $PAGE->get_renderer('qbehaviour_adaptive'); $this->options = new question_display_options(); } public function test_blank_before_graded() { $this->assertEquals('', $this->renderer->render_adaptive_marks(new qbehaviour_adaptive_mark_details( question_state::$todo), $this->options)); } public function test_correct_no_penalty() { $this->assertEquals('
' . get_string('correct', 'question') . '
' . '
' . get_string('gradingdetails', 'qbehaviour_adaptive', array('cur' => '1.00', 'raw' => '1.00', 'max' => '1.00')) . '
', $this->renderer->render_adaptive_marks(new qbehaviour_adaptive_mark_details( question_state::$gradedright, 1, 1, 1, 0, 0, false), $this->options)); } public function test_partial_first_try() { $this->assertEquals('
' . get_string('partiallycorrect', 'question') . '
' . '
' . get_string('gradingdetails', 'qbehaviour_adaptive', array('cur' => '0.50', 'raw' => '0.50', 'max' => '1.00')) . ' ' . get_string('gradingdetailspenalty', 'qbehaviour_adaptive', '0.10') . '
', $this->renderer->render_adaptive_marks(new qbehaviour_adaptive_mark_details( question_state::$gradedpartial, 1, 0.5, 0.5, 0.1, 0.1, true), $this->options)); } public function test_partial_second_try() { $mark = array('cur' => '0.80', 'raw' => '0.90', 'max' => '1.00'); $this->assertEquals('
' . get_string('partiallycorrect', 'question') . '
' . '
' . get_string('gradingdetails', 'qbehaviour_adaptive', $mark) . ' ' . get_string('gradingdetailsadjustment', 'qbehaviour_adaptive', $mark) . ' ' . get_string('gradingdetailspenalty', 'qbehaviour_adaptive', '0.10') . ' ' . get_string('gradingdetailspenaltytotal', 'qbehaviour_adaptive', '0.20') . '
', $this->renderer->render_adaptive_marks(new qbehaviour_adaptive_mark_details( question_state::$gradedpartial, 1, 0.8, 0.9, 0.1, 0.2, true), $this->options)); } public function test_correct_third_try() { $mark = array('cur' => '0.80', 'raw' => '1.00', 'max' => '1.00'); $this->assertEquals('
' . get_string('partiallycorrect', 'question') . '
' . '
' . get_string('gradingdetails', 'qbehaviour_adaptive', $mark) . ' ' . get_string('gradingdetailsadjustment', 'qbehaviour_adaptive', $mark) . '
', $this->renderer->render_adaptive_marks(new qbehaviour_adaptive_mark_details( question_state::$gradedpartial, 1, 0.8, 1.0, 0.1, 0.3, false), $this->options)); } public function test_correct_third_try_if_we_dont_increase_penalties_for_wrong() { $mark = array('cur' => '0.80', 'raw' => '1.00', 'max' => '1.00'); $this->assertEquals('
' . get_string('partiallycorrect', 'question') . '
' . '
' . get_string('gradingdetails', 'qbehaviour_adaptive', $mark) . ' ' . get_string('gradingdetailsadjustment', 'qbehaviour_adaptive', $mark) . '
', $this->renderer->render_adaptive_marks(new qbehaviour_adaptive_mark_details( question_state::$gradedpartial, 1, 0.8, 1.0, 0, 0.2, false), $this->options)); } }