original_string: public static function get_effective_contextlevel_value($contextlevel, $element) {
          if ($element !== 'purpose' && $element !== 'category') {
              throw new coding_exception('Only \'purpose\' and \'category\' are supported.');
          }
          $fieldname = $element . 'id';
  
          if ($contextlevel != CONTEXT_SYSTEM && $contextlevel != CONTEXT_USER) {
              throw new \coding_exception('Only context_system and context_user values can be retrieved, no other context levels ' .
                  'have a purpose or a category.');
          }
  
          list($purposeid, $categoryid) = self::get_effective_default_contextlevel_purpose_and_category($contextlevel);
  
          // Note: The $$fieldname points to either $purposeid, or $categoryid.
          if (context_instance::NOTSET != $$fieldname && context_instance::INHERIT != $$fieldname) {
              // There is a specific value set.
              return self::get_element_instance($element, $$fieldname);
          }
  
          throw new coding_exception('Something went wrong, system defaults should be set and we should already have a value.');
      }
code: public static function get_effective_contextlevel_value($contextlevel, $element) {
          if ($element !== 'purpose' && $element !== 'category') {
              throw new coding_exception('Only \'purpose\' and \'category\' are supported.');
          }
          $fieldname = $element . 'id';
  
          if ($contextlevel != CONTEXT_SYSTEM && $contextlevel != CONTEXT_USER) {
              throw new \coding_exception('Only context_system and context_user values can be retrieved, no other context levels ' .
                  'have a purpose or a category.');
          }
  
          list($purposeid, $categoryid) = self::get_effective_default_contextlevel_purpose_and_category($contextlevel);
  
          // Note: The $$fieldname points to either $purposeid, or $categoryid.
          if (context_instance::NOTSET != $$fieldname && context_instance::INHERIT != $$fieldname) {
              // There is a specific value set.
              return self::get_element_instance($element, $$fieldname);
          }
  
          throw new coding_exception('Something went wrong, system defaults should be set and we should already have a value.');
      }
code_tokens: public static function get_effective_contextlevel_value ( $ contextlevel , $ element ) { if ( $ element !== 'purpose' && $ element !== 'category' ) { throw new coding_exception ( 'Only \'purpose\' and \'category\' are supported.' ) ; } $ fieldname = $ element . 'id' ; if ( $ contextlevel != CONTEXT_SYSTEM && $ contextlevel != CONTEXT_USER ) { throw new \ coding_exception ( 'Only context_system and context_user values can be retrieved, no other context levels ' . 'have a purpose or a category.' ) ; } list ( $ purposeid , $ categoryid ) = self :: get_effective_default_contextlevel_purpose_and_category ( $ contextlevel ) ; // Note: The $$fieldname points to either $purposeid, or $categoryid. if ( context_instance :: NOTSET != $ $ fieldname && context_instance :: INHERIT != $ $ fieldname ) { // There is a specific value set. return self :: get_element_instance ( $ element , $ $ fieldname ) ; } throw new coding_exception ( 'Something went wrong, system defaults should be set and we should already have a value.' ) ; }
docstring: Returns the effective value for a context level.
  
  Note that this is different from the effective default context level
  (see get_effective_default_contextlevel_purpose_and_category) as this is returning
  the value set in the data registry, not in the defaults page.
  
  @param int $contextlevel
  @param string $element 'category' or 'purpose'
  @return \tool_dataprivacy\purpose|false
docstring_tokens: Returns the effective value for a context level .