/** * @param int $num The number, starting at 0. * @param string $style The style to render the number in. One of the * options returned by {@link qtype_multichoice:;get_numbering_styles()}. * @return string the number $num in the requested style. */ protected function number_in_style($num, $style) { switch($style) { case 'abc': $number = chr(ord('a') + $num); break; case 'ABCD': $number = chr(ord('A') + $num); break; case '123': $number = $num + 1; break; case 'iii': $number = question_utils::int_to_roman($num + 1); break; case 'IIII': $number = strtoupper(question_utils::int_to_roman($num + 1)); break; case 'none': return ''; default: return 'ERR'; } return $this->number_html($number); }
/** * @param int $num The number, starting at 0. * @param string $style The style to render the number in. One of the * options returned by {@link qtype_multichoice:;get_numbering_styles()}. * @return string the number $num in the requested style. */ public static function number_answer($num, $style) { switch ($style) { case 'abc': $number = chr(ord('a') + $num); break; case 'ABCD': $number = chr(ord('A') + $num); break; case '123': $number = $num + 1; break; case 'iii': $number = question_utils::int_to_roman($num + 1); break; case 'IIII': $number = strtoupper(question_utils::int_to_roman($num + 1)); break; case 'none': return ''; default: return 'ERR'; } return "({$number})"; }
/** * @expectedException moodle_exception */ public function test_int_to_roman_not_int() { question_utils::int_to_roman(1.5); }
public function test_int_to_roman_not_int() { $this->setExpectedException('moodle_exception'); question_utils::int_to_roman(1.5); }
public function test_int_to_roman_not_int() { $this->expectException(); question_utils::int_to_roman(1.5); }