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


PHP question_utils类代码示例

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


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

示例1: is_same_response

 /** This function is used by the question engine to prevent regrading of
  *  unchanged submissions.
  *
  * @param array $prevresponse
  * @param array $newresponse
  * @return boolean
  */
 public function is_same_response(array $prevresponse, array $newresponse)
 {
     if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer') || !question_utils::arrays_same_at_key_integer($prevresponse, $newresponse, 'rating')) {
         return false;
     }
     return true;
 }
开发者ID:pac,项目名称:CodeRunner,代码行数:14,代码来源:question.php

示例2: quiz_question_tostring

/**
 * Creates a textual representation of a question for display.
 *
 * @param object $question A question object from the database questions table
 * @param bool $showicon If true, show the question's icon with the question. False by default.
 * @param bool $showquestiontext If true (default), show question text after question name.
 *       If false, show only question name.
 * @param bool $return If true (default), return the output. If false, print it.
 */
function quiz_question_tostring($question, $showicon = false, $showquestiontext = true, $return = true)
{
    global $COURSE;
    $result = '';
    $result .= '<span class="questionname">';
    if ($showicon) {
        $result .= print_question_icon($question, true);
        echo ' ';
    }
    $result .= shorten_text(format_string($question->name), 200) . '</span>';
    if ($showquestiontext) {
        $questiontext = question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false));
        $questiontext = shorten_text($questiontext, 200);
        $result .= '<span class="questiontext">';
        if (!empty($questiontext)) {
            $result .= s($questiontext);
        } else {
            $result .= '<span class="error">';
            $result .= get_string('questiontextisempty', 'quiz');
            $result .= '</span>';
        }
        $result .= '</span>';
    }
    if ($return) {
        return $result;
    } else {
        echo $result;
    }
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:38,代码来源:editlib.php

示例3: validate_manual_mark

 /**
  * Validate the manual mark for a question.
  * @param unknown $currentmark the user input (e.g. '1,0', '1,0' or 'invalid'.
  * @return string any errors with the value, or '' if it is OK.
  */
 public function validate_manual_mark($currentmark)
 {
     if ($currentmark === null || $currentmark === '') {
         return '';
     }
     $mark = question_utils::clean_param_mark($currentmark);
     if ($mark === null) {
         return get_string('manualgradeinvalidformat', 'question');
     }
     $maxmark = $this->get_max_mark();
     if ($mark > $maxmark * $this->get_max_fraction() || $mark < $maxmark * $this->get_min_fraction()) {
         return get_string('manualgradeoutofrange', 'question');
     }
     return '';
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:questionattempt.php

示例4: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     foreach ($this->places as $place => $notused) {
         $fieldname = $this->field($place);
         if (!question_utils::arrays_same_at_key_integer($prevresponse, $newresponse, $fieldname)) {
             return false;
         }
     }
     return true;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:10,代码来源:questionbase.php

示例5: number_answer

 /**
  * @param int $num The number, starting at 0.
  * @param string $style The style to render the number in. One of the
  * options returned by {@link qtype_multichoice:;get_numbering_styles()}.
  * @return string the number $num in the requested style.
  */
 public static function number_answer($num, $style)
 {
     switch ($style) {
         case 'abc':
             $number = chr(ord('a') + $num);
             break;
         case 'ABCD':
             $number = chr(ord('A') + $num);
             break;
         case '123':
             $number = $num + 1;
             break;
         case 'iii':
             $number = question_utils::int_to_roman($num + 1);
             break;
         case 'IIII':
             $number = strtoupper(question_utils::int_to_roman($num + 1));
             break;
         case 'none':
             return '';
         default:
             return 'ERR';
     }
     return "({$number})";
 }
开发者ID:kikkomep,项目名称:moodle.omero-qtypes,代码行数:31,代码来源:renderer.php

示例6: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer')) {
         return false;
     }
     if ($this->has_separate_unit_field()) {
         return question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'unit');
     }
     return true;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:10,代码来源:question.php

