File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ class constants {
3636 public const QT_VAR_SCORING_STATE = '_scoringstate ' ;
3737 /** @var string */
3838 public const QT_VAR_RESPONSE = 'qpy_response ' ;
39+ /** @var string */
40+ public const QT_VAR_ERROR = '_qpy_error ' ;
3941
4042 /** @var string This isn't needed after the action has been processed, so it's not a qt var. */
4143 public const FORM_DRAFT_AREAS = 'qpy_draft_areas ' ;
Original file line number Diff line number Diff line change 2323 */
2424
2525use qtype_questionpy \constants ;
26+ use qtype_questionpy \exception \request_error ;
2627use qtype_questionpy \local \api \api ;
2728use qtype_questionpy \local \api \attempt ;
2829use qtype_questionpy \local \api \attempt_ui ;
@@ -372,7 +373,7 @@ public function summarise_response(array $response) {
372373 }
373374 }
374375
375- return $ summary ?: ' - ' ;
376+ return $ summary ;
376377 }
377378
378379 /**
@@ -427,6 +428,10 @@ public function grade_response(array $response): array {
427428 $ event ->trigger ();
428429 debugging ($ event ->get_description (), backtrace: $ t ->getTrace ());
429430
431+ // Our question behaviour constructs an error message containing this error representation.
432+ $ error = $ t instanceof request_error ? $ t ->requesterrorcode ->value : $ t ::class . "( {$ t ->getCode ()}" ;
433+ $ this ->get_behaviour ()->get_pending_step ()->set_qt_var (constants::QT_VAR_ERROR , $ error );
434+
430435 // As the server was not able to score the response, we mark this question with manual scoring.
431436 return [0 , question_state::$ needsgrading ];
432437 }
You can’t perform that action at this time.
0 commit comments