You are here

function text_format_name in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle_support.php \text_format_name()

Converts the text format from the value to the 'internal' name or vice versa. $key can either be the value or the name and you get the other back.

Parameters

mixed int 0-4 or string one of 'moodle','html','plain','markdown': @return mixed as above but the other way around!

2 calls to text_format_name()
qformat_gift::readquestion in includes/moodle/question/format/gift/format.php
Given the data known to define a question in this format, this function converts it into a question object suitable for processing and insertion into Moodle.
qformat_gift::writequestion in includes/moodle/question/format/gift/format.php
convert a single question object into text output in the given format. This must be overriden

File

includes/moodle_support.php, line 23

Code

function text_format_name($key) {
  $lookup = array();
  $lookup[FORMAT_MOODLE] = 'moodle';
  $lookup[FORMAT_HTML] = 'html';
  $lookup[FORMAT_PLAIN] = 'plain';
  $lookup[FORMAT_MARKDOWN] = 'markdown';
  $lookup[FORMAT_LATEX] = 'latex';

  // added by turadg 2009-05-26
  $value = "error";
  if (!is_numeric($key)) {
    $key = strtolower($key);
    $value = array_search($key, $lookup);
  }
  else {
    if (isset($lookup[$key])) {
      $value = $lookup[$key];
    }
  }
  return $value;
}