Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-29854_b' of git://github.com/timhunt/moodle

  • Loading branch information...
commit a0b10b271f3627ded63748c132ae4caf4ab8bb6c 2 parents 036f27a + bed4955
@nebgor nebgor authored
View
2  lang/en/question.php
@@ -135,7 +135,7 @@
$string['errorpostprocess'] = 'Error occurred during post-processing!';
$string['errorpreprocess'] = 'Error occurred during pre-processing!';
$string['errorprocess'] = 'Error occurred during processing!';
-$string['errorprocessingresponses'] = 'An error occurred while processing your responses.';
+$string['errorprocessingresponses'] = 'An error occurred while processing your responses ({$a}). Click continue to return to the page you were on and try again.';
$string['errorsavingcomment'] = 'Error saving the comment for question {$a->name} in the database.';
$string['errorupdatingattempt'] = 'Error updating attempt {$a->id} in the database.';
$string['exportcategory'] = 'Export category';
View
30 mod/quiz/processattempt.php
@@ -94,10 +94,22 @@
// Just process the responses for this page and go to the next page.
try {
$attemptobj->process_all_actions($timenow);
+
} catch (question_out_of_sequence_exception $e) {
print_error('submissionoutofsequencefriendlymessage', 'question',
$attemptobj->attempt_url(null, $thispage));
+
+ } catch (Exception $e) {
+ // This sucks, if we display our own custom error message, there is no way
+ // to display the original stack trace.
+ $debuginfo = '';
+ if (!empty($e->debuginfo)) {
+ $debuginfo = $e->debuginfo;
+ }
+ print_error('errorprocessingresponses', 'question',
+ $attemptobj->attempt_url(null, $thispage), $e->getMessage(), $debuginfo);
}
+
$transaction->allow_commit();
redirect($nexturl);
}
@@ -110,7 +122,23 @@
$attemptobj->get_quizid(), $attemptobj->get_cmid());
// Update the quiz attempt record.
-$attemptobj->finish_attempt($timenow);
+try {
+ $attemptobj->finish_attempt($timenow);
+
+} catch (question_out_of_sequence_exception $e) {
+ print_error('submissionoutofsequencefriendlymessage', 'question',
+ $attemptobj->attempt_url(null, $thispage));
+
+} catch (Exception $e) {
+ // This sucks, if we display our own custom error message, there is no way
+ // to display the original stack trace.
+ $debuginfo = '';
+ if (!empty($e->debuginfo)) {
+ $debuginfo = $e->debuginfo;
+ }
+ print_error('errorprocessingresponses', 'question',
+ $attemptobj->attempt_url(null, $thispage), $e->getMessage(), $debuginfo);
+}
// Send the user to the review page.
$transaction->allow_commit();
View
74 question/preview.php
@@ -82,13 +82,18 @@
if (!isset($SESSION->question_previews[$previewid])) {
print_error('notyourpreview', 'question');
}
+
try {
$quba = question_engine::load_questions_usage_by_activity($previewid);
+
} catch (Exception $e) {
+ // This may not seem like the right error message to display, but
+ // actually from the user point of view, it makes sense.
print_error('submissionoutofsequencefriendlymessage', 'question',
question_preview_url($question->id, $options->behaviour,
$options->maxmark, $options, $options->variant, $context), null, $e);
}
+
$slot = $quba->get_first_question_number();
$usedquestion = $quba->get_question($slot);
if ($usedquestion->id != $question->id) {
@@ -140,48 +145,57 @@
// Process any actions from the buttons at the bottom of the form.
if (data_submitted() && confirm_sesskey()) {
- if (optional_param('restart', false, PARAM_BOOL)) {
- restart_preview($previewid, $question->id, $options, $context);
- } else if (optional_param('fill', null, PARAM_BOOL)) {
- $correctresponse = $quba->get_correct_response($slot);
- $quba->process_action($slot, $correctresponse);
+ try {
+
+ if (optional_param('restart', false, PARAM_BOOL)) {
+ restart_preview($previewid, $question->id, $options, $context);
+
+ } else if (optional_param('fill', null, PARAM_BOOL)) {
+ $correctresponse = $quba->get_correct_response($slot);
+ $quba->process_action($slot, $correctresponse);
- $transaction = $DB->start_delegated_transaction();
- question_engine::save_questions_usage_by_activity($quba);
- $transaction->allow_commit();
+ $transaction = $DB->start_delegated_transaction();
+ question_engine::save_questions_usage_by_activity($quba);
+ $transaction->allow_commit();
- redirect($actionurl);
+ redirect($actionurl);
- } else if (optional_param('finish', null, PARAM_BOOL)) {
- try {
+ } else if (optional_param('finish', null, PARAM_BOOL)) {
$quba->process_all_actions();
- } catch (question_out_of_sequence_exception $e) {
- print_error('submissionoutofsequencefriendlymessage', 'question', $actionurl);
- }
- $quba->finish_all_questions();
+ $quba->finish_all_questions();
- $transaction = $DB->start_delegated_transaction();
- question_engine::save_questions_usage_by_activity($quba);
- $transaction->allow_commit();
- redirect($actionurl);
+ $transaction = $DB->start_delegated_transaction();
+ question_engine::save_questions_usage_by_activity($quba);
+ $transaction->allow_commit();
+ redirect($actionurl);
- } else {
- try {
+ } else {
$quba->process_all_actions();
- } catch (question_out_of_sequence_exception $e) {
- print_error('submissionoutofsequencefriendlymessage', 'question', $actionurl);
+
+ $transaction = $DB->start_delegated_transaction();
+ question_engine::save_questions_usage_by_activity($quba);
+ $transaction->allow_commit();
+
+ $scrollpos = optional_param('scrollpos', '', PARAM_RAW);
+ if ($scrollpos !== '') {
+ $actionurl->param('scrollpos', (int) $scrollpos);
+ }
+ redirect($actionurl);
}
- $transaction = $DB->start_delegated_transaction();
- question_engine::save_questions_usage_by_activity($quba);
- $transaction->allow_commit();
+ } catch (question_out_of_sequence_exception $e) {
+ print_error('submissionoutofsequencefriendlymessage', 'question', $actionurl);
- $scrollpos = optional_param('scrollpos', '', PARAM_RAW);
- if ($scrollpos !== '') {
- $actionurl->param('scrollpos', (int) $scrollpos);
+ } catch (Exception $e) {
+ // This sucks, if we display our own custom error message, there is no way
+ // to display the original stack trace.
+ $debuginfo = '';
+ if (!empty($e->debuginfo)) {
+ $debuginfo = $e->debuginfo;
}
- redirect($actionurl);
+ print_error('errorprocessingresponses', 'question', $actionurl,
+ $e->getMessage(), $debuginfo);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.