You are here

function context_to_string_translator::generate_context_to_string_array in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/questionlib.php \context_to_string_translator::generate_context_to_string_array()
1 call to context_to_string_translator::generate_context_to_string_array()
context_to_string_translator::context_to_string_translator in includes/moodle/lib/questionlib.php

File

includes/moodle/lib/questionlib.php, line 2145

Class

context_to_string_translator

Code

function generate_context_to_string_array($contexts) {
  if (!$this->contexttostringarray) {
    $catno = 1;
    foreach ($contexts as $context) {
      switch ($context->contextlevel) {
        case CONTEXT_MODULE:
          $contextstring = 'module';
          break;
        case CONTEXT_COURSE:
          $contextstring = 'course';
          break;
        case CONTEXT_COURSECAT:
          $contextstring = "cat{$catno}";
          $catno++;
          break;
        case CONTEXT_SYSTEM:
          $contextstring = 'system';
          break;
      }
      $this->contexttostringarray[$context->id] = $contextstring;
    }
  }
}