本文整理汇总了PHP中quiz_attempt::render_question方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt::render_question方法的具体用法?PHP quiz_attempt::render_question怎么用?PHP quiz_attempt::render_question使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quiz_attempt
的用法示例。
在下文中一共展示了quiz_attempt::render_question方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attempt_form
/**
* Ouputs the form for making an attempt
*
* @param quiz_attempt $attemptobj
* @param int $page Current page number
* @param array $slots Array of integers relating to questions
* @param int $id ID of the attempt
* @param int $nextpage Next page number
*/
public function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {
$output = '';
// Start the form.
$output .= html_writer::start_tag('form',
array('action' => $attemptobj->processattempt_url(), 'method' => 'post',
'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8',
'id' => 'responseform'));
$output .= html_writer::start_tag('div');
// Print all the questions.
foreach ($slots as $slot) {
$output .= $attemptobj->render_question($slot, false,
$attemptobj->attempt_url($slot, $page));
}
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next',
'value' => get_string('next')));
$output .= html_writer::end_tag('div');
// Some hidden fields to trach what is going on.
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'attempt',
'value' => $attemptobj->get_attemptid()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'thispage',
'value' => $page, 'id' => 'followingpage'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'nextpage',
'value' => $nextpage));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'timeup',
'value' => '0', 'id' => 'timeup'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scrollpos',
'value' => '', 'id' => 'scrollpos'));
// Add a hidden field with questionids. Do this at the end of the form, so
// if you navigate before the form has finished loading, it does not wipe all
// the student's answers.
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'slots',
'value' => implode(',', $slots)));
// Finish the form.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('form');
return $output;
}
示例2: get_attempt_questions_data
/**
* Return questions information for a given attempt.
*
* @param quiz_attempt $attemptobj the quiz attempt object
* @param bool $review whether if we are in review mode or not
* @param mixed $page string 'all' or integer page number
* @return array array of questions including data
*/
private static function get_attempt_questions_data(quiz_attempt $attemptobj, $review, $page = 'all')
{
global $PAGE;
$questions = array();
$contextid = $attemptobj->get_quizobj()->get_context()->id;
$displayoptions = $attemptobj->get_display_options($review);
$renderer = $PAGE->get_renderer('mod_quiz');
foreach ($attemptobj->get_slots($page) as $slot) {
$question = array('slot' => $slot, 'type' => $attemptobj->get_question_type_name($slot), 'page' => $attemptobj->get_question_page($slot), 'flagged' => $attemptobj->is_question_flagged($slot), 'html' => $attemptobj->render_question($slot, $review, $renderer) . $PAGE->requires->get_end_code());
if ($attemptobj->is_real_question($slot)) {
$question['number'] = $attemptobj->get_question_number($slot);
$question['state'] = (string) $attemptobj->get_question_state($slot);
$question['status'] = $attemptobj->get_question_status($slot, $displayoptions->correctness);
}
if ($displayoptions->marks >= question_display_options::MAX_ONLY) {
$question['maxmark'] = $attemptobj->get_question_attempt($slot)->get_max_mark();
}
if ($displayoptions->marks >= question_display_options::MARK_AND_MAX) {
$question['mark'] = $attemptobj->get_question_mark($slot);
}
$questions[] = $question;
}
return $questions;
}