/** * Generate the display of the marks for this question. * @param question_attempt $qa the question attempt to display. * @param question_display_options $options controls what should and should not be displayed. * @return HTML fragment. */ protected function mark_summary(question_attempt $qa, question_display_options $options) { if (!$options->marks) { return ''; } if ($qa->get_max_mark() == 0) { $summary = get_string('notgraded', 'question'); } else { if ($options->marks == question_display_options::MAX_ONLY || is_null($qa->get_fraction())) { //$summary = get_string('markedoutofmax', 'question', if ($qa->format_max_mark($options->markdp) > 1) { $summary = get_string('points', 'question', $qa->format_max_mark($options->markdp)); } else { $summary = get_string('point', 'question', $qa->format_max_mark($options->markdp)); } } else { $a = new stdClass(); $a->mark = $qa->format_mark($options->markdp); $a->max = $qa->format_max_mark($options->markdp); $summary = get_string('markoutofmax', 'question', $a); } } return html_writer::tag('h2', $summary, array('class' => 'grade quizpoints_no')); }
/** * Generate the display of the marks for this question out of the available marks. * @param question_attempt $qa the question attempt to display. * @param question_display_options $options controls what should and should not be displayed. * @return HTML fragment. */ public function standard_mark_out_of_max(question_attempt $qa, question_display_options $options) { $a = new stdClass(); $a->mark = $qa->format_mark($options->markdp); $a->max = $qa->format_max_mark($options->markdp); return get_string('markoutofmax', 'question', $a); }
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_current_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->set_text($commenttext); $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'] = $currentmark; } $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())); $error = $qa->validate_manual_mark($currentmark); $errorclass = ''; if ($error !== '') { $erroclass = ' error'; $error = html_writer::tag('span', $error, 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')); }