Skip to content

Commit

Permalink
Revert changes in questiontype.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AnupamaSarjoshi committed Oct 17, 2023
1 parent 7a7b861 commit 15f5c0a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,19 @@ protected function initialise_question_rows(question_definition $question, $ques
foreach ($questiondata->rows as $index => $row) {
$newrow = $this->make_row($row);
$correctanswers = [];
if($questiondata->options->inputtype == 'single') {
foreach ($questiondata->columns as $column) {
if (isset($newrow->correctanswers) && array_key_exists($column->id, $newrow->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') {
$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

0 comments on commit 15f5c0a

Please sign in to comment.