Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Feb 21, 2024
1 parent d8c365c commit e3cf0b3
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class qtype_oumatrix_base extends question_graded_automatically {
public $incorrectfeedback;
public $incorrectfeedbackformat;

/** @var column[] The columns (answers) object. */
/** @var column[] The columns (answers) object, indexed by number. */
public $columns;

/** @var row[] The rows (subquestions) object. */
Expand Down Expand Up @@ -184,21 +184,6 @@ public function has_specific_feedback(): bool {
return false;
}

/**
* Return a colun object.
*
* @param int $number
* @return object column|null
*/
protected function get_column_by_number(int $number): ?qtype_oumatrix\column {
foreach ($this->columns as $column) {
if ($column->number == $number) {
return $column;
}
}
return null;
}

/**
* Return a row object.
*
Expand Down Expand Up @@ -313,11 +298,11 @@ public function classify_response(array $response): array {

$choices = [];
foreach ($selectedchoices as $rowid => $colnumber) {
if ($selectedchoices[$rowid] === 0) {
if ($colnumber === 0) {
$choices[$rowid] = question_classified_response::no_response();
continue;
}
$column = $this->get_column_by_number($colnumber);
$column = $this->columns[$colnumber];
if (in_array($colnumber, array_keys($this->rows[$rowid]->correctanswers))) {
$fraction = 1;
} else {
Expand Down Expand Up @@ -475,7 +460,7 @@ public function classify_response(array $response) {
preg_match('/([\d+])_([\d+])/', $responsekey, $matches);
$rowid = $this->roworder[$matches[1]];
$colnumber = $matches[2];
$column = $this->get_column_by_number($colnumber);
$column = $this->columns[$colnumber];
$row = $this->get_row_by_id($rowid);
$rowcorrectanswers = $this->rows[$rowid]->correctanswers;
if ($responsevalue && in_array($colnumber, array_keys($rowcorrectanswers))) {
Expand Down

0 comments on commit e3cf0b3

Please sign in to comment.