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


PHP question_attempt类代码示例

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


在下文中一共展示了question_attempt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>&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

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


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