Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AnupamaSarjoshi committed Oct 16, 2023
1 parent ff82354 commit 7a7b861
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 4 additions & 8 deletions questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,15 @@ protected function initialise_question_rows(question_definition $question, $ques
foreach ($questiondata->rows as $index => $row) {
$newrow = $this->make_row($row);
$correctanswers = [];
$todecode = implode(",", $newrow->correctanswers);
$decodedanswers = json_decode($todecode, true);
foreach ($questiondata->columns as $key => $column) {
if ($decodedanswers != null && array_key_exists($column->id, $decodedanswers)) {
if ($questiondata->options->inputtype == 'single') {
if($questiondata->options->inputtype == 'single') {
foreach ($questiondata->columns as $column) {
if (isset($newrow->correctanswers) && array_key_exists($column->id, $newrow->correctanswers)) {
$anslabel = 'a' . ($column->number + 1);
$correctanswers[$column->id] = $anslabel;
} else {
$correctanswers[$column->id] = $decodedanswers[$column->id];
}
}
$newrow->correctanswers = $correctanswers;
}
$newrow->correctanswers = $correctanswers;
$question->rows[$index] = $newrow;
}
}
Expand Down
4 changes: 0 additions & 4 deletions tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,4 @@ public function get_test_question_data($which) {
public function get_test_question_form_data($which) {
return (array)\test_question_maker::get_question_form_data('oumatrix', $which);
}

public function get_test_question_form_data($witch) {
return (array)\test_question_maker::get_question_form_data('oumatrix', $witch);
}
}

0 comments on commit 7a7b861

Please sign in to comment.