Hi Tim
Thanks for your quick response.
I'm storing the data within my plugin for reporting and for manual grading of essay questions in a separate process and removing the data from the questions_usages, questions_attempts and associated step tables afterwards (at the end of the activity). I think that it also makes it easier to implement privacy requirements if I have all the data and none is in the the usages and related tables.
I permit adaptive and immediate behaviours and, when the check button on the form is clicked, the data is transferred into those usage tables, so far so good. There was a problem with saving essay data so I've added a button to allow that to be saved multiple times.
However, deferred feedback does not offer a button on the form so I've supplied a submit button in the renderer code.
public function render_question_form(
$actionurl, $options, $slot, $quba,
$starttime, $qtype, $behaviour) {
$html = html_writer::start_div('mod_simplelesson_question');
$headtags = '';
$headtags .= $quba->render_question_head_html($slot);
// Start the question form.
$html .= html_writer::start_tag('form',
array('method' => 'post', 'action' => $actionurl,
'enctype' => 'multipart/form-data',
'accept-charset' => 'utf-8',
'id' => 'responseform'));
$this->page->requires->js_init_call('M.core_question_engine.init_form',
array('#responseform'), false, null);
$html .= html_writer::start_tag('div');
$html .= html_writer::empty_tag('input',
array('type' => 'hidden',
'name' => 'sesskey', 'value' => sesskey()));
$html .= html_writer::empty_tag('input',
array('type' => 'hidden',
'name' => 'slots', 'value' => $slot));
$html .= '<input type="hidden" name="scrollpos" value="" />';
$html .= html_writer::empty_tag('input',
array('type' => 'hidden',
'name' => 'starttime', 'value' => $starttime));
$html .= html_writer::end_tag('div');
// Output the question. slot = display number.
$html .= $quba->render_question($slot, $options);
// If it's an essay question, output a save button.
// If it's deferred feedback add a save button.
if ( ($qtype == 'essay') || ($behaviour == 'deferredfeedback') ) {
$html .= html_writer::start_div(
'mod_simplelesson_save_button');
$html .= $this->output->single_button($actionurl,
get_string('saveanswer', 'mod_simplelesson'));
$html .= html_writer::end_div();
}
// Finish the question form.
$html .= html_writer::start_tag(
'mod_simplelesson_action_buttons');
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
$html .= html_writer::end_div('div');
return $html;
}
This submit button works for the essay question but doesn't cause any usage data to be stored for deferred feedback. Clearly I'm missing some important processing step.
I wanted to report the student responses for later review and I had intended to cover the main question types, t/f, multiple choice, fill blanks, matching and essay. I have not yet thought about D&D and so on. The original intent was simplification (for teachers) as quiz/lesson already offer pretty comprehensive alternatives.