MDL-20636 Reveiw all throw statements.

This commit is contained in:
Tim Hunt 2011-02-23 16:50:09 +00:00
parent f7970e3ca7
commit 88f0eb1546
15 changed files with 56 additions and 80 deletions

View file

@ -265,6 +265,7 @@ $string['correct'] = 'Correct';
$string['correctfeedback'] = 'For any correct response'; $string['correctfeedback'] = 'For any correct response';
$string['decimalplacesingrades'] = 'Decimal places in grades'; $string['decimalplacesingrades'] = 'Decimal places in grades';
$string['defaultmark'] = 'Default mark'; $string['defaultmark'] = 'Default mark';
$string['errorsavingflags'] = 'Error saving the flag state.';
$string['feedback'] = 'Feedback'; $string['feedback'] = 'Feedback';
$string['fillincorrect'] = 'Fill in correct responses'; $string['fillincorrect'] = 'Fill in correct responses';
$string['flagged'] = 'Flagged'; $string['flagged'] = 'Flagged';

View file

@ -104,15 +104,9 @@ class quiz {
static public function create($quizid, $userid) { static public function create($quizid, $userid) {
global $DB; global $DB;
if (!$quiz = $DB->get_record('quiz', array('id' => $quizid))) { $quiz = $DB->get_record('quiz', array('id' => $quizid), '*', MUST_EXIST);
throw new moodle_exception('invalidquizid', 'quiz'); $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
} $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST);
if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
throw new moodle_exception('invalidcoursemodule');
}
if (!$cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id)) {
throw new moodle_exception('invalidcoursemodule');
}
// Update quiz with override information // Update quiz with override information
$quiz = quiz_update_effective_access($quiz, $userid); $quiz = quiz_update_effective_access($quiz, $userid);
@ -385,18 +379,10 @@ class quiz_attempt {
// quiz_upgrade_states($attempt); // quiz_upgrade_states($attempt);
// } // }
if (!$attempt = $DB->get_record('quiz_attempts', $conditions)) { $attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST);
throw new moodle_exception('invalidattemptid', 'quiz'); $quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
} $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
if (!$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz))) { $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST);
throw new moodle_exception('invalidquizid', 'quiz');
}
if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
throw new moodle_exception('invalidcoursemodule');
}
if (!$cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id)) {
throw new moodle_exception('invalidcoursemodule');
}
// Update quiz with override information // Update quiz with override information
$quiz = quiz_update_effective_access($quiz, $attempt->userid); $quiz = quiz_update_effective_access($quiz, $attempt->userid);
@ -1002,9 +988,8 @@ class quiz_attempt {
if ($this->attempt->timefinish) { if ($this->attempt->timefinish) {
$this->attempt->sumgrades = $this->quba->get_total_mark(); $this->attempt->sumgrades = $this->quba->get_total_mark();
} }
if (!$DB->update_record('quiz_attempts', $this->attempt)) { $DB->update_record('quiz_attempts', $this->attempt);
throw new moodle_quiz_exception($this->get_quizobj(), 'saveattemptfailed');
}
if (!$this->is_preview() && $this->attempt->timefinish) { if (!$this->is_preview() && $this->attempt->timefinish) {
quiz_save_best_grade($this->get_quiz(), $this->get_userid()); quiz_save_best_grade($this->get_quiz(), $this->get_userid());
} }
@ -1029,9 +1014,7 @@ class quiz_attempt {
$this->attempt->timemodified = $timestamp; $this->attempt->timemodified = $timestamp;
$this->attempt->timefinish = $timestamp; $this->attempt->timefinish = $timestamp;
$this->attempt->sumgrades = $this->quba->get_total_mark(); $this->attempt->sumgrades = $this->quba->get_total_mark();
if (!$DB->update_record('quiz_attempts', $this->attempt)) { $DB->update_record('quiz_attempts', $this->attempt);
throw new moodle_quiz_exception($this->get_quizobj(), 'saveattemptfailed');
}
if (!$this->is_preview()) { if (!$this->is_preview()) {
quiz_save_best_grade($this->get_quiz()); quiz_save_best_grade($this->get_quiz());

View file

@ -51,9 +51,7 @@ $PAGE->set_url($quizobj->view_url());
// Check login and sesskey. // Check login and sesskey.
require_login($quizobj->get_courseid(), false, $quizobj->get_cm()); require_login($quizobj->get_courseid(), false, $quizobj->get_cm());
if (!confirm_sesskey()) { require_sesskey();
throw new moodle_exception('confirmsesskeybad', 'error', $quizobj->view_url());
}
$PAGE->set_pagelayout('base'); $PAGE->set_pagelayout('base');
// if no questions have been set up yet redirect to edit.php // if no questions have been set up yet redirect to edit.php
@ -188,9 +186,7 @@ if (!($quiz->attemptonlast && $lastattempt)) {
$transaction = $DB->start_delegated_transaction(); $transaction = $DB->start_delegated_transaction();
question_engine::save_questions_usage_by_activity($quba); question_engine::save_questions_usage_by_activity($quba);
$attempt->uniqueid = $quba->get_id(); $attempt->uniqueid = $quba->get_id();
if (!$attempt->id = $DB->insert_record('quiz_attempts', $attempt)) { $attempt->id = $DB->insert_record('quiz_attempts', $attempt);
throw new moodle_quiz_exception($quizobj, 'newattemptfail');
}
// Log the new attempt. // Log the new attempt.
if ($attempt->preview) { if ($attempt->preview) {

View file

@ -73,7 +73,7 @@ abstract class question_behaviour {
$this->question = $qa->get_question(); $this->question = $qa->get_question();
$requiredclass = $this->required_question_definition_type(); $requiredclass = $this->required_question_definition_type();
if (!$this->question instanceof $requiredclass) { if (!$this->question instanceof $requiredclass) {
throw new Exception('This behaviour (' . $this->get_name() . throw new coding_exception('This behaviour (' . $this->get_name() .
') cannot work with this question (' . get_class($this->question) . ')'); ') cannot work with this question (' . get_class($this->question) . ')');
} }
} }
@ -543,7 +543,7 @@ abstract class question_behaviour_with_save extends question_behaviour {
if ($this->qa->get_state()->is_finished()) { if ($this->qa->get_state()->is_finished()) {
return question_attempt::DISCARD; return question_attempt::DISCARD;
} else if (!$this->qa->get_state()->is_active()) { } else if (!$this->qa->get_state()->is_active()) {
throw new Exception('Question is not active, cannot process_actions.'); throw new coding_exception('Question is not active, cannot process_actions.');
} }
if ($this->is_same_response($pendingstep)) { if ($this->is_same_response($pendingstep)) {

View file

@ -100,7 +100,7 @@ class qbehaviour_informationitem extends question_behaviour {
public function process_comment(question_attempt_pending_step $pendingstep) { public function process_comment(question_attempt_pending_step $pendingstep) {
if ($pendingstep->has_behaviour_var('mark')) { if ($pendingstep->has_behaviour_var('mark')) {
throw new Exception('Information items cannot be graded.'); throw new coding_exception('Information items cannot be graded.');
} }
return parent::process_comment($pendingstep); return parent::process_comment($pendingstep);
} }

View file

@ -55,14 +55,14 @@ class qbehaviour_missing extends question_behaviour {
} }
public function init_first_step(question_attempt_step $step) { public function init_first_step(question_attempt_step $step) {
throw new Exception('The behaviour used for this question is not available. No processing is possible.'); throw new coding_exception('The behaviour used for this question is not available. No processing is possible.');
} }
public function process_action(question_attempt_pending_step $pendingstep) { public function process_action(question_attempt_pending_step $pendingstep) {
throw new Exception('The behaviour used for this question is not available. No processing is possible.'); throw new coding_exception('The behaviour used for this question is not available. No processing is possible.');
} }
public function get_min_fraction() { public function get_min_fraction() {
throw new Exception('The behaviour used for this question is not available. No processing is possible.'); throw new coding_exception('The behaviour used for this question is not available. No processing is possible.');
} }
} }

View file

@ -48,7 +48,7 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base {
global $DB; global $DB;
$engineid = $DB->get_field('question_opaque_engines', 'MIN(id)', array()); $engineid = $DB->get_field('question_opaque_engines', 'MIN(id)', array());
if (empty($engineid)) { if (empty($engineid)) {
throw new Exception('Cannot test Opaque. No question engines configured.'); throw new coding_exception('Cannot test Opaque. No question engines configured.');
} }
question_bank::load_question_definition_classes('opaque'); question_bank::load_question_definition_classes('opaque');

View file

@ -70,7 +70,7 @@ abstract class question_bank {
$file = get_plugin_directory('qtype', $qtypename) . '/questiontype.php'; $file = get_plugin_directory('qtype', $qtypename) . '/questiontype.php';
if (!is_readable($file)) { if (!is_readable($file)) {
if ($mustexist || $qtypename == 'missingtype') { if ($mustexist || $qtypename == 'missingtype') {
throw new Exception('Unknown question type ' . $qtypename); throw new coding_exception('Unknown question type ' . $qtypename);
} else { } else {
return self::get_qtype('missingtype'); return self::get_qtype('missingtype');
} }
@ -186,7 +186,7 @@ abstract class question_bank {
} }
$file = $CFG->dirroot . '/question/type/' . $qtypename . '/question.php'; $file = $CFG->dirroot . '/question/type/' . $qtypename . '/question.php';
if (!is_readable($file)) { if (!is_readable($file)) {
throw new Exception('Unknown question type (no definition) ' . $qtypename); throw new coding_exception('Unknown question type (no definition) ' . $qtypename);
} }
include_once($file); include_once($file);
self::$loadedqdefs[$qtypename] = 1; self::$loadedqdefs[$qtypename] = 1;
@ -256,7 +256,7 @@ abstract class question_bank {
private static function return_test_question_data($questionid) { private static function return_test_question_data($questionid) {
if (!isset(self::$testdata[$questionid])) { if (!isset(self::$testdata[$questionid])) {
throw new Exception('question_bank::return_test_data(' . $questionid . throw new coding_exception('question_bank::return_test_data(' . $questionid .
') called, but no matching question has been loaded by load_test_data.'); ') called, but no matching question has been loaded by load_test_data.');
} }
return self::$testdata[$questionid]; return self::$testdata[$questionid];
@ -269,7 +269,7 @@ abstract class question_bank {
*/ */
public static function load_test_question_data(question_definition $question) { public static function load_test_question_data(question_definition $question) {
if (!self::$testmode) { if (!self::$testmode) {
throw new Exception('question_bank::load_test_data called when not in test mode.'); throw new coding_exception('question_bank::load_test_data called when not in test mode.');
} }
self::$testdata[$question->id] = $question; self::$testdata[$question->id] = $question;
} }

View file

@ -150,7 +150,7 @@ WHERE
", array('stepid' => $stepid)); ", array('stepid' => $stepid));
if (!$records) { if (!$records) {
throw new Exception('Failed to load question_attempt_step ' . $stepid); throw new coding_exception('Failed to load question_attempt_step ' . $stepid);
} }
return question_attempt_step::load_from_records($records, $stepid); return question_attempt_step::load_from_records($records, $stepid);
@ -202,7 +202,7 @@ ORDER BY
", array('questionattemptid' => $questionattemptid)); ", array('questionattemptid' => $questionattemptid));
if (!$records) { if (!$records) {
throw new Exception('Failed to load question_attempt ' . $questionattemptid); throw new coding_exception('Failed to load question_attempt ' . $questionattemptid);
} }
$record = current($records); $record = current($records);
@ -259,7 +259,7 @@ ORDER BY
", array('qubaid' => $qubaid)); ", array('qubaid' => $qubaid));
if (!$records) { if (!$records) {
throw new Exception('Failed to load questions_usage_by_activity ' . $qubaid); throw new coding_exception('Failed to load questions_usage_by_activity ' . $qubaid);
} }
return question_usage_by_activity::load_from_records($records, $qubaid); return question_usage_by_activity::load_from_records($records, $qubaid);
@ -599,9 +599,7 @@ ORDER BY
$record->component = addslashes($quba->get_owning_component()); $record->component = addslashes($quba->get_owning_component());
$record->preferredbehaviour = addslashes($quba->get_preferred_behaviour()); $record->preferredbehaviour = addslashes($quba->get_preferred_behaviour());
if (!$this->db->update_record('question_usages', $record)) { $this->db->update_record('question_usages', $record);
throw new Exception('Failed to update question_usage_by_activity ' . $record->id);
}
} }
/** /**
@ -620,9 +618,7 @@ ORDER BY
$record->responsesummary = addslashes($qa->get_response_summary()); $record->responsesummary = addslashes($qa->get_response_summary());
$record->timemodified = time(); $record->timemodified = time();
if (!$this->db->update_record('question_attempts', $record)) { $this->db->update_record('question_attempts', $record);
throw new Exception('Failed to update question_attempt ' . $record->id);
}
} }
/** /**
@ -696,7 +692,7 @@ ORDER BY
public function update_question_attempt_flag($qubaid, $questionid, $qaid, $slot, $newstate) { public function update_question_attempt_flag($qubaid, $questionid, $qaid, $slot, $newstate) {
if (!$this->db->record_exists('question_attempts', array('id' => $qaid, if (!$this->db->record_exists('question_attempts', array('id' => $qaid,
'questionusageid' => $qubaid, 'questionid' => $questionid, 'slot' => $slot))) { 'questionusageid' => $qubaid, 'questionid' => $questionid, 'slot' => $slot))) {
throw new Exception('invalid ids'); throw new moodle_exception('errorsavingflags', 'question');
} }
$this->db->set_field('question_attempts', 'flagged', $newstate, array('id' => $qaid)); $this->db->set_field('question_attempts', 'flagged', $newstate, array('id' => $qaid));
@ -1002,7 +998,7 @@ class qubaid_list extends qubaid_condition {
global $DB; global $DB;
if (is_null($this->columntotest)) { if (is_null($this->columntotest)) {
throw new coding_exception('Must call another method that before where().'); throw new coding_exception('Must call from_question_attempts before where().');
} }
if (empty($this->qubaids)) { if (empty($this->qubaids)) {
$this->params = array(); $this->params = array();

View file

@ -144,7 +144,7 @@ abstract class question_engine {
question_engine::load_behaviour_class($preferredbehaviour); question_engine::load_behaviour_class($preferredbehaviour);
$class = 'qbehaviour_' . $preferredbehaviour; $class = 'qbehaviour_' . $preferredbehaviour;
if (!constant($class . '::IS_ARCHETYPAL')) { if (!constant($class . '::IS_ARCHETYPAL')) {
throw new Exception('The requested behaviour is not actually an archetypal one.'); throw new coding_exception('The requested behaviour is not actually an archetypal one.');
} }
return new $class($qa, $preferredbehaviour); return new $class($qa, $preferredbehaviour);
} }
@ -200,7 +200,7 @@ abstract class question_engine {
} }
$file = $CFG->dirroot . '/question/behaviour/' . $behaviour . '/behaviour.php'; $file = $CFG->dirroot . '/question/behaviour/' . $behaviour . '/behaviour.php';
if (!is_readable($file)) { if (!is_readable($file)) {
throw new Exception('Unknown question behaviour ' . $behaviour); throw new coding_exception('Unknown question behaviour ' . $behaviour);
} }
include_once($file); include_once($file);
self::$loadedbehaviours[$behaviour] = 1; self::$loadedbehaviours[$behaviour] = 1;
@ -545,7 +545,7 @@ abstract class question_flags {
// probably makes it sufficiently difficult for malicious users to toggle // probably makes it sufficiently difficult for malicious users to toggle
// other users flags. // other users flags.
if ($checksum != question_flags::get_toggle_checksum($qubaid, $questionid, $qaid, $slot)) { if ($checksum != question_flags::get_toggle_checksum($qubaid, $questionid, $qaid, $slot)) {
throw new Exception('checksum failure'); throw new moodle_exception('errorsavingflags', 'question');
} }
$dm = new question_engine_data_mapper(); $dm = new question_engine_data_mapper();
@ -785,7 +785,7 @@ class question_usage_by_activity {
*/ */
protected function check_slot($slot) { protected function check_slot($slot) {
if (!array_key_exists($slot, $this->questionattempts)) { if (!array_key_exists($slot, $this->questionattempts)) {
throw new exception("There is no question_attempt number $slot in this attempt."); throw new coding_exception("There is no question_attempt number $slot in this attempt.");
} }
} }
@ -1198,7 +1198,7 @@ class question_usage_by_activity {
while ($record->qubaid != $qubaid) { while ($record->qubaid != $qubaid) {
$record = next($records); $record = next($records);
if (!$record) { if (!$record) {
throw new Exception("Question usage $qubaid not found in the database."); throw new coding_exception("Question usage $qubaid not found in the database.");
} }
} }
@ -1280,10 +1280,10 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
return $this->quba->get_question_attempt($slot); return $this->quba->get_question_attempt($slot);
} }
public function offsetSet($slot, $value) { public function offsetSet($slot, $value) {
throw new Exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot set.'); throw new coding_exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot set.');
} }
public function offsetUnset($slot) { public function offsetUnset($slot) {
throw new Exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot unset.'); throw new coding_exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot unset.');
} }
} }
@ -1561,7 +1561,7 @@ class question_attempt {
*/ */
public function get_step($i) { public function get_step($i) {
if ($i < 0 || $i >= count($this->steps)) { if ($i < 0 || $i >= count($this->steps)) {
throw new Exception('Index out of bounds in question_attempt::get_step.'); throw new coding_exception('Index out of bounds in question_attempt::get_step.');
} }
return $this->steps[$i]; return $this->steps[$i];
} }
@ -1755,7 +1755,7 @@ class question_attempt {
/** @return number the maximum mark possible for this question attempt. */ /** @return number the maximum mark possible for this question attempt. */
public function get_min_fraction() { public function get_min_fraction() {
if (is_null($this->minfraction)) { if (is_null($this->minfraction)) {
throw new Exception('This question_attempt has not been started yet, the min fraction is not yet konwn.'); throw new coding_exception('This question_attempt has not been started yet, the min fraction is not yet konwn.');
} }
return $this->minfraction; return $this->minfraction;
} }
@ -2207,7 +2207,7 @@ class question_attempt {
while ($record->questionattemptid != $questionattemptid) { while ($record->questionattemptid != $questionattemptid) {
$record = next($records); $record = next($records);
if (!$record) { if (!$record) {
throw new Exception("Question attempt $questionattemptid not found in the database."); throw new coding_exception("Question attempt $questionattemptid not found in the database.");
} }
} }
@ -2384,10 +2384,10 @@ class question_attempt_step_iterator implements Iterator, ArrayAccess {
return $this->qa->get_step($i); return $this->qa->get_step($i);
} }
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
throw new Exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot set.'); throw new coding_exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot set.');
} }
public function offsetUnset($offset) { public function offsetUnset($offset) {
throw new Exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot unset.'); throw new coding_exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot unset.');
} }
} }
@ -2554,7 +2554,7 @@ class question_attempt_step {
*/ */
public function set_qt_var($name, $value) { public function set_qt_var($name, $value) {
if ($name[0] != '_') { if ($name[0] != '_') {
throw new Exception('Cannot set question type data ' . $name . ' on an attempt step. You can only set variables with names begining with _.'); throw new coding_exception('Cannot set question type data ' . $name . ' on an attempt step. You can only set variables with names begining with _.');
} }
$this->data[$name] = $value; $this->data[$name] = $value;
} }
@ -2599,7 +2599,7 @@ class question_attempt_step {
*/ */
public function set_behaviour_var($name, $value) { public function set_behaviour_var($name, $value) {
if ($name[0] != '_') { if ($name[0] != '_') {
throw new Exception('Cannot set question type data ' . $name . ' on an attempt step. You can only set variables with names begining with _.'); throw new coding_exception('Cannot set question type data ' . $name . ' on an attempt step. You can only set variables with names begining with _.');
} }
return $this->data['-' . $name] = $value; return $this->data['-' . $name] = $value;
} }
@ -2659,7 +2659,7 @@ class question_attempt_step {
while ($currentrec->attemptstepid != $attemptstepid) { while ($currentrec->attemptstepid != $attemptstepid) {
$currentrec = next($records); $currentrec = next($records);
if (!$currentrec) { if (!$currentrec) {
throw new Exception("Question attempt step $attemptstepid not found in the database."); throw new coding_exception("Question attempt step $attemptstepid not found in the database.");
} }
} }
@ -2750,7 +2750,7 @@ class question_null_step {
} }
public function set_state($state) { public function set_state($state) {
throw new Exception('This question has not been started.'); throw new coding_exception('This question has not been started.');
} }
public function get_fraction() { public function get_fraction() {

View file

@ -314,7 +314,7 @@ abstract class testing_db_record_builder {
$records = array(); $records = array();
foreach ($table as $row) { foreach ($table as $row) {
if (count($row) != count($columns)) { if (count($row) != count($columns)) {
throw new Exception("Row contains the wrong number of fields."); throw new coding_exception("Row contains the wrong number of fields.");
} }
$rec = new stdClass(); $rec = new stdClass();
foreach ($columns as $i => $name) { foreach ($columns as $i => $name) {

View file

@ -98,7 +98,7 @@ abstract class question_state {
} }
} }
if (empty($states)) { if (empty($states)) {
throw new Exception('unknown summary state ' . $summarystate); throw new coding_exception('unknown summary state ' . $summarystate);
} }
return $states; return $states;
} }
@ -246,7 +246,7 @@ abstract class question_state {
* @return int the new state. * @return int the new state.
*/ */
public function corresponding_commented_state($fraction) { public function corresponding_commented_state($fraction) {
throw new Exception('Unexpected question state.'); throw new coding_exception('Unexpected question state.');
} }
/** /**
@ -295,7 +295,7 @@ class question_state_notstarted extends question_state {
return false; return false;
} }
public function get_state_class($showcorrectness) { public function get_state_class($showcorrectness) {
throw new Exception('Unexpected question state.'); throw new coding_exception('Unexpected question state.');
} }
} }
class question_state_unprocessed extends question_state { class question_state_unprocessed extends question_state {
@ -303,7 +303,7 @@ class question_state_unprocessed extends question_state {
return false; return false;
} }
public function get_state_class($showcorrectness) { public function get_state_class($showcorrectness) {
throw new Exception('Unexpected question state.'); throw new coding_exception('Unexpected question state.');
} }
} }
class question_state_todo extends question_state { class question_state_todo extends question_state {

View file

@ -80,7 +80,7 @@ class qtype_missingtype_question extends question_definition implements question
} }
public function grade_response(array $response) { public function grade_response(array $response) {
throw new Exception('This question is of a type that is not installed on your system. No processing is possible.'); throw new coding_exception('This question is of a type that is not installed on your system. No processing is possible.');
} }
public function get_hint($hintnumber, question_attempt $qa) { public function get_hint($hintnumber, question_attempt $qa) {

View file

@ -117,7 +117,7 @@ class qtype_numerical_answer extends question_answer {
public function get_tolerance_interval() { public function get_tolerance_interval() {
if ($this->answer === '*') { if ($this->answer === '*') {
throw new Exception('Cannot work out tolerance interval for answer *.'); throw new coding_exception('Cannot work out tolerance interval for answer *.');
} }
// We need to add a tiny fraction depending on the set precision to make // We need to add a tiny fraction depending on the set precision to make
@ -140,7 +140,7 @@ class qtype_numerical_answer extends question_answer {
return array($this->answer / $quotient, $this->answer * $quotient); return array($this->answer / $quotient, $this->answer * $quotient);
default: default:
throw new Exception('Unknown tolerance type ' . $this->tolerancetype); throw new coding_exception('Unknown tolerance type ' . $this->tolerancetype);
} }
} }

View file

@ -375,7 +375,7 @@ function qtype_opaque_get_step($seq, question_attempt $qa, $pendingstep) {
if ($seq == $qa->get_num_steps() && !is_null($pendingstep)) { if ($seq == $qa->get_num_steps() && !is_null($pendingstep)) {
return $pendingstep; return $pendingstep;
} }
throw new Exception('Sequence number ' . $seq . ' out of range.'); throw new coding_exception('Sequence number ' . $seq . ' out of range.');
} }
/** /**