/** * 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')); }
/** * Like {@link render_question()} but displays the question at the past step * indicated by $seq, rather than showing the latest step. * * @param int $seq the seq number of the past state to display. * @param question_display_options $options controls how the question is rendered. * @param string|null $number The question number to display. 'i' is a special * value that gets displayed as Information. Null means no number is displayed. * @return string HTML fragment representing the question. */ public function render_at_step($seq, $options, $number, $preferredbehaviour) { $restrictedqa = new question_attempt_with_restricted_history($this, $seq, $preferredbehaviour); return $restrictedqa->render($options, $number); }