Skip to content

Commit

Permalink
First cut of moving text to qtext and answer options to their own div
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed May 3, 2023
1 parent 71ce425 commit 5d34d09
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class qtype_gapfill_renderer extends qtype_with_combined_feedback_renderer {
*/
public function formulation_and_controls(question_attempt $qa, question_display_options $options) {
$this->displayoptions = $options;
/** @var qtype_gapfill_question $question */
$question = $qa->get_question();
if (!$options->readonly) {
$question->initjs((Boolean) $question->singleuse);
Expand All @@ -73,10 +74,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_
$seranswers = $qa->get_step(0)->get_qt_var('_allanswers');
$this->allanswers = unserialize($seranswers);
$output = "";
$answeroptions = '';
if ($question->answerdisplay == "dragdrop") {
$answeroptions = $this->setup_answeroptions($qa);
}

$questiontext = '';
$markedgaps = $question->get_markedgaps($qa, $options);

Expand All @@ -91,23 +89,31 @@ public function formulation_and_controls(question_attempt $qa, question_display_

}

if ($qa->get_state() == question_state::$invalid) {
$questiontext .= html_writer::nonempty_tag('div', $question->get_validation_error(array('answer' => $output)),
['class' => 'validationerror']);
}

$answeroptions = '';
if ($question->answerdisplay == "dragdrop") {
$answeroptions = $this->setup_answeroptions($qa);
$answeroptions = html_writer::tag('div', $answeroptions, ['class' => 'answeroptions']);
}

$output = '';
if ($question->answerdisplay == 'dragdrop') {
$questiontext = $this->app_connect($question, $questiontext);
$questiontext .= html_writer::tag('div', $output, ['class' => 'qtext']);
if ($question->optionsaftertext == true) {
$output .= '<div>'.$questiontext . '</div>' . $answeroptions;
$output .= $questiontext . $answeroptions;
} else {
$output .= '<div>'.$answeroptions . '</div>' . $questiontext;
$output .= $answeroptions.$questiontext;
}
} else {
// For gapfill and dropdown rendering.
$output .= $questiontext;
}

if ($qa->get_state() == question_state::$invalid) {
$output .= html_writer::nonempty_tag('div', $question->get_validation_error(array('answer' => $output)),
['class' => 'validationerror']);
}
$output = html_writer::tag('div', $output, ['class' => 'qtext']);
return $output;
}
/**
Expand Down

0 comments on commit 5d34d09

Please sign in to comment.