/** * Generate the display of the response history part of the question. This * is the table showing all the steps the question has been through. * * @param question_attempt $qa the question attempt to display. * @param qbehaviour_renderer $behaviouroutput the renderer to output the behaviour * specific parts. * @param qtype_renderer $qtoutput the renderer to output the question type * specific parts. * @param question_display_options $options controls what should and should not be displayed. * @return HTML fragment. */ protected function response_history(question_attempt $qa, qbehaviour_renderer $behaviouroutput, qtype_renderer $qtoutput, question_display_options $options) { if (!$options->history) { return ''; } $table = new html_table(); $table->head = array(get_string('step', 'question'), get_string('time'), get_string('action', 'question'), get_string('state', 'question')); if ($options->marks >= question_display_options::MARK_AND_MAX) { $table->head[] = get_string('marks', 'question'); } foreach ($qa->get_full_step_iterator() as $i => $step) { $stepno = $i + 1; $rowclass = ''; if ($stepno == $qa->get_num_steps()) { $rowclass = 'current'; } else { if (!empty($options->questionreviewlink)) { $url = new moodle_url($options->questionreviewlink, array('slot' => $qa->get_slot(), 'step' => $i)); $stepno = $this->output->action_link($url, $stepno, new popup_action('click', $url, 'reviewquestion', array('width' => 450, 'height' => 650)), array('title' => get_string('reviewresponse', 'question'))); } } $restrictedqa = new question_attempt_with_restricted_history($qa, $i, null); $user = new stdClass(); $user->id = $step->get_user_id(); $row = array($stepno, userdate($step->get_timecreated(), get_string('strftimedatetimeshort')), s($qa->summarise_action($step)), $restrictedqa->get_state_string($options->correctness)); if ($options->marks >= question_display_options::MARK_AND_MAX) { $row[] = $qa->format_fraction_as_mark($step->get_fraction(), $options->markdp); } $table->rowclasses[] = $rowclass; $table->data[] = $row; } return html_writer::tag('h4', get_string('responsehistory', 'question'), array('class' => 'responsehistoryheader')) . $options->extrahistorycontent . html_writer::tag('div', html_writer::table($table, true), array('class' => 'responsehistoryheader')); }
/** * This is a copy of the history function in the question renderer class * Since the access to that function is protected I cannot access it outside of the renderer class. * * There are a few changes to this function to facilitate simpler use * * @param \question_attempt $qa * @return string */ public function question_attempt_history($qa) { $table = new \html_table(); $table->head = array(get_string('step', 'question'), get_string('time'), get_string('action', 'question')); foreach ($qa->get_full_step_iterator() as $i => $step) { $stepno = $i + 1; $rowclass = ''; if ($stepno == $qa->get_num_steps()) { $rowclass = 'current'; } $user = new \stdClass(); $user->id = $step->get_user_id(); $row = array($stepno, userdate($step->get_timecreated(), get_string('strftimedatetimeshort')), s($qa->summarise_action($step))); $table->rowclasses[] = $rowclass; $table->data[] = $row; } return \html_writer::tag('h4', get_string('responsehistory', 'question'), array('class' => 'responsehistoryheader')) . \html_writer::tag('div', \html_writer::table($table, true), array('class' => 'responsehistoryheader')); }