本文整理汇总了PHP中question_attempt类的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt类的具体用法?PHP question_attempt怎么用?PHP question_attempt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了question_attempt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: controls
public function controls(question_attempt $qa, question_display_options $options)
{
if ($options->readonly || $qa->get_state() != question_state::$todo) {
return '';
}
// Hidden input to move the question into the complete state.
return html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_behaviour_field_name('seen'), 'value' => 1));
}
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:renderer.php
示例2: subquestion
public function subquestion(question_attempt $qa, question_display_options $options, qtype_combined_combinable_base $subq, $placeno)
{
$question = $subq->question;
$place = $placeno + 1;
$group = $question->places[$place];
$fieldname = $subq->step_data_name($question->field($place));
$value = $qa->get_last_qt_var($fieldname);
$attributes = array('id' => str_replace(':', '_', $qa->get_qt_field_name($fieldname)));
if ($options->readonly) {
$attributes['disabled'] = 'disabled';
}
$orderedchoices = $question->get_ordered_choices($group);
$selectoptions = array();
foreach ($orderedchoices as $orderedchoicevalue => $orderedchoice) {
$selectoptions[$orderedchoicevalue] = $orderedchoice->text;
}
$feedbackimage = '';
if ($options->correctness) {
$response = $qa->get_last_qt_data();
if (array_key_exists($fieldname, $response)) {
$fraction = (int) ($response[$fieldname] == $question->get_right_choice_for($place));
$attributes['class'] = $this->feedback_class($fraction);
$feedbackimage = $this->feedback_image($fraction);
}
}
$selecthtml = html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname), $value, get_string('choosedots'), $attributes) . ' ' . $feedbackimage;
return html_writer::tag('span', $selecthtml, array('class' => 'control'));
}
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:28,代码来源:renderer.php
示例3: get_graded_step
protected function get_graded_step(question_attempt $qa) {
foreach ($qa->get_reverse_step_iterator() as $step) {
if ($step->has_behaviour_var('_try')) {
return $step;
}
}
}
开发者ID:nottmoo,项目名称:moodle,代码行数:7,代码来源:renderer.php
示例4: feedback
public function feedback(question_attempt $qa, question_display_options $options) {
if (!$options->feedback) {
return '';
}
if ($qa->get_state() == question_state::$gaveup || $qa->get_state() ==
question_state::$mangaveup) {
return '';
}
$feedback = '';
if (!$qa->get_last_behaviour_var('certainty') &&
$qa->get_last_behaviour_var('_assumedcertainty')) {
$feedback .= html_writer::tag('p',
get_string('assumingcertainty', 'qbehaviour_deferredcbm',
question_cbm::get_string($qa->get_last_behaviour_var('_assumedcertainty'))));
}
if ($options->marks >= question_display_options::MARK_AND_MAX) {
$a = new stdClass();
$a->rawmark = format_float($qa->get_last_behaviour_var('_rawfraction') *
$qa->get_max_mark(), $options->markdp);
$a->mark = $qa->format_mark($options->markdp);
$feedback .= html_writer::tag('p',
get_string('markadjustment', 'qbehaviour_deferredcbm', $a));
}
return $feedback;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:29,代码来源:renderer.php
示例5: question
/**
* Generate the display of a question in a particular state, and with certain
* display options. Normally you do not call this method directly. Intsead
* you call {@link question_usage_by_activity::render_question()} which will
* call this method with appropriate arguments.
*
* @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.
* @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 representation of the question.
*/
public function question(question_attempt $qa, qbehaviour_renderer $behaviouroutput, qtype_renderer $qtoutput, question_display_options $options, $number)
{
//start a new output buffer
$output = '';
//add the quesiton number (TODO: style?)
//$output .= '<strong>' . $number .'.</strong> ';
$output .= html_writer::start_tag('table', array('style' => 'width: 100%; padding-bottom: 4px;'));
$output .= html_writer::start_tag('tr', array());
$output .= html_writer::tag('td', $number . '.', array('valign' => 'top', 'width' => '10%', 'style' => 'padding-right: 10px;'));
$output .= html_writer::start_tag('td', array('width' => '90%'));
//get the question from the attempt object
$question = $qa->get_question();
$pragmas = self::extract_pragmas($question->format_questiontext($qa));
//add the question's formulation
$output .= $this->formulation($qa, $behaviouroutput, $qtoutput, $options);
//an indication of output, if appropriate
$output .= $this->outcome($qa, $behaviouroutput, $qtoutput, $options);
//any manual comments, if appropriate
$output .= $this->manual_comment($qa, $behaviouroutput, $qtoutput, $options);
//the user's response history, if appropriate
$output .= $this->response_history($qa, $behaviouroutput, $qtoutput, $options);
$output .= html_writer::end_tag('td');
$output .= html_writer::end_tag('tr');
$output .= html_writer::end_tag('table');
//if a pragma exists specifying the space after a given quesiton, use it; otherwise, assume 5px
//$space_after = array_key_exists('space_after', $pragmas) ? $pragmas['space_after'] : '5px';
$space_after = array_key_exists('space_after', $pragmas) ? $pragmas['space_after'] : 0;
//and add a spacer after the given question
if ($space_after !== 0) {
$output .= html_writer::tag('div', ' ', array('style' => 'height: ' . $space_after . ';'));
}
//return the contents of the output buffer
return $output;
}
开发者ID:advancingdesign,项目名称:moodle-theme_pdf,代码行数:50,代码来源:core_question_pdf_renderer.php
示例6: embedded_element
protected function embedded_element(question_attempt $qa, $place, question_display_options $options)
{
$question = $qa->get_question();
$group = $question->places[$place];
$fieldname = $question->field($place);
$value = $qa->get_last_qt_var($question->field($place));
$attributes = array('id' => $this->box_id($qa, 'p' . $place));
$groupclass = 'group' . $group;
if ($options->readonly) {
$attributes['disabled'] = 'disabled';
}
$orderedchoices = $question->get_ordered_choices($group);
$selectoptions = array();
foreach ($orderedchoices as $orderedchoicevalue => $orderedchoice) {
$selectoptions[$orderedchoicevalue] = $orderedchoice->text;
}
$feedbackimage = '';
if ($options->correctness) {
$response = $qa->get_last_qt_data();
if (array_key_exists($fieldname, $response)) {
$fraction = (int) ($response[$fieldname] == $question->get_right_choice_for($place));
$attributes['class'] = $this->feedback_class($fraction);
$feedbackimage = $this->feedback_image($fraction);
}
}
$selecthtml = html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname), $value, get_string('choosedots'), $attributes) . ' ' . $feedbackimage;
return html_writer::tag('span', $selecthtml, array('class' => 'control ' . $groupclass));
}
开发者ID:ndunand,项目名称:moodle-qtype_gapselect,代码行数:28,代码来源:renderer.php
示例7: feedback
public function feedback(question_attempt $qa, question_display_options $options)
{
if ($qa->get_last_behaviour_var('_precheck', 0)) {
return '';
} else {
return parent::feedback($qa, $options);
}
}
开发者ID:trampgeek,项目名称:moodle-qbehaviour_adaptive_adapted_for_coderunner,代码行数:8,代码来源:renderer.php
示例8: manual_comment
public function manual_comment(question_attempt $qa, question_display_options $options)
{
if ($options->manualcomment != question_display_options::EDITABLE) {
return '';
}
$question = $qa->get_question();
return html_writer::nonempty_tag('div', $question->format_text($question->graderinfo, $question->graderinfo, $qa, 'qtype_poodllrecording', 'graderinfo', $question->id), array('class' => 'graderinfo'));
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:8,代码来源:renderer.php
示例9: __construct
/**
* Normally you should not call this constuctor directly. The appropriate
* behaviour object is created automatically as part of
* {@link question_attempt::start()}.
* @param question_attempt $qa the question attempt we will be managing.
* @param string $preferredbehaviour the type of behaviour that was actually
* requested. This information is not needed in most cases, the type of
* subclass is enough, but occasionally it is needed.
*/
public function __construct(question_attempt $qa, $preferredbehaviour) {
$this->qa = $qa;
$this->question = $qa->get_question();
if (!$this->is_compatible_question($this->question)) {
throw new coding_exception('This behaviour (' . $this->get_name() .
') cannot work with this question (' . get_class($this->question) . ')');
}
}
开发者ID:nigeli,项目名称:moodle,代码行数:17,代码来源:behaviourbase.php
示例10: feedback
public function feedback(question_attempt $qa, question_display_options $options)
{
// If the latest answer was invalid, display an informative message.
if ($qa->get_state() == question_state::$invalid) {
return html_writer::nonempty_tag('div', $this->disregarded_info(), array('class' => 'gradingdetails'));
}
// Otherwise get the details.
return $this->render_adaptive_marks($qa->get_behaviour()->get_adaptive_marks(), $options);
}
开发者ID:evltuma,项目名称:moodle,代码行数:9,代码来源:renderer.php
示例11: __construct
/**
* Normally you should not call this constuctor directly. The appropriate
* behaviour object is created automatically as part of
* {@link question_attempt::start()}.
* @param question_attempt $qa the question attempt we will be managing.
* @param string $preferredbehaviour the type of behaviour that was actually
* requested. This information is not needed in most cases, the type of
* subclass is enough, but occasionally it is needed.
*/
public function __construct(question_attempt $qa, $preferredbehaviour)
{
$this->qa = $qa;
$this->question = $qa->get_question();
$requiredclass = $this->required_question_definition_type();
if (!$this->question instanceof $requiredclass) {
throw new coding_exception('This behaviour (' . $this->get_name() . ') cannot work with this question (' . get_class($this->question) . ')');
}
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:18,代码来源:behaviourbase.php
示例12: correct_response
public function correct_response(question_attempt $qa)
{
$question = $qa->get_question();
$answer = $question->get_matching_answer($question->get_correct_response());
if (!$answer) {
return '';
}
return get_string('correctansweris', 'qtype_shortanswer', s($answer->answer));
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:9,代码来源:renderer.php
示例13: specific_feedback
public function specific_feedback(question_attempt $qa)
{
$question = $qa->get_question();
$response = array();
foreach ($question->get_parameters() as $param) {
$response['answer_' . $param] = $qa->get_last_qt_var('answer_' . $param);
}
$question->compute_feedbackperconditions($response);
return $question->computedfeedbackperconditions;
}
开发者ID:ndunand,项目名称:moodle-qtype_multinumerical,代码行数:10,代码来源:renderer.php
示例14: specific_feedback
/**
* Generates the specific feedback from the database when the attempt is finished and the question is answered.
*/
public function specific_feedback(question_attempt $qa)
{
global $DB, $CFG;
// get feedback from the database
$record = $DB->get_record('qtype_javaunittest_feedback', array('questionattemptid' => $qa->get_database_id()), 'feedback');
if ($record === false) {
return '';
}
$feedback = $record->feedback;
$question = $qa->get_question();
return $question->format_text($feedback, 0, $qa, 'question', 'answerfeedback', 1);
}
开发者ID:printz81,项目名称:javaunittest,代码行数:15,代码来源:renderer.php
示例15: correct_response
public function correct_response(question_attempt $qa)
{
$question = $qa->get_question();
$answer = $question->get_correct_response();
if (!$answer) {
return '';
}
$response = $answer['answer'];
if ($question->unitdisplay != qtype_numerical::UNITNONE && $question->unitdisplay != qtype_numerical::UNITINPUT) {
$response = $question->ap->add_unit($response);
}
return get_string('correctansweris', 'qtype_shortanswer', $response);
}
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:renderer.php
示例16: correct_response
public function correct_response(question_attempt $qa)
{
$question = $qa->get_question();
$correctanswer = '';
foreach ($question->textfragments as $i => $fragment) {
if ($i > 0) {
$group = $question->places[$i];
$choice = $question->choices[$group][$question->rightchoices[$i]];
$correctanswer .= '[' . str_replace('-', '‑', $choice->text) . ']';
}
$correctanswer .= $fragment;
}
if (!empty($correctanswer)) {
return get_string('correctansweris', 'qtype_gapselect', $question->format_text($correctanswer, $question->questiontextformat, $qa, 'question', 'questiontext', $question->id));
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:rendererbase.php
示例17: test_render_missing
public function test_render_missing()
{
$records = new question_test_recordset(array(array('questionattemptid', 'contextid', 'questionusageid', 'slot', 'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged', 'questionsummary', 'rightanswer', 'responsesummary', 'timemodified', 'attemptstepid', 'sequencenumber', 'state', 'fraction', 'timecreated', 'userid', 'name', 'value'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, '_order', '1,2,3'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.5, 1256233705, 1, '-submit', '1'), array(1, 123, 1, 1, 'strangeunknown', -1, 1, 2.0, 0.0, 1.0, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.5, 1256233705, 1, 'choice0', '1')));
$question = test_question_maker::make_question('truefalse', 'true');
$question->id = -1;
question_bank::start_unit_test();
question_bank::load_test_question_data($question);
$qa = question_attempt::load_from_records($records, 1, new question_usage_null_observer(), 'deferredfeedback');
question_bank::end_unit_test();
$this->assertEquals(2, $qa->get_num_steps());
$step = $qa->get_step(0);
$this->assertEquals(question_state::$todo, $step->get_state());
$this->assertNull($step->get_fraction());
$this->assertEquals(1256233700, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array('_order' => '1,2,3'), $step->get_all_data());
$step = $qa->get_step(1);
$this->assertEquals(question_state::$complete, $step->get_state());
$this->assertEquals(0.5, $step->get_fraction());
$this->assertEquals(1256233705, $step->get_timecreated());
$this->assertEquals(1, $step->get_user_id());
$this->assertEquals(array('-submit' => '1', 'choice0' => '1'), $step->get_all_data());
$output = $qa->render(new question_display_options(), '1');
$this->assertRegExp('/' . preg_quote($qa->get_question()->questiontext, '/') . '/', $output);
$this->assertRegExp('/' . preg_quote(get_string('questionusedunknownmodel', 'qbehaviour_missing'), '/') . '/', $output);
$this->assertTag(array('tag' => 'div', 'attributes' => array('class' => 'warning')), $output);
}
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:missingbehaviour_test.php
示例18: penalty_info
/**
* Display the information about the penalty calculations.
* @param question_attempt $qa the question attempt.
* @param object $mark contains information about the current mark.
* @param question_display_options $options display options.
*/
protected function penalty_info(question_attempt $qa, $mark, question_display_options $options)
{
if (!$qa->get_question()->penalty) {
return '';
}
$output = '';
// print details of grade adjustment due to penalties
if ($mark->raw != $mark->cur) {
$output .= ' ' . get_string('gradingdetailsadjustment', 'qbehaviour_adaptive', $mark);
}
// print info about new penalty
// penalty is relevant only if the answer is not correct and further attempts are possible
if (!$qa->get_state()->is_finished()) {
$output .= ' ' . get_string('gradingdetailspenalty', 'qbehaviour_adaptive', format_float($qa->get_question()->penalty, $options->markdp));
}
return $output;
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:23,代码来源:renderer.php
示例19: formulation_and_controls
/**
* Generate the display of the formulation part of the question. This is the
* area that contains the quetsion text, and the controls for students to
* input their answers. Some question types also embed bits of feedback, for
* example ticks and crosses, in this area.
*
* @param question_attempt $qa the question attempt to display.
* @param question_display_options $options controls what should and should not be displayed.
* @return string HTML fragment.
*/
public function formulation_and_controls(question_attempt $qa, question_display_options $options)
{
$question = $qa->get_question();
$response = $qa->get_last_qt_data();
$table = new html_table();
$table->attributes['class'] = 'matrix';
$table->head = array();
$table->head[] = '';
foreach ($question->cols as $col) {
$table->head[] = self::matrix_header($col);
}
if ($options->correctness) {
$table->head[] = '';
}
foreach ($question->rows as $row) {
$row_data = array();
$row_data[] = self::matrix_header($row);
foreach ($question->cols as $col) {
$key = $question->key($row, $col);
$cell_name = $qa->get_field_prefix() . $key;
$is_readonly = $options->readonly;
$is_checked = $question->is_answered($response, $row, $col);
if ($question->multiple) {
$cell = self::checkbox($cell_name, $is_checked, $is_readonly);
} else {
$cell = self::radio($cell_name, $col->id, $is_checked, $is_readonly);
}
if ($options->correctness) {
$weight = $question->weight($row, $col);
$cell .= $this->feedback_image($weight);
}
$row_data[] = $cell;
}
if ($options->correctness) {
$row_grade = $question->grading()->grade_row($question, $row, $response);
$feedback = $row->feedback;
$feedback = strip_tags($feedback) ? $feedback : '';
$row_data[] = $this->feedback_image($row_grade) . $feedback;
}
$table->data[] = $row_data;
//$row_index++;
}
$result = $question->questiontext;
$result .= html_writer::table($table, true);
return $result;
}
开发者ID:sunilwebaccess,项目名称:moodle-question-matrix,代码行数:56,代码来源:renderer.php
示例20: formulation_and_controls
public function formulation_and_controls(question_attempt $qa, question_display_options $options)
{
$question = $qa->get_question();
$questiontext = $question->format_questiontext($qa);
$placeholder = false;
if (preg_match('/_____+/', $questiontext, $matches)) {
$placeholder = $matches[0];
}
$input = '**subq controls go in here**';
if ($placeholder) {
$questiontext = substr_replace($questiontext, $input, strpos($questiontext, $placeholder), strlen($placeholder));
}
$result = html_writer::tag('div', $questiontext, array('class' => 'qtext'));
/* if ($qa->get_state() == question_state::$invalid) {
$result .= html_writer::nonempty_tag('div',
$question->get_validation_error(array('answer' => $currentanswer)),
array('class' => 'validationerror'));
}*/
return $result;
}
开发者ID:edwinp-catalyst-eu,项目名称:moodle-qtype_TEMPLATE,代码行数:20,代码来源:renderer.php
注:本文中的question_attempt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论