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


PHP question_utils::to_plain_text方法代码示例

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


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

示例1: summarise_response

 public function summarise_response(array $response)
 {
     if (isset($response['answer'])) {
         return question_utils::to_plain_text($response['answer'], $response['answerformat'], array('para' => false));
     } else {
         return null;
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:question.php

示例2: format_question_text

 /**
  * Convert the question text to plain text, so it can safely be displayed
  * during import to let the user see roughly what is going on.
  */
 protected function format_question_text($question)
 {
     return question_utils::to_plain_text($question->questiontext, $question->questiontextformat);
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:8,代码来源:format.php

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

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

示例5: html_to_text

 /**
  * Convert some part of the question text to plain text. This might be used,
  * for example, by get_response_summary().
  * @param string $text The HTML to reduce to plain text.
  * @param int $format the FORMAT_... constant.
  * @return string the equivalent plain text.
  */
 public function html_to_text($text, $format)
 {
     return question_utils::to_plain_text($text, $format);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:11,代码来源:questionbase.php

示例6: offlinequiz_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 offlinequiz_question_tostring($question, $showicon = false, $showquestiontext = true, $return = true, $shorttitle = false)
{
    global $COURSE;
    $result = '';
    $formatoptions = new stdClass();
    $formatoptions->noclean = true;
    $formatoptions->para = false;
    $questiontext = strip_tags(question_utils::to_plain_text($question->questiontext, $question->questiontextformat, array('noclean' => true, 'para' => false)));
    $questiontitle = strip_tags(format_text($question->name, $question->questiontextformat, $formatoptions, $COURSE->id));
    $result .= '<span class="questionname" title="' . $questiontitle . '">';
    if ($shorttitle && strlen($questiontitle) > 25) {
        $questiontitle = shorten_text($questiontitle, 25, false, '...');
    }
    if ($showicon) {
        $result .= print_question_icon($question, true);
        echo ' ';
    }
    if ($shorttitle) {
        $result .= $questiontitle;
    } else {
        $result .= shorten_text(format_string($question->name), 200) . '</span>';
    }
    if ($showquestiontext) {
        $result .= '<span class="questiontext" title="' . $questiontext . '">';
        $questiontext = shorten_text($questiontext, 200);
        if (!empty($questiontext)) {
            $result .= $questiontext;
        } else {
            $result .= '<span class="error">';
            $result .= get_string('questiontextisempty', 'offlinequiz');
            $result .= '</span>';
        }
        $result .= '</span>';
    }
    if ($return) {
        return $result;
    } else {
        echo $result;
    }
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:49,代码来源:locallib.php

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

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

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


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