示例7: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse) {
     foreach ($this->order as $key => $notused) {
         $fieldname = $this->field($key);
         if (!question_utils::arrays_same_at_key($prevresponse, $newresponse, $fieldname)) {
             return false;
         }
     }
     return true;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:9,代码来源:question.php

示例8: get_submitted_var

    /**
     * Get a particular parameter from the current request. A wrapper round
     * {@link optional_param()}, except that the results is returned without
     * slashes.
     * @param string $name the paramter name.
     * @param int $type one of the standard PARAM_... constants, or one of the
     *      special extra constands defined by this class.
     * @param array $postdata (optional, only inteded for testing use) take the
     *      data from this array, instead of from $_POST.
     * @return mixed the requested value.
     */
    public function get_submitted_var($name, $type, $postdata = null) {
        switch ($type) {
            case self::PARAM_MARK:
                // Special case to work around PARAM_FLOAT converting '' to 0.
                return question_utils::clean_param_mark($this->get_submitted_var($name, PARAM_RAW_TRIMMED, $postdata));

            case self::PARAM_FILES:
                return $this->process_response_files($name, $name, $postdata);

            case self::PARAM_RAW_FILES:
                $var = $this->get_submitted_var($name, PARAM_RAW, $postdata);
                return $this->process_response_files($name, $name . ':itemid', $postdata, $var);

            default:
                if (is_null($postdata)) {
                    $var = optional_param($name, null, $type);
                } else if (array_key_exists($name, $postdata)) {
                    $var = clean_param($postdata[$name], $type);
                } else {
                    $var = null;
                }

                return $var;
        }
    }
开发者ID:Burick,项目名称:moodle,代码行数:36,代码来源:questionattempt.php

示例9: is_same_response

 public function is_same_response(array $prevresponse, array $newresponse)
 {
     foreach ($this->get_parameters() as $param) {
         if (!question_utils::arrays_same_at_key_missing_is_blank($prevresponse, $newresponse, 'answer_' . $param)) {
             return false;
         }
     }
     return true;
 }
开发者ID:ndunand,项目名称:moodle-qtype_multinumerical,代码行数:9,代码来源:question.php

示例10: modify_questionresults_duringquiz

 /**
  * Updating output to include a graph of multiple choice answer possibilities
  * with the percentage of students that answered that option
  *
  * @param \mod_activequiz\activequiz_question $question The realtime quiz question
  * @param array                               $attempts An array of \mod_activequiz\activequiz_attempt classes
  * @param string                              $output The current output from getting the results
  * @return string Return the updated output to be passed to the client
  */
 public function modify_questionresults_duringquiz($question, $attempts, $output)
 {
     global $DB;
     // store the possible answersid as the key of the array, and then a count
     //  for the number of times it was answered
     $answers = array();
     $dbanswers = array();
     foreach ($attempts as $attempt) {
         /** @var \mod_activequiz\activequiz_attempt $attempt */
         // only count attempts where they have "responded"
         if ($attempt->responded == 0) {
             continue;
         }
         $quba = $attempt->get_quba();
         $slot = $attempt->get_question_slot($question);
         $qa = $quba->get_question_attempt($slot);
         // now get question definition
         $questiondef = $qa->get_question();
         // if dbanswers is empty get them from the question definition (as this will be the same for all attempts for this slot
         // also save a db query
         if (empty($dbanswers)) {
             $dbanswers = $questiondef->answers;
         }
         // single and multi answers are handled differently for steps
         if ($questiondef instanceof \qtype_multichoice_single_question) {
             $this->update_answers_single($answers, $qa, $questiondef);
         } else {
             if ($questiondef instanceof \qtype_multichoice_multi_question) {
                 $this->update_answers_multi($answers, $qa, $questiondef);
             } else {
             }
         }
     }
     $xaxis = array();
     foreach ($dbanswers as $dbanswer) {
         $xaxis[$dbanswer->id] = \question_utils::to_plain_text($dbanswer->answer, $dbanswer->answerformat);
     }
     $newoutput = $this->add_chart($output, $xaxis, $answers);
     return $newoutput;
 }
开发者ID:agarnav,项目名称:moodle-mod_activequiz,代码行数:49,代码来源:multichoice.php

示例11: is_same_response

    public function is_same_response(array $prevresponse, array $newresponse) {
        if (!question_utils::arrays_same_at_key_missing_is_blank(
                $prevresponse, $newresponse, 'answer')) {
            return false;
        }

        if ($this->unitdisplay == qtype_numerical::UNITSELECT) {
            return question_utils::arrays_same_at_key_missing_is_blank(
                $prevresponse, $newresponse, 'unit');
        }

        return false;
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:13,代码来源:question.php

示例12: summarise_manual_comment

 /**
  * @return string a summary of a manual comment action.
  * @param unknown_type $step
  */
 protected function summarise_manual_comment($step)
 {
     $a = new stdClass();
     if ($step->has_behaviour_var('comment')) {
         $a->comment = shorten_text(html_to_text($this->format_comment($step->get_behaviour_var('comment')), 0, false), 200);
     } else {
         $a->comment = '';
     }
     $mark = question_utils::clean_param_mark($step->get_behaviour_var('mark'));
     if (is_null($mark) || $mark === '') {
         return get_string('commented', 'question', $a->comment);
     } else {
         $a->mark = $mark / $step->get_behaviour_var('maxmark') * $this->qa->get_max_mark();
         return get_string('manuallygraded', 'question', $a);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:behaviourbase.php

示例13: render_question_text_plain

 /**
  * @param object $question question data.
  * @return string HTML of question text, ready for display.
  */
 protected function render_question_text_plain($question, $showimages = true)
 {
     global $OUTPUT;
     if ($showimages) {
         $text = question_rewrite_question_preview_urls($question->questiontext, $question->id, $question->contextid, 'question', 'questiontext', $question->id, $this->context->id, 'quiz_statistics');
     } else {
         $text = $question->questiontext;
     }
     $questiontext = question_utils::to_plain_text($text, $question->questiontextformat, array('noclean' => true, 'para' => false, 'overflowdiv' => true));
     return '&nbsp;&nbsp;&nbsp;' . $questiontext;
 }
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:15,代码来源:report.php

示例14: quiz_question_tostring

/**
 * Creates a textual representation of a question for display.
 *
 * @param object $question A question object from the database questions table
 * @param bool $showicon If true, show the question's icon with the question. False by default.
 * @param bool $showquestiontext If true (default), show question text after question name.
 *       If false, show only question name.
 * @return string
 */
function quiz_question_tostring($question, $showicon = false, $showquestiontext = true)
{
    $result = '';
    $name = shorten_text(format_string($question->name), 200);
    if ($showicon) {
        $name .= print_question_icon($question) . ' ' . $name;
    }
    $result .= html_writer::span($name, 'questionname');
    if ($showquestiontext) {
        $questiontext = question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false));
        $questiontext = shorten_text($questiontext, 200);
        if ($questiontext) {
            $result .= ' ' . html_writer::span(s($questiontext), 'questiontext');
        }
    }
    return $result;
}
开发者ID:aleph-n,项目名称:lms.aaenl,代码行数:26,代码来源:locallib.php

示例15: get_possible_responses

 public function get_possible_responses($questiondata)
 {
     if ($questiondata->options->single) {
         $responses = array();
         foreach ($questiondata->options->answers as $aid => $answer) {
             $responses[$aid] = new question_possible_response(question_utils::to_plain_text($answer->answer, $answer->answerformat), $answer->fraction);
         }
         $responses[null] = question_possible_response::no_response();
         return array($questiondata->id => $responses);
     } else {
         $parts = array();
         foreach ($questiondata->options->answers as $aid => $answer) {
             $parts[$aid] = array($aid => new question_possible_response(question_utils::to_plain_text($answer->answer, $answer->answerformat), $answer->fraction));
         }
         return $parts;
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:17,代码来源:questiontype.php


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