当前位置: 首页>>代码示例>>PHP>>正文


PHP question_attempt::get_question方法代码示例

本文整理汇总了PHP中question_attempt::get_question方法的典型用法代码示例。如果您正苦于以下问题:PHP question_attempt::get_question方法的具体用法?PHP question_attempt::get_question怎么用?PHP question_attempt::get_question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在question_attempt的用法示例。


在下文中一共展示了question_attempt::get_question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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>&nbsp; &nbsp;';
     $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', '&nbsp;', 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

示例2: 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

示例3: 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

示例4: __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

示例5: 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

示例6: __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

示例7: 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

示例8: controls

 public function controls(question_attempt $qa, question_display_options $options)
 {
     $question = $qa->get_question();
     if (!empty($question->precheck)) {
         $buttons = $this->precheck_button($qa, $options) . "\n" . $this->submit_button($qa, $options);
     } else {
         $buttons = $this->submit_button($qa, $options);
     }
     return $buttons;
 }
开发者ID:trampgeek,项目名称:moodle-qbehaviour_adaptive_adapted_for_coderunner,代码行数:10,代码来源:renderer.php

示例9: 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

示例10: 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

示例11: formulation_and_controls

 public function formulation_and_controls(question_attempt $qa, question_display_options $options)
 {
     $question = $qa->get_question();
     $output = '';
     foreach ($question->textfragments as $i => $fragment) {
         if ($i > 0) {
             $index = $question->places[$i];
             $output .= $this->subquestion($qa, $options, $index, $question->subquestions[$index]);
         }
         $output .= $question->format_text($fragment, $question->questiontextformat, $qa, 'question', 'questiontext', $question->id);
     }
     $this->page->requires->js_init_call('M.qtype_multianswer.init', array('#q' . $qa->get_slot()), false, array('name' => 'qtype_multianswer', 'fullpath' => '/question/type/multianswer/module.js', 'requires' => array('base', 'node', 'event', 'overlay')));
     return $output;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:14,代码来源:renderer.php

示例12: 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('-', '&#x2011;', $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

示例13: 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

示例14: 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

示例15: 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::get_question方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。