本文整理汇总了PHP中question_attempt::get_last_step_with_qt_var方法的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt::get_last_step_with_qt_var方法的具体用法?PHP question_attempt::get_last_step_with_qt_var怎么用?PHP question_attempt::get_last_step_with_qt_var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_attempt
的用法示例。
在下文中一共展示了question_attempt::get_last_step_with_qt_var方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formulation_and_controls
public function formulation_and_controls(question_attempt $qa, question_display_options $options)
{
$question = $qa->get_question();
$responseoutput = $question->get_format_renderer($this->page);
// Answer field.
$step = $qa->get_last_step_with_qt_var('answer');
if (empty($options->readonly)) {
$answer = $responseoutput->response_area_input('answer', $qa, $step, $question->responsefieldlines, $options->context);
} else {
$answer = $responseoutput->response_area_read_only('answer', $qa, $step, $question->responsefieldlines, $options->context);
}
$files = '';
if ($question->attachments) {
if (empty($options->readonly)) {
$files = $this->files_input($qa, $question->attachments, $options);
} else {
$files = $this->files_read_only($qa, $options);
}
}
$result = '';
$result .= html_writer::tag('div', $question->format_questiontext($qa), array('class' => 'qtext'));
$result .= html_writer::start_tag('div', array('class' => 'ablock'));
$result .= html_writer::tag('div', $answer, array('class' => 'answer'));
$result .= html_writer::tag('div', $files, array('class' => 'attachments'));
$result .= html_writer::end_tag('div');
return $result;
}
示例2: formulation_and_controls
/**
* Generates the web-side when te student is attempting the question. This is the side which is showed with the
* question text and the response field
*/
public function formulation_and_controls(question_attempt $qa, question_display_options $options)
{
global $DB;
$question = $qa->get_question();
$responseoutput = $question->get_format_renderer($this->page);
// Answer field.
$step = $qa->get_last_step_with_qt_var('answer');
// Get the question options to show the question text
$question->options = $DB->get_record('qtype_javaunittest_options', array('questionid' => $question->id));
$studentscode = $question->options->givencode;
if (empty($options->readonly)) {
$answer = $responseoutput->response_area_input('answer', $qa, $step, $question->responsefieldlines, $options->context, $studentscode);
} else {
$answer = $responseoutput->response_area_read_only('answer', $qa, $step, $question->responsefieldlines, $options->context, $studentscode);
}
// Generate the html code which will be showed
$result = '';
$result .= html_writer::tag('div', $question->format_questiontext($qa), array('class' => 'qtext'));
$result .= html_writer::start_tag('div', array('class' => 'ablock'));
$result .= html_writer::tag('div', $answer, array('class' => 'answer'));
$result .= html_writer::end_tag('div');
return $result;
}
示例3: update_answers_single
/**
*
*
* @param array $answers The overall answers array that handles the count of answers
* @param \question_attempt $qa
* @param \qtype_multichoice_single_question $questiondef
*
*/
protected function update_answers_single(&$answers, $qa, $questiondef)
{
// get the latest step that has an answer
$lastanswerstep = $qa->get_last_step_with_qt_var('answer');
if ($lastanswerstep->has_qt_var('answer')) {
// may not as if the step doesn't exist get last step will return empty read only step
// get the student answer from the last answer step
// along with the answers within the
$answerorder = $questiondef->get_order($qa);
$response = $lastanswerstep->get_qt_data();
// make sure the response answer actually exists in the order
if (array_key_exists($response['answer'], $answerorder)) {
$studentanswer = $questiondef->answers[$answerorder[$response['answer']]];
// update the count of the answerid on the answers array
if (isset($answers[$studentanswer->id])) {
$current = (int) $answers[$studentanswer->id];
$answers[$studentanswer->id] = $current + 1;
} else {
$answers[$studentanswer->id] = 1;
}
}
}
}