~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to question/engine/lib.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-09-09 15:22:35 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130909152235-d9njbvgugzm380an
Tags: 2.5.2-1
* New upstream version: 2.5.2.
  - Incorporates S3 security patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
defined('MOODLE_INTERNAL') || die();
28
28
 
 
29
require_once($CFG->libdir . '/filelib.php');
29
30
require_once(dirname(__FILE__) . '/questionusage.php');
30
31
require_once(dirname(__FILE__) . '/questionattempt.php');
31
32
require_once(dirname(__FILE__) . '/questionattemptstep.php');
818
819
        return self::clean_param_mark(
819
820
                optional_param($parname, null, PARAM_RAW_TRIMMED));
820
821
    }
 
822
 
 
823
    /**
 
824
     * Convert part of some question content to plain text.
 
825
     * @param string $text the text.
 
826
     * @param int $format the text format.
 
827
     * @param array $options formatting options. Passed to {@link format_text}.
 
828
     * @return float|string|null cleaned mark as a float if possible. Otherwise '' or null.
 
829
     */
 
830
    public static function to_plain_text($text, $format, $options = array('noclean' => 'true')) {
 
831
        // The following call to html_to_text uses the option that strips out
 
832
        // all URLs, but format_text complains if it finds @@PLUGINFILE@@ tokens.
 
833
        // So, we need to replace @@PLUGINFILE@@ with a real URL, but it doesn't
 
834
        // matter what. We use http://example.com/.
 
835
        $text = str_replace('@@PLUGINFILE@@/', 'http://example.com/', $text);
 
836
        return html_to_text(format_text($text, $format, $options), 0, false);
 
837
    }
821
838
}
822
839
 
823
840