Skip to content

Commit

Permalink
feat: implement is_same_response
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Nov 7, 2024
1 parent 513fedc commit 27278e8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

use qtype_questionpy\api\api;
use qtype_questionpy\api\attempt_ui;
use qtype_questionpy\constants;
use qtype_questionpy\api\scoring_code;
use qtype_questionpy\constants;
use qtype_questionpy\question_ui_metadata_extractor;
use qtype_questionpy\utils;

Expand Down Expand Up @@ -267,7 +267,7 @@ public function is_complete_response(array $response): bool {
}

/**
* Use by many of the behaviours to determine whether the student's
* Used by many of the behaviours to determine whether the student's
* response has changed. This is normally used to determine that a new set
* of responses can safely be discarded.
*
Expand All @@ -277,8 +277,10 @@ public function is_complete_response(array $response): bool {
* @return bool whether the two sets of responses are the same - that is
* whether the new set of responses can safely be discarded.
*/
public function is_same_response(array $prevresponse, array $newresponse) {
return false;
public function is_same_response(array $prevresponse, array $newresponse): bool {
/* The response has already been filtered against get_expected_data, we just need to filter out attempt state
and scoring state before comparing. */
return $newresponse == array_filter($prevresponse, fn($key) => !str_starts_with($key, "_"), ARRAY_FILTER_USE_KEY);
}

/**
Expand Down

0 comments on commit 27278e8

Please sign in to comment.