本文整理汇总了PHP中question_attempt::format_fraction_as_mark方法的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt::format_fraction_as_mark方法的具体用法?PHP question_attempt::format_fraction_as_mark怎么用?PHP question_attempt::format_fraction_as_mark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_attempt
的用法示例。
在下文中一共展示了question_attempt::format_fraction_as_mark方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manual_comment_fields
public function manual_comment_fields(question_attempt $qa, question_display_options $options)
{
$inputname = $qa->get_behaviour_field_name('comment');
$id = $inputname . '_id';
list($commenttext, $commentformat) = $qa->get_manual_comment();
$editor = editors_get_preferred_editor($commentformat);
$strformats = format_text_menu();
$formats = $editor->get_supported_formats();
foreach ($formats as $fid) {
$formats[$fid] = $strformats[$fid];
}
$commenttext = format_text($commenttext, $commentformat, array('para' => false));
$editor->use_editor($id, array('context' => $options->context));
$commenteditor = html_writer::tag('div', html_writer::tag('textarea', s($commenttext), array('id' => $id, 'name' => $inputname, 'rows' => 10, 'cols' => 60)));
$editorformat = '';
if (count($formats) == 1) {
reset($formats);
$editorformat .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $inputname . 'format', 'value' => key($formats)));
} else {
$editorformat = html_writer::start_tag('div', array('class' => 'fitem'));
$editorformat .= html_writer::start_tag('div', array('class' => 'fitemtitle'));
$editorformat .= html_writer::tag('label', get_string('format'), array('for' => 'menu' . $inputname . 'format'));
$editorformat .= html_writer::end_tag('div');
$editorformat .= html_writer::start_tag('div', array('class' => 'felement fhtmleditor'));
$editorformat .= html_writer::select($formats, $inputname . 'format', $commentformat, '');
$editorformat .= html_writer::end_tag('div');
$editorformat .= html_writer::end_tag('div');
}
$comment = html_writer::tag('div', html_writer::tag('div', html_writer::tag('label', get_string('comment', 'question'), array('for' => $id)), array('class' => 'fitemtitle')) . html_writer::tag('div', $commenteditor, array('class' => 'felement fhtmleditor')), array('class' => 'fitem'));
$comment .= $editorformat;
$mark = '';
if ($qa->get_max_mark()) {
$currentmark = $qa->get_current_manual_mark();
$maxmark = $qa->get_max_mark();
$fieldsize = strlen($qa->format_max_mark($options->markdp)) - 1;
$markfield = $qa->get_behaviour_field_name('mark');
$attributes = array('type' => 'text', 'size' => $fieldsize, 'name' => $markfield, 'id' => $markfield);
if (!is_null($currentmark)) {
$attributes['value'] = $qa->format_fraction_as_mark($currentmark / $maxmark, $options->markdp);
}
$a = new stdClass();
$a->max = $qa->format_max_mark($options->markdp);
$a->mark = html_writer::empty_tag('input', $attributes);
$markrange = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_behaviour_field_name('maxmark'), 'value' => $maxmark)) . html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_control_field_name('minfraction'), 'value' => $qa->get_min_fraction())) . html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_control_field_name('maxfraction'), 'value' => $qa->get_max_fraction()));
$errorclass = '';
$error = '';
if ($currentmark > $maxmark * $qa->get_max_fraction() || $currentmark < $maxmark * $qa->get_min_fraction()) {
$errorclass = ' error';
$error = html_writer::tag('span', get_string('manualgradeoutofrange', 'question'), array('class' => 'error')) . html_writer::empty_tag('br');
}
$mark = html_writer::tag('div', html_writer::tag('div', html_writer::tag('label', get_string('mark', 'question'), array('for' => $markfield)), array('class' => 'fitemtitle')) . html_writer::tag('div', $error . get_string('xoutofmax', 'question', $a) . $markrange, array('class' => 'felement ftext' . $errorclass)), array('class' => 'fitem'));
}
return html_writer::tag('fieldset', html_writer::tag('div', $comment . $mark, array('class' => 'fcontainer clearfix')), array('class' => 'hidden'));
}
示例2: response_history
/**
* 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'));
}
示例3: marked_out_of_max
public function marked_out_of_max(question_attempt $qa, core_question_renderer $qoutput, question_display_options $options)
{
return get_string('basemark', 'qbehaviour_deferredcbm', $qa->format_fraction_as_mark(question_cbm::adjust_fraction(1, question_cbm::default_certainty()), $options->markdp));
}